Page tree
Skip to end of metadata
Go to start of metadata

In our demo, we need to start multiple launch files on different ROS masters:

  • the openni2_launch should be started on the local ROS master (otherwise it may crash due to network issues)
  • the detection & control nodes should be started on the Baxter's ROS master

Starting Multiple Processes

The main script looks as follows: The script creates 2 background processes (one for each ROS master):

  • roslaunch openni2_launch openni2.launch&
    • The & at the end specifies that the command is run as a background process (the main process continues, it does not wait for the command to complete).
  • ${SHELL}
    • The script is a modified version of (from the Baxter SDK). The original ( script prepares the environment for running nodes on the Baxter ROS system. The modified script does the same preparation, and then starts the detection & control nodes (roslaunch baxter_smach demo.launch).


In order to be able to stop & restart the demo, the script waits until a kill signal is received (CTRL+C). When the kill signal appears, it kills the background processes. The kill signal handler is set using the command: "trap terminate SIGINT SIGTERM" (when a SIGINT or SIGTERM signal occurs, call the terminate procedure). In order to kill a background process, we need to know its process id. So, after starting each background process, we saved its process id using the "$!" command.