Gazebo | Ignition | Community
Ask Your Question
0

Cant add more than one link per xacro

asked 2021-01-22 10:53:18 -0600

AJahueyM gravatar image

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?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2021-01-25 12:09:49 -0600

nkoenig gravatar image

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.

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2021-01-22 10:53:18 -0600

Seen: 16 times

Last updated: Jan 25