ROS进二阶学习笔记(3) - programmatic way to start/stop a roslaunch
Sometimes, we need to start/stop a ros .launch file/ ros node in a programmatic way, especially when we bring in the SMACH method to handle our applications.
Here are some threads in answers.ros.org web, and I summarised.
First of first:
You have two requirments: Starting a node or a launch file:-----------------------------------------------------------
To Start a Node:
1. roslaunch api:http://wiki.ros.org/roslaunch/API%20Usage
==========================
To Start a Launch file:
=== 1. subprocess ===
subprocess module may be the first choose to start/stop a roslaunch process in programmatic way.
The subprocess
module allows you to spawn new processes, connect to theirinput/output/error pipes, and obtain their return codes. This module intends toreplace several older modules and functions: