Gazebo | Ignition | Community
Ask Your Question
1

SDF world/model composition across files is impossible? Grouping/empty containers of models.

asked 2020-07-11 16:15:30 -0600

SamG gravatar image

I am trying to group models to use across .worlds, and with relative poses instead of hardcoded global/world poses. It appears impossible. I have tried <include> and nested <model> but cannot find the right behavior.

Am I missing something?

Requirements Say we have house with rooms of furniture. Each furniture object (table, chair) should be non-static and manipulated individually or as a group via gzclient. I want the ability to 1) load the house as its own world, 2) add the house to an existing world e.g, a street, 3) load one room of the house, or 4) add each furniture object to other worlds (chair/model.sdf). Ideally, using relatively coordinates, each room model is at the origin and the house model sets their poses accordingly. Similarly, each house model is at the origin and the street model/world offsets these.

Attempt using nested <model> elements: For instance, we have room/model.sdf that includes chair/model.sdf and table/model.sdf. There are two problems: 1) room model requires <collision> element otherwise its physics is not applied to its nested models (introduces another issue) and 2) cannot translate/rotate the chair or table models independently in gzclient -- the entire room is transformed.

  <model name="my_room">
    <model name="my_bookshelf">
      <static>false</static>
      <include>
        <uri>model://bookshelf</uri>
        <pose>0 0 1 0 0 0.0</pose>
      </include>
    </model>
    <model name="my_table">
      <static>false</static>
      <include>
        <uri>model://cafe_table</uri>
        <pose>0 4 1 0 0 0.0</pose>
      </include>
    </model>
  </model>

Attempt using <include> only, no nested <model> elements: In addition to the above problems, this has three _more_ problems: 4) Sub-models are added as Link implicit to the parent model, 5) consequently world outliner does not show their model names and 6) secondary+ levels are flattened.

<model name="my_room">
      <static>false</static>
      <include>
        <uri>model://bookshelf</uri>
        <pose>0 0 1 0 0 0.0</pose>
      </include>
      <include>
        <uri>model://cafe_table</uri>
        <pose>0 4 1 0 0 0.0</pose>
      </include>
  </model>

The work-around appears to be entirely flat <model> lists in separate <world> elements / .world files for house.world, room.world, street.world. If I want to mix rooms, I need to copy the flat list of models from each room.world and apply a new pose offset to every model, instead of simply including the room model with a single pose offset.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2020-07-13 15:55:27 -0600

chapulina gravatar image

I am trying to group models to use across .worlds

I think this is an important use case, but unfortunately as you've noticed not one that's well supported at the moment.

1) room model requires <collision> element otherwise its physics is not applied to its nested models

This sounds like a bug in Gazebo, I'd expect collisions / visuals to be optional on nested models, just like they are on regular models.

2) cannot translate/rotate the chair or table models independently in gzclient -- the entire room is transformed

This is also a feature that was never implemented, I added a note to this issue.

Attempt using <include> only

I'd recommend against using this for your case, as you saw, the models get flattened.


In the past, we've used other templating / scripting tools to implement this kind of scenario. I often use ERB to generate and combine SDF files based on input parameters. See an example here.

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2020-07-11 15:58:55 -0600

Seen: 109 times

Last updated: Jul 13 '20