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

How to call functions defined in an external C file from a ROS package? [closed]

asked 2014-07-12 18:31:53 -0500

Keerthi Raj gravatar image

Hi,

I have a C file(cluster.c) and a header file(cluster.h) which are not a part of any ROS package. I want to call functions in that C file from my already existing ROS package's source file(detect.cpp). Note that "cluster.c" is just a collection of some C functions without a main(). So, it can't be compiled separately.

I thought of creating a library out of "cluster.c" and "cluster.h" and link that library to my ROS package? How do I do this? What changes should I make to my existing package's CMakeLists.txt and package.xml?

This may be a silly and repeated question as I found similar questions being answered. As I am very new to ROS I couldn't understand much from those answers. If someone could explain me in simple terms, it would be great.

Thanks, Raj

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by Keerthi Raj
close date 2014-07-12 22:26:11.056206

1 Answer

Sort by ยป oldest newest most voted
1

answered 2014-07-12 19:48:57 -0500

sai gravatar image

Just add those files as header files like #include<filename.h> or #include<filename.c> in your source files in ros package.

Then you can call those functions from the source file.

edit flag offensive delete link more

Comments

@Sai, Thank you very much. It was such a simple thing.

Keerthi Raj gravatar image Keerthi Raj  ( 2014-07-12 22:26:02 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2014-07-12 18:31:53 -0500

Seen: 731 times

Last updated: Jul 12 '14