Ask Your Question
1

ROS subscriber integration

asked 2012-02-27 08:00:53 -0500

bzt gravatar image

updated 2014-01-28 17:11:30 -0500

ngrennan gravatar image

Hi,

I have a 32-bit C program that sends data over UDP to a windows GUI. I need to integrate a simple ros subscriber node into the program to subscribe to a node publishing a joy message. I've had no luck following the tutorials or methods I've been able to find. What is the normal method for doing such a task?

I've checked a couple of Q/A already, such as: http://answers.ros.org/question/3277/wrap-existing-crrcsim-project-in-ros with no luck.

EDIT:

After making a new project, adding the file to the CMakeLists.txt, and adding ros.h to the c program, I get the following error:

In file included from /opt/ros/electric/stacks/ros_comm/utilities/rostime/include/ros/time.h:53:0, from /opt/ros/electric/stacks/ros_comm/clients/cpp/roscpp/include/ros/ros.h:38, from .../ros_workspace/project_1/src/project_1.c:26:

/opt/ros/electric/stacks/ros_comm/utilities/cpp_common/include/ros/platform.h:55:18:

fatal error: string: No such file or directory

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
4

answered 2012-02-27 08:16:57 -0500

dornhege gravatar image

When porting code to ROS you can try to port the software fully or to just write a ROS interface that translates ROS request and calls some interface functions in the software.

When I port code to ROS, what I usually do is:

  1. Create a ROS package using roscreate-pkg.
  2. Copy the source code to the package and make it compile (without any ROS interfacing). This should result in the same program as before.
  3. Add ros stuff, i.e. ros::init, spinning, subscribers/publishers, maybe switch in some ROS features, i.e. using ros::Time, ROS_INFO, etc.
edit flag offensive delete link more

Comments

Gotcha, the program works up to step 3, where I need to include ros/ros.h right? How do I include ros.h? Will i make the program with "gcc progam.c -m32" or with a "rosmake program" command ?

bzt gravatar imagebzt ( 2012-02-27 08:26:26 -0500 )edit

In step 3, you'll need to use rosmake.

joq gravatar imagejoq ( 2012-02-27 08:38:54 -0500 )edit

I've edited my original post to reflect the error I'm now getting after attempting this method.

bzt gravatar imagebzt ( 2012-02-27 08:49:17 -0500 )edit
1

This is only a suspicion, but you are using a C program in a .c file. This will automatically run gcc (not g++) and thus there is no string (c++) only. Do you need the program to be C or can it be compiled as c++ (using C only code) - then just rename the file to end in .cpp and see.

dornhege gravatar imagedornhege ( 2012-02-27 12:01:06 -0500 )edit

Fixing the headers with "extern "C" {(headers here)}" and converting some data types to c++ solved the issue! (Changing the extension to .cpp) Thanks!

bzt gravatar imagebzt ( 2012-02-28 08:20:58 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2012-02-27 08:00:53 -0500

Seen: 1,244 times

Last updated: Feb 27 '12