LiDAR-based real-time 3D localization and mapping
github:https://github.com/erik-nelson/blam.git
官方视频:https://youtu.be/08GTGfNneCI
sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
sudo apt-key adv --keyserver hkp://ha.pool.sks-keyservers.net:80 --recv-key 0xB01FA116
sudo apt-get update
sudo apt-get install ros-kinetic-desktop-full
source /opt/ros/kinetic/setup.zsh
#Boost >= 1.43
sudo apt-get install libboost-all-dev
#CMake >= 2.6
sudo apt-get install cmake
git clone https://bitbucket.org/gtborg/gtsam.git
cd gtsam
mkdir build
cd build
cmake ..
sudo make install
git clone https://github.com/erik-nelson/blam.git
首先确保ROS_PACKAGE_PATH中没有任何其他ROS工作区
cd blam
./update
1、fatal error: ros/ros.h: No such file or directory
cd blam/internal/src/geometry_utils
添加以下两行到 package.xml
<build_depend>roscppbuild_depend>
<run_depend>roscpprun_depend>
添加以下下两行到CMakeList.txt
find_package(catkin REQUIRED COMPONENTS roscpp)
include_directories(include ${catkin_INCLUDE_DIRS})
2、Invalid (NaN, Inf) point coordinates given to nearestKSearch!
my solution is edit the “point_cloud_filter.cc”, add the following code at the end of the Filter function
if (!points->is_dense)
{
points_filtered->is_dense = false;
std::vector indices;
pcl::removeNaNFromPointCloud(points_filtered,points_filtered, indices);
}
3、按照以上方法修改后,在回环后还是出现Invalid (NaN, Inf) point coordinates given to nearestKSearch
修改”BlamSlam.cc”,修改以下几行(这几行不是连在一起的),即把使用原始msg的地方替换为msg_filtered
//1、change loop_closure_.AddKeyScanPair(0, msg); to
loop_closure_.AddKeyScanPair(0, msg_filtered);
//2、change if (HandleLoopClosures(msg, &new_keyframe)) to
if (HandleLoopClosures(msg_filtered, &new_keyframe))
//3、localization_.TransformPointsToFixedFrame(*msg, msg_fixed.get());
localization_.TransformPointsToFixedFrame(*msg_filtered, msg_fixed.get());
以上nan问题主要是因为所使用的点云数据is_desne:false也就是说,点云里面可能含有nan所以在filter里面
统一做了去除无效值
官方使用的是velodyne的数据
rosbag play velodyne.bag#输出话题rslidar_points
source your_path/blam-master/internal/devel/setup.zsh
roslaunch blam_example test_online.launch
使用自己的数据集,修改test_online.launch文件
<remap from="~pcld" to="/rslidar_points"/>
1、效果不好
注意查看自己的点云数据量和velodyne的区别,如果点云数量少就修改point_cloud_filter/config/parameters.yaml
#关闭voxel grid filter
grid_filter: false
2、按照1修改了,效果还不好,旋转特别大
修改point_cloud_localization/config/parameters.yaml
# Maximum acceptable incremental rotation and translation.
transform_thresholding: true #false
max_translation: 0.5 #0.05
max_rotation: 0.3 #0.1
3、不回环
观察你的pose相差多远,修改laser_loop_closure/config/parameters.yaml
#默认0.5米检测一次回环或记录关键帧,值越大效率越高,发现构图缓慢的时候可以放大这个值
translation_threshold: 1.0 #0.5
#默认是在1.5米范围内匹配,根据你自己的回环误差放大这个值
proximity_threshold: 10 #1.5
#ICP "fitness score" must be less than this number,就是越小越难回环
max_tolerable_fitness: 5 #0.15
#根据你自己的地图大小适当放宽跳过回环的点数,一般地图越大值越大
skip_recent_poses: 100 #40
poses_before_reclosing: 100 #40
4、看到位姿回环并修正了,但是点云没有被修正
取消订阅/blam/blam_slam/octree_map_updates再重新订阅就看到了
使用自己的rslidar室外数据集,效果如下(网格大小10m):
首次构图,还未回环,几乎无偏差
经过一圈之后已经产生了角度的偏差,回环之后依然良好,最终图如下
效果还不错,首次构图误差小,回环速度够快,调参也方便,关键是不需要其他传感器