< >
Home » ROS与激光雷达教程 » ROS与激光雷达入门教程-ROS中使用16线混合固态激光雷达(镭神智能)

ROS与激光雷达入门教程-ROS中使用16线混合固态激光雷达(镭神智能)

说明

  • 介绍如何在ROS中使用镭神智能C16系列小型化16线混合固态激光雷达

产品介绍

  • 镭神智能自主研发的16线激光雷达拥有超高性价比,可适用于室外无人车,汽车辅助驾驶(ADAS)、无人驾驶等领域

请输入图片描述

在ROS中使用

  • 网络设置

  • 连接电源和雷达网络接口

请输入图片描述

  • 连上后,手动设置PC的IP地址为192.168.1.102

请输入图片描述

  • 设置完成后,使用ifconfig命令查看有线 ip 是否设置成功
$ ifconfig
enp2s0    Link encap:以太网  硬件地址 6c:2b:59:33:d6:fc  
          inet 地址:192.168.1.102  广播:192.168.1.255  掩码:255.255.255.0
          inet6 地址: fe80::9a90:c66e:e81b:3ae8/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  跃点数:1
          接收数据包:981462 错误:0 丢弃:0 过载:0 帧数:0
          发送数据包:2118 错误:48 丢弃:0 过载:0 载波:2
          碰撞:1 发送队列长度:1000
          接收字节:1224774316 (1.2 GB)  发送字节:773407 (773.4 KB)

lo        Link encap:本地环回  
          inet 地址:127.0.0.1  掩码:255.0.0.0
          inet6 地址: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  跃点数:1
          接收数据包:113550 错误:0 丢弃:0 过载:0 帧数:0
          发送数据包:113550 错误:0 丢弃:0 过载:0 载波:0
          碰撞:0 发送队列长度:1000
          接收字节:2897494734 (2.8 GB)  发送字节:2897494734 (2.8 GB)
  • 使用ping或者tcpdump命令,测试硬件是否连接正常
$ ping 192.168.1.200
PING 192.168.1.200 (192.168.1.200) 56(84) bytes of data.
64 bytes from 192.168.1.200: icmp_seq=1 ttl=128 time=0.080 ms
64 bytes from 192.168.1.200: icmp_seq=2 ttl=128 time=0.098 ms
64 bytes from 192.168.1.200: icmp_seq=3 ttl=128 time=0.086 ms
64 bytes from 192.168.1.200: icmp_seq=4 ttl=128 time=0.096 ms
64 bytes from 192.168.1.200: icmp_seq=5 ttl=128 time=0.117 ms

//enp2s0为有线网络设备名
$ sudo tcpdump -n -i enp2s0 
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on enp2s0, link-type EN10MB (Ethernet), capture size 262144 bytes
09:40:54.525833 IP 192.168.1.200.2369 > 192.168.1.102.2368: UDP, length 1206
09:40:54.527020 IP 192.168.1.200.2369 > 192.168.1.102.2368: UDP, length 1206
09:40:54.528256 IP 192.168.1.200.2369 > 192.168.1.102.2368: UDP, length 1206
  • 正如上面显示雷达发送到目的端数据包 1206 个字节,则表示雷达数据发送正常

备注

  • 雷达出厂默认目的 ip:192.168.1.102,要根据雷达实际配置修改的目的 IP 对电脑进行配置
  • 第一次设置IP,重启雷达电源
  • 软件安装及使用

  • 软件安装

$ mkdir -p ~/lslidar_ws/src
$ cd ~/lslidar_ws/src

//ROS包可以从镭神智能的官网或客服处获取,获取后复制到`~/lslidar_ws/src`下

$ git clone https://github.com/ncnynl/lslidar_C16
$ cd ~/lslidar_ws/ && catkin_make
$ echo "source ~/lslidar_ws/devel/setup.bash" >> ~/.bashrc
  • 创建Rviz文件
$ vim ~/lslidar_ws/src/lslidar_c16/lslidar_c16_decoder/launch/lslidar_c16.rviz
//添加以下内容
Panels:
  - Class: rviz/Displays
    Help Height: 78
    Name: Displays
    Property Tree Widget:
      Expanded:
        - /Global Options1
        - /Status1
      Splitter Ratio: 0.5
    Tree Height: 565
  - Class: rviz/Selection
    Name: Selection
  - Class: rviz/Tool Properties
    Expanded:
      - /2D Pose Estimate1
      - /2D Nav Goal1
      - /Publish Point1
    Name: Tool Properties
    Splitter Ratio: 0.588679016
  - Class: rviz/Views
    Expanded:
      - /Current View1
    Name: Views
    Splitter Ratio: 0.5
  - Class: rviz/Time
    Experimental: false
    Name: Time
    SyncMode: 0
    SyncSource: PointCloud2
Visualization Manager:
  Class: ""
  Displays:
    - Alpha: 0.5
      Cell Size: 1
      Class: rviz/Grid
      Color: 160; 160; 164
      Enabled: true
      Line Style:
        Line Width: 0.0299999993
        Value: Lines
      Name: Grid
      Normal Cell Count: 0
      Offset:
        X: 0
        Y: 0
        Z: 0
      Plane: XY
      Plane Cell Count: 10
      Reference Frame: <Fixed Frame>
      Value: true
    - Alpha: 1
      Autocompute Intensity Bounds: true
      Autocompute Value Bounds:
        Max Value: 10
        Min Value: -10
        Value: true
      Axis: Z
      Channel Name: intensity
      Class: rviz/PointCloud2
      Color: 255; 255; 255
      Color Transformer: Intensity
      Decay Time: 0
      Enabled: true
      Invert Rainbow: false
      Max Color: 255; 255; 255
      Max Intensity: 198
      Min Color: 0; 0; 0
      Min Intensity: 0
      Name: PointCloud2
      Position Transformer: XYZ
      Queue Size: 10
      Selectable: true
      Size (Pixels): 3
      Size (m): 0.00999999978
      Style: Flat Squares
      Topic: /lslidar_point_cloud
      Unreliable: false
      Use Fixed Frame: true
      Use rainbow: true
      Value: true
  Enabled: true
  Global Options:
    Background Color: 48; 48; 48
    Default Light: true
    Fixed Frame: laser_link
    Frame Rate: 30
  Name: root
  Tools:
    - Class: rviz/Interact
      Hide Inactive Objects: true
    - Class: rviz/MoveCamera
    - Class: rviz/Select
    - Class: rviz/FocusCamera
    - Class: rviz/Measure
    - Class: rviz/SetInitialPose
      Topic: /initialpose
    - Class: rviz/SetGoal
      Topic: /move_base_simple/goal
    - Class: rviz/PublishPoint
      Single click: true
      Topic: /clicked_point
  Value: true
  Views:
    Current:
      Class: rviz/Orbit
      Distance: 17.6234169
      Enable Stereo Rendering:
        Stereo Eye Separation: 0.0599999987
        Stereo Focal Distance: 1
        Swap Stereo Eyes: false
        Value: false
      Focal Point:
        X: 0
        Y: 0
        Z: 0
      Focal Shape Fixed Size: true
      Focal Shape Size: 0.0500000007
      Invert Z Axis: false
      Name: Current View
      Near Clip Distance: 0.00999999978
      Pitch: 0.785398006
      Target Frame: <Fixed Frame>
      Value: Orbit (rviz)
      Yaw: 0.785398006
    Saved: ~
Window Geometry:
  Displays:
    collapsed: false
  Height: 846
  Hide Left Dock: false
  Hide Right Dock: false
  QMainWindow State: 000000ff00000000fd00000004000000000000016a000002c4fc0200000008fb0000001200530065006c0065006300740069006f006e00000001e10000009b0000006100fffffffb0000001e0054006f006f006c002000500072006f007000650072007400690065007302000001ed000001df00000185000000a3fb000000120056006900650077007300200054006f006f02000001df000002110000018500000122fb000000200054006f006f006c002000500072006f0070006500720074006900650073003203000002880000011d000002210000017afb000000100044006900730070006c0061007900730100000028000002c4000000d700fffffffb0000002000730065006c0065006300740069006f006e00200062007500660066006500720200000138000000aa0000023a00000294fb00000014005700690064006500530074006500720065006f02000000e6000000d2000003ee0000030bfb0000000c004b0069006e0065006300740200000186000001060000030c00000261000000010000010f000002c4fc0200000003fb0000001e0054006f006f006c002000500072006f00700065007200740069006500730100000041000000780000000000000000fb0000000a005600690065007700730100000028000002c4000000ad00fffffffb0000001200530065006c0065006300740069006f006e010000025a000000b200000000000000000000000200000490000000a9fc0100000001fb0000000a00560069006500770073030000004e00000080000002e10000019700000003000004b00000003efc0100000002fb0000000800540069006d00650100000000000004b00000030000fffffffb0000000800540069006d006501000000000000045000000000000000000000022b000002c400000004000000040000000800000008fc0000000100000002000000010000000a0054006f006f006c00730100000000ffffffff0000000000000000
  Selection:
    collapsed: false
  Time:
    collapsed: false
  Tool Properties:
    collapsed: false
  Views:
    collapsed: false
  Width: 1200
  X: 65
  Y: 60
  • 启动程序
$ roslaunch lslidar_c16_decoder lslidar_c16.launch --screen
... logging to /home/lalala/.ros/log/7a8cea76-d8ec-11e9-b618-6c2b5933d6fc/roslaunch-lalala-Inspiron-3576-5233.log
Checking log directory for disk usage. This may take awhile.
Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.

started roslaunch server http://192.168.1.102:36347/

SUMMARY
========

PARAMETERS
 * /lslidar_c16_decoder_node/angle3_disable_max: 0
 * /lslidar_c16_decoder_node/angle3_disable_min: 0
 * /lslidar_c16_decoder_node/angle_disable_max: 0
 * /lslidar_c16_decoder_node/angle_disable_min: 0
 * /lslidar_c16_decoder_node/channel_num: 0
 * /lslidar_c16_decoder_node/frame_id: laser_link
 * /lslidar_c16_decoder_node/frequency: 10.0
 * /lslidar_c16_decoder_node/max_range: 150.0
 * /lslidar_c16_decoder_node/min_range: 0.15
 * /lslidar_c16_decoder_node/point_num: 2000
 * /lslidar_c16_decoder_node/publish_point_cloud: True
 * /lslidar_c16_decoder_node/publish_scan: True
 * /lslidar_c16_decoder_node/use_gps_ts: False
 * /lslidar_c16_driver_node/add_multicast: False
 * /lslidar_c16_driver_node/device_port: 2368
 * /lslidar_c16_driver_node/group_ip: 224.1.1.2
 * /lslidar_c16_driver_node/lidar_ip: 192.168.1.200
 * /rosdistro: kinetic
 * /rosversion: 1.12.14

NODES
  /
    lslidar_c16_decoder_node (lslidar_c16_decoder/lslidar_c16_decoder_node)
    lslidar_c16_driver_node (lslidar_c16_driver/lslidar_c16_driver_node)

auto-starting new master
process[master]: started with pid [5243]
ROS_MASTER_URI=http://192.168.1.102:11311

setting /run_id to 7a8cea76-d8ec-11e9-b618-6c2b5933d6fc
process[rosout-1]: started with pid [5256]
started core service [/rosout]
process[lslidar_c16_driver_node-2]: started with pid [5272]
process[lslidar_c16_decoder_node-3]: started with pid [5274]
[ INFO] [1568684580.115466190]: namespace is /lslidar_c16_driver_node
[ INFO] [1568684580.123349604]: Opening UDP socket: address 192.168.1.200
[ INFO] [1568684580.123385941]: Opening UDP socket: port 2368
[ INFO] [1568684580.123419348]: expected frequency: 833.333 (Hz)
[ INFO] [1568684580.124647095]: Opening UDP socket: port 2368
[ INFO] [1568684580.124678308]: Initialised lslidar c16 without error
[ WARN] [1568684580.131127438]: discard Point cloud angle from 0.00 to 0.00
[ WARN] [1568684580.131182506]: switch angle from 6.28 to 6.28 in left hand rule
[ WARN] [1568684580.136251472]: Using GPS timestamp or not 0
[ INFO] [1568684580.560078684]: default channel is 0

备注

  • 若出现timeout则表示接收不到数据,请检查硬件连接
  • 若修改了雷达目的端口及转速,请打开 lslidar_C16.launch 进行相应的修改配置,默认IP为192.168.1.200,默认端口为2368,转速为 10HZpoint_num2000
  • 启动Rviz
$ rosrun rviz rviz -d `rospack find lslidar_c16_decoder`/launch/lslidar_c16.rviz

请输入图片描述

演示视频

纠错,疑问,交流: 请进入讨论区点击加入Q群

获取最新文章: 扫一扫右上角的二维码加入“创客智造”公众号


标签: ros与激光雷达入门教程