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

Integrate ROS publisher Node in C-Code

asked 2018-03-29 06:07:21 -0500

felix_a gravatar image

Hi everyone, I´m really new to this whole programming thing, and also to ROS. I am curently working on my Bachelor Thesis, in which I want to implement a Surface between ROS and a autonomous driving simulationsoftware called CarMaker by IPG.

I´m using ROS Kinetics on Linux Ubuntu 16.04 and CarMaker Version 6.0.5.

For now, my goal is to read some variable values like the current velocity of the car which is simulated in CarMaker, and publish these values on a ROS node. Carmaker is written in C, so is it possible to integrate a ROS node written in C++ in the sourcecode of the CarMaker Software, and if it is possible, how is the basic approach to achieve this?

I´m very happy about every kind of help.

Thank you very much, Felix

edit retag flag offensive close merge delete

Comments

5

Not an answer, but maybe an interesting reference: Robust, Marker-Based Head Tracking for Testing Cognitive Vehicles in the Loop:

we present [..] based [..] on ROS with an [..] coupling to [..] CarMaker

gvdhoorn gravatar image gvdhoorn  ( 2018-03-29 06:17:57 -0500 )edit

Hi, I´m facing the same problem at the moment. Did you find any solution? Thank you!

julianS gravatar image julianS  ( 2019-08-08 01:49:35 -0500 )edit

1 Answer

Sort by » oldest newest most voted
0

answered 2021-02-10 08:57:08 -0500

carlosmR gravatar image

Hi Felix,

Not sure if you still need this, most likely not, but here are my thoughts when it comes to your question.

It is possible to call C++ functions in C but you will need to create wrapper functions around each call. However, my suggestion would be to do it the other way around which will be easier (calling C functions from C++). To do so you just need to provide the "extern C" when including the C headers in the cpp code.

Either way, you can see how to accomplish both here: https://isocpp.org/wiki/faq/mixing-c-...

For your case in specific you can call the C function which retrieves the speed from your node then publish it. It looks easier to do this way.

You have some example nodes which call C APIs (ex: AMCL) but I have never seen the other way around. But, once again, it can be done. If you really want it in this way, and to provide further assistance, I can try to give a look to the code a provide a simple way to do so.

Carlos

edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2018-03-29 06:07:21 -0500

Seen: 970 times

Last updated: Feb 10 '21