Tutorials/2.2/plugins/WorldEdit


 * 1) Tutorial: Programmatic World Control#

This plugin example programmatically modifies the gravity.


 * Prerequisite**: See the HelloWorld tutorial.

Source: `gazebo/examples/plugins/world_edit`
 * 1) Setup

1. Create a working directory

mkdir ~/world_edit; cd ~/world_edit

1. Create a file called `~/world_edit/world_edit.world`

gedit world_edit.world

Add the following contents to it: 


 * 1) Code ##

1. Create a file called `~/world_edit/world_edit.cc`:

gedit world_edit.cc

Add the following content to it: 


 * 1) The Code Explained ###

We create a new node pointer, and initialize it to using the world name. The world name allows the node to communicate with one specific world. 

A publishers is created for sending physics messages on the "~/physics" topic. 

A physics message is created, and the step time and gravity are altered. This message is then published to the "~/physics" topic.

Create a CMake script called `~/world_edit/CMakeLists.txt`:
 * 1) Build ##

gedit CMakeLists.txt

Copy the following content into it: 

Create a `build` directory

mkdir build; cd build

Compile the plugin

cmake ../; make


 * 1) Run Tutorial ##

First you need to add the folder to the `GAZEBO_PLUGIN_PATH` environment variable:

$ export GAZEBO_PLUGIN_PATH=${GAZEBO_PLUGIN_PATH}:~/world_edit/build/

Then in a terminal

cd ~/world_edit/build gazebo ../world_edit.world

You should see an empty world.

Now add a box to the world using the Box icon located above the render window. The box should float up and away from the camera.