Robotics StackExchange | Archived questions

Running a cpp program outside ROS and publishing messages

Hi, I am trying to case specific drone which uses image processing, the code I built works ideally when it is a standalone but becomes terribly slow when run within ROS core. I would like to know whether there is any method of running the CPP code outside ROS yet be able to publish messages.

PS: I need the publishing part to send commands and operate the drone

Asked by MSK on 2018-11-21 07:52:11 UTC

Comments

Pedantic and not an answer, but:

but becomes terribly slow when run within ROS core

ROS nodes do not run inside ROS core. They are stand-alone programs, just like other Linux binaries.

Asked by gvdhoorn on 2018-11-21 14:50:58 UTC

But I have tested it in such a way, first as a standalone code and then with rosrun. I thought rosrun means it is running within the ros framework.

Asked by MSK on 2018-11-22 00:21:51 UTC

Technically, there is no way to "run inside/within the ROS framework". That would imply that your entire control flow is taken over. That is not how typical ROS nodes work.

They are just programs that happen to use topics/services/actions for input-output.

Asked by gvdhoorn on 2018-11-22 01:09:37 UTC

I'm not doubting what you saw, but perhaps, to avoid an xy-problem, you can give us a little bit more information about your setup.

How does your non-ROS program work? Does it interface directly with your camera for instance? How is this done in your ROS-based one? Etc.

Asked by gvdhoorn on 2018-11-22 01:10:49 UTC

You can run your executable any way you want, they will behave the same given the conditions are the same. rosrun <package> <executable> will be the same with ./path/to/executable with some ROS python scripts wrapped around it. Most likely, your code is either faster because it doesn't receive anything (if other nodes are not running) and doesn't do anything or you are printing so much with ROS logging that it slows you down

Asked by OzzieTheHead on 2021-05-06 10:29:54 UTC

Answers