1

i have a problem with my gazebo world and hope you could help me out. I Created a custom world in gazebo. However, after i add the world in my world robot setup launch, the objects shifted.

I think this have to do something with the state tag: https://answers.gazebosim.org//question/16144/world-shifts-after-reset/

I can fix it manually:

  1. Go to the .world file
  2. Go to the state tag and get a position tag of an object
  3. change the position of the object outside the state tag

Example:

<sdf version='1.7'>
  <world name='default'>
   <model name='NurseDesk'>
      <static>1</static>
      <link name='body'>
        <pose>0 0 0 0 -0 0</pose>
        <visual name='visual'>
          <geometry>
            <mesh>
              <uri>model://NurseDesk/meshes/NurseDesk.obj</uri>
              <scale>0.001 0.001 0.001</scale>
            </mesh>
          </geometry>
        </visual>
        <collision name='collision'>
          <geometry>
            <mesh>
              <uri>model://NurseDesk/meshes/NurseDesk.obj</uri>
            </mesh>
          </geometry>
          <max_contacts>10</max_contacts>
          <surface>
            <contact>
              <ode/>
            </contact>
            <bounce/>
            <friction>
              <torsional>
                <ode/>
              </torsional>
              <ode/>
            </friction>
          </surface>
        </collision>
        <self_collide>0</self_collide>
        <enable_wind>0</enable_wind>
        <kinematic>0</kinematic>
      </link>
      <pose>-0.209073 5.49471 0 0 -0 0</pose>
   </model>

<state world_name='default'> <model name='NurseDesk'> <pose>-0.108871 7.62391 0 0 -0 0</pose> <scale>1 1 1</scale> <link name='body'> <pose>-0.108871 7.62391 0 0 -0 0</pose> <velocity>0 0 0 0 -0 0</velocity> <acceleration>0 0 0 0 -0 0</acceleration> <wrench>0 0 0 0 -0 0</wrench> </link> </model> </state>

</world> </sdf>

If i change the position of the nurse desk outside the state tag from "-0.209073 5.49471 0 0 -0 0" to "-0.108871 7.62391 0 0 -0 0" (this position tag is inside the state tag), it fixed the problem.

If i start gazebo in the terminal with "gazebo my_world.world" --> World not shifted.: https://ibb.co/F5x1v2k

If i start gazebo in my launch file (inside include tag "include file="$(find gazebo_ros)/launch/empty_world.launch"") --> World shifted: https://ibb.co/840Y1VW

--> I don't want to fix every object. How can i launch my world without the shift?

Thank you so much !

ChangeNAL
  • 35
  • 7

2 Answers2

0

The answers.gazebosim.org answer is clear about the reason:

when Gazebo loads the world, it first loads the <world> tag and then applies the state changes described in <state>. When you reset the world, it goes back to before the states, so the world looks different from when you first loaded it.

I would reconsider changing the <pose> tags manually (or trough some script): yes it is boring work, but once it is done, it is done and you know it works...

However, if that is not an option: an alternative could be to convert the <state> info into set_model_state service calls, see here.

JRTG
  • 1,654
  • 2
  • 2
  • 11
0

You don't need the state tag at all! If you look at the default maps that come with the Gazebo package, at least some of them do not have the state tag. So if your world tag has the objects where you want them just delete that state tag altogether.

Like @JRTG said the state tag is used to modify the environment after the world tag has already been loaded so if the state tag is messing stuff up just delete it!

EDIT: If the world tag has the wrong location, and the state tag has the right pose, then you can manually copy the state pose to the matching pose in the world tag. After that you can delete the state tag :)

FWIW: If you haven't used markup languages before, you have to delete everything from to including the brackets themselves :)

stephan
  • 103
  • 3
  • 1
    I think the OP realizes that, but has the issue that the <world> tag has the objects in the incorrect position, and the <state> tag pose specifications put those in the correct position. So the OP cannot just delete the <state> tag without changing the <pose> of each of the models/links in the <world>. – JRTG Oct 16 '23 at 07:56
  • Oh I see! I misunderstood and have now updated to reflect it :) Thanks JRTG! – stephan Oct 16 '23 at 23:11