Embedded Motion Control 2013/Simulator: Difference between revisions

From Control Systems Technology Group
Jump to navigation Jump to search
No edit summary
 
(13 intermediate revisions by 2 users not shown)
Line 1: Line 1:
== Installation ==
== Installation ==


If you followed all steps specified on [[ Embedded_Motion_Control_2013#Installation | the installation page ]], you will already have downloaded the simulator Gazebo and our specific Jazz simulator. To be able to use the Jazz simulator, you first have to ''compile'' the downloaded ROS packages:
If you followed all steps specified on [[ Embedded_Motion_Control_2013/Installation | the installation page ]], you will already have downloaded the simulator Gazebo and our specific Jazz simulator. To be able to use the Jazz simulator, you first have to ''compile'' the downloaded ROS packages:


# Open a terminal ''(ctrl-alt-t)''
# Open a terminal ''(ctrl-alt-t)''
 
# Make sure ''rosdep'' is initialized and up to date:<pre>sudo rosdep init</pre><pre>rosdep update</pre>
# Navigate to the ''jazz_gazebo'' ROS package: <pre>roscd jazz_gazebo</pre>
# Build and compile the jazz simulator and other necessary packages: <pre>rosmake jazz_gazebo gazebo_map_spawner</pre>
# And build and compile the jazz simulator and other necessary packages: <pre>rosmake jazz_gazebo gazebo_map_spawner</pre>


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'':
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'':
Line 12: Line 11:
# Open a terminal ''(ctrl-alt-t)''
# Open a terminal ''(ctrl-alt-t)''
# Open ''.bashrc'':<pre>gedit ~/.bashrc</pre>
# Open ''.bashrc'':<pre>gedit ~/.bashrc</pre>
# Add the following lines:<pre>export GAZEBO_PLUGIN_PATH=~/ros/general/jazz_gazebo/lib:~/ros/general/tue_gazebo_plugins/lib:$GAZEBO_PLUGIN_PATH</pre><pre>export GAZEBO_MODEL_PATH=~/ros/general/jazz_description:$GAZEBO_MODEL_PATH</pre>
# Add the following lines:<pre>export GAZEBO_PLUGIN_PATH=~/ros/emc/general/jazz_gazebo/lib:~/ros/emc/general/tue_gazebo_plugins/lib:$GAZEBO_PLUGIN_PATH</pre><pre>export GAZEBO_MODEL_PATH=~/ros/emc/general/jazz_description:$GAZEBO_MODEL_PATH</pre>
# and source your ''.bashrc'':<pre>source ~/.bashrc</pre>or start a new terminal.


== Usage ==
== Starting the Simulator ==


# Start Gazebo:<pre>gazebo</pre>
# Start Gazebo:<pre>gazebo</pre>
# Spawn the maze:<pre>rosrun gazebo_map_spawner spawn_maze</pre>
# Start another terminal and spawn the maze:<pre>rosrun gazebo_map_spawner spawn_maze</pre>
# Spawn Jazz:<pre>roslaunch jazz_gazebo jazz.launch</pre>
# Spawn PICO:<pre>roslaunch pico_gazebo pico.launch</pre>


Notice that the Jazz 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 [ http://ros.org/wiki/rviz Rviz ]. You can start RViz with a pre-defined config showing most of Jazz' sensors using:
Notice that the Jazz 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 [http://ros.org/wiki/rviz Rviz]. You can start RViz with a pre-defined config showing most of Jazz' sensors using:


<pre>rosrun jazz_visualization rviz</pre>
<pre>rosrun jazz_visualization rviz</pre>


... Some more explanation ...
In fact, this simply runs the following command:
 
<pre>rosrun rviz rviz -d ~/ros/general/jazz_visualization/rviz/jazz.vcg</pre>
 
If you are running the Gazebo simulation, you will see the Jazz 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.
# Click in the field right next to ''Image Topic'' and click the ''...'' button. Now you can select the camera topic (''/pico/camera/image'')
 
You will see the camera images visualized in the lower left of your screen.


== Examples ==  
== Examples ==  
Line 34: Line 44:
# Build the package:<pre>rosmake jazz_example</pre>
# Build the package:<pre>rosmake jazz_example</pre>
# Run the node (make sure the simulator is still running):<pre>rosrun jazz_example jazz_node</pre>Check the result in both Gazebo and RViz.
# Run the node (make sure the simulator is still running):<pre>rosrun jazz_example jazz_node</pre>Check the result in both Gazebo and RViz.
# Load the package in Eclipse, or create your own package, and... have fun!
# 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:
## <pre>roscd jazz_example</pre>
## <pre>svn up</pre>
# 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:<pre>rosmake jazz_example</pre>
# Run the node (make sure the simulator is still running):<pre>rosrun jazz_example safe_drive</pre>Check the result in both Gazebo and RViz.
# Feel free to use this example as a start for your project


== Corridor ==
<!--
=== Corridor ===


An extra Gazebo world has been added, which contains a simple corridor with a side exit.
An extra Gazebo world has been added, which contains a simple corridor with a side exit.
Line 55: Line 75:


It may also be nice to change the corridor, ''e.g.'', changing the position of the exit. To do so, simply edit the file '''tue_corridor.png''' in the ''./Media/materials/textures'' folder of the ''jazz_simulator'' package. As you can see, this is a simple image in which white pixels represent free space, and black pixels represent walls. Of course, you need to restart the simulator to see the effects of your change.
It may also be nice to change the corridor, ''e.g.'', changing the position of the exit. To do so, simply edit the file '''tue_corridor.png''' in the ''./Media/materials/textures'' folder of the ''jazz_simulator'' package. As you can see, this is a simple image in which white pixels represent free space, and black pixels represent walls. Of course, you need to restart the simulator to see the effects of your change.
 
-->


== Troubleshoot ==
== Troubleshoot ==

Latest revision as of 21:59, 23 April 2014

Installation

If you followed all steps specified on the installation page , you will already have downloaded the simulator Gazebo and our specific Jazz simulator. To be able to use the Jazz simulator, you first have to compile the downloaded ROS packages:

  1. Open a terminal (ctrl-alt-t)
  2. Make sure rosdep is initialized and up to date:
    sudo rosdep init
    rosdep update
  3. Build and compile the jazz simulator and other necessary packages:
    rosmake jazz_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:

  1. Open a terminal (ctrl-alt-t)
  2. Open .bashrc:
    gedit ~/.bashrc
  3. Add the following lines:
    export GAZEBO_PLUGIN_PATH=~/ros/emc/general/jazz_gazebo/lib:~/ros/emc/general/tue_gazebo_plugins/lib:$GAZEBO_PLUGIN_PATH
    export GAZEBO_MODEL_PATH=~/ros/emc/general/jazz_description:$GAZEBO_MODEL_PATH
  4. and source your .bashrc:
    source ~/.bashrc
    or start a new terminal.

Starting the Simulator

  1. Start Gazebo:
    gazebo
  2. Start another terminal and spawn the maze:
    rosrun gazebo_map_spawner spawn_maze
  3. Spawn PICO:
    roslaunch pico_gazebo pico.launch

Notice that the Jazz 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 Jazz' sensors using:

rosrun jazz_visualization rviz

In fact, this simply runs the following command:

rosrun rviz rviz -d ~/ros/general/jazz_visualization/rviz/jazz.vcg

If you are running the Gazebo simulation, you will see the Jazz 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:

  1. Click on the Add button in the lower left
  2. Select Camera and click OK. A Camera item will pop up in the Displays view on the left.
  3. Click in the field right next to Image Topic and click the ... button. Now you can select the camera topic (/pico/camera/image)

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

  1. 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.
  2. Build the package:
    rosmake jazz_example
  3. Run the node (make sure the simulator is still running):
    rosrun jazz_example jazz_node
    Check the result in both Gazebo and RViz.
  4. Feel free to use this example as a start for your project

Jazz Safe Driving Example

  1. First of all, make sure you have the latest version of the jazz_example package:
    1. roscd jazz_example
    2. svn up
  2. 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.
  3. Build the package:
    rosmake jazz_example
  4. Run the node (make sure the simulator is still running):
    rosrun jazz_example safe_drive
    Check the result in both Gazebo and RViz.
  5. 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.