MRC/Tutorials/Setting up the PICO simulator: Difference between revisions
No edit summary |
|||
Line 101: | Line 101: | ||
You may get the warning:<pre>Warning [gazebo_main.cc:59] escalating to SIGKILL on server</pre> when stopping Gazebo. This is a known bug and has no consequences, other than that it takes a bit longer to kill Gazebo. | You may get the warning:<pre>Warning [gazebo_main.cc:59] escalating to SIGKILL on server</pre> when stopping Gazebo. This is a known bug and has no consequences, other than that it takes a bit longer to kill Gazebo. | ||
That's all folks! You are now ready to start your own ROS package, and create a maze solving robot! |
Revision as of 17:10, 24 April 2014
Installing Gazebo
We will use the robot simulator [Gazebo] to simulate the PICO robot and its environment. This includes simulation of the physics and sensors of the robot. To install Gazebo:
- Open a terminal (ctrl-alt-t)
- Setup your computer to accept software from packages.osrfoundation.org:
sudo sh -c 'echo "deb http://packages.osrfoundation.org/gazebo/ubuntu precise main" > /etc/apt/sources.list.d/gazebo-latest.list'
- Retrieve and install the keys for the Gazebo repositories:
wget http://packages.osrfoundation.org/gazebo.key -O - | sudo apt-key add -
- Update apt-get and install Gazebo.
sudo apt-get update
sudo apt-get install gazebo
- Initialize.
gzserver
Wait until you get a message like Publicized address: ....
You can try if your Gazebo installation was successfull by either executing a gazebo client on a seperate terminal (i.e., while gzserver is running):
gzclient
Or by running the server and client at the same time with one command:
gazebo
Configuring the PICO simulator
Now you have installed Gazebo, we can almost start using the PICO simulator. However, we first need to compile the ROS packages that we checked-out in the ~/ros/emc folder before:
- Open a terminal (ctrl-alt-t)
- Make sure rosdep is initialized and up to date:
sudo rosdep init
rosdep update
- Build and compile the PICO simulator and other necessary packages:
rosmake pico_gazebo gazebo_map_spawner
Furthermore, Gazebo needs to know where to find the robot description (located in jazz_description) which includes its meshes, textures, kinematic chain, etc, and where to find the plugins for the controllers and sensors. This information can be set in the environment variables GAZEBO_PLUGIN_PATH and GAZEBO_MODEL_PATH:
- Open a terminal (ctrl-alt-t)
- Open .bashrc:
gedit ~/.bashrc
- Add the following lines:
export GAZEBO_PLUGIN_PATH=~/ros/emc/general/pico_gazebo/lib:~/ros/emc/general/tue_gazebo_plugins/lib:$GAZEBO_PLUGIN_PATH
export GAZEBO_MODEL_PATH=~/ros/emc/general/pico_description:$GAZEBO_MODEL_PATH
- and source your .bashrc:
source ~/.bashrc
or start a new terminal.
Starting the Simulator
- Start Gazebo:
gazebo
- Using another terminal, spawn the maze:
rosrun gazebo_map_spawner spawn_maze
- Then spawn PICO:
roslaunch pico_gazebo pico.launch
Notice that the PICO robot is spawned in the Gazebo world. The Gazebo GUI shows how the world actually is. We can also visualize how the robot perceives it through its sensors, by using the ROS tool Rviz. You can start RViz with a pre-defined config showing most of PICO' sensors using:
rosrun pico_visualization rviz
In fact, this simply runs the following command:
rosrun rviz rviz -d ~/ros/general/pico_visualization/rviz/pico.rviz
If you are running the Gazebo simulation, you will see the PICO robot model and white dots which represent the sensor data originating from the (simulated) laser range finder. RViz allows you to visualize many more things. For example, to show the data from the camera:
- Click on the Add button in the lower left
- Select Camera and click OK. A Camera item will pop up in the Displays view on the left.
- Expand the Camera item by clicking the arrow on the left
- Click in the field right next to Image Topic and click the drop down arrow. Now you can select the camera topic (/pico/camera/image). Make sure you press enter.
You will see the camera images visualized in the lower left of your screen.
Examples
Here are some examples on how to use the simulator and how to practice the corridor competition in simulation.
Jazz Driving Example
- Have a look at the file jazz_node.cpp in the src folder of the jazz_example package. You should be able to understand what the program will do.
- Build the package:
rosmake jazz_example
- Run the node (make sure the simulator is still running):
rosrun jazz_example jazz_node
Check the result in both Gazebo and RViz. - Feel free to use this example as a start for your project
Jazz Safe Driving Example
- First of all, make sure you have the latest version of the jazz_example package:
roscd jazz_example
svn up
- Take some time to have a good look at the file safe_drive.cpp in the src folder of the jazz_example package. It contains a quite elaborate explanation of what is going on in the code, which will hopefully clarify quite some things.
- Build the package:
rosmake jazz_example
- Run the node (make sure the simulator is still running):
rosrun jazz_example safe_drive
Check the result in both Gazebo and RViz. - Feel free to use this example as a start for your project
Troubleshoot
Gazebo does not stop gracefully upon exit or interrupt (ctrl-c)
You may get the warning:
Warning [gazebo_main.cc:59] escalating to SIGKILL on server
when stopping Gazebo. This is a known bug and has no consequences, other than that it takes a bit longer to kill Gazebo.
That's all folks! You are now ready to start your own ROS package, and create a maze solving robot!