Ask Your Question
0

complex urdf files

asked 2019-07-11 11:10:32 -0500

johnconn gravatar image

How do most people end up creating their complex urdf and sdf files? Most of the tutorials I see edit the xml in their text editor of choice.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2019-07-12 09:18:08 -0500

ChuiV gravatar image

I would recommend either using the ros1 xacro (a bit clanky in my opinion) or to use some templating language like Jinja2 or empy, both of which are independent of ros/ros2. The advantages of using jinja2 or empy are that you can specify templates with parameters, and then use those templates as many times as you want. You can also include other template files into a new template.

Using a robotic arm for example, you could create a single "segment" template that creates a hing, with a rigid arm on the other end. The "segment" template would need to be parameterized such that you can specify where to attach the hing, and how long the segment is, etc. Then you can create a new "Arm" template that pulls in multiple "segment" templates to build up a arm with several segments.

Once you have a template, you can write a python script that renders the urdf, and spits it out to be spawned by gazebo.

edit flag offensive delete link more

Comments

The "segment" template would need to be parameterized such that you can specify where to attach the hing, and how long the segment is, etc. Then you can create a new "Arm" template that pulls in multiple "segment" templates to build up a arm with several segments.

like how xacro does this, you mean ? ;)

gvdhoorn gravatar imagegvdhoorn ( 2019-07-12 09:21:31 -0500 )edit

As an example of using empy, see the way (the) O(S)R(F) created the worlds and parts for the ARIAC challenge: osrf/ariac/src/osrf_gear/worlds/gear.world.template. It's just one example, but does illustrate the idea.

gvdhoorn gravatar imagegvdhoorn ( 2019-07-12 09:26:29 -0500 )edit

Correct. I've used Jinja2 in the past to create urdfs where each sensor type (gps, imu, camera, etc) was it's own template. When I needed to test a new sensor configuration, I could just include that template, and pass it the correct parameters of where to mount the sensor, frequency to publish data, topic to publish on, noise parameters, etc. It worked quite well.

ChuiV gravatar imageChuiV ( 2019-07-12 09:28:21 -0500 )edit

Which again is exactly how it works with xacro :)

Not saying using something else cannot be beneficial, just making sure it's clear that that is not much different from how xacro works. See ubi-agni/human_hand/model/human_hand.urdf.xacro for an example.

gvdhoorn gravatar imagegvdhoorn ( 2019-07-12 09:46:43 -0500 )edit

Interesting, thanks for the recommendations.

I'm surprised that everyone seems to prefer defining their models in code rather than using some CAD tool that exports the model to the format of choice.

johnconn gravatar imagejohnconn ( 2019-07-12 10:17:32 -0500 )edit
1

I'm surprised that everyone seems to prefer defining their models in code

you have a sample size of 2 here (at least here on ROS Answers).

And this is coming from a community that consists of a lot of programmers.

rather than using some CAD tool that exports the model to the format of choice.

that would be nice, but:

  • most of those tools cost a lot of money
  • it's way quicker to add an additional link by copy-pasting some text and adjusting some parameters than to fire up your cad tool (probably Windows only), loading the assembly, rearrange geometry, run an exporter and then fixing up / post processing whatever the exporter didn't do correctly
  • anyone can edit text files, becoming proficient with a CAD tool is not as easy
  • CAD tools typically don't use open formats, increasing vendor lock-in
  • CAD tools don't necessarily support ...
(more)
gvdhoorn gravatar imagegvdhoorn ( 2019-07-12 10:26:20 -0500 )edit

..

I'm not dismissing using more high-level modeling tools for this (and in fact, they are being used, see fi sw_urdf_exporter and dfki-ric/phobos), it's just that in an environment that is so code heavy/centric, being able to generate models from parametric descriptions fits the overall development workflow a bit better.

All in my opinion of course.

gvdhoorn gravatar imagegvdhoorn ( 2019-07-12 10:28:37 -0500 )edit

I've never seen that phobos one.. It looks intriguing! I'll have to look into it! Thanks!

ChuiV gravatar imageChuiV ( 2019-07-12 10:31:02 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

2 followers

Stats

Asked: 2019-07-11 11:10:32 -0500

Seen: 15 times

Last updated: Jul 12