Unit 7 xacro makro reuse fails

Hi,

to execise unit 7 I have created a makro in xacro for the robot arm parts.
Unfortunatetly only the first arm part is put in rightly the rest is false.

image

any is there anything obvious ?

<?xml version="1.0"?>
<robot xmlns:xacro="http://www.ros.org/wiki/xacro" name="my_robot_arm_description">
    <xacro:property name="robot_stand_width" value="0.5"/>
    <xacro:property name="robot_stand_length" value="0.5"/>
    <xacro:property name="robot_stand_height" value="0.2"/>
    <xacro:property name="waist_height" value="0.1" />
    <xacro:property name="waist_radius" value="0.2" />
    <xacro:property name="arm_start" value="0.3" />
    <xacro:property name="arm_joint_width" value="0.15" />
    <xacro:property name="arm_joint_radius" value="0.05" />

    <material name="orange">
        <color rgba="1.0 0.423529411765 0.0392156862745 1.0"/>
    </material>
    <material name="grey">
        <color rgba="0.2 0.2 0.2 1.0"/>
    </material>

    <!-- arm part macro -->
    <xacro:macro name="arm_part" params="arm_part_name parent_name position length">
        <link name="${arm_part_name}-part-joint">    
            <visual>
                <origin rpy="0 0 0" xyz="0 0 0"/>
                <geometry>
                <cylinder length="${arm_joint_width}" radius="${arm_joint_radius}"/>
                </geometry>
                <material name="grey" />
            </visual>

            <collision>
                <origin rpy="0 0 0" xyz="0 0 0"/>
                <geometry>
                <cylinder length="${arm_joint_width}" radius="${arm_joint_radius}"/>
                </geometry>
            </collision>

            <inertial>
                <origin rpy="0 0 0" xyz="0 0 0"/>
                <mass value="0.05"/>
                <inertia ixx="1.531666666666667e-05" ixy="0" ixz="0" iyy="1.531666666666667e-05" iyz="0" izz="3.0625000000000006e-05"/>
            </inertial>
        </link>
        <joint name="${arm_part_name}-joint" type="continuous">
            <parent link="${parent_name}" />
            <child link="${arm_part_name}-part-joint" />
            <origin xyz="${position}" rpy="0 -1.5708 0" />
            <axis xyz="0 0 1.0"/>
        </joint>
        <!-- arm part-->
        <link name="${arm_part_name}-part-arm">
            <visual>
                <geometry>
                    <box size="${arm_joint_width} ${arm_joint_radius} ${length}"/>
                </geometry>
                <material name="orange"/>
            </visual>
            <collision>
                <geometry>
                    <box size="${arm_joint_width} ${arm_joint_radius} ${length}"/>
                </geometry>
            </collision>
            <inertial>
                <origin rpy="0 0 0" xyz="-${arm_joint_width} 0 0"/>
                <mass value="1.0"/>
                <inertia ixx="0.0008333333333333335" ixy="0" ixz="0" iyy="0.0008333333333333335" iyz="0" izz="0.0008333333333333335"/>
            </inertial>
        </link>
        <joint name="${arm_part_name}-arm" type="fixed">
            <parent link="${arm_part_name}-part-joint" />
            <child link="${arm_part_name}-part-arm" />
            <origin xyz="0.2 0 0" rpy="0 -1.5708 0" />
        </joint>
    </xacro:macro>
    <!-- init end   --> 

    <link name="world" />

    <link name="robot_stand">
        <visual>
            <geometry>
                <box size="${robot_stand_width} ${robot_stand_length} ${robot_stand_height}"/>
            </geometry>
            <material name="orange"/>
        </visual>
        <collision>
            <geometry>
                <box size="${robot_stand_width} ${robot_stand_length} ${robot_stand_height}"/>
            </geometry>
        </collision>
        <inertial>
            <origin rpy="0 0 0" xyz="0 0 0"/>
            <mass value="1.0"/>
            <inertia ixx="0.0008333333333333335" ixy="0" ixz="0" iyy="0.0008333333333333335" iyz="0" izz="0.0008333333333333335"/>
        </inertial>
    </link>
    <joint name="world_to_stand" type="fixed">
        <parent link="world" />
        <child link="robot_stand" />
        <origin xyz="0 0 0.1" rpy="0 0 0" />
    </joint>

    <!-- waist -->
    <link name="robot_waist">    
        <visual>
            <origin rpy="0 0 0" xyz="0 0 0"/>
            <geometry>
            <cylinder length="${waist_height}" radius="${waist_radius}"/>
            </geometry>
            <material name="orange"/>
        </visual>

        <collision>
            <origin rpy="0 0 0" xyz="0 0 0"/>
            <geometry>
            <cylinder length="${waist_height}" radius="${waist_radius}"/>
            </geometry>
        </collision>

        <inertial>
            <origin rpy="0 0 0" xyz="0 0 0"/>
            <mass value="0.05"/>
            <inertia ixx="1.531666666666667e-05" ixy="0" ixz="0" iyy="1.531666666666667e-05" iyz="0" izz="3.0625000000000006e-05"/>
        </inertial>
    </link>

    <joint name="stand_to_waist" type="continuous">
        <parent link="robot_stand" />
        <child link="robot_waist" />
        <origin rpy="0 0 0" xyz="0 0 0.15" />
        <axis xyz="0 0 1.0"/>
    </joint> 

    <!-- arm joints   -->
    <xacro:arm_part arm_part_name="shoulder" parent_name="robot_waist" position="0 0 0.1" length="0.4"/>
    <xacro:arm_part arm_part_name="forearm" parent_name="shoulder-part-arm" position="0 0 0.8" length="0.3"/>
    <xacro:arm_part arm_part_name="hand" parent_name="forearm-part-arm" position="0 0 1.2" length="0.1"/>

</robot>

thanks for any hint here

Kind Regards,
Volker

Hi,

The issues wree mainly in the distances and orientation of the joints. Because you reuse a xacro for all the joints, you have to take into account the different orientation of the parent frames. I added some extra parameters for that ) yaw and pitch angles).

I also changed the joints to revolute, becauserobot arms don’t normally have continuous joints and lead to many issues. At least the configuration I see of this robot is not continuous in the main joints.

And finally, because of the way you change the origins of the links based on the width and so on, thatleads to some displacements. I changed some lengths also. But you should playaround to see how to avoid that issue.

Here you have the final result:

You can find the code here:
urdf_issues

You have to launch:

ros2 launch urdf_issues start_world.launch.py

ros2 launch urdf_issues volker_arm_xacro.launch.py

And that it. Try pausing the gazebo GUI before spawning anything, you can see a lot of issues just by doing that.

Hi @duckfrost2 ,

thanks a lot for the great help and explenations.
Almost there.
The arm looks now as it should but starting the joint state publisher with

ros2 run joint_state_publisher_gui joint_state_publisher_gui

does not have the expected result.

For gazebo only the stand very slowly rotates. All other joints do not react.
gazebo_result

For rviz2 the screenshot does not show it but there are very short reactions. Also only for the stand they cause a bit more
robot_arm_stiff

is that also explainable ?
Can it be fixed ?

Kind Regards,

Hi,

I imagne you have placed the control and everything, right?

@duckfrost2

not sure what you mean.
In the older version the urdf did not look nice but the Joints did rotate. Is there something I have to do additionally to colcon build ?

Hi @rzegers, @duckfrost2 ,

before the question closes can you kindly share some hints which make the arm work ?

Kind Regards,
Volker

Hi,

So The simulation wont move if the controller values ar enot correct, maybe the joints effort limit is to low, or the weight of the arm is too much. This is case you want to move the real simulated robot in gazebo.

If what you want is just move the robot model in RVIZ, without the robot simulation then you really don’t nee the gazbeo simulation. In fact it could be interfering in the joint state telling rviz that the joints are not moving, while the rviz tries to move the robot_description loaded model.

Hi @duckfrost2

not sure from the course content how I could actually know all that and tweak it in a form that it just works but thanks.

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.