基于激光里程计的gmapping建图

文章目录

  • rplidar_ros通过源码安装
  • 安装rf2o_laser_odometry激光里程计
  • 配置gmapping参数
  • 参考

rplidar_ros通过源码安装

mkdir -p ~/catkin_ws/src
cd  ~/catkin_ws/src
git clone https://github.com/Slamtec/rplidar_ros.git
cd ..
catkin_make 
echo "source ~/catkin_ws/devel/setup.bash" >> ~/.bashrc

安装rf2o_laser_odometry激光里程计

#依然是将rf2o_laser_odometry下载到ROS工作空间
cd ~/catkin_ws/src/
git clone https://github.com/MAPIRlab/rf2o_laser_odometry.git
cd ~/catkin_ws/
catkin_make

配置参数

<launch>

  <node pkg="rf2o_laser_odometry" type="rf2o_laser_odometry_node" name="rf2o_laser_odometry" output="screen">
    <param name="laser_scan_topic" value="/scan"/>        # topic where the lidar scans are being published
    <param name="odom_topic" value="/odom" />              # topic where tu publish the odometry estimations
    <param name="publish_tf" value="true" />                   # wheter or not to publish the tf::transform (base->odom)
    <param name="base_frame_id" value="base_link"/>            # frame_id (tf) of the mobile robot base. A tf transform from the laser_frame to the base_frame is mandatory
    <param name="odom_frame_id" value="odom" />                # frame_id (tf) to publish the odometry estimations    
    <param name="init_pose_from_topic" value="" /> # (Odom topic) Leave empty to start at point (0,0)
    <param name="freq" value="6.0"/>                            # Execution frequency.
    <param name="verbose" value="true" />      
  </node>
  
</launch>

下载得到的原始rf2o_laser_odometry代码有两个问题,如果不修复会有下面这两个报错:

#报错1:

ERRO:“base_link” passed to lookupTransform argument source_frame does not exist. 或者 ERRO:Invalid argument passed to lookupTrasform argument source_frame in tf2 frame_ids cannot be empty

#报错2:

[rf2o] ERROR: Eigensolver couldn’t find a solution. Pose is not updated

第1个错误是由于程序订阅/tf话题数据时超时,加个延迟就好了。在源码rf2o_laser_odometry/src/CLaserOdometry2DNode.cpp中第126行的上面添加下面这句:

tf_listener.waitForTransform(base_frame_id,"laser_link",ros::Time(),ros::Duration(5.0));

第2个错误是你的激光雷达上传来的数据包含Inf或NaNs非法格式数据,我亲测发现EAI-X4雷达没有这个问题,而Rplidar-A1雷达会有这个问题,以防万一还是修复一下吧。将源码rf2o_laser_odometry/src/CLaserOdometry2D.cpp中第292和316行的条件语句都改成下面这个:

if (std::isfinite(dcenter) && dcenter > 0.f)

配置gmapping参数

在./rplidar_ros/launch文件夹中设置a1_gmapping.launch

<!-- 
Example launch file: uses laser_scan_matcher together with
slam_gmapping 
-->

<launch>

  <include file="$(find rplidar_ros)/launch/rplidar.launch"/>
 
  <node pkg="tf" type="static_transform_publisher" name="base_link_to_laser" 
    args="0.0 0.0 0.0 0.0 0.0 0.0 /base_link /laser 100" />
  
  <node pkg="tf" type="static_transform_publisher" name="odom_to_laser" 
    args="0.0 0.0 0.0 0.0 0.0 0.0 /odom /laser 100" />

  <node pkg="tf" type="static_transform_publisher" name="map_to_laser" 
    args="0.0 0.0 0.0 0.0 0.0 0.0 /map /laser 100" />

  <include file="$(find rf2o_laser_odometry)/launch/rf2o_laser_odometry.launch"/>

  <node pkg="gmapping" type="slam_gmapping" name="slam_gmapping" output="screen">
    <param name="map_udpate_interval" value="1.0"/>
    <param name="maxUrange" value="12.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="-10.0"/>
    <param name="ymin" value="-10.0"/>
    <param name="xmax" value="10.0"/>
    <param name="ymax" value="10.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>

</launch>


参考

https://huaweicloud.csdn.net/64f987ec6b896f66024ca8ab.html?dp_token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpZCI6MjAxNTYzLCJleHAiOjE3MDE2NTYxODcsImlhdCI6MTcwMTA1MTM4NywidXNlcm5hbWUiOiJ3ZWl4aW5fNDI5OTA0NjQifQ.0-th9fBousxKLdtCglRdh2r99y395OoaTDG1hgzuc_0#devmenu7

你可能感兴趣的:(机器人导航定位,ros)