node label
Specify a ROS node in the tag, which is the most common roslaunch tag because it supports the most important function: start and close the node.
roslaunch does not guarantee the order in which nodes start. Since there is no way to know from the outside when the node is fully initialized, all the initiated nodes must be robust in order to start in any order.
In node nodes, PKG type name args output value is used more today.
pkg = mypackage node package.
Type = nodetype node type. There must be a corresponding executable file with the same name.
Name = nodename node base name. Note: Name cannot contain namespaces. Please use the ns attribute instead.
args = arg1 arg2 arg3 (optional) passes parameters to the node.
output is generally screen or log, default to log (log file)
Value given value
The entire launch file code is as follows:
<launch> <node pkg="lslidar_n301_driver" type="lslidar_n301_driver_node" name="lslidar_n301_driver_node" output="screen"> <param name="frame_id" value="laser_link"/> <param name="device_ip" value="192.168.1.222"/> <param name="device_port" value="2368"/> </node> <node pkg="lslidar_n301_decoder" type="lslidar_n301_decoder_node" name="lslidar_n301_decoder_node" output="screen"> <param name="child_frame_id" value="laser_link"/> <param name="point_num" value="2000"/> <param name="angle_disable_min" value="0"/> <param name="angle_disable_max" value="0"/> <param name="min_range" value="0.3"/> <param name="max_range" value="100.0"/> <param name="frequency" value="10.0"/> <param name="publish_point_cloud" value="false"/> </node> <node pkg="tf" type="static_transform_publisher" name="link1" args="0 0 0 0 0 0 laser laser_link 100" /> <node pkg="tf" type="static_transform_publisher" name="link2" args="0 0 0 0 0 0 base_link laser 100" /> <node pkg="laser_scan_matcher" type="laser_scan_matcher_node" name="laser_scan_matcher_node" output="screen"> <param name="fixed_frame" value = "odom"/> <param name="max_iterations" value="10"/> </node> <node pkg="gmapping" type="slam_gmapping" name="slam_gmapping" output="screen"> <param name="map_udpate_interval" value="1.0"/> <param name="maxUrange" value="10.0"/> <param name="sigma" value="0.1"/> <param name="kernelSize" value="1"/> <param name="lstep" value="0.15"/> <param name="astep" value="0.15"/> <param name="iterations" value="1"/> <param name="lsigma" value="0.1"/> <param name="ogain" value="3.0"/> <param name="lskip" value="1"/> <param name="srr" value="0.1"/> <param name="srt" value="0.2"/> <param name="str" value="0.1"/> <param name="stt" value="0.2"/> <param name="linearUpdate" value="1.0"/> <param name="angularUpdate" value="0.5"/> <param name="temporalUpdate" value="0.4"/> <param name="resampleThreshold" value="0.5"/> <param name="particles" value="10"/> <param name="xmin" value="-5.0"/> <param name="ymin" value="-5.0"/> <param name="xmax" value="5.0"/> <param name="ymax" value="5.0"/> <param name="delta" value="0.02"/> <param name="llsamplerange" value="0.01"/> <param name="llsamplestep" value="0.05"/> <param name="lasamplerange" value="0.05"/> <param name="lasamplestep" value="0.05"/> </node> <node name="rviz" pkg="rviz" type="rviz" output="screen"/> </launch>
Next, I'll explain why the following sections should be added to the launch file:
<node pkg="tf" type="static_transform_publisher" name="link1" args="0 0 0 0 0 0 laser laser_link 100" /> <node pkg="tf" type="static_transform_publisher" name="link2" args="0 0 0 0 0 0 base_link laser 100" /> <node pkg="laser_scan_matcher" type="laser_scan_matcher_node" name="laser_scan_matcher_node" output="screen"> <param name="fixed_frame" value = "odom"/> <param name="max_iterations" value="10"/> </node>
Why do we need laser-laser_link, base_link-laser two TFS
First is the tf from base_link to laser, because laser_scan_matcher needs such a tf (laser_scan_matcher part 4.2.1 in roswiki)
In addition, in this launch file, the first two nodes publish the data in laser_link, which needs to be converted to laser in order to be associated with other nodes. (Each coordinate system is not an island, but is related to each other so that data can be used universally.)
(Of course, the tf of laser-laser_link step can also be omitted from the launch file, which requires modifying the frame_id in the first two node s and the setting value of child_frame_id to laser.)
In laser_scan_matcher_node, the fixed_frame value is set to odom because gmapping requires an odom (odometer information), which is the default value of the world.
Two TFS
tf is written in a format, which can be found in roswiki:
<launch> <node pkg="tf" type="static_transform_publisher" name="link1_broadcaster" args="1 0 0 0 0 0 1 link1_parent link1 100" /> </launch>
The static_transform_publisher tool is used to publish static coordinate transformations between two reference systems, which generally do not change relative positions.
Name is your choice. Give this node a name.
args has two schemes, one is displacement + rotation angle, the other is quaternion expression.
static_transform_publisher x y z yaw pitch roll frame_id child_frame_id period_in_ms
static_transform_publisher x y z qx qy qz qw frame_id child_frame_id period_in_ms
Frame_id and child_frame_id correspond to the two coordinate systems involved in the transformation.
period_in_ms is the publishing frequency, and the default value is 100ms.