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

Convert XACRO to URDF on macOS?

asked 2019-06-04 17:04:32 -0500

randomuserhelloworld gravatar image


I'm trying to use ur10_robot.urdf.xacro from this repository in ikpy which requires a URDF file to simulate the Inverse Kinematics. To my understanding XACRO is an XML based markup language containing macros which are expanded into a URDF file. Since I am using macOS and don't have access to a Ubuntu machine (or option to dual boot) at the moment, I have no way of compiling (?) this XACRO file into a URDF.

Does anyone have any suggestions on how I can go about expanding an XACRO file to a URDF without installing ROS? There seems to be limited to no compatibility with macOS.

Thanks for any assistance.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2019-06-04 19:24:51 -0500

Geoff gravatar image

updated 2019-06-04 19:27:09 -0500

xacro is a fairly stand-alone Python program. Although the repository is set up as a ROS package, you could easily clone it, copy out the scripts/xacro file as (not the existing file) and the src/xacro directory as xacro/ to make something that would run from the current directory using python [args]. That would allow you to do what you want to do. If you want to go one step further you could wrap it in a directory and a simple to make it a native Python package with about five minutes' work.

In fact I just had a look at PyPI and someone has done exactly that. It's a slightly older version from September 2018, but it will almost certainly be up-to-date enough for your needs. Install it using pip and you should be away laughing.

edit flag offensive delete link more


Thanks for the reply. I tried running using the Python package, and got the following error

$ xacro ur10.urdf.xacro > ur10.urdf
No module named 'rosgraph'
substitution args not supported:  No module named 'roslaunch'
when processing file: ur10.urdf.xacro
randomuserhelloworld gravatar image randomuserhelloworld  ( 2019-06-05 00:08:01 -0500 )edit

That sounds like it's missing some dependencies. rosgraph and roslaunch are also Python modules. So you should perhaps be able to 'install' those similar to xacro.

But as @Geoff implied, it's going to take some manual work.

If you feel up for it, you might want to try Docker. Once you have that setup on your Mac, it'd be a simple:

docker run -it --rm -v /path/on/your/host:/work osrf/ros:kinetic-desktop

and then you'd be able to do whatever you'd normally do on Ubuntu & ROS Kinetic.

gvdhoorn gravatar image gvdhoorn  ( 2019-06-05 01:23:03 -0500 )edit

Converted it for you. Find it here (raw link: here).

gvdhoorn gravatar image gvdhoorn  ( 2019-06-05 01:34:30 -0500 )edit

@randomuserhelloworld I did look through for dependencies that could have been a problem, but as you found out I missed a couple.

I think the easiest solution (other than using the one @gvdhoorn did for you) is the suggestion to use Docker.

Geoff gravatar image Geoff  ( 2019-06-05 02:56:50 -0500 )edit

Thank you so much!! Docker completely slipped my mind, I will set that up for the future.

randomuserhelloworld gravatar image randomuserhelloworld  ( 2019-06-05 12:43:33 -0500 )edit

Thank you @gvdhoorn for the UR10 urdf. As @Geoff mentioned, xacro is fairly standalone. The dependencies such as rosgraph and roslaunch do not seem totally necessary, especially for someone like me who has access only to Windows temporarily and is working on generating simulations directly from Python without installing ROS as a whole. Do you suggest an alternate method with which I can convert xacro to URDF without using ROS/docker?

nikpod gravatar image nikpod  ( 2020-08-12 19:12:42 -0500 )edit

Thank you @gvdhoorn for the UR10 urdf.

Note: that's a URDF from 2 years ago now. Things have changed.

Do you suggest an alternate method with which I can convert xacro to URDF without using ROS/docker?

No. I'm afraid not.

gvdhoorn gravatar image gvdhoorn  ( 2020-08-13 03:06:57 -0500 )edit

Question Tools

1 follower


Asked: 2019-06-04 17:04:32 -0500

Seen: 714 times

Last updated: Jun 04 '19