运行环境
- Linux:Ubuntu18.04
- ros:Melodic
- Ceres Solver 2.0.0(Ubuntu18.04安装Ceres)
- PCL 1.8.1(Ubuntu系统的PCL、Eigen卸载和安装)
====================== 运行数据集 lego-loam 39/39 ===========================
终端一:进入catkin_ws工作空间
1) source ./devel/setup.bash
2) export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
3) roslaunch lego_loam run.launch 或 roslaunch lego_loam run_test.launch
终端二:进入catkin_ws工作空间
1)source ./devel/setup.bash
2) rosbag play 38.bag --clock 或 rosbag play 39.bag --clock
注意:
//(播放数据包的时候,使用的use_sim_time是仿真时间戳,所以要使用 --clock 进行数据播放。这边下载的数据包都要使用rosbag play *.bag --clock 这样的形式播放,不然,Lego-LOAM那边没法进行建图。自己录制的数据包也是要以这样的形式播放。)//在rviz中把Fixed Frame : velodyne
//在Add中添加PointCloud2,topic:/velodyne_points
运行结果如下:
================== 数据集 mick1.bag (mick_2021-01-27-21-34-13.bag) ===============
终端1:进入catkin_ws工作空间
1) source ./devel/setup.bash
2) export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
3) roslaunch lego_loam mickx4.launch
终端2:进入catkin_ws工作空间
1)source ./devel/setup.bash
2) rosbag play mick1.bag --clock --topic /rslidar_points /imu/data
运行 mick1.bag
=========================数据集lego-loagm-demo =============================
终端1:进入catkin_ws工作空间
1) source ./devel/setup.bash
2) export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
3) roslaunch lego_loam run.launch 或 roslaunch lego_loam run_test.launch
终端2:进入catkin_ws工作空间
1)source ./devel/setup.bash
2) rosbag play 39.bag --clock --topic /velodyne_points /imu/data
39-bag-velodyne
========================= 全流程 案例 ===================================
终端1:
进入catkin_ws工作空间
1) source ./devel/setup.bash
2) export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
3)roslaunch lego_loam mickx4.launch //把mickx4.launch文件换成run.launch
// roslaunch lego_loam run.launch // 注意:mick4.launch 对应终端2中的 mick1.bag
// run.launch 对应终端2中的38.bag或39.bag
终端2:
进入catkin_ws工作空间
1)source ./devel/setup.bash //把mick1.bag 文件 换成 38.bag/39.bag
2) rosbag play mick1.bag --clock --topic /rslidar_points /imu/data
// rosbag play 38.bag --clock --topic /velodyne_points /imu/data// 注意:mick1.bag 对应 /rslidar_points
// 38/39.bag 对应 /velodyne_points
如图所示 38.bag :
如图所示 mick1.bag
/*********地图保存**********///LeGO-LOAM 的点云地图是发布在 /laser_cloud_surround 这个话题上的,在这篇博客[7]中提供了一种方法就是记录这个topic上的数据,然后利用 pcl_ros 包进行转换。终端3:进入catkin_ws工作空间 source ./devel/setup.bash
//step1: 记录话题 /laser_cloud_surround 数据,这个可以在快结束的时候录制
1) rosbag record -o lego-loam-out /laser_cloud_surround
//然后录制完成后, ctrl+c 退出 ,发现 catkin_ws 目录下 .bag.active文件,变成 .bag 文件 终端4:进入catkin_ws工作空间 source ./devel/setup.bash
//step2: 把 lego-loam-out* 这个bag的话题上的数据存为pcd文件
2) // rosrun pcl_ros bag_to_pcd lego-loam-out_2023-05-10-14-22-31.bag /laser_cloud_surround testrosrun pcl_ros bag_to_pcd lego-loam-out_2024-03-07-14-48-36.bag /laser_cloud_surround test4//这时候会在你的目录下生成一个test目录,里面会有很多个pcd文件,选最后一个就是最新的点云地图了终端5:cd catkin_ws/test
//pcl_viewer xxxxxx.pcd 此命令既可打开pcd文件
3) pcl_viewer 1611754659.194505930.pcd
pcl_viewer 1611754659.082526922.pcd
run.launch
<launch><!--- Sim Time --><param name="/use_sim_time" value="true" /><!--- Run Rviz--><node pkg="rviz" type="rviz" name="rviz" args="-d $(find lego_loam)/launch/test.rviz" /><!--- TF --><node pkg="tf" type="static_transform_publisher" name="camera_init_to_map" args="0 0 0 1.570795 0 1.570795 /map /camera_init 10" /><node pkg="tf" type="static_transform_publisher" name="base_link_to_camera" args="0 0 0 -1.570795 -1.570795 0 /camera /base_link 10" /><!--- LeGO-LOAM --> <node pkg="lego_loam" type="imageProjection" name="imageProjection" output="screen"/><node pkg="lego_loam" type="featureAssociation" name="featureAssociation" output="screen"/><node pkg="lego_loam" type="mapOptmization" name="mapOptmization" output="screen"/><node pkg="lego_loam" type="transformFusion" name="transformFusion" output="screen"/></launch>
mickx4.launch
<launch><!--- Sim Time --><param name="/use_sim_time" value="true" /><node pkg="nodelet" type="nodelet" name="pcl_manager" args="manager" output="screen" /><!-- Run a passthrough filter to clean NaNs --><node pkg="nodelet" type="nodelet" name="passthrough" args="load pcl/PassThrough pcl_manager" output="screen"><remap from="~input" to="/rslidar_points" /><remap from="/passthrough/output" to="/velodyne_points" /><rosparam>filter_field_name: zfilter_limit_negative: True</rosparam><rosparam>filter_field_name: xfilter_limit_negative: True</rosparam><rosparam>filter_field_name: yfilter_limit_negative: True</rosparam></node><!--- Run Rviz--><node pkg="rviz" type="rviz" name="rviz" args="-d $(find lego_loam)/launch/test.rviz" /><!--- TF --><node pkg="tf" type="static_transform_publisher" name="camera_init_to_map" args="0 0 0 1.570795 0 1.570795 /map /camera_init 10" /><node pkg="tf" type="static_transform_publisher" name="base_link_to_camera" args="0 0 0 -1.570795 -1.570795 0 /camera /base_link 10" /><!--- LeGO-LOAM --> <node pkg="lego_loam" type="imageProjection" name="imageProjection" output="screen"/><node pkg="lego_loam" type="featureAssociation" name="featureAssociation" output="screen"/><node pkg="lego_loam" type="mapOptmization" name="mapOptmization" output="screen"/><node pkg="lego_loam" type="transformFusion" name="transformFusion" output="screen"/></launch>
demo
lego-loam demo
参考文献
https://blog.csdn.net/weixin_42141088/article/details/115747989
https://blog.csdn.net/crp997576280/article/details/111657554?spm=1001.2014.3001.5506
https://blog.csdn.net/weixin_44444810/article/details/121659270?spm=1001.2014.3001.5506