Robotics StackExchange | Archived questions

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

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 and nested 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.

Asked by SamG on 2020-07-11 15:58:55 UTC

Comments

Answers

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 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.

Asked by chapulina on 2020-07-13 15:55:27 UTC

Comments