Create Custom Robot Tutorial¶
Description: This tutoial provides the information needed to create a robot from scratch for use in the flatland simulator.
Tutorial Level: BEGINNER
1. Prerequisites¶
The following tutorials provide a good foundation for understanding the flatland simulator architecture:
2. Create the model Yaml file¶
Create a new Yaml file, or make a copy of an existing Yaml file as a starting place. The Yaml files can be located anywhere, however, the usual location is within the Flatland simulator directory structure:
flatland_server/test/conestogo_office_tests
We will start with a simple custom model and increase the complexity as we go. Edit your custom robot model file to contain the following:
bodies:
- name: base
type: dynamic
color: [1, 1, 1, 1]
footprints:
- type: polygon
density: 100
points: [ [-1.03, -0.337],
[.07983, -0.337],
[.30, -.16111],
[.30, .16111],
[.07983, 0.337],
[-1.03, 0.337] ]
This model has one body, of type dynamic and color white. It defines a polygonal footprint with a density of 100. The shape is a box with corners trimmed.
3. Configure Flatland to load your model¶
There are two ways to load a model into the Flatland simulator. You can load your model ineractively using the Spawn Model Tool or you can configure the simulaor to automatically load your model on startup.
Note
Any errors generated while loading a model will be sent to the console where the Flatland simulator was started.
If you want to configure the Flatland Simulator to load your specific robot model during startup, follow the instructions below.
Make a copy of the default world Yaml file:
cd flatland_server/test/conestogo_office_test
cp world.yaml custom_world.yaml
Edit your custom world yaml file and add the following:
models:
- name: your_custom_model
pose: [0, 0, 0]
model: "your_custom_model.yaml"
Note
Delete the default model if desired.
To run the Flatland simulator with your custom model, you must provide the following world_path override on the launch command:
roslaunch flatland_server server.launch world_path:=/home/mikeb/Dev/flatland_ws/src/flatland/flatland_server/test/conestogo_office_test/your_custom_world.yaml
Warning
You need to modify the path above to use the location of your Flatland installation.
You should see the flatland window appear with your new custom robot at x=0, y=0.