We can even go one step further. Imagine I have a set of entities that always show up together, or, in other words, a model that consists of other models. A practical example is the model specification of a certain environment, e.g. your robot lab. Such a robot lab consists of walls, tables, etc. We can use composition to include models inside models.
An example. Assume we want to create a model called robot-lab. And let's say this robot lab contains walls and two tables of which we've specified the model above. Then we can create a directory called 'robot-lab' and put the following in its 'model.yaml':
composition:
- id: table1
type: table
pose: { x: 2, y: 0, z: 0 }
- id: table2
type: table
pose: { x: 3, y: 2, z: 0, Z: 1.54 }
- id: walls
shape:
heightmap:
image: $(file my-walls.pgm)
height: 2
resolution: 0.025
pose: { x: -10.0, y: -10.0, z: 0 }
Don't forget to put the 'my-walls.pgm' in the 'robot-lab' model directory! Now we have specified a model which includes other models. Our configuration file can be as simple as:
world:
- type: robot-lab
pose: { x: 0, y: 0, z: 0 }
plugins:
- name: gui_server
lib: libed_gui_server_plugin.so
Run ED and visualize the world model. You should see two tables and some walls, as specified by your heightmap.