ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A
Ask Your Question

Problem using ROS-Package-Headers in Gazebo-Plugin

asked 2013-06-18 02:37:29 -0500

Seba gravatar image

Hi, I'm currently working on my first Gazebo Plugin where I use several ROS-Packages. When I try to compile it, the compiler doesn't find these includes (i.e. PCL Headers). Is there anything I've got to add to the Cmake-File?

edit retag flag offensive close merge delete


Hey, are you using simulator_gazebo (the ROS package) or the Gazebo 1.9 (the standalone)? If you're using the standalone, I might be able to help you as I just solved a similar problem.

Throst Gunnulf gravatar image Throst Gunnulf  ( 2013-07-16 01:46:55 -0500 )edit

Thank you for your reply. I work with Gazebo Standalone

Seba gravatar image Seba  ( 2013-07-16 02:32:52 -0500 )edit

I'll try to post an answer later today. I am new to these forums, so I need to learn how to correctly format everything and can only do that later.

Throst Gunnulf gravatar image Throst Gunnulf  ( 2013-07-16 03:35:58 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2013-07-16 10:33:59 -0500

Throst Gunnulf gravatar image

updated 2013-07-17 10:38:50 -0500

Solution 2 (better)

I realised there is a much simpler way of solving this problem. Just create a ROS package as usual with your plugin code in the /src/ folder of the ROS package directory. Then, edit your CMakeLists.txt to be something like this

cmake_minimum_required(VERSION 2.4.6)

include (FindPkgConfig)
  pkg_check_modules(GAZEBO gazebo)

# 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
#set(ROS_BUILD_TYPE RelWithDebInfo)


#set the default path for built executables to the "bin" directory
#set the default path for built libraries to the "lib" directory

#uncomment if you have defined messages
#uncomment if you have defined services


#common commands for building c++ executables and libraries
rosbuild_add_library(${PROJECT_NAME} ${GAZEBO_libraries} src/
#target_link_libraries(${PROJECT_NAME} another_library)
#rosbuild_link_boost(${PROJECT_NAME} thread)
#rosbuild_add_executable(example examples/example.cpp)
target_link_libraries(${PROJECT_NAME} ${GAZEBO_libraries})

What this does is compile your plugin into a .so file (output to the /lib/ folder). Put this plugin into one of the directories in the GAZEBO_PLUGIN_PATH environment variable and everything should run just fine.

Solution 1

Hey, sorry for the delay. I am quite new to Gazebo and ROS, so take everything I say with a grain of salt. The following makes sense in my head, but I might be terribly wrong about some things. Nevertheless, it solved my problem. I hope this helps. Don't hesitate to ask for a better explanation of something I might have overlooked.

First, I assume you use a CMake script similar to this one to compile your plugin into a .so file.

cmake_minimum_required(VERSION 2.8 FATAL_ERROR)

include (FindPkgConfig)
  pkg_check_modules(GAZEBO gazebo)


add_library(example SHARED
target_link_libraries(example ${GAZEBO_libraries})

The first thing I did, to solve the missing header files, was to change the sixth and the last lines to the following.

include_directories(${GAZEBO_INCLUDE_DIRS} /path/to/ROS/include/folder)

target_link_libraries(example ${GAZEBO_libraries} ${LD_LIBRARY_PATH})

Notice you should change /path/to/ROS/include/folder to the correct path to your ROS include folder. In my system, the path is /opt/ros/fuerte/include/

Now, if you run the CMake script, the compiler should find the header files and compile everything without problems. But, if you're using functions that are defined in the example_package package, when you run the Gazebo plugin, you will probably get an error saying something like "undefined symbol". This is because the linker doesn't know where the code of the functions is.

The problem here is that this code is defined in the example_package package, and I don't know how to link a program with a ROS package. Luckily, I found the following CMake script, which, when included in your ...

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2013-06-18 02:37:29 -0500

Seen: 451 times

Last updated: Jul 17 '13