他们在Youtube上有介绍视频,有能力的可以去看一下,视频演示了loam和LeGO-LOAM在i7 4710mq和jetson tx2两种平台下的对比,效果十分好。https://www.youtube.com/watch?v=O3tz_ftHV48

1.编译安装LeGO-LOAM的依赖

gtasm的编译安装

1.下载gtsam的源代码     

git clone https://bitbucket.org/gtborg/gtsam.git

编译安装

mkdir build
cd build
cmake ..
sudo make install

至此,gtsam已经编译安装完成了。

2.LeGO-LOAM的编译安装

1.LeGO-LOAM的编译需要使用catkin,如果已经建立catkin_ws,可以跳过下面这步

mkdir -p catkin_ws/src
cd catkin_ws/src
catkin_init_workspace

2.下载LeGO-Loam的源码

cd ~/catkin_ws/src

git clone https://github.com/RobustFieldAutonomyLab/LeGO-LOAM.git

如果觉得github下载慢,可以使用我clone到gitee的代码

git clone https://gitee.com/Yeah2333/LeGO-LOAM.git

3.编译LeGO-Loam

cd catkin_ws
catkin_make -j1
source ~/devel/setup.bash

4.运行LeGO-LOAM

roslaunch lego_loam run.launch
rosbag play *.bag --clock --topic /velodyne_points /imu/data

5.遇到的问题及解决方法

(1)提示缺少pcl_ros的相关配置文件

$sudo apt-get install ros-kinetic-pcl-ros

(2)

CMake Error at /usr/share/cmake-3.5/Modules/CMakeFindDependencyMacro.cmake:45 (message):
  Invalid arguments to find_dependency
Call Stack (most recent call first):
  /usr/local/lib/cmake/GTSAM/GTSAMConfig.cmake:17 (find_dependency)
  LeGO-LOAM/LeGO-LOAM/CMakeLists.txt:23 (find_package)


-- Configuring incomplete, errors occurred!
See also "/home/chenyi/legoloam_ws/build/CMakeFiles/CMakeOutput.log".
See also "/home/chenyi/legoloam_ws/build/CMakeFiles/CMakeError.log".
Makefile:1508: recipe for target 'cmake_check_build_system' failed
make: *** [cmake_check_build_system] Error 1
Invoking "make cmake_check_build_system" failed

gtsam库有问题,使用一位热心的网友发给我的库后重新编译,问题解决,在此表示感谢!

看到很多小伙伴也遇到了相同的问题,现把gtsam库在这里分享给大家。
链接:https://pan.baidu.com/s/1wVwtAT-Q3uD2WZN9xoiMBg
提取码:i64o

6.RS-LIDAR-16

RS-LIDAR-16默认发布的 topic 为/rslidar_points,而LeGO-LOAM需要订阅的 topic 为/velodyne_points,因此使用以下命令:

rosbag play *.bag --clock /rslidar_points:=/velodyne_points

但是,出现以下错误:

featureAssociation: /build/pcl-2t3l2O/pcl-1.7.2/kdtree/include/pcl/kdtree/impl/kdtree_flann.hpp:136: int pcl::KdTreeFLANN<PointT, Dist>::nearestKSearch(const PointT&, int, std::vector&, std::vector&) const [with PointT = pcl::PointXYZI; Dist = flann::L2_Simple]: Assertion `point_representation_->isValid (point) && “Invalid (NaN, Inf) point coordinates given to nearestKSearch!”’ failed.
[featureAssociation-6] process has died [pid 4388, exit code -6, cmd /home/nvidia/LeGO-LOAM-catkin_ws/devel/lib/lego_loam/featureAssociation __name:=featureAssociation __log:=/home/nvidia/.ros/log/20171d1e-1a4c-11e9-bf05-00044bc4e145/featureAssociation-6.log].
log file: /home/nvidia/.ros/log/20171d1e-1a4c-11e9-bf05-00044bc4e145/featureAssociation-6*.log

猜测是要针对RS-LIDAR-16的硬件特性,在代码上做一些必要的修改,因为LeGO-LOAM是专门基于VLP-16优化的。

参考下一部分【新传感器】的内容,如果RS-LIDAR-16与VLP-16硬件参数不同,需要修改参数,但是有点疑惑,因为在没有修改参数的前提下,Velodyne 32线激光雷达数据效果非常好。

新传感器

使代码适应新传感器的关键是确保点云可以正确投影到距离图像,并且可以正确检测地面。例如,VLP-16沿两个方向的角分辨率为0.2°和2°。它有16个光束。最底部光束的角度为-15°。
因此,“utility.h” 中的参数如下所示。
使用新传感器时,请确保 ground_cloud 具有足够的匹配点。在发布任何问题之前,请阅读此内容。

extern const int N_SCAN = 16;
extern const int Horizon_SCAN = 1800;
extern const float ang_res_x = 0.2;
extern const float ang_res_y = 2.0;
extern const float ang_bottom = 15.0;
extern const int groundScanInd = 7;

(3)使用速腾聚创雷达在线运行时,首先是在rslidar的launch文件内添加一个映射,将rslidar_points修改为velodyne_points。修改之后话题之间的联系虽然建立起来了但是仍然没有输出,最后发现是tf关系没建立起来。在legoloam的launch文件内添加rslidar和base_link这两个frame的tf转换,问题解决!

 <node pkg="tf" type="static_transform_publisher" name="base_link_to_rslidar" args="0 0 0 -1.570795 -1.570795 0        /rslidar /base_link   10" />

另外需要注意的是下面launch文件中/use_sim_time的值仿真是设为true,用实际的雷达运行时设为false。

经过近期调试发现,并不需要另外添加tf关系,在正确数据输入后,建图模块会输出相应缺少的tf关系。主要是在RS16数据输入后lego-loam会报错(刚开始一直强行忽略了这一大串红字,折腾了一天才弄清楚原因):

featureAssociation: /home/chenyi/pcl-1.9/kdtree/include/pcl/kdtree/impl/kdtree_flann.hpp:136: int pcl::KdTreeFLANN<PointT, Dist>::nearestKSearch(const PointT&, int, st
d::vector<int>&, std::vector<float>&) const [with PointT = pcl::PointXYZI; Dist = flann::L2_Simple<float>]: Assertion `point_representation_->isValid (point) && "Inval
id (NaN, Inf) point coordinates given to nearestKSearch!"' failed.
[featureAssociation-6] process has died [pid 30877, exit code -6, cmd /home/chenyi/legoloam_ws/devel/lib/lego_loam/featureAssociation __name:=featureAssociation __log:
=/home/chenyi/.ros/log/c90973c6-82f3-11e9-a7c2-2c4d5498d09e/featureAssociation-6.log].
log file: /home/chenyi/.ros/log/c90973c6-82f3-11e9-a7c2-2c4d5498d09e/featureAssociation-6*.log

原来是程序运行不完整,导致缺少一定的tf关系。

在原作者的github的issue里发现也有人遇到了同样的问题,是由于RS16的输出有NaN points ,需要自己利用pcl函数进行过滤。
另外加一个launch文件:

<launch>
    <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: z
      filter_limit_negative: True
    </rosparam>

   <rosparam>
      filter_field_name: x
      filter_limit_negative: True
    </rosparam>

   <rosparam>
      filter_field_name: y
      filter_limit_negative: True
    </rosparam>
  </node>
</launch>

问题解决!建立起了漂亮的实验室地图和tf tree~
在这里插入图片描述
在这里插入图片描述

Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐