Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Slow speed when generating a URDF #292

Closed
captain-yoshi opened this issue Oct 8, 2021 · 6 comments
Closed

Slow speed when generating a URDF #292

captain-yoshi opened this issue Oct 8, 2021 · 6 comments

Comments

@captain-yoshi
Copy link

It takes 40 seconds for my pc (Intel i7-7700HQ 2.8GHz) to generate a URDF containing links and joints that represent a collection of collision objects (10 shelves on top of each other). Information such as subframes is also added. There is a lot of xacro loops used. The URDF generated has a size of 500kB.

Is it normal for this process to be slow ? My xacro skills may be to blame, could xacro for loops introduces some sort of slowdown that could be improved with #291 ?

You can run the example (xacro_scene.zip)

rosrun xacro xacro scene.urdf.xacro > scene.urdf

@rhaschke
Copy link
Contributor

rhaschke commented Oct 8, 2021

Wow! What a huge shelf! Unfortunately, I have to blame python's xml.dom.minidom. I filed a PR in the past to improve the situation for Python 2.7, but they didn't accept it (not trying to risk stability): https://bugs.python.org/issue24424
Maybe the patch provided there helps you as well.

For Python 3.x, the situation is slightly better. We typically generate our URDFs once when building.
To this end xacro provides some convience cmake functions.

@captain-yoshi
Copy link
Author

It's a shame they did not accept it. If I read correctly, for Python 2.7 the patch gain is 150 folds for one of the examples! Will try the patch this weekend and will report the gains I have.

Thank you for the detailed explanation and feel free to close this issue.

@captain-yoshi
Copy link
Author

Just for comparison without applying patches:

Melodic Noetic
1 Shelf 22 sec 1 sec
10 Shelf 54 min 34 sec

Note: The PCs are different between Melodic and Noetic so it may be hard to compare.
Melodic: Intel i7-2600
Noetic: Intel i7-7700

@captain-yoshi
Copy link
Author

Comparing timing on same machine (i7-2600) gives roughly the same table:

Melodic Noetic
1 Shelf 22 sec 1 sec
10 Shelf 54 min 35 sec

@rhaschke Trying to generate a urdf from xacro for Python 3.x (ROS Noetic) using the conveniance cmake functions. Do you have an exemple on how to do that ? Not sure if I have to uncomment parts of cmake...

@rhaschke
Copy link
Contributor

Trying to generate a urdf from xacro using the convenience cmake functions. Do you have an example on how to do that?

Sure:

See doc.

@captain-yoshi
Copy link
Author

Benchmarked my Pisa tower example using a loop and an unrolled loop on Noetic (see below). It seems that looping can be quite taxing. Maybe this can be improved with #291.

Test Time (s)
Loop 28
Unrolled Loop 8
   <!-- Unrolled loop x10 -->

  <xacro:shelf name="bookshelf1"
               frame_id="world"
               xyz="0.8 0 0"
               h_board_thickness="0.02"/>

  <xacro:shelf name="bookshelf2"
               frame_id="world"
               xyz="0.8 0 1"
               h_board_thickness="0.02"/>
 ...

  <xacro:shelf name="bookshelf10"
               frame_id="world"
               xyz="0.8 0 9"
               h_board_thickness="0.02"/>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants