ROS is the abbreviation of Robot Operating System. This article introduces the introduction of ROS application development and the use of roslaunch. Without roslaunch, we need to open a lot of terminals, start roscore, various nodes and so on. For ros developers or users, roslaunch is a very important tool.
roslaunch is a tool that can easily launch multiple ROS nodes locally and remotely (via SSH), and set parameters on the parameter server. It includes the option to automatically regenerate dead processes. roslaunch receives one or more XML configuration files (extension .launch), these files specify the parameters to be set and the node to be launched and the host on which it should be run.
The launch of roslaunch
There are 2 ways to start roslaunch:
Method 1: roslaunch launch file path + launch file name
If it's in the launch file directory, don't need the directory
比如: roslaunch turtle.launch
or:
Method 2: roslaunch project package name launch file name
such as:
Create a simple launch file
The simulation turtle under ROS introduces an example of starting and controlling the movement of the turtle. There are 3 terminals opened there, respectively starting roscore, rosrun turtlesim turtlesim_node, and rosrun turtlesim turtle_teleop_key. Now only one terminal is used for launch.
mkdir launch
cd launch
nano turtle.launch
The content of the file is:
<launch>
<node pkg="turtlesim" type="turtlesim_node" name="turtle1" output="screen" />
<node pkg="turtlesim" type="turtle_teleop_key" name="key" output="screen" />
</launch>
Save and exit.
Execute in the terminal: roslaunch turtle.launch
I saw that the emulation turtle is started, because now in the turtle terminal, click to return to the original terminal. Of course, the relative position of the two terminals must be set to avoid blocking. Use the keyboard arrow keys to control the movement of the little turtle.
Engineering package method
The ROS workspace is established in the article ROS Development and Application Preparation: Create a Workspace . Now, create a functional package:
cd ~/catkin_ws/src
catkin_create_pkg learning_launch
cd ~/catkin_ws/src/learning_launch
mkdir launch
cd launch
nano turtle.launch
The content is the same as above, or copy the above file directly.
Go back to the project directory, and then compile, source
cd ~/catkin_ws/
catkin_make
source ~/catkin_ws/devel/setup.bash
Now you can start roslaunch as a project package
roslaunch learning_launch turtle.launch
It can be seen that the project package method is the same as the file method. It may be easy to remember, or it may be in its project package, for example, learning_tf is placed in the directory where it is located.
launch file content
Starting roslaunch is very simple, the key is the content of the launch file.
The launch file is an xml file whose root element is the <launch> tag definition
Start the node: <node>
<node name="$(anon foo)" pkg="rospy_tutorials" type="talker.py" />
<node pkg="turtlesim" type="turtlesim_node" name="turtle1" output="screen" />The
most The three important
pkg project package names
type Execution file name
name Node name
Others include:
output respawn required ns args
parameter settings
Set the system parameters and store them in the parameter server
<param>Set parameters
<param name="publish_frequency" type="double" value="10.0" />
<rosparam> Import all the parameters in the YAML parameter file
<rosparam command="load" file="FILENAME" />
Local variables in the launch file
<arg>
<arg name="hoge" value="fuga" />
<remap> remap
<remap from="/different_topic" to="/needed_topic"/>
<include> contains other launch files
<includefile="$(find pkg-name)/path/filename.xml" />
For more information, please refer to http://wiki.ros.org/roslaunch/XML/
Now general tutorials have a launch method. After you know the basic principles, you will be familiar with the content of the launch file several times.
That's it for the introduction.