Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Fast way to read entire frame tree
#1
Hi,

I am trying to access the entire station frame graph over the Python API. I noticed a function setPoses for improving efficiency setting multiple poses at once. Is there anything similar for getting all station poses?

Thank you,
Rick
#2
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.
#3
Sorry my question was unclear. I want to call getPose very 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.
#4
What programming language are you using? Can you share a sample RDK project and code?

We may be able to help you improve speed.
#5
Code:
   def publish_transform(self, item: robolink.Item):
       if item.type == robolink.ITEM_TYPE_ROBOT:
           parent_tform_item = item.PoseFrame()
       elif item.type == robolink.ITEM_TYPE_TOOL:
           parent_tform_item = item.PoseTool()
       else:
           parent_tform_item = item.Pose()

       parent_name = item.Parent().Name()
       child_name = item.Name()
       # self.tf_broadcaster.sendTransform(parent_tform_item, parent_name, child_name)

   def publish_transforms_recursive(self, item: robolink.Item):
       for child in item.Childs():
           self.publish_transform(child)
           self.publish_transforms_recursive(child)

   def publish_all_frames(self):
       base_item = self.link.Item(get_root_frame_name())
       self.publish_transforms_recursive(base_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.
#6
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 = {}
for item in RDK.ItemList():
items[item] = item.Pose()

Can you use pstats to find the bottleneck?
Could it be that you process items recursively more than once?
Find useful information about RoboDK and its features by visiting our Online Documentation and by watching tutorials on our YouTube Channel.
#7
(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.


Code:
items = {}
for item in RDK.ItemList():
items[item] = item.Pose()

Can you use pstats to find the bottleneck?
Could it be that you process items recursively more than once?

Hi Sam,

Thank you for the response. I will try to run some more tests on my end. 

How fast is the call to item.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 the link.Item(get_roof_frame_name()) branch of the tree.
#8
One other thing. Just saw the Event_Loop example, which looks pretty interesting. https://github.com/RoboDK/RoboDK-API/blo...nt_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!
#9
(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/blo...nt_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!

I eventually resolved my issues by setting the following flag.
Code:
robolink.Robolink.NODELAY = True
link = robolink.Robolink(robodk_ip)

This sped up API calls by 20X to 100X
#10
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
link = robolink.Robolink(robodk_ip)

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/blo...K.cs#L2807

Thank you for your feedback regarding the No Delay option! I understand this applies to Linux only.
  




Users browsing this thread:
1 Guest(s)