Ask Your Question
1

Rotate link in xacro-file for rviz

asked 2021-05-21 09:57:10 -0600

masterkey gravatar image

Hello,

I have a xacro file. In this file I want to rotate a link 90 degrees clockwise. How do I do that? The code is:

<!-- Mast Mount -->
<link name="mastmount_link">
    <visual>
        <origin rpy="0 0 0" xyz="0 0 0" />
        <geometry>
            <mesh filename="package://curio_description/meshes/bases/mastmount.stl" />
        </geometry>
        <material name="dark_gray" />
    </visual>
    <collision>
        <origin rpy="0 0 0" xyz="0 0 0" />
        <geometry>
            <mesh filename="package://curio_description/meshes/bases/mastmount.stl" />
        </geometry>
    </collision> 
</link>
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2021-05-21 11:00:40 -0600

shonigmann gravatar image

When you say 90 degrees clockwise, its not giving us quite enough information to give you an exact answer. Clockwise about which axis? ROS uses a right handed coordinate system (more info here), with x = forward, y = left, z = up

URDF, SDF, and XACRO define rotations using Euler angles in radians. The rpy field in your visual and collision elements are the roll (rotation about x), pitch (rotation about y) and yaw (rotation a bout z) angles. 90 degrees in radians is approx. 1.5708rad. Whether "clockwise" means positive or negative depends on the axis you choose and the direction you are looking from.

All that aside, there are two ways you can apply a rotation to a joint.

  1. in the link, you can apply a rotation to the origin of your inertial, collision, and visual fields. E.g. for 90deg clockwise about z, you'd set`rpy="0 0 -1.5708"; this can be a bit tedious, and I'd only recommend it if your CAD just happened to use a different coordinate frame and you'll be including the link in different files

  2. the alternative is to define the joint between your link and whatever its attached to. The joint field also lets you specify the rotation of a part relative to its parent; this way, you only have to specify it once (less error prone if you need to change it). again, you'd be setting the rpy field of the joint's origin.

As a final note, if all you want to do is have the RVIZ viewer look at your model from a different perspective, without actually changing the part's orientation with respect to the rest of the robot, then I'd suggest defining a dummy joint at 90 degrees to the mastmount_link, making sure you are publishing the tf, and changing the reference frame in RVIZ (under the fixed frame setting)

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2021-05-21 09:57:10 -0600

Seen: 93 times

Last updated: May 21