Gazebo 9.0 restricts a cylinder's radius parameter's fractional part to two digits

asked 2020-01-28 03:19:57 -0500

Orhan gravatar image

I have a model which includes a cylinder, and I gave the radius 0.025 and the length 0.4. And I'm including this model in my world file.

However, in the sim, when I click on this link, it's radius is becoming 0.03. There's some rounding going on which I don't understand. I tried giving 0.02 and it spawns as 0.02 successfully. Also tried 0.025000 but no luck. Then I realized that it only has two digits after the comma (comma is my local standard to show floating point numbers):

image description

Here's the link:

<link name='link_0'>
        <pose frame=''>0 0 0 0 -0 0</pose>
      <pose frame=''>0 0 0 0 -0 0</pose>
      <visual name='visual'>
        <pose frame=''>0 0 0 0 -0 0</pose>
          <shader type='vertex'>
          <ambient>1 1 1 1</ambient>
          <diffuse>1 1 1 1</diffuse>
          <specular>0.01 0.01 0.01 1</specular>
          <emissive>0 0 0 1</emissive>
      <collision name='collision'>
        <pose frame=''>0 0 0 0 -0 0</pose>
edit retag flag offensive close merge delete



It might be that the round occurs only in the GUI for displaying information while Gazebo keeps the original value with all the decimals for all the computations. What is the out of: gz model -i -m <model_name> | grep radius?

Jose Luis Rivero gravatar imageJose Luis Rivero ( 2020-01-28 14:12:05 -0500 )edit

It outputs 0.025 values. I was thinking that it might be like that yesterday, because my ROS navigation map resolution is 0.05 and in RViz, the laser reading was showing my model within a single 5cm x 5cm pixel. But I wasn't sure since the difference between rounded and non-rounded values in this resolution isn't so big.

Orhan gravatar imageOrhan ( 2020-01-28 23:27:16 -0500 )edit

Does this mean that the value is correct and the GUI just shows the rounded for e.g. performance related stuff? I also tried exporting a single STL file of a cylinder with same specs from SolidWorks and in the GUI, it was showing up exactly like the 0.03 cylinder. Compared both to the 0.02 cylinder and the difference was observable in the GUI.

Orhan gravatar imageOrhan ( 2020-01-28 23:30:57 -0500 )edit

I was unable to find the source code that demonstrate the hypothesis but if the gz tool displays the correct value my impression is that the value is right and the GUI just round it. Makes little sense to me to lost precision for computational operations in the simulator.

Jose Luis Rivero gravatar imageJose Luis Rivero ( 2020-01-30 09:44:24 -0500 )edit