本文使用环境:Ubuntu20.04+ROS1-noetic
参考博客:
使用mid360从0开始搭建实物机器人入门级导航系统,基于Fast_Lio,Move_Base
MID360+fastlio功能笔记
本文基于第一篇参考博客进行配置,代码使用的博主修改过的代码
1. 依赖包下载安装
首先安装SDK(不安装后面也可以用ros调用)
git clone https://github.com/Livox-SDK/Livox-SDK2.git
cd ./Livox-SDK2/
mkdir build
cd build
cmake .. && make -j
sudo make install
安装ros驱动
git clone https://github.com/Livox-SDK/livox_ros_driver2.git
source /opt/ros/noetic/setup.sh
cd livox_ros_driver2
./build.sh ROS1
cd ../
catkin_make
接下来启动雷达并看下效果
roslaunch livox_ros_driver2 rviz_MID360.launch
接下来安装FAST_LIO,如果使用的是第一篇参考博客博主的代码的话此步骤可省略
在ros工作空间中打开一个终端
git clone https://github.com/hku-mars/FAST_LIO.git
这里使用的是Mid360,需要将fast-lio中的CMakeLists.txt和package.xml以及涉及到的几个程序中的livox_ros_driver
改为livox_ros_driver2
,如果不知道在哪里改,就直接编译,从报错信息中可以看到需要在哪里改
编译
cd FAST_LIO
git submodule update --init
cd ../..
catkin_make
source devel/setup.bash
如果之前没有安装sophus需要安装一下,有报错的话可以参考第一篇博客
git clone https://github.com/strasdat/Sophus.git
cd Sophus
git checkout a621ff
mkdir build
cd build
cmake ../ -DUSE_BASIC_LOGGING=ON
make
sudo make install
之后再次编译fast-lio
还有一些依赖
sudo apt-get install ros-$ROS_DISTRO-octomap-ros
sudo apt-get install ros-$ROS_DISTRO-octomap-msgs
sudo apt-get install ros-$ROS_DISTRO-octomap-server
2. 建图并保存
OK!现在来运行FAST_Lio
roslaunch livox_ros_driver2 msg_MID360.launch
再开一个终端
roslaunch fast_lio mapping_mid360.launch
现在就是在建图中了,等建图完毕关闭进程就会自动保存为pcd格式了
3. 将pcd格式3D图转为2D栅格地图
roslaunch pcd2pgm run.launch
pcd文件名及路径可以在run.launch
中修改
等待几秒待上面程序有了如下图所示的运行结果再进行保存
这时可以保存栅格地图了,但是上面的程序不要关闭
rosrun map_server map_saver map:=/map -f path_to_your_2dmap
#eg
rosrun map_server map_saver map:=/map -f /home/dawn/unitree_ws/src/NEXTE_Sentry_Nav/sentry_slam/FAST_LIO/PCD/scans
4. 使用地图
安装ros包pointcloud_to_laserscan
,第一篇博客中的包是对应的ROS2,本文需要ROS1版本的
https://wiki.ros.org/pointcloud_to_laserscan
sudo apt install ros-noetic-pointcloud-to-laserscan
# 另外还有几个包要安装
sudo apt install ros-noetic-ros-numpy
pip install numpy==1.21
pip install open3d
不想改动代码的话就直接在系统环境中进行上述安装,如果在conda环境中进行安装,但是之后要用到的几个py脚本程序指定了系统环境中的python
启动雷达
roslaunch livox_ros_driver2 msg_MID360.launch
开启重定位
roslaunch fast_lio mapping_mid360.launch
move_base
roslaunch sentry_nav sentry_movebase.launch
Pointcloud2 to Lasercan
roslaunch pointcloud_publisher demo.launch