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

xacro.py generates empty urdf file

asked 2015-01-18 06:27:52 -0500

Alireza gravatar image

updated 2015-01-18 06:29:27 -0500

I am using following command to convert *.urdf.xacro to *.urdf in ROS indigo,ubuntu 14.04:

rosrun xacro xacro.py a.urdf.xacro > a.urdf

also

rosrun xacro xacro.py -o a.urdf a.urdf.xacro

content of a.urdf.xacro(just for test):

<?xml version="1.0"?>
<robot xmlns:xacro="http://www.ros.org/wiki/xacro">
<property name="base_mass" value="3.7000" />
<xacro:macro name="hunter">
    <xacro:macro name="hunter_robot" >
        <link name="base_link" />
    </xacro:macro>
</xacro:macro>
</robot>

and the content of generated urdf:

<?xml version="1.0" ?>
<!-- =================================================================================== -->
<!-- |    This document was autogenerated by xacro from a.urdf.xacro                   | -->
<!-- |    EDITING THIS FILE BY HAND IS NOT RECOMMENDED                                 | -->
<!-- =================================================================================== -->
<robot xmlns:xacro="http://www.ros.org/wiki/xacro">
</robot>

I have faced this problem in two different machines. any idea?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2015-01-18 06:52:09 -0500

gvdhoorn gravatar image

a.urdf.xacro only defines the hunter xacro macro, but that macro is never called (and thus your robot never instantiated).

I typically create a 'top level' .xacro file for this (something like hunter.xacro fi) which is empty, apart from a call to the macro. In your case:

<?xml version="1.0" ?>
<robot name="hunter" xmlns:xacro="http://ros.org/wiki/xacro">
  <xacro:include filename="$(find hunter_pkg)/a.urdf.xacro"/>
  <xacro:hunter/>
</robot>

Then convert / use as normal.

In my experience, keeping your xacro macro definitions separate makes it easier to include them in other, composite, xacros.

edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2015-01-18 06:27:52 -0500

Seen: 2,140 times

Last updated: Jan 18 '15