Ask Your Question

Software architecture for sequential execution of two ROS nodes

asked 2018-06-08 10:32:01 -0600

Ravi Joshi gravatar image

updated 2018-06-08 10:34:53 -0600

This question is regarding the best programming practices while heavily using ROS. I am trying to achieve sequential execution of two ROS nodes. I have a depth camera mounted on a moving robot. The camera works on ROS CPP and robot works on ROS Python.

Below is the sequential execution plan-

  1. Command the robot to move robot little bit.
  2. Stop the robot.
  3. Once the robot is stopped, take a picture from the camera.
  4. Process the picture. The processing is time-consuming and takes around few seconds.
  5. Once processing is done, the robot is commanded to move next.
  6. The cycle repeats.

The above execution could be done quickly if the camera and robot operate on the same programming language.

At present, I have defined two ROS topics. I have one publisher and one subscriber inside robot node, and similarly, I have another publisher and subscriber inside camera node. However, it is getting complicated to debug. I believe, there should be a more natural way in ROS to handle such scenarios.'

I want to know how to achieve sequential execution of two ROS nodes in this scenario.

PS: The code snippet wasn't provided since it is too long to put here. However, I tried to convey the approach I have implemented. Sorry for such a long post!

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2018-06-08 16:13:28 -0600

For this kind of problem, I would go with a state machine, for example : smach

with 3 state : 'plan waypoint', 'move to waypoint' and 'process picture'

and you design your state machine like this : "plan" > "move" > "process" >> repeat

each state will call a service or action implemented in ROS nodes.

The most difficult thing with this approach would be to have the correct balance between having simple states and having a simple state machine :

  • Too much states will lead to simple states code, so easily understandable, but a complex state machine
  • A too simple state machine will lead to complex state

But this is my point of view, there is no best pattern for this kind of problem I think.

edit flag offensive delete link more

Your Answer

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

Add Answer

Question Tools



Asked: 2018-06-08 10:32:01 -0600

Seen: 70 times

Last updated: Jun 08 '18