Skip to content

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

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

Step 2: Extract the Packages

Extract the following two archives from the resource package into the src directory:

lslidar_driver.zip
lslidar_msgs.zip

After extraction, the recommended directory structure is as follows:

~/lslidar_ws/src/
├── lslidar_driver/
└── lslidar_msgs/

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:

sudo apt update
sudo apt install -y python3-colcon-common-extensions

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:

sudo apt install -y ros-$ROS_DISTRO-diagnostic-updater

Step 4: Build the Packages

Return to the workspace root:

cd ~/lslidar_ws
colcon build
source install/setup.bash

If you only want to rebuild the LiDAR driver package, run:

colcon build --packages-select lslidar_driver
source install/setup.bash
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:

gedit ~/lslidar_ws/src/lslidar_driver/config/lslidar_n10_uart.yaml

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:

serial_port: "/dev/ttyUSB0"

Step 2: Start the N10 Serial Port Version LiDAR

source ~/lslidar_ws/install/setup.bash
ros2 launch lslidar_driver lsn10_launch.py

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:

source ~/lslidar_ws/install/setup.bash
ros2 topic list

Under normal conditions, you should see topics similar to the following:

/scan
/lslidar_point_cloud

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:

ros2 topic echo /scan

View the publishing frequency:

ros2 topic hz /scan

View the point cloud data frequency:

ros2 topic hz /lslidar_point_cloud

4. RViz2 Visualization Display

Step 1: Start RViz2

rviz2

If you use the RViz configuration included in the package, run:

rviz2 -d ~/lslidar_ws/install/lslidar_driver/share/lslidar_driver/rviz/lslidar_x10.rviz

Step 2: Set the Fixed Frame

In Global Options on the left side of RViz2, set Fixed Frame to:

laser

This value corresponds to the following in the N10 parameter file:

frame_id: "laser"

Step 3: Add a LaserScan Display

Click Add and select:

By topic -> /scan -> LaserScan

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:

By topic -> /lslidar_point_cloud -> PointCloud2

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:

lslidar_driver/config/lslidar_n10_uart.yaml

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:

use_high_precision: true
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:

angle_disable_min: [0]
angle_disable_max: [0]

If you need to mask 0° to 90°:

angle_disable_min: [0]
angle_disable_max: [9000]

If you need to mask two regions, for example 0° to 90° and 180° to 270°:

angle_disable_min: [0, 18000]
angle_disable_max: [9000, 27000]

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:

is_pretreatment: false
x_offset: 0.0
y_offset: 0.0
z_offset: 0.0
roll: 0.0
pitch: 0.0
yaw: 0.0

If you want to translate or rotate the point cloud, you can enable:

is_pretreatment: true

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:

scan_topic: /scan

At the same time, the TF must contain a transform from the robot base coordinate frame to the LiDAR coordinate frame, for example:

base_link -> laser

If there is no LiDAR TF, you can temporarily publish a static TF:

ros2 run tf2_ros static_transform_publisher 0 0 0.15 0 0 0 base_link laser

Here 0 0 0.15 needs to be modified according to the actual mounting height and position of the LiDAR.

8. N10 Minimal Startup Procedure

Minimal Procedure for the Serial Port Version

mkdir -p ~/lslidar_ws/src
# Place lslidar_driver and lslidar_msgs in src
cd ~/lslidar_ws
sudo apt install -y python3-colcon-common-extensions libpcap-dev libpcl-dev libyaml-cpp-dev
colcon build
source install/setup.bash
ros2 launch lslidar_driver lsn10_launch.py

Image 1