Keypoints
- Launch file syntax
- Examples
<launch>
<node pkg="turtlesim" type="turtlesim_node" name="turtlesim_node"/>
<node pkg="turtlesim" type="turtle_teleop_key" name="turtle_teleop_key"/>
</launch>
pkg is the package nametype is the node namename is the name when the node is launchedoutput is the output type of the node to the terminalrespawn is to restart the node when it is killedrequired is to kill all the nodes when one of them is killedns is to add a namespace to the nodeargs is to add arguments to the node<param> is to set the parameter of one node. Stored in ROS server.<rosparam> is to set the parameter of multiple nodes. Stored in ROS server. <param name="output_frame" value="odom"/> <rosparam file="$(find my_package)/config/my_params.yaml" command="load" ns="params"/> arg is to set the argument of the launch file, only used in this launch file. <arg name="output_frame" default="arg-value"/> <param name="output_frame" value="$(arg output_frame)"/> value must begin with $(arg. This value is decided by default in <arg><node name="node" pkg="package" type="type" output="screen" respawn="true" required="true" ns="namespace" args="$(arg output_frame)"/><remap> is to remap the ROS computation graph resource. Just to rename the topic name. <remap from="old_topic" to="new_topic"/> <include> is to include another launch file, like C language. <include file="$(find my_package)/launch/my_launch_file.launch"/> <launch>
<node pkg="topic_learning" type="person_publisher" name="talker" output="screen"/>
<node pkg="topic_learning" type="person_subscriber" name="listener" output="screen"/>
</launch>
<launch>
<param name="/turtle_number" value="2"/>
<node pkg="turtlesim" type="turtlesim_node" name="turtlesim_node">
<param name="turtle_name1" value="turtle1"/>
<param name="turtle_name2" value="turtle2"/>
<rosparam file="$(find learning_launch)/config/param.yaml" command="load" />
</node>
<node pkg="turtlesim" type="turtle_teleop_key" name="turtle_teleop_key" output="screen"/>
</launch>
<launch>
<!-- Tuetlesim Node -->
<node pkg="turtlesim" type="turtlesim_node" name="turtlesim_node"/>
<node pkg="turtlesim" type="turtle_teleop_key" name="turtle_teleop_key" output="screen"/>
<node pkg="learning_tf" type="turtle_tf_broadcaster" args="/turtle1" name="turtle1_tf_broadcaster"/>
<node pkg="learning_tf" type="turtle_tf_broadcaster" args="/turtle2" name="turtle2_tf_broadcaster"/>
<node pkg="learning_tf" type="turtle_tf_listener" name="turtle_tf_listener"/>
</launch>
<launch>
<!-- Tuetlesim Node -->
<node pkg="turtlesim" type="turtlesim_node" name="turtlesim_node"/>
<node pkg="turtlesim" type="turtle_teleop_key" name="turtle_teleop_key" output="screen"/>
<node name="turtle1_tf_broadcaster" pkg="learning_tf" type="turtle_tf_broadcaster.py" >
<param name="turtle" type="string" value="turtle1"/>
</node>
<node name="turtle2_tf_broadcaster" pkg="learning_tf" type="turtle_tf_broadcaster.py" >
<param name="turtle" type="string" value="turtle2"/>
</node>
<node pkg="learning_tf" type="turtle_tf_listener.py" name="turtle_tf_listener"/>
</launch>
<launch>
<include file="$(find learning_launch)/launch/simple.launch"/>
<node pkg="turtlesim" type="turtlesim_node" name="turtlesim_node">
<remap from="turtle1/cmd_vel" to="cmd_vel"/>
</node>
</launch>