Robotics StackExchange | Archived questions

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?

Asked by AJahueyM on 2021-01-22 11:53:18 UTC

Comments

Answers

Your second xacro file produces a robot with two links that are not connected via a joint. URDF wants a root link, and can't determine which link is the root. You can add a joint, or take a look at options on the urdf wiki.

Asked by nkoenig on 2021-01-25 13:09:49 UTC

Comments