Can I use roslaunch to cobine two application (Cpp and python)?

asked 2019-05-13 06:00:38 -0500

macleonsh gravatar image

Hello, Here I have two packages one is two single node package developed by Cpp (A) and another is a roslaunch package write by python (B) -- Now I have one idea that combine them together but need with a timing sequence, something like below:

  1. rosrun A;
  2. After A finished: roslaunch B;
  3. After B finished, return to A.

Is that doable? It would be OK to use linux shell bash? But I wonder if I can use roslaunch to do that as that could esaier to setup some commnuication (for exp, a sevice message link) between A and B so they can exchange some information and also make sure they will not conlict (so B alway happen after A finished and issue a flag...)

If this is doable, anyoe can refer a good example for me to start with rather than start from scratch? I am not be familar to roslaunch command actually.

Thanks so much.

edit retag flag offensive close merge delete


Take a look in this, is that what you want?

kosmastsk gravatar image kosmastsk  ( 2019-05-13 08:33:56 -0500 )edit

I don't completely understand your use case. But maybe some clarification is required:

  • rosrun and roslaunch are tools to start ROS nodes / executables. One starts directly the executable, the other a launch file which can contain a lot of things... There is no such thing as a "roslaunch package".
  • Nodes can be written in C++ and python, but can interact without any problems when using standard ROS communication methods.

Then, if your two nodes A and B depend on each other, instead of spawning and stopping them sequentially, I'd rather implement them in a way that they can run continuously in parallel (if you want, in "idle" mode, doing nothing) and use standard ROS communications (seems like service/action would be the way to go, but pub/sub could also be okay) to trigger the "working threads".

Does this make sense? Or do you have a specific reason ...(more)

mgruhler gravatar image mgruhler  ( 2019-05-15 01:34:51 -0500 )edit

@kosmastsk is the rosapwn an old release? I see it is EOL.From description it is something useful to me.

@mgruhler Sorry for my silly description.. Yes roslaunch is a tool rather than a package.

So your suggestion is roslaunch both nodes A(CPP) and B (python) at the same time and use the communication (Service or Actionlib?) to decide when one is idle/running? Some thing like While(check communication flag) loop can move Node A and NodeB into working model sequencily.. is that correct understanding?

macleonsh gravatar image macleonsh  ( 2019-05-15 09:31:18 -0500 )edit

@macleonsh yes, in essence, this is what I was suggesting. There are obviously quite a lot of ways to achieve this, depending on what you actually need the nodes to do...

mgruhler gravatar image mgruhler  ( 2019-05-16 00:54:46 -0500 )edit

@mgruhler great thanks.. can you make this an offcial answer so I can credit it?

macleonsh gravatar image macleonsh  ( 2019-05-16 02:57:25 -0500 )edit