N10 LiDAR ROS2 Package Usage
Hint
The operating environment and hardware/software configuration are as follows:
- LiDAR model: Leishen N10 LiDAR
- Operating system: Ubuntu 22.04
- ROS2 version: Humble
- ROS2 package:
lslidar_driver+lslidar_msgs - This document covers the N10 only
Package/resource archive download link: (you can refer to Kit resources/Resource links to download)
Scenario Description
This document explains how to start the N10 LiDAR in ROS2 and view LiDAR data such as /scan and lslidar_point_cloud. After the N10 starts, it mainly publishes 2D laser scan data, which can be used for robot obstacle avoidance, SLAM, Nav2 navigation, and other functions.
The N10-related files are as follows:
| Purpose | File |
|---|---|
| N10 serial port version parameters | lslidar_driver/config/lslidar_n10_uart.yaml |
| N10 Ethernet port version parameters | lslidar_driver/config/lslidar_n10_net.yaml |
| N10 serial port version launch | lslidar_driver/launch/lsn10_launch.py |
| N10 Ethernet port version launch | lslidar_driver/launch/lsn10_net_launch.py |
| Custom messages/services | lslidar_msgs |
1. Package Preparation
Step 1: Create a Workspace
Step 2: Extract the Packages
Extract the following two archives from the resource package into the src directory:
After extraction, the recommended directory structure is as follows:
If you also need to use a serial port alias, you can place wheeltec_udev.sh in the workspace as well, or run it directly from the original directory in the resource package.
Step 3: Install Dependencies
Install the ROS2 build tools:
Install the dependencies required by the driver:
sudo apt install -y \
ros-$ROS_DISTRO-pcl-conversions \
ros-$ROS_DISTRO-builtin-interfaces \
ros-$ROS_DISTRO-rosidl-default-generators \
libpcl-dev \
libpcap-dev \
libyaml-cpp-dev
If the build reports that diagnostic_updater is missing, install it additionally:
Step 4: Build the Packages
Return to the workspace root:
If you only want to rebuild the LiDAR driver package, run:
Attention
After modifying the parameters in config/*.yaml, it is recommended to rebuild and re-source the environment, so that the launch process does not still read the parameter file from the old install directory.
2. Starting the N10 Serial Port Version
Step 1: Confirm the Serial Port Parameters
Open the N10 serial port version configuration file:
Check the following key settings:
x10:
lslidar_driver_node:
ros__parameters:
lidar_type: "X10"
lidar_model: "N10"
serial_port: "/dev/wheeltec_lidar"
frame_id: "laser"
pointcloud_topic: "lslidar_point_cloud"
laserscan_topic: "/scan"
publish_scan: true
If you do not use a fixed alias and the actual serial port is /dev/ttyUSB0, change it to:
Step 2: Start the N10 Serial Port Version LiDAR
After a successful start, the driver node reads the parameters in lslidar_n10_uart.yaml and starts publishing LiDAR data.
3. Viewing ROS2 Topics
After starting the N10, open a new terminal and source the workspace:
Under normal conditions, you should see topics similar to the following:
Where:
| Topic | Type | Description |
|---|---|---|
/scan |
sensor_msgs/msg/LaserScan |
2D laser scan data, commonly used for navigation and obstacle avoidance |
lslidar_point_cloud |
sensor_msgs/msg/PointCloud2 |
Point cloud data, can be used for RViz display |
View /scan data:
View the publishing frequency:
View the point cloud data frequency:
4. RViz2 Visualization Display
Step 1: Start RViz2
If you use the RViz configuration included in the package, run:
Step 2: Set the Fixed Frame
In Global Options on the left side of RViz2, set Fixed Frame to:
This value corresponds to the following in the N10 parameter file:
Step 3: Add a LaserScan Display
Click Add and select:
If /scan is published normally, you should see a ring of 2D laser points in RViz2.
Step 4: Add a PointCloud2 Display
Click Add and select:
If the point cloud topic is published normally, you can see the LiDAR point cloud in RViz2.
5. Common N10 Parameters
The N10 parameters are mainly modified in the following two files:
1. Basic Parameters
| Parameter | Default Value | Description |
|---|---|---|
lidar_type |
X10 |
Driver type to which the N10 belongs; not recommended to modify |
lidar_model |
N10 |
LiDAR model; this document only uses the N10 |
serial_port |
/dev/wheeltec_lidar or empty |
Enter the serial port for the serial port version; leave it empty for the Ethernet port version |
device_ip |
192.168.1.200 |
LiDAR IP for the Ethernet port version |
msop_port |
2368 |
LiDAR data port |
difop_port |
2369 |
LiDAR device port |
frame_id |
laser |
LiDAR coordinate frame name |
laserscan_topic |
/scan |
LaserScan topic name |
pointcloud_topic |
lslidar_point_cloud |
Point cloud topic name |
2. Data Publishing Parameters
| Parameter | Default Value | Description |
|---|---|---|
publish_scan |
true |
Whether to publish /scan |
use_high_precision |
false |
LaserScan high-precision mode; can be enabled for the N10 as needed |
min_range |
0.15 |
Minimum valid range, in m |
max_range |
50.0 |
Maximum valid range, in m |
If you need higher angular precision, you can try:
Attention
High-precision mode increases the amount of LaserScan data. If the host computer or robot has limited computing power, it is recommended to keep the default value first and enable it after confirming that the data is stable.
3. Angle Mask Parameters
No angles are masked by default:
If you need to mask 0° to 90°:
If you need to mask two regions, for example 0° to 90° and 180° to 270°:
The angle unit is 0.01°, so 9000 represents 90°.
4. Coordinate Transform Parameters
If you only need ordinary /scan data, you generally do not need to modify the following parameters:
If you want to translate or rotate the point cloud, you can enable:
Then modify parameters such as x_offset, y_offset, and yaw according to the LiDAR mounting position.
7. Using Nav2
If the N10 is used for Nav2 obstacle avoidance or mapping, /scan is usually used as the laser input.
Common settings in Nav2 or SLAM configurations are as follows:
At the same time, the TF must contain a transform from the robot base coordinate frame to the LiDAR coordinate frame, for example:
If there is no LiDAR TF, you can temporarily publish a static TF:
Here 0 0 0.15 needs to be modified according to the actual mounting height and position of the LiDAR.
