ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

use ros header files in c++ project

asked 2018-02-16 10:59:19 -0500

lounis gravatar image

Hi,

I am new to ROS. I want to include ros header files (for example #include <rosbag bag.h="">) in a c++ project. I do not want to create a node and start roscore. How can I include this header + other dependencies in a CMakeLists file ?

Thanks.

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
0

answered 2018-02-16 12:49:51 -0500

lucasw gravatar image

See #q238955

catkin ( http://wiki.ros.org/catkin/Tutorials ) which makes use of CMake is the best supported way to go, otherwise you could do cmake on your own like:

find_package(roscpp REQUIRED)
include_directories(${roscpp_INCLUDE_DIRS})
...

Replace roscpp with whatever library you need.

pkg-config also can get ros libraries and includes.

edit flag offensive delete link more

Comments

@lucasw Thanks a lot. This is just what I was looking for.

lounis gravatar image lounis  ( 2018-02-16 14:20:03 -0500 )edit

using these lines in my CMakeList : cmake_minimum_required(VERSION 2.8.12) project(writeBag) find_package(roscpp REQUIRED) I get this error :CMake Error at CMakeLists.txt:3 (find_package): By not providing "Findroscpp.cmake" in CMAKE_MODULE_PATH this project has asked CMake to find a package

lounis gravatar image lounis  ( 2018-02-19 07:37:25 -0500 )edit

../.. configuration file provided by "roscpp", but CMake did not find one.

Could not find a package configuration file provided by "roscpp" with any of the following names:

roscppConfig.cmake
roscpp-config.cmake

Add the installation prefix of "roscpp" to CMAKE_PREFIX_PATH or set..

lounis gravatar image lounis  ( 2018-02-19 07:38:14 -0500 )edit
1

I fixed this issue : I needed to source the ROS setup.bash file...

lounis gravatar image lounis  ( 2018-02-19 09:46:45 -0500 )edit

Question Tools

2 followers

Stats

Asked: 2018-02-16 10:59:19 -0500

Seen: 1,532 times

Last updated: Feb 16 '18