0
$\begingroup$

I'm am trying to write a simple 2 link URDF in ros2 humble but the orientation of one of the joints continuously flips from one orientation to another.

Half of the time the "body2" link is in this orientation:

enter image description here

The other half it's like this:

enter image description here

This only happens when the joint is not "fixed". When it is "fixed" it behaves as expected (orientation 2).

Does anyone know why the orientation isn't stable?

Bellow is my URDF:

<?xml version="1.0"?>
<robot xmlns:xacro="http://www.ros.org/wiki/xacro" >

    <material name="white">
        <color rgba="1 1 1 1" />
    </material>

    <link name="base_link"></link>

     <joint name="base_body" type="fixed">
        <parent link="base_link"/>
        <child link="body1"/>
        <origin rpy="0 -1.570796 0"/>
    </joint>
   
    <link name="body1">
        <visual>
            <origin xyz="0 0 .15"/>
            <geometry>
                <cylinder radius="0.1" length="0.3"/>
            </geometry>
            <material name="white"/>
        </visual>
    </link>

    <joint name="body1_body2" type="revolute">
        <axis xyz="0 0 1"/>
        <limit effort="1000.0" lower="-1.570796" upper="1.570796" velocity="0.5"/>
        <origin rpy="-1.570796 0 0" xyz="0 0 0.3"/>
        <parent link="body1"/>
        <child link="body2"/>
    </joint>

    <link name="body2">
        <visual>
            <origin rpy="1.570796 0 0" xyz="0 -0.15 0"/>
            <geometry>
                <cylinder radius="0.1" length="0.3"/>
            </geometry>
            <material name="white"/>
        </visual>
    </link>

</robot>

Thank you,

$\endgroup$
2
  • 2
    $\begingroup$ URDF by itself doesn't define the current state of a revolute joint. There has to be some other node running that is publishing /joint_state information that defines what the current state of that joint is, so that RVIZ can visualize it for you. based on the symptoms, it suggests that either you have multiple nodes publishing contradictory joint state information (e.g. perhaps using 2 different conventions), or that the one source of the joint state information (e.g. a gazebo simulation) is unstable. But that's where I'd look first $\endgroup$
    – shonigmann
    Commented Jun 14 at 2:36
  • $\begingroup$ Thank you for your reply, this is what I thought at first so I tried using an example launch file from ros 2 control that only starts the robot state publisher and joint state publisher and the joint still flip-flops. The URDF does define the orientation of the joint which is what is switching here. It's supposed to rotate around the Z (blue) axis. The angle stays constant across the different orientations, so I'm not sure why the orientation is changing when it's a constant in the URDF. $\endgroup$ Commented Jun 14 at 16:59

1 Answer 1

1
$\begingroup$

For anyone having a similar issue: I flipped the orientation of both the joint "body1_body2" and the link "body2" by 180 degrees and it is now working correctly.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.