Gazebo | Ignition | Community
Ask Your Question

Revision history [back]

Cant add more than one link per xacro

I have been trying to use xacro for a robotics project, I have mainly used the Graphic Model Editor for simpler projects, but considering this model will be a lot more complex I decided to give xacro a try, but I have not been able to spawn a robot with more than one link defined.

My xacro file is this:

<?xml version="1.0"?>
<robot name="intake" xmlns:xacro="http://www.ros.org/wiki/xacro">
    <xacro:macro name="piston_mount" params="suffix *pose">
        <link name="piston_mount_${suffix}_link">
            <visual name="piston_mount_${suffix}_visual">
                <geometry>
                    <mesh filename="model://Slimer2021/meshes/Intake/PistonBody.dae"/>
                </geometry>
            </visual>
            <xacro:insert_block name="pose"/>
            <collision>
                <geometry>
                    <mesh filename="model://Slimer2021/meshes/Intake/PistonBody_Collision.dae"/>
                </geometry>
            </collision>
            <inertial>
                <mass value="0.174995936"/>
                <inertia ixx="9.148e-5" ixy="0.0" ixz="0.0" iyy="0.00264602" iyz="0.0" izz="0.00265423"/>
                <origin xyz="0 0 0.1" rpy="0 0 0"/>
            </inertial>
        </link>
    </xacro:macro>

    <xacro:piston_mount suffix="right">
        <pose xyz="0 1.0 0" rpy="0 0 0"/>
    </xacro:piston_mount>
</robot>

When I run that file, it spawns the model correctly and everything works, however, the following gives an error:

<?xml version="1.0"?>
<robot name="intake" xmlns:xacro="http://www.ros.org/wiki/xacro">
    <xacro:macro name="piston_mount" params="suffix *pose">
        <link name="piston_mount_${suffix}_link">
            <visual name="piston_mount_${suffix}_visual">
                <geometry>
                    <mesh filename="model://Slimer2021/meshes/Intake/PistonBody.dae"/>
                </geometry>
            </visual>
            <xacro:insert_block name="pose"/>
            <collision>
                <geometry>
                    <mesh filename="model://Slimer2021/meshes/Intake/PistonBody_Collision.dae"/>
                </geometry>
            </collision>
            <inertial>
                <mass value="0.174995936"/>
                <inertia ixx="9.148e-5" ixy="0.0" ixz="0.0" iyy="0.00264602" iyz="0.0" izz="0.00265423"/>
                <origin xyz="0 0 0.1" rpy="0 0 0"/>
            </inertial>
        </link>
    </xacro:macro>

    <xacro:piston_mount suffix="right">
        <pose xyz="0 1.0 0" rpy="0 0 0"/>
    </xacro:piston_mount>

    <xacro:piston_mount suffix="left">
        <pose xyz="0 -1.0 0" rpy="0 0 0"/>
    </xacro:piston_mount>

</robot>

image description

I have not found any information regarding this error while Googling, just some issues were Gazebo could not find the meshes. Could anyone help me?