Difference between revisions of "ROS summary"

From AIRWiki
Jump to: navigation, search
m (How to correctly setup a Gazebo package with a plugin inside Groovy)
 
(20 intermediate revisions by 3 users not shown)
Line 1: Line 1:
This page is dedicated to '''experienced ROS users'''. Its purpose is to provide a brief summary of the most useful commands and configurations for ROS and for the external programs, with few additional explanations.
+
= ROS in AIRWiki =
 +
The page you are reading provides additional information about installation and package management in ROS.  
  
This page should not be used to provide general-purpose information about ROS or its elements, which is the task of [[ROS HOWTO]] and its secondary AIRWiki pages (e.g., [[ROS packages]], [[ROS commands]] or [[ROS components]]).
+
Basic information about ROS and its elements is available in the [[ROS HOWTO]] page. Such page also includes links to other AIRWiki pages related to ROS.
  
Please note that some of the most commonly used commands are already described in a condensed form in the [http://www.ros.org/wiki/Documentation?action=AttachFile&do=get&target=ROScheatsheet.pdf ROS Official Cheat Sheet].
+
= ROS and IDE initial setup =
 
+
== Configure your environment ==
== ROS and IDE initial setup ==
+
=== Configure your environment ===
+
 
If you followed the [http://www.ros.org/wiki/ROS/Tutorials/InstallingandConfiguringROSEnvironment ROS tutorial] to configure your environment, the variable $ROS_PACKAGE_PATH should be set. This can be easily verified by check if the command <code> echo $ROS_PACKAGE_PATH </code> returns an output similar to:
 
If you followed the [http://www.ros.org/wiki/ROS/Tutorials/InstallingandConfiguringROSEnvironment ROS tutorial] to configure your environment, the variable $ROS_PACKAGE_PATH should be set. This can be easily verified by check if the command <code> echo $ROS_PACKAGE_PATH </code> returns an output similar to:
  
Line 19: Line 18:
 
: <code> source /opt/ros/<ROS DISTIBUTION>/setup.bash </code>
 
: <code> source /opt/ros/<ROS DISTIBUTION>/setup.bash </code>
  
=== Eclipse ===
+
== Eclipse ==
 
* '''To reuse your shell environment''' it is advisable to launch  [http://www.eclipse.org/ Eclipse] with the following command:
 
* '''To reuse your shell environment''' it is advisable to launch  [http://www.eclipse.org/ Eclipse] with the following command:
  
 
: <code> bash -i -c /usr/lib/eclipse/eclipse </code>
 
: <code> bash -i -c /usr/lib/eclipse/eclipse </code>
  
*  '''To let ROS create the Eclipse project files''' you can use the following command:
+
*  '''To let ROS create the Eclipse project files''' you can use the following command (only for Fuerte or older releases):
  
 
::<code> make eclipse-project </code>
 
::<code> make eclipse-project </code>
Line 31: Line 30:
  
 
*  '''To add an existing project to Eclipse''' select File --> Import --> General --> Existing Projects into Workspace, select the project's root directory and be sure that the "Copy projects into workspace" option is NOT selected.
 
*  '''To add an existing project to Eclipse''' select File --> Import --> General --> Existing Projects into Workspace, select the project's root directory and be sure that the "Copy projects into workspace" option is NOT selected.
 +
 +
* '''For Groovy users''': you have to use the following command from within your ''catkin_ws'' folder:
  
== Package management ==
+
::<code> catkin_make --force-cmake -G"Eclipse CDT4 - Unix Makefiles </code>
 +
 
 +
: Then import the project from the ''build/'' folder. A link named ''Source directory'' within the project is provided, and you can edit the source code from there.
 +
 
 +
= Package management =
 
ROS packages can be managed using your linux distribution package manager and/or with the built-in ROS package manager.
 
ROS packages can be managed using your linux distribution package manager and/or with the built-in ROS package manager.
  
=== ROS package environment ===
+
== Internal structure of a package ==
 +
In ROS, each package has its own directory on disk: all the elements of the package are contained in such directory. The ROS package takes the name of the directory. Some of the package directories are installed by ROS, and reside somewhere on your hard disk (tip: to quickly reach a ROS package from the command line, and discover where it's located, simply use ''roscd name_of_the_package''). Other package directories are created by you, and you can put them wherever you like (usually somewhere in /home/your_username).
 +
 
 +
It doesn't matter where your packages are, provided that the directory that contains them is one where ROS looks for packages. You can't just put your ROS package directory anywhere you want: you will also need to tell ROS where it can find them. In practice, this is done by [http://www.ros.org/wiki/ROS/Tutorials/InstallingandConfiguringROSEnvironment properly configuring ROS]. The simplest way to create and prepare the directory for a new ROS package is to use [http://www.ros.org/wiki/roscreate roscreate-pkg]; otherwise you can do the preparation manually.
 +
 
 +
The contents of a package directory in ROS are standardized. Most of these are only modified by ROS, and you can ignore them; however, there are some elements of your package's directory that you will have to modify manually. Let us suppose that you are creating a new ROS package called MyPkg. As said above, all the elements of your package will be contained in a directory called MyPkg, located somewhere in your PC's filesystem. The elements of MyPkg that you might need to modify while working on your new package are the following:
 +
 
 +
* MyPkg'''/CMakeLists.txt''', a text file which tells ROS which elements (executable files, message types, ROS services, ...) it will have to create while building package MyPkg. [http://www.ros.org/wiki/rosbuild/CMakeLists?action=show&redirect=CMakeLists CMakeLists.txt] defines the compile behaviour of [http://www.ros.org/wiki/rosmake rosmake] for package MyPkg.
 +
 
 +
* MyPkg'''/src/''', where the source code for your ROS nodes reside (in the form of .cpp files, if you are using C++). (By the way: the executable files that rosmake creates are in MyPkg/bin.)
 +
 
 +
* MyPkg'''/launch/''', where you put your [http://www.ros.org/wiki/roslaunch launchfiles], if you use them (which is very likely when you build complex ROS systems).
 +
 
 +
* MyPkg'''/msg/''', where you define your own types of [http://www.ros.org/wiki/msg ROS messages].
 +
 
 +
* MyPkg'''/srv/''', where you define your own [http://www.ros.org/wiki/srv ROS services].
 +
 
 +
* MyPkg'''/manifest.xml''', which (by being present) specifies that MyPkg is a ROS package directory, and which defines some properties of the package; usually you won't need to modify [http://ros.org/wiki/Manifest manifest.xml] unless you need to add a '''dependency''' to your package.
 +
 
 +
== ROS package environment ==
 
* To initialize the ROS package management environment:
 
* To initialize the ROS package management environment:
 
::<code> (as root) rosdep init </code>
 
::<code> (as root) rosdep init </code>
Line 42: Line 66:
 
::<code> rosdep update </code>
 
::<code> rosdep update </code>
  
=== ROS package installation ===
+
== ROS package installation ==
 
* To find a package:
 
* To find a package:
 
::browse to [http://www.ros.org/browse/ this page] to browse a list of available packages.
 
::browse to [http://www.ros.org/browse/ this page] to browse a list of available packages.
Line 55: Line 79:
 
::<code> (as root) rosdep install package_name </code>
 
::<code> (as root) rosdep install package_name </code>
  
=== New package creation ===
+
== New package creation ==
 
This command creates a new package in the current directory:
 
This command creates a new package in the current directory:
  
Line 62: Line 86:
 
Please note that package dependencies can be explicitly specified when the package is created, but they can also be manually added afterwards to the ''manifest.xml'' file or with the ''rospack command''. Take a look at [http://www.ros.org/wiki/ROS/Tutorials/CreatingPackage#ROS.2BAC8-Tutorials.2BAC8-rosbuild.2BAC8-CreatingPackage.First-order_package_dependencies this page] if you need further information.
 
Please note that package dependencies can be explicitly specified when the package is created, but they can also be manually added afterwards to the ''manifest.xml'' file or with the ''rospack command''. Take a look at [http://www.ros.org/wiki/ROS/Tutorials/CreatingPackage#ROS.2BAC8-Tutorials.2BAC8-rosbuild.2BAC8-CreatingPackage.First-order_package_dependencies this page] if you need further information.
  
===== CMakeLists.txt =====
+
==== CMakeLists.txt ====
  
 
Official pages:<br />
 
Official pages:<br />
Line 129: Line 153:
 
</pre></code>
 
</pre></code>
  
===== Makefile =====
+
==== Makefile ====
 
Be sure that the following line is present in the Makefile in order for the command <code> make eclipse-project </code> to work:
 
Be sure that the following line is present in the Makefile in order for the command <code> make eclipse-project </code> to work:
  
 
<code> include $(shell rospack find mk)/cmake.mk </code>
 
<code> include $(shell rospack find mk)/cmake.mk </code>
  
===== Manifest.xml =====
+
==== Manifest.xml ====
 
<code><pre><nowiki>
 
<code><pre><nowiki>
 
<package>
 
<package>
Line 152: Line 176:
 
</nowiki></pre></code>
 
</nowiki></pre></code>
  
== ROS commands ==
+
= Gazebo wrapped into Groovy (a.k.a. ''Questo matrimonio non s'ha da fare'') =
=== ROS Filesystem ===
+
Don't waste your time trying to execute the tutorials available on the ROS website!!
* To change directory directly to a package or stack directory:
+
::<code> roscd package_name </code>
+
or
+
::<code> roscd stack_name </code>
+
  
== External programs ==
+
They are outdated and will almost surely not work in every ROS distribution later than electric. ([http://answers.gazebosim.org/question/1067/ros-groovy-gazebo-cannot-spawn-objects/ Source]). You can (almost) safely follow [http://gazebosim.org/wiki/Tutorials Gazebo's tutorials the gazebo standalone's tutorials], but be sure to select the right tutorials for the version of Gazebo included in your distribution of ROS (as of 15 March 2013, Groovy --> Gazebo 1.3) and to read the following instructions.
=== rviz (ROS visualization system) ===
+
* To open rviz you will need '''roscore''' running in background (execute <code> roscore </code> in a different shell) and then run the following command:
+
::<code> rosrun rviz rviz </code>
+
: The rviz interface will pop up, to visualize something published by a node you will have to
+
:* Add a type by clicking ''Add'' and selecting a display type (e.g.: poing cloud)
+
:* Set the topic that you want to listen (the one specified in the node that is publishing)
+
:* Set in the ''Global Options'' menu the desired ''Fixed Frame'' (typically <code> /map </code>)
+
  
=== Gazebo wrapped into Groovy (a.k.a. ''Questo matrimonio non s'ha da fare'') ===
+
=== How to correctly setup a Gazebo package with a plugin inside Groovy ===  
Don't waste your time trying to execute the tutorials available on the ROS website!! They are outdated and will almost surely not work in every ROS distribution later than electric. ([http://answers.gazebosim.org/question/1067/ros-groovy-gazebo-cannot-spawn-objects/ Source]).
+
You can (almost) safely follow [http://gazebosim.org/wiki/Tutorials Gazebo's tutorials the gazebo standalone's tutorials], but be sure to select the right tutorials for the version of Gazebo included in your distribution of ROS (as of 15 March 2013, Groovy --> Gazebo 1.3) and to follow the following instructions.
+
 
+
==== How to correctly setup a Gazebo package with a plugin inside Groovy ====  
+
 
Note: the following supposes a working and correctly configured ROS environment (follow the [http://www.ros.org/wiki/ROS/Tutorials/InstallingandConfiguringROSEnvironment ROS official installation guide] otherwise)
 
Note: the following supposes a working and correctly configured ROS environment (follow the [http://www.ros.org/wiki/ROS/Tutorials/InstallingandConfiguringROSEnvironment ROS official installation guide] otherwise)
  
We use the [http://gazebosim.org/wiki/Tutorials/1.3/intermediate/control_model Control model tutorial] of gazebo standalone, as an example to show what to do to successfully complete Gazebo standalone's tutorials in the ROS-wrapped gazebo.
+
Hereby we will use the [http://gazebosim.org/wiki/Tutorials/1.3/intermediate/control_model Control model tutorial] of gazebo standalone as an example to show what to do to make Gazebo standalone's tutorials work with the ROS-wrapped gazebo.
# Create the ROS package, specifying the dependency on gazebo, and open it: <code>roscreate-pkg gazebo_control_model gazebo; cd gazebo_control_model/</code>
+
#'''Create the ROS package''', specifying the dependency on gazebo, and browse its folder: <br /><code>roscreate-pkg gazebo_control_model gazebo; cd gazebo_control_model/</code>
# Create the .world file and the plugin file, as specified in the tutorial
+
#'''Create the .world file, the model file (.sdf) and the plugin file (.cc)''', if any, as specified in the tutorial
# Look for the ''<plugin>'' tag in the world file and modify the ''filename'' property adding "lib/" (without quotes) before the filename (e.g., from <code>filename="libcontrol_model.so"</code> to <code>filename="lib/libcontrol_model.so"</code>)
+
#'''Edit the CMakeLists.txt file''', adding the following at the end (substitute the .cc filename appropriately):<br /><code>rosbuild_add_library(${PROJECT_NAME} control_model.cc)</code>
# Open the CMakeLists.txt file and add at the end <code>rosbuild_add_library(control_model SHARED control_model.cc)</code>
+
#'''Create the build folder and open it'''<br /><code>mkdir build; cd build</code>
# Create the ''build'' folder <code>mkdir build; cd build</code>
+
#'''Run cmake and make''' <br /><code>cmake .. ; make</code> (note the double point after cmake!)
# Run cmake and make <code>cmake ..; make</code>
+
#'''Modify the ''<plugin filename>'' tag''', if any, in the world files and in the model files. Write the library filename in a full path form. Note also that it is likely that the plugin will be in a  "''lib/''" folder inside your package folder, be sure to write the correct path to the library.
 +
#'''Download and extract''' [[Media:zzz_launchers_autogenerator.zip|the following script]] in the package folder (in the main one, not inside the build folder). Read the included instructions (at the beginning of the script file) and modify the required variables. Then make it executable and run it to create the .launch file: <br /><code> chmod ugoa+x zzz_launchers_generator.sh;    ./zzz_launchers_generator.sh</code><br />
  
==== Interesting links for the future (to be tested) ====
+
=== Interesting links for the future (to be tested) ===
[http://answers.gazebosim.org/question/854/error-loading-sdf-in-gazebo-131/ This discussion] proposes a method to use Gazebo's models included with Groovy and [http://answers.gazebosim.org/question/60/tutorial-for-simple-urdf-models/ this one] cites some model that seem to be working with the ROS-wrapped-Gazebo.
+
*[http://answers.gazebosim.org/question/60/tutorial-for-simple-urdf-models/ This discussion] cites some model that seem to be working with the ROS-wrapped-Gazebo.
  
==== Common error messages ====
+
=== Common error messages ===
 
* Trying to execute the wrapped-into-Groovy Gazebo, you could encounter the following error:
 
* Trying to execute the wrapped-into-Groovy Gazebo, you could encounter the following error:
 
::<code> Error [Rendering.cc:37] Failed to load the Rendering engine subsystem unable to find OpenGL rendering system. OGRE is probably installed incorrectly. Double check the OGRE cmake output, and make sure OpenGL is enabled </code>
 
::<code> Error [Rendering.cc:37] Failed to load the Rendering engine subsystem unable to find OpenGL rendering system. OGRE is probably installed incorrectly. Double check the OGRE cmake output, and make sure OpenGL is enabled </code>
Line 202: Line 212:
 
::In this case the namespace could be wrong, try to specify the "gazeborver" namespace at the end of your spawing command, e.g.:
 
::In this case the namespace could be wrong, try to specify the "gazeborver" namespace at the end of your spawing command, e.g.:
 
:::<code> rosrun gazebo spawn_model -file object.urdf -urdf  -model my_object -gazebo_namespace gazeborver </code>
 
:::<code> rosrun gazebo spawn_model -file object.urdf -urdf  -model my_object -gazebo_namespace gazeborver </code>
 
+
:::<code> rosrun gazebo spawn_model -file object.sdf -gazebo  -model my_object -gazebo_namespace gazeborver </code>
 +
:: NOTE: spawning models in this way will work only if you specify the full urdf/sdf filename path!
 
* Trying to spawn a model in gazebo, following the tutorial, you could receive an error like this:
 
* Trying to spawn a model in gazebo, following the tutorial, you could receive an error like this:
 
::: <code>Invalid <param> tag: Cannot load command parameter [table_description]: no such command [/opt/ros/groovy/share/xacro/xacro.py /opt/ros/groovy/stacks/simulator_gazebo/gazebo_worlds/objects/table.urdf.xacro]. </code>
 
::: <code>Invalid <param> tag: Cannot load command parameter [table_description]: no such command [/opt/ros/groovy/share/xacro/xacro.py /opt/ros/groovy/stacks/simulator_gazebo/gazebo_worlds/objects/table.urdf.xacro]. </code>
 
::Solution: as stated at the very beginning of this section, don't follow the tutorials on the ROS website!!
 
::Solution: as stated at the very beginning of this section, don't follow the tutorials on the ROS website!!
 +
 +
* Launching Gazebo you could get the following error:
 +
:::<code>run_id on parameter server does not match declared run_id</code>
 +
::This is due to Gazebo opening before roscore has completely started. Just ignore it and open it again and it should work!

Latest revision as of 11:28, 9 November 2016

ROS in AIRWiki

The page you are reading provides additional information about installation and package management in ROS.

Basic information about ROS and its elements is available in the ROS HOWTO page. Such page also includes links to other AIRWiki pages related to ROS.

ROS and IDE initial setup

Configure your environment

If you followed the ROS tutorial to configure your environment, the variable $ROS_PACKAGE_PATH should be set. This can be easily verified by check if the command echo $ROS_PACKAGE_PATH returns an output similar to:

/home/your_user_name/fuerte_workspace/sandbox:/opt/ros/<ROS DISTRIBUTION>/share:/opt/ros/<ROS DISTIBUTION>/stacks

If you use a different path (e.g.: ~/eclipse_workspace) you should add it to the $ROS_PACKAGE_PATH variable. The simplest way to achieve this is to edit the .bashrc file located in your home directory and add the line

export ROS_PACKAGE_PATH=~/eclipse_workspace:${ROS_PACKAGE_PATH}

NOTE: Please be sure to add this command AFTER the following line (that you should have added to your .bashrc, according to the tutorial) or you will get an error running make eclipse-project:

source /opt/ros/<ROS DISTIBUTION>/setup.bash

Eclipse

  • To reuse your shell environment it is advisable to launch Eclipse with the following command:
bash -i -c /usr/lib/eclipse/eclipse
  • To let ROS create the Eclipse project files you can use the following command (only for Fuerte or older releases):
make eclipse-project
Note that if you change anything to your manifest.xml, you will have to run this script again, which will overwrite your Eclipse project file and thereby reverting all manual changes to the project settings. Please refer to this page if you need further information.
  • To add an existing project to Eclipse select File --> Import --> General --> Existing Projects into Workspace, select the project's root directory and be sure that the "Copy projects into workspace" option is NOT selected.
  • For Groovy users: you have to use the following command from within your catkin_ws folder:
catkin_make --force-cmake -G"Eclipse CDT4 - Unix Makefiles
Then import the project from the build/ folder. A link named Source directory within the project is provided, and you can edit the source code from there.

Package management

ROS packages can be managed using your linux distribution package manager and/or with the built-in ROS package manager.

Internal structure of a package

In ROS, each package has its own directory on disk: all the elements of the package are contained in such directory. The ROS package takes the name of the directory. Some of the package directories are installed by ROS, and reside somewhere on your hard disk (tip: to quickly reach a ROS package from the command line, and discover where it's located, simply use roscd name_of_the_package). Other package directories are created by you, and you can put them wherever you like (usually somewhere in /home/your_username).

It doesn't matter where your packages are, provided that the directory that contains them is one where ROS looks for packages. You can't just put your ROS package directory anywhere you want: you will also need to tell ROS where it can find them. In practice, this is done by properly configuring ROS. The simplest way to create and prepare the directory for a new ROS package is to use roscreate-pkg; otherwise you can do the preparation manually.

The contents of a package directory in ROS are standardized. Most of these are only modified by ROS, and you can ignore them; however, there are some elements of your package's directory that you will have to modify manually. Let us suppose that you are creating a new ROS package called MyPkg. As said above, all the elements of your package will be contained in a directory called MyPkg, located somewhere in your PC's filesystem. The elements of MyPkg that you might need to modify while working on your new package are the following:

  • MyPkg/CMakeLists.txt, a text file which tells ROS which elements (executable files, message types, ROS services, ...) it will have to create while building package MyPkg. CMakeLists.txt defines the compile behaviour of rosmake for package MyPkg.
  • MyPkg/src/, where the source code for your ROS nodes reside (in the form of .cpp files, if you are using C++). (By the way: the executable files that rosmake creates are in MyPkg/bin.)
  • MyPkg/launch/, where you put your launchfiles, if you use them (which is very likely when you build complex ROS systems).
  • MyPkg/msg/, where you define your own types of ROS messages.
  • MyPkg/manifest.xml, which (by being present) specifies that MyPkg is a ROS package directory, and which defines some properties of the package; usually you won't need to modify manifest.xml unless you need to add a dependency to your package.

ROS package environment

  • To initialize the ROS package management environment:
(as root) rosdep init
  • To update the package list:
rosdep update

ROS package installation

  • To find a package:
browse to this page to browse a list of available packages.
  • To check if a ROS package or stack is installed, use the following commands:
rospack find package_name
rosstack find [stack_name]
If you get an error, install the stack that contains the package with the package manager of your linux distribution (e.g.: sudo apt-get install ros-distribution_release_name-stack_name ), then check again if rospack can find the package. If not, install it with the command:
(as root) rosdep install package_name

New package creation

This command creates a new package in the current directory:

roscreate-pkg package_name package_dependency_1 package_dependency_2 package_dependency_3 ...

Please note that package dependencies can be explicitly specified when the package is created, but they can also be manually added afterwards to the manifest.xml file or with the rospack command. Take a look at this page if you need further information.

CMakeLists.txt

Official pages:
Full description of the syntax
Examples.

cmake_minimum_required(VERSION 2.4.6)
include($ENV{ROS_ROOT}/core/rosbuild/rosbuild.cmake)

# Set the build type.  Options are:
#  Coverage       : w/ debug symbols, w/o optimization, w/ code-coverage
#  Debug          : w/ debug symbols, w/o optimization
#  Release        : w/o debug symbols, w/ optimization
#  RelWithDebInfo : w/ debug symbols, w/ optimization
#  MinSizeRel     : w/o debug symbols, w/ optimization, stripped binaries
# Usage:
#     set(ROS_BUILD_TYPE build_type)
set(ROS_BUILD_TYPE Debug)

rosbuild_init()

# Set the default path for built executables to the "bin" directory
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
# Set the default path for built libraries to the "lib" directory
set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib)

# Uncomment if you have defined messages
#rosbuild_genmsg()

# Uncomment if you have defined services
#rosbuild_gensrv()

# **** Common commands for building c++ executables and libraries ****

# To add an executable cpp file: 
# Usage:
#     rosbuild_add_executable(${PROJECT_NAME} executable_path)
rosbuild_add_executable(test_read_map src/test_read_map.cpp)

# To add a library:
# Usage:
#     rosbuild_add_library(${PROJECT_NAME} libraries_path)
rosbuild_add_library(map
                    src/map/map_cspace.cpp
                    src/map/map_draw.c)

# To link a library to an executable file:
# Usage:
#     target_link_libraries(${PROJECT_NAME} library_name)
target_link_libraries(test_read_map map)

# To add boost directories:
# rosbuild_add_boost_directories()

# To link boost:
# rosbuild_link_boost(${PROJECT_NAME} thread)

# To add the dynamic reconfigure api:
# rosbuild_find_ros_package(dynamic_reconfigure)
# include(${dynamic_reconfigure_PACKAGE_PATH}/cmake/cfgbuild.cmake)
# gencfg()
# rosbuild_add_executable(dynamic_reconfigure_node src/dynamic_reconfigure_node.cpp)
# rosbuild_add_executable(FIRST_dynamic_reconfigure_node src/FIRST_dynamic_reconfigure_node.cpp)

Makefile

Be sure that the following line is present in the Makefile in order for the command make eclipse-project to work:

include $(shell rospack find mk)/cmake.mk

Manifest.xml

<package>
  <description brief="brief description of your package">

     [write here your package name]

  </description>
  <author>Your name</author>
  <license>BSD</license>
  <review status="unreviewed" notes=""/>
  <url>http://ros.org/wiki/package_name</url>
  <depend package="package dependance 1"/>
  <depend package="package dependance 2"/>
  ....
</package>

Gazebo wrapped into Groovy (a.k.a. Questo matrimonio non s'ha da fare)

Don't waste your time trying to execute the tutorials available on the ROS website!!

They are outdated and will almost surely not work in every ROS distribution later than electric. (Source). You can (almost) safely follow Gazebo's tutorials the gazebo standalone's tutorials, but be sure to select the right tutorials for the version of Gazebo included in your distribution of ROS (as of 15 March 2013, Groovy --> Gazebo 1.3) and to read the following instructions.

How to correctly setup a Gazebo package with a plugin inside Groovy

Note: the following supposes a working and correctly configured ROS environment (follow the ROS official installation guide otherwise)

Hereby we will use the Control model tutorial of gazebo standalone as an example to show what to do to make Gazebo standalone's tutorials work with the ROS-wrapped gazebo.

  1. Create the ROS package, specifying the dependency on gazebo, and browse its folder:
    roscreate-pkg gazebo_control_model gazebo; cd gazebo_control_model/
  2. Create the .world file, the model file (.sdf) and the plugin file (.cc), if any, as specified in the tutorial
  3. Edit the CMakeLists.txt file, adding the following at the end (substitute the .cc filename appropriately):
    rosbuild_add_library(${PROJECT_NAME} control_model.cc)
  4. Create the build folder and open it
    mkdir build; cd build
  5. Run cmake and make
    cmake .. ; make (note the double point after cmake!)
  6. Modify the <plugin filename> tag, if any, in the world files and in the model files. Write the library filename in a full path form. Note also that it is likely that the plugin will be in a "lib/" folder inside your package folder, be sure to write the correct path to the library.
  7. Download and extract the following script in the package folder (in the main one, not inside the build folder). Read the included instructions (at the beginning of the script file) and modify the required variables. Then make it executable and run it to create the .launch file:
    chmod ugoa+x zzz_launchers_generator.sh; ./zzz_launchers_generator.sh

Interesting links for the future (to be tested)

  • This discussion cites some model that seem to be working with the ROS-wrapped-Gazebo.

Common error messages

  • Trying to execute the wrapped-into-Groovy Gazebo, you could encounter the following error:
Error [Rendering.cc:37] Failed to load the Rendering engine subsystem unable to find OpenGL rendering system. OGRE is probably installed incorrectly. Double check the OGRE cmake output, and make sure OpenGL is enabled
This can be due to two different issues:
  1. The OGRE's package is not correctly installed: in this case install ogre with sudo apt-get install ros-groovy-visualization-common
  2. The OGRE_RESOURCE_PATH variable is not correctly set in ROS: to solve this problem you will have to modify the "export OGRE_RESOURCE_PATH" in /opt/ros/groovy/stacks/simulator_gazebo/gazebo/scripts/setup.sh (potentially also in /opt/ros/groovy/stacks/simulator_gazebo/gazebo/setup.bash) with the correct OGRE path. This is usually located in one of the following folders:
/usr/lib/OGRE
/usr/lib/x86_64-linux-gnu/OGRE-1.7.4
/usr/lib/i386-linux-gnu/OGRE-1.7.4
Further information please refer to Gazebo answers
  • Trying to spawn a model in gazebo, you could end up stuck with the following message forever:
waiting for service /gazebo/spawn_urdf_model
In this case the namespace could be wrong, try to specify the "gazeborver" namespace at the end of your spawing command, e.g.:
rosrun gazebo spawn_model -file object.urdf -urdf -model my_object -gazebo_namespace gazeborver
rosrun gazebo spawn_model -file object.sdf -gazebo -model my_object -gazebo_namespace gazeborver
NOTE: spawning models in this way will work only if you specify the full urdf/sdf filename path!
  • Trying to spawn a model in gazebo, following the tutorial, you could receive an error like this:
Invalid <param> tag: Cannot load command parameter [table_description]: no such command [/opt/ros/groovy/share/xacro/xacro.py /opt/ros/groovy/stacks/simulator_gazebo/gazebo_worlds/objects/table.urdf.xacro].
Solution: as stated at the very beginning of this section, don't follow the tutorials on the ROS website!!
  • Launching Gazebo you could get the following error:
run_id on parameter server does not match declared run_id
This is due to Gazebo opening before roscore has completely started. Just ignore it and open it again and it should work!