Using the ROSlaunch API in combination with SMACH

asked 2019-02-12 08:25:00 -0600

Isha Dijcks gravatar image

Introduction

I'm looking for a way to control the startup sequence of a custom robot we are developing. As we have limited experience with ROS I figured it was best to ask the ROS community for input on such a complicated topic.

Current Situation

We have decided to use SMACH for our state machine as it is quite easy to work with and the visualization is nice. Currently we have one main launch file that takes some arguments (e.g. if we are running a simulation or not), and passes them down to included launchfiles and so on.

The problem with this approach is that we have no control over the timing when nodes are launched, some nodes need to wait on other nodes to properly start up for example. Also you end up with complicated logic in your launch file that makes it difficult to quickly see which nodes will be ran at launch, especially when they are nested deeply.

Possible Solution

I've done some research on the ROSlaunch API and how it could help. If we create a state machine in SMACH that contains nodes that can start launchfiles, we only need to launch the state machine at the beginning. This statemachine will traverse a different path based on its launch parameters as shown below. launch state machine

This will make it easy to see at launch which nodes are started, and the statemachine can simply wait until a file is launched before it goes to the next state. Another advantage of this method is that when an important node dies, the statemachine can remain alive and relaunch the entire progress again with the press of a button instead of having to restart ROS.

As I am quite inexperienced I have no idea if this is a proper approach to such a problem or if there are better solutions already out there. Feedback and criticism is very much welcome!

edit retag flag offensive close merge delete