Ask Your Question

Convert XACRO to URDF on macOS?

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


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 imagerandomuserhelloworld ( 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 imagegvdhoorn ( 2019-06-05 01:23:03 -0500 )edit

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

gvdhoorn gravatar imagegvdhoorn ( 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 imageGeoff ( 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 imagerandomuserhelloworld ( 2019-06-05 12:43:33 -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

1 follower


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

Seen: 53 times

Last updated: Jun 04