Rotate link in xacro-file for rviz
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>
Asked by masterkey on 2021-05-21 09:57:10 UTC
Answers
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.
in the link, you can apply a rotation to the
origin
of yourinertial
,collision
, andvisual
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 filesthe alternative is to define the
joint
between yourlink
and whatever its attached to. Thejoint
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 therpy
field of thejoint
'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)
Asked by shonigmann on 2021-05-21 11:00:40 UTC
Comments