How can you place two objects that seem to overlap with their units but appear stacked on top of each other [original intent] in RViz?

I was watching this video tutorial on ROS and URDF. I have tried to paste screenshots to clarify but feel free to watch the video if you have the time. The presenter is showing how to create a joint between base link and link 01 in the first image below.


Here's the xacro file that I am confused about. If the xyz coordinates of the origin of the box are [0 0 0] and its dimensions are [1 1 1], how can the cylinder have its origin at [0 0 0.2]? Isn't it within the box?

xacro.xml file

I considered that the xyz coordinates may be relative to the link itself but where does RViz know where to place the object in the world? Moreover, the joint is placed at [0 0 0.5] and this makes sense. Shouldn't the origin of the cylinder have been [0 0 1.2]? This is how it looks like in RViz. RViz image


1 Answer 1


The origin defined inside link_01 is not the position of the cylinder in the global coordinate frame (the "world"), but in its own private frame. By default the object's center lies at the origin of its own coordinate frame, but in this case, the cylinder is shifted $0.2 m$ upwards along the $z$ axis, placing its bottom on the origin.

The effect of this shift is that the reference point for any further manipulations of link_01 now lies on its bottom, instead of its center as would normally be the case.

Likewise, the origin defined in the base_link__link_01 joint is defined relative to the coordinate frame of the parent link, in this case base_link. It also specifies where the origin frame of the child link will be placed, relative to the frame of the parent link.

All this leads to the following configuration:

links and frames

As you can see in the image above, the base_link__link_01 joint places the origin frame of link_01 $0.5 m$ above the origin frame of base_link. And since link_01 itself is shifted relative to its own frame, the result is that the bottom of link_01 is placed exactly on top of base_link.

The topic of coordinate frames, the transforms between them and their use in robotics is one of the more advanced, and unfortunately I don't know of a comprehensive reference on it, but this tutorial seems a good start point to getting acquainted with it.

  • $\begingroup$ You wrote, "And since base_link ..." but did you mean to say, "And since link_01..."? $\endgroup$ Apr 25, 2020 at 12:55
  • 1
    $\begingroup$ Yes, you're right. Changed the answer to fix it. $\endgroup$
    – xperroni
    Apr 25, 2020 at 12:58

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.