Initial commit

This commit is contained in:
2026-07-27 13:51:19 +08:00
commit 7bec56ca51
5408 changed files with 1126933 additions and 0 deletions
@@ -0,0 +1,115 @@
# 4 如何与rslidar_sdk_node v1.3.x共存?
## 4.1 问题描述
`rslidar_sdk_node` `v1.3.x``v1.5.x`的配置方式不同。除了如下两个可能有交互的场景外, 两者各自运行,没有关系。
+ `rslidar_sdk_node`在主题`/rslidar_points`下发布点云,rosbag订阅并录制到一个cloud rosbag文件。后面rosbag又会回放这个文件,发布到`/rslidar_points``rslidar_sdk_node`订阅并播放它。
+ `rslidar_sdk_node`在主题`/rslidar_packets`下发布原始的`MSOP/DIFOP Packet`rosbag订阅并录制到一个packet rosbag文件。后面rosbag又会回放这个文件到`/rslidar_packets``rslidar_sdk_node`订阅并播放它。
第一种场景下,`v1.3.x``v1.5.x`发布的点云格式相同,所以`v1.3.x`录制的点云,在`v1.5.x`上播放是没有问题的。
第二种场景下,`v1.3.x`将MSOP/DIFOP Packet分别发布在两个主题`/rslidar_packets``/rslidar_packets_difop`下,而`v1.5.x`将MSOP/DIFOP Packet发布在单个主题`/rslidar_packets`下,而且`v1.3.x``v1.5.x`的消息定义也不同,所以`v1.3.x`录制的packet rosbag在`v1.5.x`上不能播放。ROS会检测出这两种格式的MD5 Checksum不匹配并报错。
本文说明如何配置`rslidar_sdk` `v1.5.x`,让它在第二种场景下可以同时播放`v1.3.x``v1.5.x`的packet rosbag。
## 4.2 场景说明
场景说明如下。
+ 2个雷达,`Lidar1`是运行`v1.3.x`的雷达,`Lidar2`是运行`v1.5.x`的雷达。
+ 1台主机,用于分析`Lidar1``Lidar2`的数据。
![](./img/04_01_packet_rosbag.png)
## 4.3 步骤
### 4.3.1 配置 v1.3.x 雷达
使用`v1.3.x` `rslidar_sdk_node`录制pacekt rosbag。
按照默认的`config.yaml`的配置,消息发布到主题`/rslidar_packets``/rslidar_packets_difop`下。
```
common:
msg_source: 1 #0: not use Lidar
#1: packet message comes from online Lidar
#2: packet message comes from ROS or ROS2
#3: packet message comes from Pcap file
#4: packet message comes from Protobuf-UDP
#5: point cloud comes from Protobuf-UDP
send_packet_ros: true #true: Send packets through ROS or ROS2(Used to record packet)
send_point_cloud_ros: true #true: Send point cloud through ROS or ROS2
lidar:
- driver:
lidar_type: RSM1 #LiDAR type - RS16, RS32, RSBP, RSHELIOS, RS128, RS80, RSM1
msop_port: 6699 #Msop port of lidar
difop_port: 7788 #Difop port of lidar
ros:
ros_send_packet_topic: /rslidar_packets #Topic used to send lidar packets through ROS
ros_send_point_cloud_topic: /rslidar_points #Topic used to send point cloud through ROS
```
### 4.3.2 配置 v1.5.x 雷达
使用`v1.5.6` `rslidar_sdk_node`录制packet rosbag。
为了与`v1.3.2`的消息区别,将消息输出到主题`/rslidar_packets_v2`下。
```
common:
msg_source: 1 #0: not use Lidar
#1: packet message comes from online Lidar
#2: packet message comes from ROS or ROS2
#3: packet message comes from Pcap file
send_packet_ros: true #true: Send packets through ROS or ROS2(Used to record packet)
send_point_cloud_ros: true #true: Send point cloud through ROS or ROS2
lidar:
- driver:
lidar_type: RSM1 #LiDAR type - RS16, RS32, RSBP, RSHELIOS, RS128, RS80, RS48, RSM1
msop_port: 6699 #Msop port of lidar
difop_port: 7788 #Difop port of lidar
ros:
ros_send_packet_topic: /rslidar_packets_v2 #Topic used to send lidar packets through ROS
ros_send_point_cloud_topic: /rslidar_points #Topic used to send point cloud through ROS
```
### 4.3.3 配置 v1.5.x 主机
+ 打开CMake编译选项`ENABLE_SOURCE_PACKET_LEGACY=ON`,编译`rslidar_sdk`
```
# CMakeLists.txt
option(ENABLE_SOURCE_PACKET_LEGACY "Enable ROS Source of MSOP/DIFOP Packet v1.3.x" ON)
```
+ 在`config.yaml`中,增加一个配置项`ros_recv_packet_legacy_topic`: `/rslidar_packets`。这样`rslidar_sdk_node`将同时订阅两个主题。
+ 订阅`/rslidar_packets``/rslidar_packets_difop`,读入`v1.3.x`的消息
+ 订阅`/rslidar_packets_v2`,读入`v1.5.x`的消息
```
common:
msg_source: 1 #0: not use Lidar
#1: packet message comes from online Lidar
#2: packet message comes from ROS or ROS2
#3: packet message comes from Pcap file
send_packet_ros: false #true: Send packets through ROS or ROS2(Used to record packet)
send_point_cloud_ros: true #true: Send point cloud through ROS or ROS2
lidar:
- driver:
lidar_type: RSM1 #LiDAR type - RS16, RS32, RSBP, RSHELIOS, RS128, RS80, RS48, RSM1
msop_port: 6699 #Msop port of lidar
difop_port: 7788 #Difop port of lidar
ros:
ros_recv_packet_legacy_topic: /rslidar_packets #Topic used to receive lidar packets from ROS
ros_recv_packet_topic: /rslidar_packets_v2 #Topic used to receive lidar packets from ROS
ros_send_point_cloud_topic: /rslidar_points #Topic used to send point cloud through ROS
```
@@ -0,0 +1,165 @@
# 5 How to change point type
## 5.1 Introduction
This document illustrates how to change the point type.
In ```CMakeLists.txt``` of the project, change the variable `POINT_TYPE`. Remember to **rebuild** the project after changing it.
```cmake
#=======================================
# Custom Point Type (XYZI,XYZIRT, XYZIF, XYZIRTF)
#=======================================
set(POINT_TYPE XYZI)
```
## 5.2 XYZI
If `POINT_TYPE` is `XYZI`, rslidar_sdk uses the RoboSense defined type as below.
```c++
struct PointXYZI
{
float x;
float y;
float z;
uint8_t intensity;
};
```
rslidar_sdk transforms point cloud of `PointXYZI` to ROS message of `PointCloud2`and publish it.
```c++
sensor_msgs::PointCloud2 ros_msg;
int offset = 0;
offset = addPointField(ros_msg, "x", 1, sensor_msgs::PointField::FLOAT32, offset);
offset = addPointField(ros_msg, "y", 1, sensor_msgs::PointField::FLOAT32, offset);
offset = addPointField(ros_msg, "z", 1, sensor_msgs::PointField::FLOAT32, offset);
offset = addPointField(ros_msg, "intensity", 1, sensor_msgs::PointField::FLOAT32, offset);
//
// copy points from point cloud of `PointXYZI` to `PointCloud2`
//
...
```
Here `intensity` of `PointCloud2` is `float` type, not `uint8_t`. This is because most ROS based applications require `intensity` of `float` type.
## 5.3 XYZIRT
If `POINT_TYPE` is `XYZIRT`, rslidar_sdk uses the RoboSense defined type as below.
```c++
struct PointXYZIRT
{
float x;
float y;
float z;
uint8_t intensity;
uint16_t ring;
double timestamp;
};
```
rslidar_sdk transforms point cloud of `PointXYZIRT` to ROS message of `PointCloud2`and publish it.
```c++
sensor_msgs::PointCloud2 ros_msg;
int offset = 0;
offset = addPointField(ros_msg, "x", 1, sensor_msgs::PointField::FLOAT32, offset);
offset = addPointField(ros_msg, "y", 1, sensor_msgs::PointField::FLOAT32, offset);
offset = addPointField(ros_msg, "z", 1, sensor_msgs::PointField::FLOAT32, offset);
offset = addPointField(ros_msg, "intensity", 1, sensor_msgs::PointField::FLOAT32, offset);
#if defined(POINT_TYPE_XYZIRT) || defined(POINT_TYPE_XYZIRTF)
offset = addPointField(ros_msg, "ring", 1, sensor_msgs::PointField::UINT16, offset);
offset = addPointField(ros_msg, "timestamp", 1, sensor_msgs::PointField::FLOAT64, offset);
#endif
//
// copy points from point cloud of `PointXYZIRT` to `PointCloud2`
//
...
```
## 5.4 XYZIF
If `POINT_TYPE` is `XYZIF`, rslidar_sdk uses the RoboSense defined type as below.
```c++
struct PointXYZIF
{
float x;
float y;
float z;
uint8_t intensity;
uint16_t ring;
double timestamp;
};
```
rslidar_sdk transforms point cloud of `PointXYZIF` to ROS message of `PointCloud2`and publish it.
```c++
sensor_msgs::PointCloud2 ros_msg;
int offset = 0;
offset = addPointField(ros_msg, "x", 1, sensor_msgs::PointField::FLOAT32, offset);
offset = addPointField(ros_msg, "y", 1, sensor_msgs::PointField::FLOAT32, offset);
offset = addPointField(ros_msg, "z", 1, sensor_msgs::PointField::FLOAT32, offset);
offset = addPointField(ros_msg, "intensity", 1, sensor_msgs::PointField::FLOAT32, offset);
#if defined(POINT_TYPE_XYZIF) || defined(POINT_TYPE_XYZIRTF)
offset = addPointField(ros_msg, "feature", 1, sensor_msgs::PointField::UINT8, offset);
#endif
//
// copy points from point cloud of `PointXYZIF` to `PointCloud2`
//
...
```
## 5.5 XYZIRTF
If `POINT_TYPE` is `XYZIRTF`, rslidar_sdk uses the RoboSense defined type as below.
```c++
struct PointXYZIRTF
{
float x;
float y;
float z;
uint8_t intensity;
uint16_t ring;
double timestamp;
};
```
rslidar_sdk transforms point cloud of `PointXYZIRTF` to ROS message of `PointCloud2`and publish it.
```c++
sensor_msgs::PointCloud2 ros_msg;
int offset = 0;
offset = addPointField(ros_msg, "x", 1, sensor_msgs::PointField::FLOAT32, offset);
offset = addPointField(ros_msg, "y", 1, sensor_msgs::PointField::FLOAT32, offset);
offset = addPointField(ros_msg, "z", 1, sensor_msgs::PointField::FLOAT32, offset);
offset = addPointField(ros_msg, "intensity", 1, sensor_msgs::PointField::FLOAT32, offset);
#if defined(POINT_TYPE_XYZIRT) || defined(POINT_TYPE_XYZIRTF)
offset = addPointField(ros_msg, "ring", 1, sensor_msgs::PointField::UINT16, offset);
offset = addPointField(ros_msg, "timestamp", 1, sensor_msgs::PointField::FLOAT64, offset);
#endif
#if defined(POINT_TYPE_XYZIF) || defined(POINT_TYPE_XYZIRTF)
offset = addPointField(ros_msg, "feature", 1, sensor_msgs::PointField::UINT8, offset);
#endif
//
// copy points from point cloud of `PointXYZIRTF` to `PointCloud2`
//
...
```
@@ -0,0 +1,162 @@
# 5 如何改变点类型的定义
## 5.1 简介
本文档介绍如何改变点类型的定义。
在项目的```CMakeLists.txt```文件中设置`POINT_TYPE`变量。修改后,需要重新编译整个工程。
```cmake
#=======================================
# Custom Point Type (XYZI,XYZIRT, XYZIF, XYZIRTF)
#=======================================
set(POINT_TYPE XYZI)
```
## 5.2 XYZI
`POINT_TYPE`为`XYZI`时,rslidar_sdk使用RoboSense自定义的点类型```PointXYZI```.
```c++
struct PointXYZI
{
float x;
float y;
float z;
uint8_t intensity;
};
```
rslidar_sdk将基于`PointXYZI`的点云,转换为ROS的`PointCloud2`消息,再发布出去。
```c++
sensor_msgs::PointCloud2 ros_msg;
int offset = 0;
offset = addPointField(ros_msg, "x", 1, sensor_msgs::PointField::FLOAT32, offset);
offset = addPointField(ros_msg, "y", 1, sensor_msgs::PointField::FLOAT32, offset);
offset = addPointField(ros_msg, "z", 1, sensor_msgs::PointField::FLOAT32, offset);
offset = addPointField(ros_msg, "intensity", 1, sensor_msgs::PointField::FLOAT32, offset);
//
// copy points from point cloud of `PointXYZI` to `PointCloud2`
//
...
```
这里`PointCloud2`中的`intensity`是`float`类型,而不是`uint8_t`类型。这是因为大多数基于ROS的程序都希望`float`类型的`intensity`。
## 5.3 XYZIRT
`POINT_TYPE`为`XYZIRT`时,rslidar_sdk使用RoboSense自定义的点类型```PointXYZRT```。
```c++
struct PointXYZIRT
{
float x;
float y;
float z;
uint8_t intensity;
uint16_t ring;
double timestamp;
};
```
rslidar_sdk将基于`PointXYZIRT`的点云,转换为ROS的PointCloud2消息,再发布出去。
```c++
sensor_msgs::PointCloud2 ros_msg;
int offset = 0;
offset = addPointField(ros_msg, "x", 1, sensor_msgs::PointField::FLOAT32, offset);
offset = addPointField(ros_msg, "y", 1, sensor_msgs::PointField::FLOAT32, offset);
offset = addPointField(ros_msg, "z", 1, sensor_msgs::PointField::FLOAT32, offset);
offset = addPointField(ros_msg, "intensity", 1, sensor_msgs::PointField::FLOAT32, offset);
#if defined(POINT_TYPE_XYZIRT) || defined(POINT_TYPE_XYZIRTF)
offset = addPointField(ros_msg, "ring", 1, sensor_msgs::PointField::UINT16, offset);
offset = addPointField(ros_msg, "timestamp", 1, sensor_msgs::PointField::FLOAT64, offset);
#endif
//
// copy points from point cloud of `PointXYZIRT` to `PointCloud2`
//
...
```
## 5.4 XYZIF
`POINT_TYPE`为`XYZIF`时,rslidar_sdk使用RoboSense自定义的点类型```PointXYZIF```。
```c++
struct PointXYZIF
{
float x;
float y;
float z;
uint8_t intensity;
uint8_t feature;
};
```
rslidar_sdk将基于`PointXYZIF`的点云,转换为ROS的PointCloud2消息,再发布出去。
```c++
sensor_msgs::PointCloud2 ros_msg;
int offset = 0;
offset = addPointField(ros_msg, "x", 1, sensor_msgs::PointField::FLOAT32, offset);
offset = addPointField(ros_msg, "y", 1, sensor_msgs::PointField::FLOAT32, offset);
offset = addPointField(ros_msg, "z", 1, sensor_msgs::PointField::FLOAT32, offset);
offset = addPointField(ros_msg, "intensity", 1, sensor_msgs::PointField::FLOAT32, offset);
#if defined(POINT_TYPE_XYZIF) || defined(POINT_TYPE_XYZIRTF)
offset = addPointField(ros_msg, "feature", 1, sensor_msgs::PointField::UINT8, offset);
#endif
//
// copy points from point cloud of `PointXYZIF` to `PointCloud2`
//
...
```
## 5.5 XYZIRTF
`POINT_TYPE`为`XYZIRTF`时,rslidar_sdk使用RoboSense自定义的点类型```PointXYZIRTF```。
```c++
struct PointXYZIRTF
{
float x;
float y;
float z;
uint8_t intensity;
uint16_t ring;
double timestamp;
uint8_t feature;
};
```
rslidar_sdk将基于`PointXYZIRTF`的点云,转换为ROS的PointCloud2消息,再发布出去。
```c++
sensor_msgs::PointCloud2 ros_msg;
int offset = 0;
offset = addPointField(ros_msg, "x", 1, sensor_msgs::PointField::FLOAT32, offset);
offset = addPointField(ros_msg, "y", 1, sensor_msgs::PointField::FLOAT32, offset);
offset = addPointField(ros_msg, "z", 1, sensor_msgs::PointField::FLOAT32, offset);
offset = addPointField(ros_msg, "intensity", 1, sensor_msgs::PointField::FLOAT32, offset);
#if defined(POINT_TYPE_XYZIRT) || defined(POINT_TYPE_XYZIRTF)
offset = addPointField(ros_msg, "ring", 1, sensor_msgs::PointField::UINT16, offset);
offset = addPointField(ros_msg, "timestamp", 1, sensor_msgs::PointField::FLOAT64, offset);
#endif
#if defined(POINT_TYPE_XYZIF) || defined(POINT_TYPE_XYZIRTF)
offset = addPointField(ros_msg, "feature", 1, sensor_msgs::PointField::UINT8, offset);
#endif
//
// copy points from point cloud of `PointXYZIRTF` to `PointCloud2`
//
...
```
@@ -0,0 +1,70 @@
# 6 How to decode on-line LiDAR
## 6.1 Introduction
This document illustrates how to connect to an on-line LiDAR, and send point cloud to ROS.
Please make sure you have read the LiDAR user-guide and [Intro to parameters](../intro/02_parameter_intro.md) before reading this document.
## 6.2 Steps
### 6.2.1 Get the LiDAR port number
Please follow the instructions in LiDAR user-guide, to connect the LiDAR, and set up your computer's ip address.
Please check the LiDAR user-guide, or use the 3rd-party tool(such as WireShark), to get your LiDAR's MSOP port number and DIFOP port number. The default values are ```msop-6699, difop-7788```.
### 6.2.2 Set up the configuration file
#### 6.2.2.1 common part
```yaml
common:
msg_source: 1
send_packet_ros: false
send_point_cloud_ros: true
```
The message come from the LiDAR, so set ```msg_source = 1```.
Send point cloud to ROS, so set ```send_point_cloud_ros = true```.
#### 6.2.2.2 lidar-driver part
```yaml
lidar:
- driver:
lidar_type: RS128
msop_port: 6699
difop_port: 7788
imu_port: 6688
start_angle: 0
end_angle: 360
min_distance: 0.2
max_distance: 200
use_lidar_clock: true
```
Set the ```lidar_type``` to your LiDAR type.
Set the ```msop_port```,```difop_port``` and ```difop_port``` to your LiDAR's port number.
#### 6.2.2.3 lidar-ros part
```yaml
ros:
ros_frame_id: rslidar
ros_recv_packet_topic: /rslidar_packets
ros_send_packet_topic: /rslidar_packets
ros_send_imu_data_topic: /rslidar_imu_data
ros_send_point_cloud_topic: /rslidar_points
```
Set the ```rslidar_imu_data``` and ```ros_send_point_cloud_topic``` to the topic you want to send to.
### 6.2.3 Run
Run the program.
@@ -0,0 +1,74 @@
# 6 如何连接在线雷达
## 6.1 简介
本文档描述如何连接在线雷达,并发送点云数据到ROS。
在阅读本文档之前, 请确保已经阅读过雷达用户手册和[参数简介](../intro/02_parameter_intro_CN.md) 。
## 6.2 步骤
### 6.2.1 获取数据端口号
根据雷达用户手册连接雷达, 并设置好您的电脑的IP地址。
请参考雷达用户手册,或使用第三方工具(如WireShark等)得到雷达的MSOP端口号和DIFOP端口号。端口的默认值分别为```6699```和```7788```。
### 6.2.2 设置参数文件
设置参数文件```config.yaml```。
#### 6.2.2.1 common部分
```yaml
common:
msg_source: 1
send_packet_ros: false
send_point_cloud_ros: true
```
消息来源于在线雷达,因此请设置```msg_source=1```。
将点云发送到ROS以便查看,因此设置 ```send_point_cloud_ros = true``` 。
#### 6.2.2.2 lidar-driver部分
```yaml
lidar:
- driver:
lidar_type: RSAIRY
msop_port: 6699
difop_port: 7788
imu_port: 6688
start_angle: 0
end_angle: 360
min_distance: 0.2
max_distance: 200
use_lidar_clock: true
```
将 ```lidar_type``` 设置为LiDAR类型 。
设置 ```msop_port``` 、 ```difop_port``` 和 ```imu_port``` 为雷达数据端口号。
#### 6.2.2.3 lidar-ros部分
```yaml
ros:
ros_frame_id: rslidar
ros_recv_packet_topic: /rslidar_packets
ros_send_packet_topic: /rslidar_packets
ros_send_imu_data_topic: /rslidar_imu_data
ros_send_point_cloud_topic: /rslidar_points
```
将 ```rslidar_imu_data``` 和```ros_send_point_cloud_topic``` 设置为发送Imu数据和发送点云的话题。
### 6.2.3 运行
运行程序。
@@ -0,0 +1,200 @@
# 7 Online LiDAR - Advanced Topics
## 7.1 Introduction
The RoboSense LiDAR may work
+ in unicast/multicast/broadcast mode,
+ with VLAN layer
+ with user layers.
+ Also rslidar_sdk supports multi-LiDARs.
This document illustrates how to configure rslidar_sdk in each case.
Before reading this document, please be sure that you have read:
+ LiDAR user-guide
+ [Intro to parameters](../intro/02_parameter_intro.md)
+ [Decode online LiDAR](./06_how_to_decode_online_lidar.md)
## 7.2 Unicast, Multicast and Broadcast
### 7.2.1 Broadcast mode
The Lidar sends MSOP/DIFOP packets to the host machine (rslidar_sdk runs on it). For simplicity, the DIFOP port is ommited here.
+ The Lidar sends to `255.255.255.255` : `6699`, and the host binds to port `6699`.
![](./img/07_01_broadcast.png)
Below is how to configure `config.yaml`.
```yaml
common:
msg_source: 1
send_point_cloud_ros: true
lidar:
- driver:
lidar_type: RSAIRY
msop_port: 6699
difop_port: 7788
imu_port: 6688
ros:
ros_frame_id: rslidar
ros_send_point_cloud_topic: /rslidar_points
```
The `common` part and the `lidar-ros` part is listed here. They will be ommited in the following examples, since they are not changed.
### 7.2.2 Unicast mode
To reduce the network load, the Lidar is suggested to work in unicast mode.
+ The Lidar sends to `192.168.1.102` : `6699`, and the host binds to port `6699`.
![](./img/07_02_unicast.png)
Below is how to configure `config.yaml`. In fact, it same with the broadcast mode.
```yaml
lidar:
- driver:
lidar_type: RSAIRY
msop_port: 6699
difop_port: 7788
imu_port: 6688
```
### 7.2.3 Multicast mode
The Lidar may also works in multicast mode.
+ The lidar sends to `224.1.1.1`:`6699`
+ The host binds to port `6699`. And it makes local NIC (Network Interface Card) join the multicast group `224.1.1.1`. The local NIC's IP is `192.168.1.102`.
![](./img/07_03_multicast.png)
Below is how to configure `config.yaml`.
```yaml
lidar:
- driver:
lidar_type: RSAIRY
msop_port: 6699
difop_port: 7788
imu_port: 6688
group_address: 224.1.1.1
host_address: 192.168.1.102
```
## 7.3 Multiple LiDARs
### 7.3.1 Different remote ports
If you have two or more Lidars, it is suggested to set different remote ports.
+ First Lidar sends to `192.168.1.102`:`6699`, and the first driver instance binds to `6699`.
+ Second Lidar sends to `192.168.1.102`:`5599`, and the second driver instance binds to `5599`.
![](./img/07_04_multi_lidars_port.png)
Below is how to configure `config.yaml`.
```yaml
lidar:
- driver:
lidar_type: RSAIRY
msop_port: 6699
difop_port: 7788
imu_port: 6688
- driver:
lidar_type: RSAIRY
msop_port: 6698
difop_port: 7789
imu_port: 6689
```
### 7.3.2 Different remote IPs
An alternate way is to set different remote IPs.
+ The host has two NICs: `192.168.1.102` and `192.168.1.103`.
+ First Lidar sends to `192.168.1.102`:`6699`, and the first driver instance binds to `192.168.1.102:6699`.
+ Second Lidar sends to `192.168.1.103`:`6699`, and the second driver instance binds to `192.168.1.103:6699`.
![](./img/07_05_multi_lidars_ip.png)
Below is how to configure `config.yaml`.
```yaml
lidar:
- driver:
lidar_type: RSAIRY
msop_port: 6699
difop_port: 7788
imu_port: 6688
host_address: 192.168.1.102
- driver:
lidar_type: RSAIRY
msop_port: 6699
difop_port: 7788
imu_port: 6688
host_address: 192.168.1.103
```
## 7.4 VLAN
In some user cases, The Lidar may work on VLAN. Its packets have a VLAN layer.
![](./img/07_06_vlan_layer.png)
The driver cannot parse this packet. Instead, it depends on a virtual NIC to strip the VLAN layer.
Below is an example.
+ The Lidar works on VLAN `80`. It sends packets to `192.168.1.102` : `6699`. The packet has a VLAN layer.
+ Suppose there is a physical NIC `eno1` on the host. It receives packets with VLAN layer.
![](./img/07_07_vlan.png)
To strip the VLAN layer, create a virtual NIC `eno1.80` on `eno1`, and assign IP `192.168.1.102` to it.
```
sudo apt-get install vlan -y
sudo modprobe 8021q
sudo vconfig add eno1 80
sudo ifconfig eno1.80 192.168.1.102 up
```
Now the driver may take `eno1.80` as a general NIC, and receives packets without VLAN layer.
```yaml
lidar:
- driver:
lidar_type: RSAIRY
msop_port: 6699
difop_port: 7788
imu_port: 6688
```
## 7.5 User Layer, Tail Layer
In some user cases, User may add extra layers before or after the MSOP/DIFOP packet.
+ USER_LAYER is before the packet and TAIL_LAYER is after it.
![](./img/07_08_user_layer.png)
These extra layers are parts of UDP data. The driver can strip them.
To strip them, just give their lengths in bytes.
In the following example, USER_LAYER is 8 bytes, and TAIL_LAYER is 4 bytes.
```yaml
lidar:
- driver:
lidar_type: RSAIRY
msop_port: 6699
difop_port: 7788
imu_port: 6688
user_layer_bytes: 8
tail_layer_bytes: 4
```
@@ -0,0 +1,199 @@
# 7 在线雷达 - 高级主题
## 7.1 简介
RoboSense雷达可以工作在如下的场景。
+ 单播/组播/广播模式。
+ 运行在VLAN协议上。
+ 向Packet加入用户自己的层。
+ 接入多个雷达。
本文描述在这些场景下如何配置rslidar_sdk。
在阅读本文档之前, 请确保已经阅读过:
+ 雷达用户手册
+ [参数介绍](../intro/02_parameter_intro_CN.md)
+ [连接在线雷达](./06_how_to_decode_online_lidar_CN.md)
## 7.2 单播、组播、广播
### 7.2.1 广播
雷达发送 MSOP/DIFOP Packet到电脑主机。为简单起见,如下的图没有显示DIFOP端口。
+ 雷达发送Packet到 `255.255.255.255` : `6699`, rslidar_sdk绑定到主机的端口 `6699`.
![](./img/07_01_broadcast.png)
如下是配置`config.yaml`的方式。
```yaml
common:
msg_source: 1
send_point_cloud_ros: true
lidar:
- driver:
lidar_type: RSAIRY
msop_port: 6699
difop_port: 7788
imu_port: 6688
ros:
ros_frame_id: rslidar
ros_send_point_cloud_topic: /rslidar_points
```
这里列出了`common`部分和`lidar-ros`部分的设置。这两部分设置将在本文中后面的例子沿用,不再列出。
### 7.2.2 单播
为了减少网络负载,建议雷达使用单播模式。
+ 雷达发送Packet到 `192.168.1.102` : `6699`, rslidar_sdk绑定端口 `6699`
![](./img/07_02_unicast.png)
如下是配置`config.yaml`的方式。这实际上与广播的方式一样。
```yaml
lidar:
- driver:
lidar_type: RSAIRY
msop_port: 6699
difop_port: 7788
imu_port: 6688
```
### 7.2.3 组播
雷达也可以工作在组播模式。
+ 雷达发送Packet到 `224.1.1.1`:`6699`
+ rslidar_sdk绑定到端口 `6699`。同时它将IP地址为`192.168.1.102`的本地网络接口加入组播组`224.1.1.1`
![](./img/07_03_multicast.png)
如下是配置`config.yaml`的方式。
```yaml
lidar:
- driver:
lidar_type: RSAIRY
msop_port: 6699
difop_port: 7788
imu_port: 6688
group_address: 224.1.1.1
host_address: 192.168.1.102
```
## 7.3 多个雷达的情况
### 7.3.1 不同的目标端口
如果有两个或多个雷达,首选的配置是让它们有不同的目标端口。
+ 第一个雷达发送Packet到 `192.168.1.102`:`6699`, 给rslidar_sdk配置的第一个driver节点绑定到`6699`
+ 第二个雷达发送Packet到 `192.168.1.102`:`5599`, 给rslidar_sdk配置的第二个driver节点绑定到`5599`
![](./img/07_04_multi_lidars_port.png)
如下是配置`config.yaml`的方式。
```yaml
lidar:
- driver:
lidar_type: RSAIRY
msop_port: 6699
difop_port: 7788
imu_port: 6688
- driver:
lidar_type: RSAIRY
msop_port: 6698
difop_port: 7789
imu_port: 6689
```
### 7.3.2 不同的目标IP
也可以让多个雷达使用不同的目标IP。
+ 主机有两个网卡, IP地址分别为`192.168.1.102``192.168.1.103`
+ 第一个雷达发送Packet到 `192.168.1.102`:`6699`, 给rslidar_sdk配置的第一个driver节点绑定到`192.168.1.102:6699`
+ 第二个雷达发送Packet到 `192.168.1.103`:`6699`, 给rslidar_sdk配置的第二个driver节点绑定到`192.168.1.103:6699`
![](./img/07_05_multi_lidars_ip.png)
如下是配置`config.yaml`的方式。
```yaml
lidar:
- driver:
lidar_type: RSAIRY
msop_port: 6699
difop_port: 7788
imu_port: 6688
host_address: 192.168.1.102
- driver:
lidar_type: RSAIRY
msop_port: 6699
difop_port: 7788
imu_port: 6688
host_address: 192.168.1.103
```
## 7.4 VLAN
在某些场景下,雷达工作在VLAN层之上。MSOP/DIFOP Packet有VLAN层,如下图。
![](./img/07_06_vlan_layer.png)
rslidar_sdk不能解析VLAN层。
需要一个虚拟网卡来剥除掉这一层。举例如下。
+ 雷达工作在VLAN id为`80`的VLAN层上。它发送Packet到`192.168.1.102` : `6699`Packet有VLAN层。
+ 假设主机上有一个支持VLAN的物理网卡`eno1`. 它接收带VLAN层的Packet。
![](./img/07_07_vlan.png)
要剥离VLAN层,需要基于`eno1`,创建一个虚拟网卡`eno1.80`, 并且将它的IP设置为`192.168.1.102`
```shell
sudo apt-get install vlan -y
sudo modprobe 8021q
sudo vconfig add eno1 80
sudo ifconfig eno1.80 192.168.1.102 up
```
现在,rslidar_sdk可以将`eno1.80`当做一个一般的网卡来处理,从这里接收不带VLAN层的Packet.
```yaml
lidar:
- driver:
lidar_type: RSAIRY
msop_port: 6699
difop_port: 7788
imu_port: 6688
```
## 7.5 User Layer, Tail Layer
在某些场景下,用户可能在MSOP/DIFOP数据前后加入自己的层。
+ 在前面的是USER_LAYER,在后面的是TAIL_LAYER。
![](./img/07_08_user_layer.png)
这两个层是UDP数据的一部分,所以rslidar_sdk可以自己剥除它们。只需要指出这两个层的长度就可以了。
在下面的例子中,USER_LAYER是8字节,TAIL_LAYER是4字节。
```yaml
lidar:
- driver:
lidar_type: RSAIRY
msop_port: 6699
difop_port: 7788
imu_port: 6688
user_layer_bytes: 8
tail_layer_bytes: 4
```
@@ -0,0 +1,79 @@
# 8 How to decode PCAP file
## 8.1 Introduction
This document illustrates how to decode PCAP file, and send point cloud to ROS.
Please make sure you have read the LiDAR user-guide and [Intro to parameters](../intro/02_parameter_intro.md) before reading this document.
## 8.2 Steps
### 8.2.1 Get the LiDAR port number
Please check the LiDAR user-guide, or use the 3rd-party tool(such as WireShark), to get your LiDAR's MSOP port number and DIFOP port number. The default values are ```msop-6699, difop-7788```.
### 8.2.2 Set up the configuration file
Set up the configuration file `config.yaml`.
#### 8.2.2.1 common part
```yaml
common:
msg_source: 3
send_packet_ros: false
send_point_cloud_ros: true
```
The messages come from the PCAP bag, so set ```msg_source = 3```.
Send point cloud to ROS, so set ```send_point_cloud_ros = true```.
#### 8.2.2.2 lidar-driver part
```yaml
lidar:
- driver:
lidar_type: RSAIRY
msop_port: 6699
difop_port: 7788
imu_port: 6688
start_angle: 0
end_angle: 360
min_distance: 0.2
max_distance: 200
use_lidar_clock: true
pcap_path: /home/robosense/lidar.pcap
```
Set the ```pcap_path``` to the absolute path of the PCAP file.
Set the ```lidar_type``` to your LiDAR type.
Set the ```msop_port```,```difop_port``` and ```difop_port``` to your LiDAR's port number.
#### 8.2.2.3 lidar-ros part
```yaml
ros:
ros_frame_id: rslidar
ros_recv_packet_topic: /rslidar_packets
ros_send_packet_topic: /rslidar_packets
ros_send_imu_data_topic: /rslidar_imu_data
ros_send_point_cloud_topic: /rslidar_points
```
Set the ```rslidar_imu_data``` and ```ros_send_point_cloud_topic``` to the topic you want to send to.
### 8.2.3 Run
Run the program.
@@ -0,0 +1,74 @@
# 8 如何解码PCAP文件
## 8.1 简介
本文档展示如何解码PCAP文件, 并发送点云数据到ROS。
在阅读本文档之前,请确保已阅读雷达用户手册和 [参数简介](../intro/02_parameter_intro_CN.md) 。
## 8.2 步骤
### 8.2.1 获取数据的端口号
请参考雷达用户手册,或者使用第三方工具(WireShark等)抓包,得到雷达的目标MSOP端口和目标DIFOP端口。端口的默认值分别为`6699``7788`
### 8.2.2 设置参数文件
设置参数文件```config.yaml```。
#### 8.2.2.1 common部分
```yaml
common:
msg_source: 3
send_packet_ros: false
send_point_cloud_ros: true
```
消息来自PCAP包,所以设置 ```msg_source = 3``` 。
将点云发送到ROS以便查看,所以设置 ```send_point_cloud_ros = true``` 。
#### 8.2.2.2 lidar-driver部分
```yaml
lidar:
- driver:
lidar_type: RSAIRY
msop_port: 6699
difop_port: 7788
imu_port: 6688
start_angle: 0
end_angle: 360
min_distance: 0.2
max_distance: 200
use_lidar_clock: true
pcap_path: /home/robosense/lidar.pcap
```
将```pcap_path``` 设置为PCAP文件的全路径。
将 ```lidar_type``` 设置为LiDAR类型。
设置 ```msop_port``` 、 ```difop_port``` 和 ```imu_port``` 为雷达数据端口号。
#### 8.2.2.3 lidar-ros部分
```yaml
ros:
ros_frame_id: rslidar
ros_recv_packet_topic: /rslidar_packets
ros_send_packet_topic: /rslidar_packets
ros_send_imu_data_topic: /rslidar_imu_data
ros_send_point_cloud_topic: /rslidar_points
```
将 ```rslidar_imu_data``` 和```ros_send_point_cloud_topic``` 设置为发送Imu数据和发送点云的话题。
### 8.2.3 运行
运行程序。
@@ -0,0 +1,94 @@
# 9 PCAP File - Advanced Topics
## 9.1 Introduction
The RoboSense LiDAR may work
+ in unicast/multicast/broadcast mode,
+ with VLAN layer
+ with user layers.
+ Also rslidar_sdk supports multi-LiDARs.
This document illustrates how to configure rslidar_sdk in each case.
Before reading this document, please be sure that you have read:
+ LiDAR user-guide
+ [Intro to parameters](../intro/02_parameter_intro.md)
+ [Online LiDAR - Advanced Topics](./07_online_lidar_advanced_topics.md)
## 9.2 General Case
Generally, below code is for decoding a PCAP file in these cases.
+ Broadcast/multicast/unicast mode
+ There are multiple LiDars in a file.
```yaml
common:
msg_source: 3
send_point_cloud_ros: true
lidar:
- driver:
lidar_type: RSAIRY
pcap_path: /home/robosense/lidar.pcap
msop_port: 6699
difop_port: 7788
imu_port: 6688
ros:
ros_frame_id: rslidar
ros_send_point_cloud_topic: /rslidar_points
```
The only exception is "Multiple Lidars with same ports but different IPs", which is not supported now.
## 9.3 VLAN
In some user cases, The LiDar may work on VLAN. Its packets have a VLAN layer.
![](./img/07_06_vlan_layer.png)
rs_driver decodes PCAP file and gets all parts of MSOP packets, including the VLAN layer.
To strip the VLAN layer, just set `use_vlan: true`.
```yaml
lidar:
- driver:
lidar_type: RSAIRY
pcap_path: /home/robosense/lidar.pcap
msop_port: 6699
difop_port: 7788
imu_port: 6688
use_vlan: true
```
## 9.4 User Layer, Tail Layer
In some user cases, User may add extra layers before or/and after the MSOP/DIFOP packet.
+ USER_LAYER is before the packet and TAIL_LAYER is after it.
![](./img/07_08_user_layer.png)
These extra layers are parts of UDP data. The driver can strip them.
To strip them, just give their lengths in bytes.
In the following example, USER_LAYER is 8 bytes, and TAIL_LAYER is 4 bytes.
```yaml
lidar:
- driver:
lidar_type: RSAIRY
pcap_path: /home/robosense/lidar.pcap
msop_port: 6699
difop_port: 7788
imu_port: 6688
user_layer_bytes: 8
tail_layer_bytes: 4
```
@@ -0,0 +1,92 @@
# 9 PCAP文件 - 高级主题
## 9.1 简介
RoboSense雷达可以工作在如下场景。
+ 单播/组播/广播模式
+ 运行在VLAN协议上
+ 向Packet中加入用户自己的层
+ 接入多个雷达
本文说明在每种场景下,如何配置rslidar_sdk。
在阅读本文之前,请先阅读:
+ 雷达用户使用手册
+ [参数介绍](../intro/02_parameter_intro_CN.md)
+ [在线雷达-高级主题](./07_online_lidar_advanced_topics_CN.md)
## 9.2 一般场景
在下列场景下,使用如下配置解码PCAP文件。
+ 广播/组播/单播模式
+ PCAP文件中有多个雷达
```yaml
common:
msg_source: 3
send_point_cloud_ros: true
lidar:
- driver:
lidar_type: RSAIRY
pcap_path: /home/robosense/lidar.pcap
msop_port: 6699
difop_port: 7788
imu_port: 6688
ros:
ros_frame_id: rslidar
ros_send_point_cloud_topic: /rslidar_points
```
一个例外是:PCAP文件中有多个雷达数据,但这些雷达目的端口相同,使用不同的目的IP地址来区分。这种情况不支持。
## 9.3 VLAN
有些场景下,雷达工作在VLAN环境下。这时MSOP/DIFOP包带VLAN层,如下图。
![](./img/07_06_vlan_layer.png)
rs_driver使用libpcap库解析PCAP文件,可以得到完整的、包括VLAN层的MSOP/DIFOP包。
要剥除VLAN层,只需要设置`use_vlan: true`
```yaml
lidar:
- driver:
lidar_type: RSAIRY
pcap_path: /home/robosense/lidar.pcap
msop_port: 6699
difop_port: 7788
imu_port: 6688
use_vlan: true
```
## 9.4 User Layer, Tail Layer
某些场景下,用户可能在MSOP/DIFOP数据前后加入自己的层。
+ USER_LAYER 在MSOP/DIFOP数据之前,TAIL_LAYER在MSOP/DIFOP数据之后。
![](./img/07_08_user_layer.png)
这些层是UDP数据的一部分,所以rs_driver可以自己剥除他们。只需要告诉它每个层的字节数就可以。
如下的例子中,指定USER_LAYER为8字节,TAIL_LAYER为4字节。
```yaml
lidar:
- driver:
lidar_type: RSAIRY
pcap_path: /home/robosense/lidar.pcap
msop_port: 6699
difop_port: 7788
imu_port: 6688
user_layer_bytes: 8
tail_layer_bytes: 4
```
@@ -0,0 +1,80 @@
# 10 How to use coordinate transformation
## 10.1 Introduction
rslidar_sdk can transform the coordinate of point cloud. This document illustrate how to do so.
Please check the [Intro to hiding parameters](../intro/03_hiding_parameters_intro.md) for more details. Here is an example of the config.yaml.
## 10.2 Dependencies
rslidar_sdk depends on the libeigen library to do coordinate transformation. Please install it first.
```bash
sudo apt-get install libeigen3-dev
```
## 10.3 Compile
To enable transformation, set the CMake option ```ENABLE_TRANSFORM```to be ```ON```.
- Compile directly
```bash
cmake -DENABLE_TRANSFORM=ON ..
```
- ROS
```bash
catkin_make -DENABLE_TRANSFORM=ON
```
- ROS2
```bash
colcon build --cmake-args '-DENABLE_TRANSFORM=ON'
```
## 10.4 Set LiDAR parameters
In the `lidar-driver` part of `config.yaml`, set the hiding parameter`x`, `y`, `z`, `roll`, `pitch` ,`yaw`.
```yaml
common:
msg_source: 1
send_packet_ros: false
send_point_cloud_ros: true
lidar:
- driver:
lidar_type: RSAIRY
msop_port: 6699
difop_port: 7788
imu_port: 6688
start_angle: 0
end_angle: 360
min_distance: 0.2
max_distance: 200
use_lidar_clock: true
pcap_path: /home/robosense/lidar.pcap
x: 1
y: 0
z: 2.5
roll: 0.1
pitch: 0.2
yaw: 1.57
```
## 10.5 Run
Run the program.
@@ -0,0 +1,80 @@
# 10 如何使用坐标变换功能
## 10.1 简介
rslidar_sdk支持对点云进行坐标变换,本文档展示如何作这种变换。
在阅读本文档之前,请确保已阅读雷达用户手册和[隐藏参数介绍](../intro/03_hiding_parameters_intro_CN.md)。
## 10.2 依赖库
rslidar_sdk的坐标变换基于libeigen库,所以要先安装它。
```bash
sudo apt-get install libeigen3-dev
```
## 10.3 编译
要启用坐标变换,编译rslidar_sdk时,需要将```ENABLE_TRANSFORM```选项设置为```ON```.
- 直接编译
```bash
cmake -DENABLE_TRANSFORM=ON ..
```
- ROS
```bash
catkin_make -DENABLE_TRANSFORM=ON
```
- ROS2
```bash
colcon build --cmake-args '-DENABLE_TRANSFORM=ON'
```
## 10.4 设置雷达参数
在`config.yaml`中,设置`lidar-lidar`部分的参数`x`、, `y`、 `z`、 `roll`、 `pitch` 、`yaw`。
```yaml
common:
msg_source: 1
send_packet_ros: false
send_point_cloud_ros: true
lidar:
- driver:
lidar_type: RSAIRY
msop_port: 6699
difop_port: 7788
imu_port: 6688
start_angle: 0
end_angle: 360
min_distance: 0.2
max_distance: 200
use_lidar_clock: true
pcap_path: /home/robosense/lidar.pcap
x: 1
y: 0
z: 2.5
roll: 0.1
pitch: 0.2
yaw: 1.57
```
## 10.5 运行
运行程序。
@@ -0,0 +1,110 @@
# 11 How to record and replay Packet rosbag
## 11.1 Introduction
This document illustrates how to record and replay MSOP/DIFOP Packet rosbag.
It is possible to record the point cloud message into a rosbag and replay it, but the point cloud rosbag is very large. rslidar_sdk provides a better way - record packet rosbag and replay it.
Please be sure you have read the LiDAR user-guide and [Connect to online LiDAR and send point cloud through ROS](./06_how_to_decode_online_lidar.md).
## 11.2 Record
### 11.2.1 Send packet to ROS
Here suppose that you have connected to an on-line LiDAR, and have sent the point cloud to ROS.
```yaml
common:
msg_source: 1
send_packet_ros: true
send_point_cloud_ros: true
```
To record packets, set ```send_packet_ros = true```.
### 11.2.2 Record the topic of packet
To change the topic of packet, change ```ros_send_packet_topic```. This topic sends out both MSOP and DIFOP packets.
```yaml
ros:
ros_frame_id: rslidar
ros_recv_packet_topic: /rslidar_packets
ros_send_packet_topic: /rslidar_packets
ros_send_imu_data_topic: /rslidar_imu_data
ros_send_point_cloud_topic: /rslidar_points
```
Record rosbag as below.
```sh
rosbag record /rslidar_packets -O bag
```
## 11.3 Replay
Suppose you have recorded a rosbag, which contains MSOP/DIFOP packets with the topic ```/rslidar_packets```.
### 11.3.1 Set Packet Source
In `config.yaml`, set the `common` part.
```yaml
common:
msg_source: 2
send_packet_ros: false
send_point_cloud_ros: true
```
Packet is from the ROS, so set ```msg_source = 2```.
To send point cloud to ROS, set ```send_point_cloud_ros = true```.
### 11.3.2 Set parameters of Lidar
In `config.yaml`, set the `lidar-driver` part.
```yaml
lidar:
- driver:
lidar_type: RSAIRY
msop_port: 6699
difop_port: 7788
imu_port: 6688
start_angle: 0
end_angle: 360
min_distance: 0.2
max_distance: 200
use_lidar_clock: true
```
Set the ```lidar_type``` to your LiDAR type.
### 11.3.3 Set Topic of packet.
In `config.yaml`, set the `lidar-ros` part.
```yaml
ros:
ros_frame_id: rslidar
ros_recv_packet_topic: /rslidar_packets
ros_send_packet_topic: /rslidar_packets
ros_send_imu_data_topic: /rslidar_imu_data
ros_send_point_cloud_topic: /rslidar_points
```
To receive MSOP/DIFOP packest, set ```ros_recv_packet_topic``` to the topic in the rosbag.
### 11.3.4 Run
Run the demo, and replay rosbag.
@@ -0,0 +1,113 @@
# 11 如何录制与回放 Packet rosbag
## 11.1 简介
本文档展示如何记录与回放MSOP/DIFOP rosbag。
使用ROS可以录制点云rosbag消息并回放,但点云包非常大,所以rslidar_sdk提供更好的选择,也就是录制Packet rosbag并回放。
在阅读本文档之前, 请先阅读雷达用户手册和 [连接在线雷达并发送点云到ROS](./06_how_to_decode_online_lidar_CN.md) 。
## 11.2 录制
### 11.2.1 将MSOP/DIFOP Packet发送至ROS
这里假设已经连接在线雷达,并能发送点云到ROS。
```yaml
common:
msg_source: 1
send_packet_ros: true
send_point_cloud_ros: true
```
要录制Packet, 设置 ```send_packet_ros = true```。
### 11.2.2 根据话题录制rosbag
修改```ros_send_packet_topic```, 来改变发送的话题。这个话题包括MSOP Packet和DIFOP Packet。
```yaml
ros:
ros_frame_id: rslidar
ros_recv_packet_topic: /rslidar_packets
ros_send_packet_topic: /rslidar_packets
ros_send_imu_data_topic: /rslidar_imu_data
ros_send_point_cloud_topic: /rslidar_points
```
ROS录制rosbag的指令如下。
```bash
rosbag record /rslidar_packets -O bag
```
## 11.3 回放
假设录制了一个rosbag,其中包含话题为 `/rslidar_packets` 的MSOP/DIFOP Packet。
### 11.3.1 设置Packet源
配置`config.yaml`的`common`部分。
```yaml
common:
msg_source: 2
send_packet_ros: false
send_point_cloud_ros: true
```
MSOP/DIFOP Packet来自ROS rosbag,因此设置 ```msg_source = 2``` 。
将点云发送到ROS,因此设置 ```send_point_cloud_ros = true```。
### 11.3.2 设置雷达参数
配置`config.yaml`的`lidar-driver`部分。
```yaml
lidar:
- driver:
lidar_type: RSAIRY
msop_port: 6699
difop_port: 7788
imu_port: 6688
start_angle: 0
end_angle: 360
min_distance: 0.2
max_distance: 200
use_lidar_clock: true
```
将 ```lidar_type``` 设置为LiDAR类型 。
### 11.3.3 设置接收Packet的主题
设置`config.yaml`的`lidar-ros`部分。
```yaml
ros:
ros_frame_id: rslidar
ros_recv_packet_topic: /rslidar_packets
ros_send_packet_topic: /rslidar_packets
ros_send_imu_data_topic: /rslidar_imu_data
ros_send_point_cloud_topic: /rslidar_points
```
将 ```ros_recv_packet_topic``` 设置为rosbag中MSOP/DIFOP Packet的话题。
### 11.3.4 运行
运行程序,回放rosbag。
@@ -0,0 +1,35 @@
# 12 How to create deb
## 12.1 Introduction
Generating a ".deb" installable file is useful.
## 12.2 Create deb
Just run the shell script:
```
./create_debian.sh
```
The deb file will be generated in the parent directory of `rslidar_sdk`.
## 12.3 Use the deb
Install the deb and set the right config_path. If leave the config_path empty, it will use the `config.yaml` in the ros package path.
```
<launch>
<node pkg="rslidar_sdk" name="rslidar_sdk_node" type="rslidar_sdk_node" output="screen">
<param name="config_path" value=""/>
</node>
<!-- rviz -->
<node pkg="rviz" name="rviz" type="rviz" args="-d $(find rslidar_sdk)/rviz/rviz.rviz" />
</launch>
```
Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

@@ -0,0 +1,272 @@
# 2 Introduction to Parameters
rslidar_sdk reads parameters from the configuration file ```config.yaml```, which is stored in ```rslidar_sdk/config```.
`config.yaml` contains two parts, the `common` part and the `lidar` part.
rslidar_sdk supports multi-LiDARs case. The `common` part is shared by all LiDARs, while in the `lidar` part, each child node is for an individual Lidar.
**config.yaml is indentation sensitive! Please make sure the indentation is not changed after adjusting the parameters!**
## 2.1 Common
The `common` part specifies the source of LiDAR packets, and where to publish point clouds and packets.
```yaml
common:
msg_source: 1
send_packet_ros: false
send_point_cloud_ros: false
```
- msg_source
- 0 -- Unused. Never set this parameter to 0.
- 1 -- LiDAR packets come from on-line LiDARs. For more details, please refer to [Connect to online LiDAR and send point cloud through ROS](../howto/06_how_to_decode_online_lidar.md)
- 2 -- LiDAR packets come from ROS/ROS2. It is used to decode from an off-line rosbag. For more details, please refer to [Record rosbag & Replay it](../howto/11_how_to_record_replay_packet_rosbag.md)
- 3 -- LiDAR packets come from a PCAP bag. For more details, please refer to [Decode PCAP file and send point cloud through ROS](../howto/08_how_to_decode_pcap_file.md)
- send_packet_ros
- true -- LiDAR packets will be sent to ROS/ROS2.
*The ROS Packet message is of a customized message type, so you can't print its content via the ROS `echo` command. This option is used to record off-line Packet rosbags. For more details, please refer to the case of msg_source=2.*
- send_point_cloud_ros
- true -- The LiDAR point cloud will be sent to ROS/ROS2.
*The ROS point cloud type is the ROS official defined type -- sensor_msgs/PointCloud2, so it can be visualized on the ROS `rviz` tool directly. It is not suggested to record the point cloud to rosbag, because its size may be very large. Please record Packets instead. Refer to the case of msg_source=2.*
## 2.2 lidar
The `lidar` part needs to be adjusted for every LiDAR seperately.
```yaml
lidar:
- driver:
lidar_type: RSM1 # LiDAR type - RS16, RS32, RSBP, RSAIRY, RSHELIOS, RSHELIOS_16P, RS128, RS80, RS48, RSP128, RSP80, RSP48,
# RSM1, RSM1_JUMBO, RSM2, RSM3, RSE1, RSMX.
msop_port: 6699 # Msop port of lidar
difop_port: 7788 # Difop port of lidar
imu_port: 0 # IMU port of lidar(only for RSAIRY, RSE1), 0 means no imu.
# If you want to use IMU, please first set ENABLE_IMU_DATA_PARSE to ON in CMakeLists.txt
user_layer_bytes: 0 # Bytes of user layer. thers is no user layer if it is 0
tail_layer_bytes: 0 # Bytes of tail layer. thers is no tail layer if it is 0
min_distance: 0.2 # Minimum distance of point cloud
max_distance: 200 # Maximum distance of point cloud
use_lidar_clock: true # true--Use the lidar clock as the message timestamp
# false-- Use the system clock as the timestamp
dense_points: false # true: discard NAN points; false: reserve NAN points
ts_first_point: true # true: time-stamp point cloud with the first point; false: with the last point;
# these parameters are used from mechanical lidar
start_angle: 0 # Start angle of point cloud
end_angle: 360 # End angle of point cloud
# When msg_source is 3, the following parameters will be used
pcap_repeat: true # true: The pcap bag will repeat play
pcap_rate: 1.0 # Rate to read the pcap file
pcap_path: /home/robosense/lidar.pcap #The path of pcap file
ros:
ros_frame_id: rslidar #Frame id of packet message and point cloud message
ros_recv_packet_topic: /rslidar_packets #Topic used to receive lidar packets from ROS
ros_send_packet_topic: /rslidar_packets #Topic used to send lidar packets through ROS
ros_send_imu_data_topic: /rslidar_imu_data #Topic used to send imu data through ROS
ros_send_point_cloud_topic: /rslidar_points #Topic used to send point cloud through ROS
```
- lidar_type
Supported LiDAR types are listed in the README file.
- msop_port, difop_port, imu_port
The MSOP/DIFOP/IMU port to receive LiDAR packets. *If no data is received, please check these parameters first.*
- user_layer_bytes, tail_layer_bytes
The number of bytes of the user layer and tail layer.
- min_distance, max_distance
The minimum distance and maximum distance of the point cloud.
- use_lidar_clock
- true -- Use the Lidar clock as the message timestamp
- false -- Use the host machine clock as the message timestamp
- dense_points
Whether to discard NAN points. The default value is ```false```.
- Discard if ```true```
- reserve if ```false```.
- ts_first_point
Stamp the point cloud with the first point or the last one. Stamp with the first point if ```true```, else stamp with the last point if ```false```. The default value is ```false```.
- start_angle, end_angle
The start angle and end angle of the point cloud, which should be in the range of 0~360°. *`start_angle` can be larger than `end_angle`*.
- pcap_path
The full path of the PCAP file. Valid if msg_source = 3.
- ros_send_by_rows
Meaningful only for Mechanical Lidars, and valid if dense_points = false。
- true -- send point cloud row by row
- false -- send point cloud clolumn by column
## 2.3 Examples
### 2.3.1 Single Lidar Case
Connect to 1 LiDAR of RSM1, and send point cloud to ROS.
```yaml
common:
msg_source: 1 # 0: not use Lidar
# 1: packet message comes from online Lidar
# 2: packet message comes from ROS or ROS2
# 3: packet message comes from Pcap file
send_packet_ros: false # true: Send packets through ROS or ROS2(Used to record packet)
send_point_cloud_ros: true # true: Send point cloud through ROS or ROS2
lidar:
- driver:
lidar_type: RSM1 # LiDAR type - RS16, RS32, RSBP, RSAIRY, RSHELIOS, RSHELIOS_16P, RS128, RS80, RS48, RSP128, RSP80, RSP48,
# RSM1, RSM1_JUMBO, RSM2, RSM3, RSE1, RSMX.
msop_port: 6699 # Msop port of lidar
difop_port: 7788 # Difop port of lidar
imu_port: 0 # IMU port of lidar(only for RSAIRY, RSE1), 0 means no imu.
# If you want to use IMU, please first set ENABLE_IMU_DATA_PARSE to ON in CMakeLists.txt
user_layer_bytes: 0 # Bytes of user layer. thers is no user layer if it is 0
tail_layer_bytes: 0 # Bytes of tail layer. thers is no tail layer if it is 0
min_distance: 0.2 # Minimum distance of point cloud
max_distance: 200 # Maximum distance of point cloud
use_lidar_clock: true # true--Use the lidar clock as the message timestamp
# false-- Use the system clock as the timestamp
dense_points: false # true: discard NAN points; false: reserve NAN points
ts_first_point: true # true: time-stamp point cloud with the first point; false: with the last point;
# these parameters are used from mechanical lidar
start_angle: 0 # Start angle of point cloud
end_angle: 360 # End angle of point cloud
# When msg_source is 3, the following parameters will be used
pcap_repeat: true # true: The pcap bag will repeat play
pcap_rate: 1.0 # Rate to read the pcap file
pcap_path: /home/robosense/lidar.pcap #The path of pcap file
ros:
ros_frame_id: rslidar #Frame id of packet message and point cloud message
ros_recv_packet_topic: /rslidar_packets #Topic used to receive lidar packets from ROS
ros_send_packet_topic: /rslidar_packets #Topic used to send lidar packets through ROS
ros_send_imu_data_topic: /rslidar_imu_data #Topic used to send imu data through ROS
ros_send_point_cloud_topic: /rslidar_points #Topic used to send point cloud through ROS
```
### 2.3.2 Multi Lidar Case
Connect to 1 LiDAR of RSM1, and 1 LiDAR of RSE1, and send point cloud to ROS.
*Pay attention to the indentation of the `lidar` part*
```yaml
common:
msg_source: 1
send_packet_ros: false
send_point_cloud_ros: true
lidar:
- driver:
lidar_type: RSM1 # LiDAR type - RS16, RS32, RSBP, RSAIRY, RSHELIOS, RSHELIOS_16P, RS128, RS80, RS48, RSP128, RSP80, RSP48,
# RSM1, RSM1_JUMBO, RSM2, RSM3, RSE1, RSMX.
msop_port: 6699 # Msop port of lidar
difop_port: 7788 # Difop port of lidar
imu_port: 0 # IMU port of lidar(only for RSAIRY, RSE1), 0 means no imu.
# If you want to use IMU, please first set ENABLE_IMU_DATA_PARSE to ON in CMakeLists.txt
user_layer_bytes: 0 # Bytes of user layer. thers is no user layer if it is 0
tail_layer_bytes: 0 # Bytes of tail layer. thers is no tail layer if it is 0
min_distance: 0.2 # Minimum distance of point cloud
max_distance: 200 # Maximum distance of point cloud
use_lidar_clock: true # true--Use the lidar clock as the message timestamp
# false-- Use the system clock as the timestamp
dense_points: false # true: discard NAN points; false: reserve NAN points
ts_first_point: true # true: time-stamp point cloud with the first point; false: with the last point;
# these parameters are used from mechanical lidar
start_angle: 0 # Start angle of point cloud
end_angle: 360 # End angle of point cloud
# When msg_source is 3, the following parameters will be used
pcap_repeat: true # true: The pcap bag will repeat play
pcap_rate: 1.0 # Rate to read the pcap file
pcap_path: /home/robosense/lidar.pcap #The path of pcap file
ros:
ros_frame_id: rslidar #Frame id of packet message and point cloud message
ros_recv_packet_topic: /left/rslidar_packets #Topic used to receive lidar packets from ROS
ros_send_packet_topic: /left/rslidar_packets #Topic used to send lidar packets through ROS
ros_send_imu_data_topic: /left/rslidar_imu_data #Topic used to send imu data through ROS
ros_send_point_cloud_topic: /left/rslidar_points #Topic used to send point cloud through ROS
- driver:
lidar_type: RSE1 # LiDAR type - RS16, RS32, RSBP, RSAIRY, RSHELIOS, RSHELIOS_16P, RS128, RS80, RS48, RSP128, RSP80, RSP48,
# RSM1, RSM1_JUMBO, RSM2, RSM3, RSE1, RSMX.
msop_port: 6699 # Msop port of lidar
difop_port: 7788 # Difop port of lidar
user_layer_bytes: 0 # Bytes of user layer. thers is no user layer if it is 0
tail_layer_bytes: 0 # Bytes of tail layer. thers is no tail layer if it is 0
min_distance: 0.2 # Minimum distance of point cloud
max_distance: 200 # Maximum distance of point cloud
use_lidar_clock: true # true--Use the lidar clock as the message timestamp
# false-- Use the system clock as the timestamp
dense_points: false # true: discard NAN points; false: reserve NAN points
ts_first_point: true # true: time-stamp point cloud with the first point; false: with the last point;
# these parameters are used from mechanical lidar
start_angle: 0 # Start angle of point cloud
end_angle: 360 # End angle of point cloud
# When msg_source is 3, the following parameters will be used
pcap_repeat: true # true: The pcap bag will repeat play
pcap_rate: 1.0 # Rate to read the pcap file
pcap_path: /home/robosense/lidar.pcap #The path of pcap file
ros:
ros_frame_id: rslidar #Frame id of packet message and point cloud message
ros_recv_packet_topic: /right/rslidar_packets #Topic used to receive lidar packets from ROS
ros_send_packet_topic: /right/rslidar_packets #Topic used to send lidar packets through ROS
ros_send_imu_data_topic: /right/rslidar_imu_data #Topic used to send imu data through ROS
ros_send_point_cloud_topic: /right/rslidar_points #Topic used to send point cloud through ROS
```
@@ -0,0 +1,276 @@
# 2 参数介绍
rslidar_sdk读取配置文件 ```config.yaml```,得到所有的参数。```config.yaml```在```rslidar_sdk/config```文件夹中。
**config.yaml遵循YAML格式。该格式对缩进有严格要求。修改config.yaml之后,请确保每行开头的缩进仍保持一致!**
config.yaml包括两部分:common部分 和 lidar部分。
rslidar_sdk支持多个雷达。common部分为所有雷达共享。lidar部分,每一个子节点对应一个雷达,针对这个雷达的实际情况分别设置。
## 2.1 common部分
common部分设置雷达消息的源(Packet或点云从哪来)和目标(Packet或点云发布到哪去)。
```yaml
common:
msg_source: 1
send_packet_ros: false
send_point_cloud_ros: false
```
- msg_source
- 1 -- 连接在线雷达。更多使用细节,请参考[连接在线雷达并发送点云到ROS](../howto/06_how_to_decode_online_lidar_CN.md)。
- 2 -- 离线解析ROS/ROS2的Packet包。更多使用细节,请参考 [录制ROS数据包然后播放它](../howto/11_how_to_record_replay_packet_rosbag_CN.md)。
- 3 -- 离线解析PCAP包。更多使用细节,请参考[离线解析PCAP包并发送点云到ROS](../howto/08_how_to_decode_pcap_file_CN.md)。
- send_packet_ros
- true -- 雷达Packet消息将通过ROS/ROS2发出
*雷达ROS packet消息为速腾聚创自定义ROS消息,用户使用ROS/ROS2 echo命令不能查看消息的具体内容。这个功能用于录制ROS/ROS2的Packet包,更多使用细节,请参考msg_source=2的情况。
- send_point_cloud_ros
- true -- 雷达点云消息将通过ROS/ROS2发出
*点云消息的类型为ROS官方定义的点云类型sensor_msgs/PointCloud2, 用户可以使用Rviz直接查看点云。用户可以录制ROS/ROS2的点云包,但点云包的体积非常大,所以不建议这么做。更好的方式是录制Packet包,请参考send_packet_ros=true的情况。*
## 2.2 lidar部分
lidar部分根据每个雷达的实际情况进行设置。
```yaml
lidar:
- driver:
lidar_type: RSM1 # LiDAR type - RS16, RS32, RSBP, RSAIRY, RSHELIOS, RSHELIOS_16P, RS128, RS80, RS48, RSP128, RSP80, RSP48,
# RSM1, RSM1_JUMBO, RSM2, RSM3, RSE1, RSMX.
msop_port: 6699 # Msop port of lidar
difop_port: 7788 # Difop port of lidar
imu_port: 0 # IMU port of lidar(only for RSAIRY, RSE1), 0 means no imu.
# If you want to use IMU, please first set ENABLE_IMU_DATA_PARSE to ON in CMakeLists.txt
user_layer_bytes: 0 # Bytes of user layer. thers is no user layer if it is 0
tail_layer_bytes: 0 # Bytes of tail layer. thers is no tail layer if it is 0
min_distance: 0.2 # Minimum distance of point cloud
max_distance: 200 # Maximum distance of point cloud
use_lidar_clock: true # true--Use the lidar clock as the message timestamp
# false-- Use the system clock as the timestamp
dense_points: false # true: discard NAN points; false: reserve NAN points
ts_first_point: true # true: time-stamp point cloud with the first point; false: with the last point;
# these parameters are used from mechanical lidar
start_angle: 0 # Start angle of point cloud
end_angle: 360 # End angle of point cloud
# When msg_source is 3, the following parameters will be used
pcap_repeat: true # true: The pcap bag will repeat play
pcap_rate: 1.0 # Rate to read the pcap file
pcap_path: /home/robosense/lidar.pcap #The path of pcap file
ros:
ros_frame_id: rslidar #Frame id of packet message and point cloud message
ros_recv_packet_topic: /rslidar_packets #Topic used to receive lidar packets from ROS
ros_send_packet_topic: /rslidar_packets #Topic used to send lidar packets through ROS
ros_send_imu_data_topic: /rslidar_imu_data #Topic used to send imu data through ROS
ros_send_point_cloud_topic: /rslidar_points #Topic used to send point cloud through ROS
```
- lidar_type
支持的雷达型号在rslidar_sdk的README文件中列出。
- msop_port, difop_port, imu_port
接收MSOP/DIFOP/IMU Packet的msop端口号、difop端口号、 Imu端口号。 *若收不到消息,请优先确认这些参数是否配置正确。*
- user_layer_bytes, tail_layer_bytes
用户自定义层和尾部层的字节数。默认为0。
- min_distance, max_distance
点云的最小距离和最大距离。这个设置是软件屏蔽,会将区域外的点设置为NAN点,不会减小每帧点云的体积。
- use_lidar_clock
- true -- 使用雷达时间作为消息时间戳。
- false -- 使用电脑主机时间作为消息时间戳。
- dense_points
输出的点云中是否剔除NAN points。默认值为false。
- true 为剔除,
- false为不剔除。
- ts_first_point
默认值为false。点云的时间戳是否第一个点的时间。true使用第一个点的时间,false使用第一个点的时间。
- start_angle, end_angle
点云消息的起始角度和结束角度。这个设置是软件屏蔽,将区域外的点设置为NAN点,不会减小每帧点云的体积。 start_angle和end_angle的范围是0~360°,**起始角可以大于结束角**.
- pcap_path
pcap包的路径。当 msg_source=3 时有效。
- pcap_rate
pcap包播放的倍率。当 msg_source=3 时有效。
- pcap_repeat
pcap包是否重复播放。当 msg_source=3 时有效。
## 2.3 示例
### 2.3.1 单台雷达
在线连接1台RSM1雷达,并发送点云数据到ROS。
```yaml
common:
msg_source: 1 # 0: not use Lidar
# 1: packet message comes from online Lidar
# 2: packet message comes from ROS or ROS2
# 3: packet message comes from Pcap file
send_packet_ros: false # true: Send packets through ROS or ROS2(Used to record packet)
send_point_cloud_ros: true # true: Send point cloud through ROS or ROS2
lidar:
- driver:
lidar_type: RSM1 # LiDAR type - RS16, RS32, RSBP, RSAIRY, RSHELIOS, RSHELIOS_16P, RS128, RS80, RS48, RSP128, RSP80, RSP48,
# RSM1, RSM1_JUMBO, RSM2, RSM3, RSE1, RSMX.
msop_port: 6699 # Msop port of lidar
difop_port: 7788 # Difop port of lidar
imu_port: 0 # IMU port of lidar(only for RSAIRY, RSE1), 0 means no imu.
# If you want to use IMU, please first set ENABLE_IMU_DATA_PARSE to ON in CMakeLists.txt
user_layer_bytes: 0 # Bytes of user layer. thers is no user layer if it is 0
tail_layer_bytes: 0 # Bytes of tail layer. thers is no tail layer if it is 0
min_distance: 0.2 # Minimum distance of point cloud
max_distance: 200 # Maximum distance of point cloud
use_lidar_clock: true # true--Use the lidar clock as the message timestamp
# false-- Use the system clock as the timestamp
dense_points: false # true: discard NAN points; false: reserve NAN points
ts_first_point: true # true: time-stamp point cloud with the first point; false: with the last point;
# these parameters are used from mechanical lidar
start_angle: 0 # Start angle of point cloud
end_angle: 360 # End angle of point cloud
# When msg_source is 3, the following parameters will be used
pcap_repeat: true # true: The pcap bag will repeat play
pcap_rate: 1.0 # Rate to read the pcap file
pcap_path: /home/robosense/lidar.pcap #The path of pcap file
ros:
ros_frame_id: rslidar #Frame id of packet message and point cloud message
ros_recv_packet_topic: /rslidar_packets #Topic used to receive lidar packets from ROS
ros_send_packet_topic: /rslidar_packets #Topic used to send lidar packets through ROS
ros_send_imu_data_topic: /rslidar_imu_data #Topic used to send imu data through ROS
ros_send_point_cloud_topic: /rslidar_points #Topic used to send point cloud through ROS
```
### 2.3.2 多台雷达
在线连接1台RSM1雷达和1台RSE1雷达,发送点云数据到ROS。
*注意lidar部分参数的缩进*
```yaml
common:
msg_source: 1
send_packet_ros: false
send_point_cloud_ros: true
lidar:
- driver:
lidar_type: RSM1 # LiDAR type - RS16, RS32, RSBP, RSAIRY, RSHELIOS, RSHELIOS_16P, RS128, RS80, RS48, RSP128, RSP80, RSP48,
# RSM1, RSM1_JUMBO, RSM2, RSM3, RSE1, RSMX.
msop_port: 6699 # Msop port of lidar
difop_port: 7788 # Difop port of lidar
imu_port: 0 # IMU port of lidar(only for RSAIRY, RSE1), 0 means no imu.
# If you want to use IMU, please first set ENABLE_IMU_DATA_PARSE to ON in CMakeLists.txt
user_layer_bytes: 0 # Bytes of user layer. thers is no user layer if it is 0
tail_layer_bytes: 0 # Bytes of tail layer. thers is no tail layer if it is 0
min_distance: 0.2 # Minimum distance of point cloud
max_distance: 200 # Maximum distance of point cloud
use_lidar_clock: true # true--Use the lidar clock as the message timestamp
# false-- Use the system clock as the timestamp
dense_points: false # true: discard NAN points; false: reserve NAN points
ts_first_point: true # true: time-stamp point cloud with the first point; false: with the last point;
# these parameters are used from mechanical lidar
start_angle: 0 # Start angle of point cloud
end_angle: 360 # End angle of point cloud
# When msg_source is 3, the following parameters will be used
pcap_repeat: true # true: The pcap bag will repeat play
pcap_rate: 1.0 # Rate to read the pcap file
pcap_path: /home/robosense/lidar.pcap #The path of pcap file
ros:
ros_frame_id: rslidar #Frame id of packet message and point cloud message
ros_recv_packet_topic: /left/rslidar_packets #Topic used to receive lidar packets from ROS
ros_send_packet_topic: /left/rslidar_packets #Topic used to send lidar packets through ROS
ros_send_imu_data_topic: /left/rslidar_imu_data #Topic used to send imu data through ROS
ros_send_point_cloud_topic: /left/rslidar_points #Topic used to send point cloud through ROS
- driver:
lidar_type: RSE1 # LiDAR type - RS16, RS32, RSBP, RSAIRY, RSHELIOS, RSHELIOS_16P, RS128, RS80, RS48, RSP128, RSP80, RSP48,
# RSM1, RSM1_JUMBO, RSM2, RSM3, RSE1, RSMX.
msop_port: 6699 # Msop port of lidar
difop_port: 7788 # Difop port of lidar
user_layer_bytes: 0 # Bytes of user layer. thers is no user layer if it is 0
tail_layer_bytes: 0 # Bytes of tail layer. thers is no tail layer if it is 0
min_distance: 0.2 # Minimum distance of point cloud
max_distance: 200 # Maximum distance of point cloud
use_lidar_clock: true # true--Use the lidar clock as the message timestamp
# false-- Use the system clock as the timestamp
dense_points: false # true: discard NAN points; false: reserve NAN points
ts_first_point: true # true: time-stamp point cloud with the first point; false: with the last point;
# these parameters are used from mechanical lidar
start_angle: 0 # Start angle of point cloud
end_angle: 360 # End angle of point cloud
# When msg_source is 3, the following parameters will be used
pcap_repeat: true # true: The pcap bag will repeat play
pcap_rate: 1.0 # Rate to read the pcap file
pcap_path: /home/robosense/lidar.pcap #The path of pcap file
ros:
ros_frame_id: rslidar #Frame id of packet message and point cloud message
ros_recv_packet_topic: /right/rslidar_packets #Topic used to receive lidar packets from ROS
ros_send_packet_topic: /right/rslidar_packets #Topic used to send lidar packets through ROS
ros_send_imu_data_topic: /right/rslidar_imu_data #Topic used to send imu data through ROS
ros_send_point_cloud_topic: /right/rslidar_points #Topic used to send point cloud through ROS
```
@@ -0,0 +1,89 @@
# 3 Introduction to hidden parameters
In order to make the configuration file as simple as possible, we hide some parameters and use default values for them.
This document explains the meanings of these hidden parameters.
## 3.1 common
```yaml
common:
msg_source: 1
send_packet_ros: false
send_point_cloud_ros: false
send_point_cloud_proto: false
```
## 3.2 lidar
```yaml
lidar:
- driver:
lidar_type: RSM1 # LiDAR type - RS16, RS32, RSBP, RSAIRY, RSHELIOS, RSHELIOS_16P, RS128, RS80, RS48, RSP128, RSP80, RSP48,
# RSM1, RSM1_JUMBO, RSM2, RSM3, RSE1, RSMX.
msop_port: 6699 # Msop port of lidar
difop_port: 7788 # Difop port of lidar
imu_port: 0 # IMU port of lidar(only for RSAIRY, RSE1), 0 means no imu.
# If you want to use IMU, please first set ENABLE_IMU_DATA_PARSE to ON in CMakeLists.txt
group_address: 0.0.0.0
host_address: 0.0.0.0
user_layer_bytes: 0 # Bytes of user layer. thers is no user layer if it is 0
tail_layer_bytes: 0 # Bytes of tail layer. thers is no tail layer if it is 0
min_distance: 0.2 # Minimum distance of point cloud
max_distance: 200 # Maximum distance of point cloud
use_lidar_clock: true # true--Use the lidar clock as the message timestamp
# false-- Use the system clock as the timestamp
dense_points: false # true: discard NAN points; false: reserve NAN points
ts_first_point: true # true: time-stamp point cloud with the first point; false: with the last point;
# these parameters are used from mechanical lidar
start_angle: 0 # Start angle of point cloud
end_angle: 360 # End angle of point cloud
# When msg_source is 3, the following parameters will be used
pcap_repeat: true # true: The pcap bag will repeat play
pcap_rate: 1.0 # Rate to read the pcap file
pcap_path: /home/robosense/lidar.pcap #The path of pcap file
use_vlan: false
x: 0
y: 0
z: 0
roll: 0
pitch: 0
yaw: 0
ros:
ros_frame_id: rslidar #Frame id of packet message and point cloud message
ros_recv_packet_topic: /rslidar_packets #Topic used to receive lidar packets from ROS
ros_send_packet_topic: /rslidar_packets #Topic used to send lidar packets through ROS
ros_send_imu_data_topic: /rslidar_imu_data #Topic used to send imu data through ROS
ros_send_point_cloud_topic: /rslidar_points #Topic used to send point cloud through ROS
ros_send_by_rows: false
```
- ```config_from_file``` -- Whether to read Lidar configuration from file. Only used for debug purpose, and can be ignored.
- ```angle_path``` -- The path of the angle.csv. Only used for debug purpose and can be ignored.
- ```ts_first_point``` -- Stamp the point cloud with the first point or the last one. Stamp with the first point if ```true```, else stamp with the last point if ```false```. The default value is ```false```.
- ```split_frame_mode``` -- The way to split the LiDAR frames. Default value is ```1```.
- 1 -- Split frame depending on the split_angle
- 2 -- Split frame depending on a fixed number of blocks
- 3 -- Split frame depending on num_blks_split
- ```split_angle``` -- The angle(in degree) to split frames. Only be used when ```split_frame_mode = 1```. The default value is ```0```.
- ```num_blks_split``` -- The number of blocks in one frame. Only be used when ```split_frame_mode = 3```.
- ```wait_for_difop``` -- If ```false```, the driver will not wait for difop packet(including lidar configuration data, especially angle data to calculate x, y, z), and send out the point cloud immediately. The default value is ```true```.
- ```group_address``` -- If use multi-cast function, this parameter needs to be set correctly. For more details, please refer to [Online LiDAR - Advanced Topics](../howto/07_online_lidar_advanced_topics.md)
- ```host_address``` -- Needed in two conditions. If the host receives packets from multiple Lidars via different IP addresses, use this parameter to specify destination IPs of the Lidars; If group_address is set, it should be set, so it will be joined into the multicast group.
- ```x, y, z, roll, pitch, yaw ``` -- The parameters to do coordinate transformation. If the coordinate transformation function is enabled in driver core, the output point cloud will be transformed based on these parameters. For more details, please refer to [Coordinate Transformation](../howto/10_how_to_use_coordinate_transformation.md)
- ```use_vlan``` -- Whether to use VLAN. The default value is ```false```. This parameter is only needed for pcap file. If it contains packets with VLAN layer, ```use_vlan``` should set to true. In the case of online Lidar, the VLAN layer is stripped by the protocol layer, so use_vlan can be ignored.
- ```ros_send_by_rows```This only applies to mechanical lidar and is only valid when dense_points=false.
-True - When sending a point cloud, arrange the points in a row by row order
-False - When sending a point cloud, arrange the points in a column by column order
@@ -0,0 +1,86 @@
# 3 隐藏参数介绍
为了使配置文件config.yaml尽可能简洁,我们隐藏了部分不常用的参数,在代码中使用默认值。
本文档将详细介绍这些隐藏参数。用户可根据需要,将它们加入参数文件,重新设置。
## 3.1 common
```yaml
common:
msg_source: 1
send_packet_ros: false
send_point_cloud_ros: false
```
## 3.2 lidar
```yaml
lidar:
- driver:
lidar_type: RSM1 # LiDAR type - RS16, RS32, RSBP, RSAIRY, RSHELIOS, RSHELIOS_16P, RS128, RS80, RS48, RSP128, RSP80, RSP48,
# RSM1, RSM1_JUMBO, RSM2, RSM3, RSE1, RSMX.
msop_port: 6699 # Msop port of lidar
difop_port: 7788 # Difop port of lidar
imu_port: 0 # IMU port of lidar(only for RSAIRY, RSE1), 0 means no imu.
# If you want to use IMU, please first set ENABLE_IMU_DATA_PARSE to ON in CMakeLists.txt
group_address: 0.0.0.0
host_address: 0.0.0.0
user_layer_bytes: 0 # Bytes of user layer. thers is no user layer if it is 0
tail_layer_bytes: 0 # Bytes of tail layer. thers is no tail layer if it is 0
min_distance: 0.2 # Minimum distance of point cloud
max_distance: 200 # Maximum distance of point cloud
use_lidar_clock: true # true--Use the lidar clock as the message timestamp
# false-- Use the system clock as the timestamp
dense_points: false # true: discard NAN points; false: reserve NAN points
ts_first_point: true # true: time-stamp point cloud with the first point; false: with the last point;
# these parameters are used from mechanical lidar
start_angle: 0 # Start angle of point cloud
end_angle: 360 # End angle of point cloud
ros_send_by_rows:
# When msg_source is 3, the following parameters will be used
pcap_repeat: true # true: The pcap bag will repeat play
pcap_rate: 1.0 # Rate to read the pcap file
pcap_path: /home/robosense/lidar.pcap #The path of pcap file
use_vlan: false
x: 0
y: 0
z: 0
roll: 0
pitch: 0
yaw: 0
ros:
ros_frame_id: rslidar #Frame id of packet message and point cloud message
ros_recv_packet_topic: /rslidar_packets #Topic used to receive lidar packets from ROS
ros_send_packet_topic: /rslidar_packets #Topic used to send lidar packets through ROS
ros_send_imu_data_topic: /rslidar_imu_data #Topic used to send imu data through ROS
ros_send_point_cloud_topic: /rslidar_points #Topic used to send point cloud through ROS
ros_send_by_rows: false
```
- ```config_from_file``` -- 默认值为false, 是否从外参文件读入雷达配置信息,仅用于调试,可忽略。
- ```angle_path``` -- angle.csv外参文件的路径,仅用于调试,可忽略。
- ```split_frame_mode``` -- 分帧模式设置,默认值为```1```。
- 1 -- 角度分帧
- 2 -- 固定block数分帧
- 3 -- 自定义block数分帧
- ```split_angle``` -- 用于分帧的角度(单位为度), 在```split_frame_mode = 1``` 时才生效,默认值为```0```。
- ```num_blks_split``` -- 用于分帧的包数,在 ```split_frame_mode = 3```时才生效,默认值为1。
- ```wait_for_difop``` -- 若设置为false, 驱动将不会等待DIFOP包(包含配置数据,尤其是角度信息),而是立即解析MSOP包并发出点云。 默认值为```true```,也就是必须要有DIFOP包才会进行点云解析。
- ```group_address``` -- 如果雷达为组播模式,此参数需要被设置为组播的地址。具体使用方式可以参考[在线雷达 - 高级主题](../howto/07_online_lidar_advanced_topics_CN.md) 。
- ```host_address``` -- 有两种情况需要这个选项。如果主机上通过多个IP地址接收多个雷达的数据,则可以将此参数指定为雷达的目标IP;如果设置了group_address,那也需要设置host_address,以便将这个IP地址的网卡加入组播组。
- ```x, y, z, roll, pitch, yaw ``` -- 坐标变换参数,若启用了内核的坐标变换功能,将会使用此参数输出经过变换后的点云。x, y, z, 单位为```米```, roll, pitch, yaw, 单位为```弧度```。具体使用方式可以参考 [坐标变换功能](../howto/10_how_to_use_coordinate_transformation_CN.md) 。
- ```use_vlan``` -- 默认为false,指定是否使用vlan。如果pcap文件中的packet带vlan层,则需要设置这个选项为true。其他情况下不需要。在线雷达的情况下,协议层到达驱动时,已经剥离vlan层,所以不需要设置这个选项。
- ```ros_send_by_rows```只对机械式雷达有意义,且只有当dense_points = false时才有效。
- true -- 发送点云时,按照一行一行的顺序排列点
- false -- 发送点云时,按照一列一列的顺序排列点
Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 93 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 183 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 263 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 255 KiB

@@ -0,0 +1,250 @@
# rslidar_sdk v1.5.17 源代码解析
## 1 简介
rslidar_sdk是基于ROS/ROS2的雷达驱动。rslidar_sdk依赖rs_driver接收和解析MSOP/DIFOP Packet。
rslidar_sdk的基本功能如下:
+ 从在线雷达或PCAP文件得到点云和Imu数据,通过ROS话题`/rslidar_points``/rslidar_imu_data`发布。使用者可以订阅这个两个话题,在rviz中看到点云和IMU数据。
+ 从在线雷达得到原始的MSOP/DIFOP/IMU Packet,通过ROS话题`/rslidar_packets`发布。使用者可以订阅这个话题,将Packet记录到rosbag文件。
+ 从ROS话题`/rslidar_packets`得到MSOP/DIFOP/IMU Packet,解析得到点云,再发布到话题`/rslidar_points`
+ 这里的话题`/rslidar_packets`,由使用者通过回放Packet rosbag文件发布。
## 2 Source 与 Destination
如前面所说,rslidar_sdk从在线雷达、PCAP文件、ROS话题这三种源得到MSOP/DIFOP/IMU Packet,将Packet发布到ROS话题`/rslidar_packets`,将点云发布到目标 - ROS话题`/rslidar_points`, 将Imu数据发布到目标 - ROS话题`/rslidar_imu_data`
+ Source定义源接口
+ DestinationPointCloud定义发送点云和Imu数据的目标接口。
+ DestinationPacket定义发送MSOP/DIFOP/IMU Packet的目标接口。
<img src="./img/class_source_destination.png" alt="source" width="50%" height="50%">
### 2.1 DestinationPointCloud
DestinationPointCloud定义发送点云的接口。
+ 虚拟成员函数init()对DestinationPointCloud实例初始化
+ 虚拟成员函数start()启动实例
+ 虚拟成员函数sendPointCloud()发送PointCloud消息
+ 虚拟成员函数sendImuData()发送Imu数据
### 2.2 DestinationPacket
DestinationPacket定义发送MSOP/DIFOP Packet的接口。
+ 虚拟成员函数init()对DestinationPacket实例初始化
+ 虚拟成员函数start()启动实例
+ 虚拟成员函数sendPacket()启动发送Packet消息
### 2.3 Source
Source是定义源的接口。
+ 成员`src_type_`是源的类型
```
enum SourceType
{
MSG_FROM_LIDAR = 1,
MSG_FROM_ROS_PACKET = 2,
MSG_FROM_PCAP = 3,
};
```
+ 成员`pc_cb_vec_[]`中是一组DestinationPointCloud的实例。
+ 成员函数sendPointCloud()调用`point_cb_vec_[]`中的实例,发送点云消息。
+ 成员`pkt_cb_vec_[]`中是一组DestinationPacket实例。
+ 成员函数sendPacket()将Packet消息发送到`pkt_cb_vec_[]`中的实例中。
+ 虚拟成员函数init()初始化Source实例
+ 虚拟成员函数start()启动实例
+ 虚拟成员函数regPointCloudCallback()将PointCloudDestination实例注册到`point_cb_vec_[]`。
+ 虚拟成员函数regPacketCallback()将PacketDestination实例注册到`packet_cb_vec_[]`。
### 2.4 DestinationPointCloudRos
DestinationPointCloudRos在ROS话题`/rslidar_points`发布点云。
+ 成员`pkt_pub_`是点云数据的ROS话题发布器。
+ 成员`imu_pub_`是IMU数据的ROS话题发布器。
+ 成员`frame_id_`保存`frame_id`。`frame_id`是坐标系名字。
<img src="./img/class_destination_pointcloud.png" alt="destination pointcloud ros" width="30%" height="20%">
#### 2.4.1 DestinationPointCloudRos::init()
init()初始化DestinationPointCloudRos实例。
+ 从YAML文件读入用户配置参数。
+ 读入`frame_id`,保存在成员`frame_id_`,默认值是`rslidar`。
+ 读入点云的ROS话题名称,保存在本地变量`ros_send_topic_`,默认值是`/rslidar_points`。
+ 读入IMU的ROS话题名称,保存在本地变量`ros_send_imu_data_topic`,默认值是`/rslidar_imu_data`。
+ 读入点云排列方式参数,保存在成员`send_by_rows_`,默认值是`false`。
+ 创建ROS话题发布器,保存在成员`pkt_sub_`.
#### 2.4.2 DestinationPointCloudRos::sendPointCloud()
sendPointCloud()在ROS话题`/rslidar_points`发布点云。
+ 调用Publisher::publish()发布ROS格式的点云消息。
#### 2.4.3 DestinationPointCloudRos::sendImuData()
sendImuData()在ROS话题`/rslidar_imu_data`发布Imu数据。
+ 调用Publisher::publish()发布ROS格式的Imu消息。
### 2.5 DestinationPacketRos
DestinationPacketRos在ROS话题`/rslidar_packets`发布MSOP/DIFOP Packet。
+ 成员`pkt_sub_`是ROS话题发布器。
+ 成员`frame_id_`保存`frame_id`。`frame_id`是坐标系名字。
![destination packet ros](./img/class_destination_packet.png)
#### 2.5.1 DestinationPacketRos::init()
init()初始化DestinationPacketRos实例。
+ 从YAML文件读入用户配置参数。
+ 读入`frame_id`,保存在成员`frame_id_`,默认值是`rslidar`
+ 读入ROS话题,保存在本地变量`ros_send_topic_`,默认值是`/rslidar_packets`。
+ 创建ROS话题发布器,保存在成员`pkt_sub_`.
#### 2.5.2 DestinationPacketRos::sendPacket()
sendPacket()在ROS话题`/rslidar_packets`发布MOSP/DIFOP packet。
+ 调用Publisher::publish()发布ROS格式的Packet消息。
### 2.6 SourceDriver
SourceDriver从在线雷达和PCAP文件得到MSOP/DIFOP/IMU Packet,并解析得到点云和Imu数据。
+ 成员`driver_ptr_`是rs_driver驱动的实例,也就是LidarDriver。
+ 成员`free_point_cloud_queue_`和`point_cloud_queue_`,分别是空闲点云的队列和待处理点云的队列。
+ 成员`point_cloud_handle_thread_`是点云的处理线程。
+ 成员`free_imu_data_queue_`和`imu_data_queue_`,分别是空闲Imu数据的队列和待处理Imu数据的队列。
+ 成员`imu_data_process_thread_`是Imu数据的处理线程。
<img src="./img/class_source_driver.png" alt="source driver" width="50%" height="60%">
#### 2.6.1 SourceDriver::init()
init()初始化SourceDriver实例。
+ 读取YAML配置文件,得到雷达的用户配置参数。
+ 根据源类型,也就是成员`src_type_`,创建相应类型的LidarDriver实例,也就是成员`driver_ptr_`。
+ `src_type_`是在SourceDriver中的构造函数中指定的。
+ 调用LidarDriver::regPointCloudCallback(),注册回调函数。这里是getPointCloud()和putPointCloud()。前者给`driver_ptr_`提供空闲点云,后者从`driver_ptr_`得到填充好的点云。
+ 注意,这里没有注册MSOP/DIFOP Packet的回调函数,因为Packet是按需获取的。这时为了避免不必要地消耗CPU资源。
+ 调用LidarDriver::regImuDataCallback(),注册回调函数。这里是getImuData()和putImuData()。前者给`driver_ptr_`提供空闲Imu数据,后者从`driver_ptr_`得到填充好的Imu数据。
+ 调用LidarDriver::init(),初始化`driver_ptr_`。
+ 创建、启动点云处理线程`point_cloud_handle_thread_` 线程函数是processPointCloud()。
+ 创建、启动IMU处理线程`imu_data_process_thread_` 线程函数是processImuData()。
#### 2.6.2 SourceDriver::getPointCloud()
getPointCloud()给成员`driver_ptr_`提供空闲的点云。
+ 优先从成员`free_point_cloud_queue_`得到点云。
+ 如果得不到,分配新的点云。
#### 2.6.3 SourceDriver::putPointCloud()
putPointCloud()给从成员`driver_ptr_`得到填充好的点云。
+ 将得到的点云推送到成员`point_cloud_queue_`,等待处理。
#### 2.6.4 SourceDriver::processPointCloud()
processPointCloud()处理点云。在while循环中,
+ 从待处理点云的队列`point_cloud_queue_`,得到点云,
+ 调用sendPointCloud(),其中调用成员`pc_cb_vec_[]`中的DestinationPointCloud实例,发送点云。
+ 回收点云,放入空闲点云的队列`free_cloud_queue_`,待下次使用。
#### 2.6.5 SourceDriver::getImuData()
getImuData()给成员`driver_ptr_`提供空闲的Imu数据。
+ 优先从成员`free_imu_data_queue_`得到Imu数据。
+ 如果得不到,分配新的Imu数据。
#### 2.6.6 SourceDriver::putImuData()
putImuData()给从成员`driver_ptr_`得到填充好的Imu数据。
+ 将得到的Imu数据推送到成员`imu_data_queue_`,等待处理。
#### 2.6.7 SourceDriver::processImuData()
processImuData()处理点云。在while循环中,
+ 从待处理点云的队列`imu_data_queue_`,得到点云,
+ 调用sendImuData(),其中调用成员`pc_cb_vec_[]`中的DestinationPointCloud实例,发送点云。
+ 回收点云,放入空闲点云的队列`free_imu_data_queue_`,待下次使用。
#### 2.6.8 SourceDriver::regPacketCallback()
regPacketCallback()用来注册DestinationPacket。
+ 调用Source::regPacketCallback(),将DestinationPacket实例,加入成员`pkt_cb_vec_[]`。
+ 如果这是首次要求Packet(`pkt_cb_vec_[]`的第1个实例),调用LidarDriver::regPacketCallback(),向`driver_ptr_`注册Packet回调函数,开始接收Packet。回调函数是putPacket()。
#### 2.6.9 SourceDriver::putPacket()
putPacket()调用sendPacket(),其中调用成员`pkt_cb_vec_[]`中的所有实例,发送MSOP/DIFOP Packet。
### 2.7 SourcePacketRos
SourcePacketRos在ROS话题`/rslidar_packets`得到MSOP/DIFOP Packet,解析后得到点云。
+ SourcePacketRos从SourceDriver派生,而不是直接从Source派生,是因为它用SourceDriver解析Packet得到点云。
+ 成员`pkt_sub_`,是ROS话题`/rslidar_packets`的订阅器。
<img src="./img/class_source_packet_ros.png" alt="source packet ros" width="25%" height="60%">
#### 2.7.1 SourcePacketRos::init()
init()初始化SourcePacketRos实例。
+ 调用SourceDriver::init()初始化成员`driver_ptr_`。
+ 在SourcePacketRos的构造函数中,SourceType设置为`SourceType::MSG_FROM_ROS_PACKET`。这样,在SourceDriver::init()中,`driver_ptr_`的`input_type`就是`InputType::RAW_PACKET`,它通过LidarDriver::feedPacket接收Packet作为源。
+ 解析YAML文件得到雷达的用户配置参数
+ 得到接收Packet的话题,默认值为`/rslidar_packets`。
+ 创建Packet话题的订阅器,也就是成员`pkt_sub_`,接收函数是putPacket()。
#### 2.7.2 SourcePacketRos::putPacket()
putPacket()接收Packet,送到`driver_ptr_`解析。
+ 调用LidarDriver::decodePacket(),将Packet喂给`driver_ptr_`。
+ 点云的接收,使用SourceDriver的已有实现。
## 3 NodeManager
NodeManager管理Source实例,包括创建、初始化、启动、停止Source。它支持多个源,但是这些源的类型必须相同。
+ 成员`sources_[]`是一个Source实例的数组。
![node_manager](./img/class_node_manager.png)
### 3.1 NodeManager::init()
init()初始化NodeManger实例。
+ 从config.yaml文件得到用户配置参数
+ 本地变量`msg_source`,数据源类型
+ 本地变量`send_point_cloud_ros` 是否在ROS话题发送点云。
+ 本地变量`send_packet_ros`,是否在ROS话题发送MSOP/DIFOP packet
+ 在.yaml文件中遍历数据源。在循环中,
+ 根据`msg_source`创建Source实例。
+ 如果是在线雷达(`SourceType::MSG_FROM_LIDAR`),创建SourceDriver实例并初始化, 源类型为`MSG_FROM_LIDAR`。
+ 如果是PCAP文件(`SourceType::MSG_FROM_PCAP`),创建SourceDriver实例并初始化,源类型为`MSG_FROM_PCAP`。
+ 如果是ROS话题(`SourceType::MSG_FROM_ROS_PACKET`), 创建SourcePacketRos并初始化。SourcePacketRos构造函数已将源类型设置为`MSG_FROM_ROS_PACKET`
+ 如果在ROS话题发送点云(`send_point_cloud_ros` = `true`),则创建DestinationPointCloudRos实例、初始化,调用Source::regPointCloudCallback(),将它加入Source的`pc_cb_vec_[]`。
+ 如果在ROS话题发送Packet(`send_packet_ros` = `true`),则创建DestinationPacketRos实例、初始化,调用Source::regPacketCallback()将它加入Source的`pkt_cb_vec_[]`。
+ 将Source实例,加入成员`sources_[]`。
### 3.2 NodeManager::start()
start()启动成员`sources_[]`中的所有实例。