ROS-YDLidar-x4-docker icon indicating copy to clipboard operation
ROS-YDLidar-x4-docker copied to clipboard

Containerized ROS node that communicates with x4 lidar via USB pass though from the docker host

ros-ydlidar-x4-docker

Overview

This repo demonstrates launching a containorized ROS node that communicates with a lidar sensor over USB. While some of this information is specific to the YDLidar x4, much of the information is generally applicable.

Specifically this guide can help you with the following:

  • Introduction to running ROS within a docker container
  • Creating a reusable dockerfile that downloads an ROS package via git
  • Allowing for bidirectional communication between a docker container and docker host hardware
  • Using Rviz to visualize ROS data that originates from an containorized ROS node

Prerequisites


Getting Started

  • Clone this repository

    it clone [email protected]:patrick--/ROS-YDLidar-x4-docker.git
    
  • If you haven't gotten the Lidar working on the host OS prior to now, go ahead and run lidar_init_env.sh to create the udev rules and appropriate /dev symlinks for the lidar

    cd ROS-YDLidar-x4-docker
    sudo chmod +x lidar_init_env.sh
    sudo sh +x lidar_init_env.sh
    
  • Build image from the provided Dockerfile

    d ROS-YDLidar-x4-docker
    ocker build --tag ros:ros-ydlidar-x4 .
    
  • Launch the container on the host network and ensure to share /dev/ydlidar

    ocker run --device /dev/ydlidar --rm --network host --name ydlidar_x4_docker_test  ros:ros-ydlidar-x4
    

    Note: We use the default host network here for ease of use. If you need to isolate network communication between containers and or your host, you will need to create a network.

  • In another tab simply launch rviz with default settings

    rosrun rviz rviz
    
  • Change the Fixed Frame drop down to laser_frame and add the LaserScan topic to start seeing lidar data in real time.