ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

URDF or Xacro?

asked 2015-01-31 04:37:16 -0500

Oguz gravatar image

updated 2015-01-31 04:45:46 -0500

I am new to ROS and I have been using SolidWorks Exporter for generating URDF for my robot. Things didn't go well adding transmissions and controller plugins, Gazebo crashes if I spawn the urdf with controller plugins and transmissions, so I started studying other robots in ROS in detail (for example universal-robot) and all of them had Xacro files. Should I also use Xacro? Or the URDF generated by SolidWorks should work fine with transmissions and controller plugins? If I should use xacro, how do I generate a Xacro?

Thanks for your attention.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2015-01-31 07:24:38 -0500

updated 2015-01-31 16:55:43 -0500

Xacro is just a scripting mechanism that allows more modularity and code re-use when defining a URDF model. When using it, what is actually uploaded to the parameter servers (per default as the "robot_description" parameter) actually is a URDF, as that gets generated from the xacro file in the launch file (by expanding the xacro macros used).

As an example, say you have a "robot.urdf.xacro" file. You can run

rosrun xacro robot.urdf.xacro > robot.urdf

and that gives you the URDF generated from your xacro file. The same approach is commonly used in launch files when a xacro-based robot_description is uploaded.

Xacro is just another way of defining a URDF, not an alternative to it. It makes certain things easier, for instance you can generate a "wheel" macro and instantiate that 6 times with different parameters to put 6 wheels on your robot, as opposed to copying and pasting the same code six times manually.

edit flag offensive delete link more


Thanks, then I will stick to my SolidWorks Exporter generated URDF.

Oguz gravatar image Oguz  ( 2015-01-31 07:45:37 -0500 )edit

Also new to urdf and have a similar confusion. Really a good answer!

Yanhao Zhu gravatar image Yanhao Zhu  ( 2019-08-17 14:25:32 -0500 )edit

Question Tools



Asked: 2015-01-31 04:37:16 -0500

Seen: 14,751 times

Last updated: Jan 31 '15