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

ROS Wrapper for C/C++ library

asked 2016-12-07 12:46:46 -0500

fabbro gravatar image


I have a library which is written in C. Let's say in folder1.

In folder1 I have some .c .h files and the generated libraries .a and .so

I build all this through a Makefile which is working correctly and it is generating the above mentioned .a and .so files.

In the folder folder1 I have a folder folder1_example which contains an file which is a c++ file to connect the library in folder1 with opencv and my camera. In folder1_example. In folder1_example there is a folder build and a CMakeLists.txt file. I go in the folder build to build my project (invoke the command make).

When I do make in the folder build I generate an executable which I can execute to get the library in folder1 to work in opencv and my camera.

Until now there is no ROS in it. So far everything is working and I am getting a pose of a target which is present in the image coming from the camera.

Now I would like to introduce ROS in the loop and I am having an hard time to understand how to do it. Basically I want that this pose is not just written on the terminal but published on a ros topic.

First of all I started by creating in the folder folder1_example the file package.xml and I modified the existing CMakeLists.txt with the following lines:

find_package(catkin REQUIRED COMPONENTS

If you want to have a closer look to what I am talking about you could check here: where folder1 corresponds to the root folder and folder1_example to the folder apriltag2_example

Could you point me in the right direction?

Thanks a lot for the help.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2016-12-07 21:40:09 -0500

lucasw gravatar image

You probably want to structure things so all the code is in a ros package (with a package.xml) and there is a top level CMakeLists.txt that builds the library (with add_library), the opencv standalone executable, and a ros node executable.

The ros node is going to be somewhat similar to the opencv executable, you could start with an example ros image subscriber , and then you'll also have to launch a node that publishes images from your camera- usb_cam for example if you are using a webcam.

edit flag offensive delete link more

Question Tools



Asked: 2016-12-07 12:46:46 -0500

Seen: 1,094 times

Last updated: Dec 07 '16