-
Notifications
You must be signed in to change notification settings - Fork 104
Speeding up PsiStudio 3D Visualization. Help/Insight appreciated. #169
To help debug issues, I have been working on a PsiStudio visualizer that displays URDF (A common XML format to describe a robot). Here's an image of how it looks in PsiStudio.
Screen Shot 2021年06月14日 at 7 06 57 PM
However, it is really really slow and I'm not too sure where the delay is coming from. As far as I can tell from my code, it only generate the model once and we only update the transform when UpdateData() is called. In a nutshell, each robot(URDFVisualizationObject) is a object derived fromModelVisual3DVisualizationObjectCollectionBase that has multiple children(URDFLinkVisualizationObject) derived from ModelVisual3DVisualizationObject. Maybe ModelVisual3D is not the right object to derive from? I saw AnimatedModelVisual but wasn't sure how to use it.
Here's the link to the two files:
URDFLinkVisualizationObject.cs
URDFVisualizationObject
Do you all have any tips to help debug this issue? I have tried CPU profile in the debug mode, but it didn't show any methods that were overused.
All reactions
Replies: 1 comment 1 reply
I noticed that you seem to read in the .stl model file on each UpdateData() in the URDFLinkVisualizationObject. It's possible that could be the culprit. Is it possible to read only once, on construction of this object, rather than in every UpdateData()? If the filename comes on the stream (in CurrentData), perhaps you could read and cache these models in a dictionary -- I'm assuming it's not a different model for every message ...
In the next release we plan to have a feature whereby each 3D visualization object has a read property that tells you how much time it spent in UpdateData(). This can be helpful especially with nested visualization objects to be able to tell where the perf issues are. In general, we've also noticed some perf issues with some of the 3D vis objects -- the code could be optimized more. In the meantime, it might be helpful to implement some of your own timing measurements to better understand the problem and where it stems from.
Deriving from ModelVisual3D should be the right approach though. AnimatedModelVisual is something we haven't maintained well and we should either revisit or deprecate. The intention was indeed to support visualizing .stl type models, but I'm honest not sure how well it's working at the moment.
I'm not sure if/how much this helps, but let us know what you find.
All reactions
Thanks for the info. It's good to know that I'm on the right track.
The stl reader was something I suspected to be the cause. However, it actually only get called once at the beginning and it save the object in the this.model variable. As an extra precaution, I actually added a initialized boolean variable as a safeguard.
I'll play around with some timers, variables, and see whether I can speed things up.