继续,由surfelmapping建立的点云生成octomap八叉树栅格地图
一、安装OctomapServer 建图包
安装插件
sudo apt-get install ros-melodic-octomap-ros
sudo apt-get install ros-melodic-octomap-msgs
sudo apt-get install ros-melodic-octomap-server
sudo apt-get install ros-melodic-octomap-rviz-plugins
编译OctomapServer 建图包
cd ~/catkin_ws/src
git clone https://github.com/OctoMap/octomap_mapping.git
cd ..
catkin_make
但是我们通过点云转octomap需要的是pointcloud2类型,所以我们需要先把pointcloud转换为pointcloud2,源码地址如下:源码
cd ~/catkin_ws/src
git clone https://github.com/1332927388/pcl2octomap.git
cd ..
catkin_make
将point_cloud_converter.launch的内容改为以下:
<launch><node pkg="point_cloud_converter" name="point_cloud_converter" type="point_cloud_converter_node" ><remap from="points_in" to="/vins_estimator/point_cloud"/><remap from="points2_out" to="/points" /></node>
</launch>
修改octomap_server/launch中的octomap_mapping.launch中的point ,将两个文件写在一起,修改后如下:
<launch><node pkg="point_cloud_converter" name="point_cloud_converter" type="point_cloud_converter_node" ><remap from="points_in" to="/vins_estimator/point_cloud"/><remap from="points2_out" to="/points" /></node><node pkg="octomap_server" type="octomap_server_node" name="octomap_server"><param name="resolution" value="0.05" /><!-- fixed map frame (set to 'map' if SLAM or localization running!) --><param name="frame_id" type="string" value="world" /><!-- maximum range to integrate (speedup!) --><param name="sensor_model/max_range" value="5.0" /><!-- data source to integrate (PointCloud2) --><remap from="cloud_in" to="/surfel_fusion/rgb_pointcloud" /></node>
</launch>
二、开始运行
启动相机:
roslaunch realsense2_camera stereo-imu.launch
开启跟踪节点:
rosrun vins vins_node ~/catkin_ws/src/VINS-Fusion/config/euroc/euroc_stereo_imu_config.yaml
开启闭环:
rosrun loop_fusion loop_fusion_node ~/catkin_ws/src/VINS-Fusion/config/euroc/euroc_stereo_imu_config.yaml
启动 Surfel Fusion
roslaunch surfel_fusion vins_realsense.launch
启动八叉树建图
roslaunch octomap_server octomap_mapping.launch
在rviz中添加occupancygrid,并选择/octomap_full话题,即可看到八叉树地图,如下: