Visible to the public Create and run your custom world fileConflict Detection Enabled

About

This tutorial demonstrates how to create a world file for Gazebo in which you can design a set of obstacles for your vehicle to detect. There are two ways to do this:

  • Start up an existing world (with the catvehicle already in it), and add obstacles while the vehicle is moving around. Then delete the vehicle from the world file after you save it.
  • Create a world from scratch (without the catvehicle already in it) and then save the world directly.

We'll start with the first, and finish with the second.

Save-as from existing world

Start up your favorite world

I like beginning with the neighborhood, and then moving stuff around, but really you could pick any one.

roslaunch catvehicle catvehicle_neighborhood.launch

And in a new tab:

gzclient

Add/move objects to your heart's content

Perhaps you want the vehicle to drive around in a large circle, and you'd like to have things distributed throughout the circle on either side of the car. Let's start with that, by running the hoffmannfollower_node (see tutorial on following a circle in order to generate the code for the Hoffmann Follower).

rosrun catvehicle_hoffmannfollower catvehicle_hoffmannfollower_node

If this package and node are not found, you will need to generate the code from Simulink and then extract to your workspace (see tutorial).

File->Save world as...

Save the world into your package/worlds directory as, say, world5.world. Next, edit the world5.world file in your favorite text editor (e.g., gedit) and remove two regions of the file.

  • Region 1 contains the links and interfaces of the catvehicle. Search for 'catvehicle' and you will find a model with that name. Find the matching /model tag about 44 lines below and delete the XML inclusive to that tag
  • Region 2 contains the poses of all the links and of the model as a whole. Search again for 'catvehicle' and you will find a model with that name. Find the matching /model tag about 830 lines below and delete the XML inclusive to that tag
  • Save the world file again. 

Now you can open it up as:

roslaunch yourpackage catvehicle_custom.launch worldfile:=world5.launch

In the beginning, "yourpackage" will probably be the cvchallenge_task2 seed you downloaded, but you will likely want to create your own version control and maybe even modify your package as such: substitute your own details as necessary.

Create from blank canvas

Start up roscore, then gazebo

Since you aren't beginning from a launchfile, you will need to start roscore before you start gazebo.

roscore

And in a new tab:

rosrun gazebo_ros gazebo

At this point, we still need one more tab:

rosrun gazebo_ros gzclient

You may be able to run this outside of ros, but doing so might also inadvertently run the wrong version of gazebo, so I recommend doing it this way. 

Insert/add to your heart's content

Now you're ready to create the world in which you'd like to operate. Add away as much as you like, and then...

File->Save world as...

Save the world into your package/worlds directory as, say, world5.world. Now you can open it up as:

roslaunch yourpackage catvehicle_custom.launch worldfile:=world5.launch

In the beginning, "yourpackage" will probably be the cvchallenge_task2 seed you downloaded, but you will likely want to create your own version control and maybe even modify your package as such: substitute your own details as necessary.

What's next?

You're ready now to start building up an array of worldfiles in which you can start to understand how to use the sensors to detect obstacles. Good luck!