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

XACRO Macro Noetic not working

asked 2021-02-22 05:14:16 -0500

vonunwerth gravatar image

Hi, I'm facing issues with xacro macros in ROS noetic. I have the following robot description (or a simplified version) containing one xacro macro. After the definition of the macro it is called by <robot_macro/>

Normally i have this macro defined in an other file and include it in a main xacro file, where i include a lot of macros and then build up the robot using those macros.

<?xml version="1.0"?>
<robot name="robot1" xmlns:xacro="http://ros.org/wiki/xacro">
    <xacro:macro name="robot_macro">
        <link name="robot1_base_link"/>
        <link name="beam_link">
            <inertial>
                <origin xyz="0.40 0 0.02" rpy="0 0 0" />
                <mass value="2" />
                <inertia ixx="0.003" ixy="0" ixz="0" iyy="0.09" iyz="0" izz="0.09" />
            </inertial>
            <visual>
                <origin xyz="0 0 0" rpy="0 0 0" />
                <geometry>
                    <cylinder length="0.6" radius="0.2"/>
                </geometry>
                <material name="white">
                    <color rgba="1 1 1 1"/>
                </material>
            </visual>
            <collision>
                <origin xyz="0.4 0 0.02" rpy="0 0 0" />
                <geometry>
                    <cylinder length="0.6" radius="0.2"/>
                </geometry>
            </collision>
        </link>
        <joint name="beam_joint" type="fixed">
            <origin xyz="0 0 0" rpy="0 0 0" />
            <parent link="robot1_base_link" />
            <child link="beam_link" />
            <axis xyz="0 0 0" />
        </joint>
    </xacro:macro>
    <robot_macro/>
</robot>

If i load the robot description in Gazebo, i get the error message No link elements found in urdf. At first i thought it could be that the mesh files can not be found. So i decided to switch to a simple conversion from xacro to urdf for debugging my problem. But if i convert this xacro file to a urdf file using rosrun xacro xacro -o model.urdf model.xacro the resulting urdf contains no links and joint:

<?xml version="1.0" ?>
<!-- =================================================================================== -->
<!-- |    This document was autogenerated by xacro from mira3d.xacro                   | -->
<!-- |    EDITING THIS FILE BY HAND IS NOT RECOMMENDED                                 | -->
<!-- =================================================================================== -->
<robot name="robot1">
  <robot_macro/>
</robot>

If i remove the two xacro macro lines around the links and joint (and the call of the macro), its working as expected. I am pretty sure, i used the xacro description like it is in Kinetic and Melodic before and had no problems with it. I also think the macro looks like the example on http://wiki.ros.org/urdf/Tutorials/Us...

Can you see any issue with it or is there any change in xacro macros in noetic?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
3

answered 2021-02-22 05:32:05 -0500

gvdhoorn gravatar image
<robot [..]>
    [..]
    <robot_macro/>
</robot>

I don't believe this is supposed to work like this.

Shouldn't it be at least:

<robot [..]>
    [..]
    <xacro:robot_macro/>
</robot>
edit flag offensive delete link more

Comments

1

This must have changed in Noetic. In Melodic, I had macros that worked without the xacro namespace, but I needed to add them when I went to Noetic.

Brian Erickson gravatar image Brian Erickson  ( 2021-02-28 23:48:48 -0500 )edit

Actually, this has been deprecated since at least Jade. See wiki/xacro - Deprecated Syntax.

And ros/xacro#79. That's from 2015.

gvdhoorn gravatar image gvdhoorn  ( 2021-03-01 02:27:17 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2021-02-22 05:14:16 -0500

Seen: 1,951 times

Last updated: Feb 22 '21