基于rslidar使用Lego-LOAM建立栅格地图

使用rslidar建立栅格地图

  1. 安装rslidar驱动并在rviz中显示点云
  1. 系统版本

ros1-noetic

  1. 官网下载驱动
git clone https://github.com/RoboSense-LiDAR/rslidar_sdk.git
cd rslidar_sdk
git submodule init
git submodule update

ps:

  1. 最后两个init与update是非常重要的,会构建很多项目下的子系统,遗漏的话会在后续cmake时报错。
  2. 强烈建议使用git clone进行工程下载,直接下载zip压缩包会确实部分文件导致编译出错
  1. 安装Pcap
sudo apt-get install -y  libpcap-dev

  1. 更改config文件

/home/leo/lidaer_ws/src/rslidar_sdk/config目录下,修改config.yaml文件

common:
  msg_source: 1                                         #0: not use Lidar
                                                        #1: packet message comes from online Lidar
                                                        #2: packet message comes from ROS or ROS2
                                                        #3: packet message comes from Pcap file
  send_packet_ros: false                                #true: Send packets through ROS or ROS2(Used to record packet)
  send_point_cloud_ros: true                            #true: Send point cloud through ROS or ROS2
lidar:
  - driver:
      lidar_type: RSHELIOS             #LiDAR type - RS16, RS32, RSBP, RSHELIOS, RSHELIOS_16P, RS128, RS80, RS48, RSP128, RSP80, RSP48, 
                                   #             RSM1, RSM1_JUMBO, RSM2, RSE1, RSMX.
      msop_port: 6699              #Msop port of lidar
      difop_port: 7788             #Difop port of lidar
      start_angle: 0               #Start angle of point cloud
      end_angle: 360               #End angle of point cloud 
      wait_for_difop: true
      min_distance: 0.2            #Minimum distance of point cloud
      max_distance: 200            #Maximum distance of point cloud
      use_lidar_clock: false       #True--Use the lidar clock as the message timestamp
                                   #False-- Use the system clock as the timestamp                        
      pcap_path: /home/robosense/lidar.pcap #The path of pcap file
    ros:
      ros_frame_id: rslidar                           #Frame id of packet message and point cloud message
      ros_recv_packet_topic: /rslidar_packets          #Topic used to receive lidar packets from ROS
      ros_send_packet_topic: /rslidar_packets          #Topic used to send lidar packets through ROS
      ros_send_point_cloud_topic: /rslidar_points      #Topic used to send point cloud through ROS

大部分时间只需要更改lidar_type:成自己所选择的雷达即可。

  1. 编译驱动
cd rslidar_sdk
mkdir build && cd build
cmake .. && make -j4

如果这里报错:

cmake报错:cmake The source directory “xxxx” does not appear to contain CMakeLists.txt

则是因为上述init过程被遗漏。

  1. launch

/home/leo/lidaer_ws/src/rslidar_sdk/launch目录下,直接启动

roslaunch rslidar_sdk star.launch

此launch可自动开启配置好的rviz观察到点云数据

  1. 可能出现的问题
  1. catkin_make报错Invoking “cmake“ failed

具体报错代码:

-- Could NOT find PY_em (missing: PY_EM) 
CMake Error at /opt/ros/noetic/share/catkin/cmake/empy.cmake:30 (message):
  Unable to find either executable 'empy' or Python module 'em'...  try
  installing the package 'python3-empy'

因为catkin找的python版本为anaconda下面的版本,所以需要改为指定采用下面的命令

解决办法:

catkin_make -DPYTHON_EXECUTABLE=/usr/bin/python3

  1. 上述报错解决之后catkin_make后报错

具体报错代码:

CMake Error at /opt/ros/noetic/share/catkin/cmake/catkinConfig.cmake:83 (find_package):
  Could not find a package configuration file provided by "autoware_msgs"
  with any of the following names:
 
    autoware_msgsConfig.cmake
    autoware_msgs-config.cmake

因为缺少autoware_msgs包

解决办法:

sudo apt update 
sudo apt install ros-noetic-autoware-msgs

  1. 基于速腾雷达( robosense )实现 Lego-LOAM三维实时建图

0..bashrc目录添加路径

export PATH=/usr/local:$PATH
export LD_LIBRARY_PATH=/USR/LOCAL/LIB:$LD_LIBRARY_PATH

  1. 将Lego-LOAM包下载到工作空间的src目录下:

cd /home/leo/lidar_ws/src
unzip SC-LeGO-LOAM.zip

  1. 编译报错

这说明缺少GTSAM

https://github.com/borglab/gtsam

我们选择4.2版本

git clone是很慢甚至难以成功的,所以我们选择直接下载zip

ps:这里的gtsam是一个cpp的一个库,所以我们不能将其放入在我们的工作空间下

否则,你将遇到以下报错:

可以直接解压到主目录中,因为是下载的单独安装包,所以需要

git init

使其成为一个git空间

随后我们进行

cd gtsam-4.2 #解压出来的文件夹是携带我们版本号的
mkdir build
cd build
cmake ..
make check
sudo make install

这里会遇到报错:

所以你在最后一步安装的时候必须使用管理员权限

  1. 添加路径

当你遇到如下报错:

有的库文件并没有找到,所以你需要在.bashrc添加库文件的路径

export PATH=/usr/local:$PATH
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
  1. 运行程序

至此准备工作全部结束,可以运行launch文件了

你会遇到最后一个问题

这是因为pkg包名文件名并不一致正确命令应当是

roslaunch lego_loam run.launch

最后运行后 ctrl + C 中断,结果文件pcd格式地图存在map文件夹内

  • 3
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值