在webots中使用激光雷达

  注意:  

  • 再学习本系列教程时,应该已经安装过ROS了并且需要有一些ROS的基本知识

webots版本:2020b rev1 ros版本:melodic   在webots中官方给我们提供了多种雷达(有2D雷达和3D雷达) 这里我们用到的是SickLms291  

扫描范围:1800 角度分辨率:0.25 … 10 分辨率:10mm 系统误差:+/-35mm(mm为单位), +/-5cm(cm为单位) 统计误差:10mm(mm为单位)

   

1.添加雷达设备

 

  1. 打开第二章节的地图
  2. 选中Robot,在Robot->children下添加PROTO nodes—>devices->sick->SickLms291(lidar)

首先查看雷达的坐标轴位置是否和body的坐标轴同向,不同向以后tf时会很麻烦。     body坐标     雷达坐标

2. 了解webots中激光雷达如何在ROS中发送数据

 

  1. 首先使用rosservice查看激光雷达是否成功加入ROS
    $ rosservice list
    
    如果没有找到/robot/Sick_LMS_291/enable,点击重新加载webots世界。

可以看到如下图所示:    

  1. 首先使能雷达 ``` shell $ rosservice call /robot/Sick_LMS_291/enable “value: 1”

  success: True  

3. 检查节点是否在发送数据,使用rostopic查看
``` shell
$ rostopic list

  可以看到雷达发布了两个主题:  

/robot/Sick_LMS_291/laser_scan/layer0
/robot/Sick_LMS_291/range_image
  1. 查看/robot/Sick_LMS_291/laser_scan/layer0消息类型 ```shell $ rostopic type /robot/Sick_LMS_291/laser_scan/layer0

  sensor_msgs/LaserScan  

5. 使用以下命令查看消息的数据结构
```shell
$ rosmsg show sensor_msgs/LaserScan
  1. 查看激光雷达发送数据信息 ```shell $ rostopic echo /robot/Sick_LMS_291/laser_scan/layer0

 


header: seq: 25796 stamp: secs: 1610417466 nsecs: 836696320 frame_id: “robot/Sick_LMS_291” angle_min: -1.5707950592 angle_max: 1.5707950592 angle_increment: 0.0174532774836 time_increment: 5.55555561732e-06 scan_time: 0.0010000000475 range_min: 0.00999999977648 range_max: 80.0 ranges: [80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 40.593505859375, 1.7109997272491455, 1.747383713722229, 42.924434661865234, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 2.1447083950042725, 1.8642678260803223, 2.059617757797241, 51.29610824584961, 80.0, 2.1025097370147705, 2.0608510971069336, 2.2517471313476562, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0]  

intensities: []

 

这些数据很难被人理解,想要更好的理解数据的含义,最好的方法就是使用rviz在图形化界面下展示数据。
``` shell
$ rviz

  加载LaserScan和Image显示类型。 LaserScan下将Topic改成/robot/Sick_LMS_291/laser_scan/layer0 Image下将Topic改成/robot/Sick_LMS_291/range_image 并且需要将Fixed Frame改成robot/Sick_LMS_291才能正确显示数据     可以看到/robot/Sick_LMS_291/laser_scan/layer0/robot/Sick_LMS_291/range_image已经成功显示出了前方的障碍物  

结语

  本文也是基于笔者的学习和使用经验总结的,主观性较强,如果有哪些不对的地方或者不明白的地方,欢迎评论区留言交流~   下一章开启导航之旅。 Bye