Navigation

    蓝鲸ROS机器人论坛

    • Register
    • Login
    • Search
    • Categories
    • Tags
    • Popular
    ROS交流群
    ROS Group
    产品服务
    Product Service
    开源代码库
    Github
    官网
    Official website
    技术交流
    Technological exchanges
    激光雷达
    LIDAR
    ROS教程
    ROS Tourials
    深度学习
    Deep Learning
    机器视觉
    Computer Vision

    xiaoqiang tutorial (13) rplidar A2 LiDAR useage and set udev rules for serial devices for xiaoqiang

    产品服务
    1
    1
    1637
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • weijiz
      weijiz last edited by weijiz

      Xiaoqiang Homepage

      rplidar A2 LiDAR useage and set udev rules for serial devices for xiaoqiang

      The 1, 2, 3, and 4 steps of the tutorial in this section are only used to demonstrate the method of adding serial devices to Xiaoqiang. These rules are already added in Xiaoqiang system image. Xiaoqiang users should directly jump to step 5 to test the lidar after connecting the hardware.

      Xiaoqiang host and motor driver communicate through the serial port, In the actual development process, we may add serial peripherals to Xiaoqiang. This can lead to confusion over the serial number (ttyUSB*), causing anomalies in the xiaoqiang’s ros driver and serial device. The following uses the rplidar A2 lidar as an example to demonstrate how to resolve serial port conflicts by modifying the device serial number specified in the udev file. The source of this method

      1.Check the ID of each serial device

      sudo apt-get install expect-dev
      unbuffer udevadm monitor --environment | grep 'ID_SERIAL='
      

      After the USB to serial cable of the platform is re-plugged, the terminal will print out the ID information of this device. For example, "Silicon_Labs_CP2102_USB_to_UART_Bridge_Controller" in the following figure.

      Then re-inserted the lidar’s usb adapter into the host, and the terminal will also print the lidar’s ID information. For example, "Prolific_Technology_Inc._USB-Serial_Controller_0001" in the following figure.

      0_1536824808194_577e1c9d-5e7c-4e18-a023-6c36a87bc2c6-image.png

      2.Please create a udev rule file based on the ID of the serial device you obtained. Specify platform communication USB to serial port as ttyUSB001 and lidar as ttyUSB002.

      sudo gedit  /etc/udev/rules.d/60-persistent-serial.rules
      

      Enter the following content and save it. Please replace the string following ID_SERIAL with the ID you obtained in step 1.

      ACTION!="add", GOTO="persistent_serial_end"
      SUBSYSTEM!="tty", GOTO="persistent_serial_end"
      KERNEL!="ttyUSB[0-9]*", GOTO="persistent_serial_end"
      
      # This is old 11.10 style: IMPORT="usb_id --export %p"
      IMPORT{builtin}="path_id"
      ENV{ID_SERIAL}=="Prolific_Technology_Inc._USB-Serial_Controller"         , SYMLINK="stm32Platform"        , SYMLINK+="ttyUSB001" , OWNER="xiaoqiang"
      ENV{ID_SERIAL}=="Silicon_Labs_CP2102_USB_to_UART_Bridge_Controller_0001" , SYMLINK="rplidarA2"       , SYMLINK+="ttyUSB002" , OWNER="xiaoqiang"
      
      LABEL="persistent_serial_end"
      

      Update system udev rules

      sudo udevadm control --reload
      

      Re-plug all USB devices, now the platform communication USB to serial successfully identified as ttyUSB001, lidar is identified as ttyUSB002, regardless of the device insertion order and port.

      0_1536825069086_17869a35-1e3f-4a58-8b74-9e74fa6b18ea-image.png

      3.Modify the ROS driver node launch file, set the serial device as ttyUSB001.

      0_1536825086406_6394cec6-e1d2-431d-b234-f3f943fa2e83-image.png

      4.Modify the ROS driver node launch file for rplidar A2 and set the serial device as ttyUSB002.

      # Driver installation
      cd ~/Documents/ros/src
      git clone https://github.com/BlueWhaleRobot/rplidar_ros.git
      cd  ..
      catkin_make
      

      0_1536825177462_9a4961c7-5433-4810-93a8-42f18458fffa-image.png

      1. After restarting Xiaoqiang, it is now possible to use the lidar and xiaoqiang normally at the same time. For example, run the following command to test the lidar.
      roslaunch rplidar_ros view_rplidar.launch
      

      0_1536825247655_ab641def-1531-42a3-a1bd-14cc3413409d-image.png

      Xiaoqiang Homepage
      Back To Index

      1 Reply Last reply Reply Quote 0
      • 1 / 1
      • First post
        Last post
      Copyright © 2015-2023 BlueWhale community