Ubuntu Linux for Robotics · Lesson 32 of 96
RealSense and LiDAR drivers
Installing sensor drivers, USB permissions, checking data and ROS 2 driver nodes.
Estimated time · 60–90 min
Learning goals
What you will understand
- Explain realsense and lidar drivers in your own words
- Use it in a small workstation example
- Verify the result instead of assuming it worked
Understand the idea first
The mental model
A sensor needs a driver that talks to the hardware and a ROS 2 node that publishes its data. Intel RealSense cameras use librealsense and the realsense2_camera node; many 2D lidars (RPLIDAR, Hokuyo, SICK) have their own ROS 2 packages that publish sensor_msgs/LaserScan. Install them with apt where available.
Before starting a ROS node, prove the operating system sees the device: lsusb for USB, ls /dev/tty* for serial adapters, and the vendor viewer (realsense-viewer). Give your user permission with udev rules and the dialout group, use a good USB 3 cable and port for cameras, and check the topic with ros2 topic hz.
Guided lesson
Work through these steps
- 1.
Open a terminal and record the current state before changing anything.
- 2.
Read the realsense and lidar drivers commands and predict what each one does.
- 3.
Run the commands one at a time and compare each output with your prediction.
- 4.
Write the commands that worked in a setup note you can repeat later.
Worked example
Read it before you run it
lsusb | grep -i -E 'intel|silicon|hokuyo'
# Check that Linux sees the sensor on USB.
sudo apt install ros-lyrical-realsense2-camera
# Install the RealSense ROS 2 driver.
realsense-viewer
# Test the camera outside ROS.
ros2 launch realsense2_camera rs_launch.py
# Start the ROS 2 camera node.
sudo apt install ros-lyrical-sllidar-ros2
# Install a lidar driver (package name depends on your lidar model).
ros2 topic hz /scan
# Confirm the lidar publishes at its expected rate.What the example is doing
- 1.Lines without sudo only inspect or change files you own; sudo authorizes a system-wide change.
- 2.Read command output before moving to the next line. Stop if names, versions, disks, or paths differ from the lesson.
- 3.Comments beginning with # explain safety checks and are not executed by the shell.
Watch it run · Sensor view
See what this code does
The terminal types this lesson's practice solution and runs it. The scene shows the kind of robot behaviour that code drives. It plays by itself and loops.
Demo for RealSense and LiDAR drivers. Expected result: average rate: 10.0
Practice code
Now type it yourself
Open a terminal, run the starter line by line (or save it as practice.sh and run bash practice.sh), and replace every TODO with your own command.
# TODO: measure the publishing rate of the /scan topicExpected output
average rate: 10.0Stuck? Show the full solution (try it yourself first)
ros2 topic hz /scanExpected result
How you know it worked
- Each command completes without an unexplained error.
- Your notes contain the command, the important output, and what it proves.
Practical exercise
Apply the lesson
Connect a lidar or camera (or use a recorded bag), prove the OS sees it, start the driver node, view the data in RViz2, and fix any permission problem with a udev rule.
Before you continue
- You recorded the starting state
- Every command and output is understood
- The change can be repeated from your notes
If something goes wrong
Check ownership and permissions first. Do not add sudo unless the command changes a documented system location.
Check spelling, Ubuntu version, enabled repositories, and whether the previous installation command succeeded.