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

Converting xacro to urdf ROS2

asked 2022-05-10 02:23:23 -0500

ludo2811 gravatar image

updated 2022-05-18 02:09:30 -0500

ljaniec gravatar image

I am using ROS 2 Galactic and was trying to simulate ur robots in Unity. Unfortunately, I have to convert xacro files from the ur_driver to urdf to implement it to Unity 3D. I have not been successful finding a command for ROS2 to convert the xacro to urdf.

I tried ros2 run xacro xacro -o ur.urdf ur.urdf.xacro to convert ur.urdf.xacro to ur.urdf.

Then i always get an output like "Undefined substitution argument name"...

Does anyone have a suggestion how my problem can be solved? Any help is appreciated.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
1

answered 2022-05-18 01:36:34 -0500

aprotyas gravatar image

ros-galactic-xacro is installed as a Python executable and can be invoked as such:

xacro [in.urdf.xacro] > [out.urdf]

edit flag offensive delete link more
0

answered 2022-05-17 19:51:10 -0500

LuisEFA1998 gravatar image

I have never used ROS2 but maybe there is a command similar to the one in ROS1, which is:

rosrun xacro xacro --inorder your_model.urdf.xacro > your_model.urdf

Any instruction of this type must be executed from the terminal being in the directory where the URDF XACRO model is located and where you want to generate the URDF copy. Maybe that's why the command you mention doesn't work.

In case something similar does not exist, you can do the conversion manually but it will take some time. Especially if you used any xacro-macro. If you didn't use any macro you only have to modify the header of the xml file.

A XACRO file starts like this:

<?xml version="1.0" encoding="utf-8"?>
<robot name="your_robot_name" xmlns:xacro="http://www.ros.org/wiki/xacro">

While one URDF:

<?xml version="1.0" encoding="utf-8" ?>
<robot name="your_robot_name">

Just remove the "xmlns:xacro="http://www.ros.org/wiki/xacro"

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2022-05-10 02:23:23 -0500

Seen: 3,737 times

Last updated: May 18 '22