This article describes two ways to use laser radar map building method
Codes used herein: network disk links (including two former code)
hector_mapping map building and localization
The advantage of this method is simple, just to have a laser radar to support the odometer data handheld built and do not require the underlying,
Here I recommend an article https://blog.csdn.net/weixin_41459903/article/details/102795148
slam_gampping map building
Ready to work
First of all, we are in his official documents can be seen in, gmapping Feature Pack subscribed tf and scan, this tf including the transformation and conversion of laser radar and base_link odom and base_link in the previous article introduced us to the former, then the next will introduce the latter configuration.
So we need to download rplidar_ros and slam_gmapping two feature packs, git too slow, then you can download my network disk inside. Link network disk
Serial Configuration
Since the laser radar plugged into the computer or another device serial numbers always come and go, modify the code too much trouble, then we will make a number of serial devices and maps can solve this problem the file download network disk, in serial_port / create_udev_rules.sh run this script, you can bind serial_port_sh / rplida / down. For details you can refer to this blog, if you can not understand my private letter.
Write rplida.launch
This document, we can see the start of the first node laser radar, while filling out the serial number of the place, we changed to / dev / rplidar This is because above the serial number corresponding to the mapping device rplidar.
In addition, the original document is not doing tf transformation, because we need to know the relative position of the radar of the robot, so it needs to add tf.
<launch>
<node name="rplidarNode" pkg="rplidar_ros" type="rplidarNode" output="screen">
<param name="serial_port" type="string" value="/dev/rplidar"/>
<param name="serial_baudrate" type="int" value="115200"/><!--A1/A2 -->
<!--param name="serial_baudrate" type="int" value="256000"--><!--A3 -->
<param name="frame_id" type="string" value="laser"/>
<param name="inverted" type="bool" value="false"/>
<param name="angle_compensate" type="bool" value="true"/>
</node>
<!-- tf 包的static_transform_publisher 节点
相对车的xyz方向位置以及xyz方向的角度偏转 父级坐标和雷达坐标,100ms广播一次-->
<node pkg="tf" type="static_transform_publisher"
name="base_link_to_laser"
args="0.01 0 0.01 0 0 0 1 /base_link /laser 100" />
</launch>
Write slam_gmapping.launch
<launch>
<param name="use_sim_time" value="false"/>
<node pkg="gmapping" type="slam_gmapping" name="slam_gmapping" output="screen">
<!--remap from="scan" to="base_scan"/-->
<param name="map_update_interval" value="5.0"/>
<param name="maxUrange" value="14.0"/>
<param name="sigma" value="0.05"/>
<param name="kernelSize" value="1"/>
<param name="lstep" value="0.05"/>
<param name="astep" value="0.05"/>
<param name="iterations" value="5"/>
<param name="lsigma" value="0.075"/>
<param name="ogain" value="3.0"/>
<param name="lskip" value="0"/>
<param name="srr" value="0.01"/>
<param name="srt" value="0.02"/>
<param name="str" value="0.01"/>
<param name="stt" value="0.02"/>
<param name="linearUpdate" value="0.5"/>
<param name="angularUpdate" value="0.218"/>
<param name="temporalUpdate" value="5.0"/>
<param name="resampleThreshold" value="0.5"/>
<param name="particles" value="80"/>
<param name="xmin" value="-1.0"/>
<param name="ymin" value="-1.0"/>
<param name="xmax" value="1.0"/>
<param name="ymax" value="1.0"/>
<param name="delta" value="0.05"/>
<param name="llsamplerange" value="0.01"/>
<param name="llsamplestep" value="0.01"/>
<param name="lasamplerange" value="0.005"/>
<param name="lasamplestep" value="0.005"/>
</node>
</launch>
Write bringup_base.launch
This file is used to start the node launch our first two articles mentioned, including the serial communications, odometer and keyboard, but also the way the radar launched
<launch>
<node pkg="serial_port" type="port_SubAndPub.py" name="serial_data_contral" launch-prefix="xterm -e"/>
<node pkg="serial_port" type="keyboard.py" name="car_teleop" launch-prefix="xterm -e"/>
<node pkg="odom_tf_package" type="odom_tf_pub" name="odom_tf_pub" launch-prefix="xterm -e" ></node>
<include file="$(find bringup)/launch/include/rplidar.launch" />
</launch>
Start construction diagram
roslaunch bringup bringup_base.launch
roslaunch bringup slam_gmapping.launch
rviz
Set about open rviz fixed frame is odom then click add, add a map, LaserScan, so far, through the keyboard to move the robot can be built on a chart (not real familiar with the process, then at first, later updated simulation environment)
Save Map
rosrun map_server map_saver -f ~/map/rplidar_gmapping