Create a world with OpenStreetMap

Get the map data

  1. Go to http://www.openstreetmap.org/

  2. Click on Export.

  3. Click on Manually select a different area and select the area. Be careful not to choose an area too large or it will take hours to download and Parrot-Sphinx or your machine may not even be able to handle it.

  4. Click on Export and save the file onto your disk.

Generate the model file

  1. Download OSM2World:

$ git clone https://github.com/tordanik/OSM2World.git
  1. Install its dependencies (you may choose another jdk):

$ sudo apt-get install default-jdk ant
  1. Build OSM2World:

$ cd OSM2World && ant jar
  1. Go to the build directory:

$ cd build
  1. Download and extract the texture pack:

$ wget http://osm2world.org/download/files/misc/OSM2World%20Texture%20Selection%202014-07-19.zip
$ unzip OSM2World\ Texture\ Selection\ 2014-07-19.zip
  1. Run OSM2World:

$ java -jar OSM2World.jar --config texture_config.properties -i /path/to/map.osm -o path/to/map.obj

Convert the OBJ (Wavefront) model into a DAE (Collada) model

  1. Install Blender with collada support:

$ sudo add-apt-repository ppa:thomas-schiex/blender
$ sudo apt-get update
$ sudo apt-get install blender
  1. Launch Blender:

$ blender
  1. Import the OBJ file you just generated: File > Import > Wavefront (.obj)

  2. Select every objects in the scene: Press a

  3. Join the selected objects: Press ** j**

  4. Export the model into a DAE file: File > Export > Collada (.dae)

  5. Select the following options in the lower left panel: * Apply Modifiers * Include UV Textures * Include Material Textures

  6. Click on Export COLLADA. Beware that Blender will create a new file for each texture, so it would be wise to create a new directory first.

Create a SDF model for Gazebo

  1. Create a directory where you will put all your models:

$ mkdir my_models && cd my_models
  1. Create a directory for your new model:

$ mkdir my_model && cd my_model

3. Copy the DAE file and all its textures in a new directory named “meshes”:

$ cp -r /path/to/dae/ meshes
  1. Create a “model.config” file with this content:

<?xml version="1.0"?>
<model>
  <name>My Model</name>
  <version>1.0</version>
  <sdf version="1.5">model.sdf</sdf>
  <description>
    My model.
  </description>
</model>
  1. Create a “model.sdf” file with this content:

<?xml version="1.0" ?>
<sdf version="1.5">
  <model name="My Model">
    <static>true</static>
    <link name="link">
      <collision name="collision">
        <geometry>
          <mesh>
            <uri>model://my_model/meshes/my_model.dae</uri>
          </mesh>
        </geometry>
      </collision>
      <visual name="visual">
        <geometry>
          <mesh>
            <uri>model://my_model/meshes/my_model.dae</uri>
          </mesh>
        </geometry>
      </visual>
    </link>
  </model>
</sdf>

Your “my_models” directory should now look like this:

my_models
 |__ my_model
        |__ meshes
            |__ my_model.dae
            |__ arbaro_tree_broad_leaved.png
            |__ arbaro_tree_broad_leaved.png.001.png
            |__ ...
        |__ model.config
        |__ model.sdf

6. To include the model in a world, simply add the following lines inside the <world> section:

<include>
  <uri>model://my_model</uri>
</include>

7. Then you are ready to fly! But don’t forget to add the path to your models in GAZEBO_MODEL_PATH:

GAZEBO_MODEL_PATH=$GAZEBO_MODEL_PATH:/path/to/my_models sphinx my_world.world