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

How to develop interface from C program with ROS [closed]

asked 2012-01-30 01:05:38 -0600

zhenli gravatar image

updated 2015-07-02 22:27:07 -0600

allenh1 gravatar image

Dear All. I am trying to setup a interface between one c Program with ROS. IS there some helpful information? The idea is that we run C program independent and use this interface send and receive information with ROS server to control PR2 simulator (ROS+Gazebo+PR2) The framework is shown as following : C program +interface with ROS +ROS +Gazebo+PR2. Best regards. Zhenli LU Email.


Dear DimitriProsser. Thank you very much for your email. In fact my C program does not expose any methods of communication. So Is there a C program client demo for ROS server. Thus I can use it for my project. In fact I am a new hand for ROS and PR2. I want to start from studying the interface with C program. Or how to develop the client program with C program to communicate with ROS server. Thus I can intergrate this client demo with my work in C program. Normally I use YARPmin.c and YARPmin.h as the interface to communcate with another middle ware YARP(Yet Another Robot Platform). Best regards. Zhenli

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by allenh1
close date 2015-07-02 22:27:38.753098

1 Answer

Sort by ยป oldest newest most voted

answered 2012-01-30 01:30:46 -0600

DimitriProsser gravatar image

updated 2012-01-31 05:49:30 -0600

Probably the best example of integration between a 3rd-party program and ROS is Gazebo. The situation depends on your external library though.

If your C program provides a communication API, you could write a ROS node that will interface with that API. Essentially, it would be a bridge between ROS and your C program. In this case, it would be very similar to writing a ROS driver for devices and very similar to Gazebo.

If your C program does not expose any methods of communication, you're going to have to modify the source code such that it does. For that, you can see this question for some help.


You cannot include ROS's libraries in your C program because ROS is written in C++ and depends heavily on other C++ libraries (Boost, Eigen, etc.). What you need to do is expose the functions of your C program and wrap them in C++. This would allow you to use ROS with your application easily. Essentially, you would write a C++ application that instantiates and instance of your C application and collects and sends data via function calls.

Here is a quick, and very simplified example:

// My ROS application
#include "C_application_header.h"

class My_New_App
        C_Application my_c_application;
edit flag offensive delete link more

Question Tools


Asked: 2012-01-30 01:05:38 -0600

Seen: 2,555 times

Last updated: Jul 02 '15