Fast way to read entire frame tree- Printable Version +- RoboDK Forum (//www.sinclairbody.com/forum) +-- Forum: RoboDK (EN) (//www.sinclairbody.com/forum/Forum-RoboDK-EN) +--- Forum: RoboDK API (//www.sinclairbody.com/forum/Forum-RoboDK-API) +--- Thread: Fast way to read entire frame tree (/Thread-Fast-way-to-read-entire-frame-tree) |
Fast way to read entire frame tree-rshanor-10-12-2022 Hi, I am trying to access the entire station frame graph over the Python API. I noticed a functionsetPosesfor improving efficiency setting multiple poses at once. Is there anything similar for getting all station poses? Thank you, Rick RE: Fast way to read entire frame tree-Albert-10-13-2022 The fastest way to set multiple poses would be to turn off rendering and update all the poses you need. Then, you can turn rendering back on. RE: Fast way to read entire frame tree-rshanor-10-13-2022 Sorry my question was unclear. I want to callgetPosevery fast. Right now I have about 70 items in the scene and each call takes ~0.05 seconds, so it takes over 3.5 seconds to look up the whole scene frame tree. RE: Fast way to read entire frame tree-Albert-10-13-2022 What programming language are you using? Can you share a sample RDK project and code? We may be able to help you improve speed. RE: Fast way to read entire frame tree-rshanor-10-13-2022
Code:
def publish_transform(self, item: robolink.Item):
Above is some sample code. I do not have a station file I can share but the above code bit should work for any station. RE: Fast way to read entire frame tree-Sam-10-14-2022 I'm not sure why you are experiencing such a delay with Pose(). I tried the following code and it's performing well with 50+ items.
Code:
items = {}
Can you use pstats to find the bottleneck? Could it be that you process items recursively more than once? RE: Fast way to read entire frame tree-rshanor-10-14-2022 (10-14-2022, 12:29 AM)Sam Wrote:I'm not sure why you are experiencing such a delay with Pose(). I tried the following code and it's performing well with 50+ items. Hi Sam, Thank you for the response. I will try to run some more tests on my end. How fast is the call toitem.Pose? Is the speed of this call in any way a function of number of items in the station? I actually have about 300 items in the station, but ~250 of them are invisible. I have to keep these around due to some robodk issues dynamically loading files with texture in Linux. Basically I create a default station in Windows and just move the objects I want when they are required. That is why I do some recursive call rather than reading every item like you show above. I only care about items that are under thelink.Item(get_roof_frame_name())branch of the tree. RE: Fast way to read entire frame tree-rshanor-10-14-2022 One other thing. Just saw the Event_Loop example, which looks pretty interesting.https://github.com/RoboDK/RoboDK-API/blob/master/Python/Examples/Macros/Event_Loop.py A lot of items in my scene are stationary. The EVENT_ITEM_MOVED_POSE event looks cool but is there any way to tell which item moved? Thanks! RE: Fast way to read entire frame tree-rshanor-12-02-2022 (10-14-2022, 04:13 PM)rshanor Wrote:One other thing. Just saw the Event_Loop example, which looks pretty interesting.https://github.com/RoboDK/RoboDK-API/blob/master/Python/Examples/Macros/Event_Loop.py I eventually resolved my issues by setting the following flag.
Code:
robolink.Robolink.NODELAY = True
This sped up API calls by 20X to 100X RE: Fast way to read entire frame tree-Albert-12-02-2022 Getting the pose of an item (item.Pose()) may be slightly slower if you have many objects when you use the safe mode option. The safe mode option means that RoboDK will check the pointers you provide exist against all available items in your project. You can speed this up by removing the safe mode option:
Code:
robolink.Robolink.SAFE_MODE = 0
Regarding events, when you get a new event you'll also receive the item associated with that event (item variable in the example you pointed to). Note that the event channel should be a separate Robolink object and it should be used to listen for events only. There is a similar example in the C# API: https://github.com/RoboDK/RoboDK-API/blob/5a9841bc882058d59c0f4684df57df4aa96c2a7c/C%23/Example/RoboDKSampleProject/RoboDK.cs#L2807 Thank you for your feedback regarding the No Delay option! I understand this applies to Linux only. |