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

Build ROS code cpp without Catkin Package

asked 2023-06-08 07:01:52 -0600

Lilipop gravatar image

updated 2023-06-08 07:02:11 -0600

Hello Community,

So I have been working with ROS lately, it was really easy testing code in python where I just had to import rospy to work with ROS as I wished. I would then execute my programs with $python code.py.

So now I want to kinda do the same thing in C++, I wrote a simple code for test, but with no CMakelists where I specify the roscpp dependency, it is not able to recognize the #include "ros/ros.h", I was wondering if it would be possible if I added the ros.h header file :

  • Where can I find this header file ?
  • Will other ROS related packages (like std_msgs) get included with it ?

Thanks for the replies :)

Lilia.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2023-06-09 08:00:13 -0600

danzimmerman gravatar image

If you look at what actually gets imported when you type import rospy you will find that it pulls in an enormous amount of code. C++ includes tend to be a lot more granular and manual.

For anything beyond some basic publisher and subscriber functionality for monitoring/interacting with ROS systems you'll probably find that it's unworkably cumbersome to satisfy C++ dependencies without building your projects in a full ROS/Catkin environment. In addition to locating and including all relevant headers, you need to find all shared library objects and link to those.

You could theoretically skip Catkin and ROS packaging and just work with plain CMake to find the packages you need to include and link with your C++ code. HOwever, that will likely make it harder to break your project into several logically independent components. Catkin is there to help you build several packages that depend on each other in the order they're needed in the source dependency graph.

edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2023-06-08 07:01:52 -0600

Seen: 409 times

Last updated: Jun 09 '23