@@ -10,7 +10,7 @@ In ```CMakeLists.txt``` of the project, change the variable `POINT_TYPE`. Rememb
1010
1111``` cmake
1212#=======================================
13- # Custom Point Type (XYZI, XYZIRT)
13+ # Custom Point Type (XYZI,XYZIRT, XYZIF, XYZIRTF )
1414#=======================================
1515set(POINT_TYPE XYZI)
1616```
@@ -34,11 +34,12 @@ struct PointXYZI
3434rslidar_sdk transforms point cloud of ` PointXYZI ` to ROS message of ` PointCloud2 ` ,and publish it.
3535
3636``` c++
37- sensor_msgs::PointCloud2 ros_msg;
38- addPointField (ros_msg, "x", 1, sensor_msgs::PointField::FLOAT32, offset);
39- addPointField(ros_msg, "y", 1, sensor_msgs::PointField::FLOAT32, offset);
40- addPointField(ros_msg, "z", 1, sensor_msgs::PointField::FLOAT32, offset);
41- addPointField(ros_msg, "intensity", 1, sensor_msgs::PointField::FLOAT32, offset);
37+ sensor_msgs::PointCloud2 ros_msg;
38+ int offset = 0 ;
39+ offset = addPointField(ros_msg, " x" , 1 , sensor_msgs::PointField::FLOAT32, offset);
40+ offset = addPointField(ros_msg, " y" , 1 , sensor_msgs::PointField::FLOAT32, offset);
41+ offset = addPointField(ros_msg, " z" , 1 , sensor_msgs::PointField::FLOAT32, offset);
42+ offset = addPointField(ros_msg, " intensity" , 1 , sensor_msgs::PointField::FLOAT32, offset);
4243
4344 //
4445 // copy points from point cloud of `PointXYZI` to `PointCloud2`
@@ -70,14 +71,15 @@ struct PointXYZIRT
7071rslidar_sdk transforms point cloud of ` PointXYZIRT ` to ROS message of ` PointCloud2 ` ,and publish it.
7172
7273``` c++
73- sensor_msgs::PointCloud2 ros_msg;
74- addPointField (ros_msg, "x", 1, sensor_msgs::PointField::FLOAT32, offset);
75- addPointField(ros_msg, "y", 1, sensor_msgs::PointField::FLOAT32, offset);
76- addPointField(ros_msg, "z", 1, sensor_msgs::PointField::FLOAT32, offset);
77- addPointField(ros_msg, "intensity", 1, sensor_msgs::PointField::FLOAT32, offset);
78- #ifdef POINT_TYPE_XYZIRT
79- sensor_msgs::PointCloud2Iterator<uint16_t> iter_ring_ (ros_msg, "ring");
80- sensor_msgs::PointCloud2Iterator<double > iter_timestamp_ (ros_msg, "timestamp");
74+ sensor_msgs::PointCloud2 ros_msg;
75+ int offset = 0 ;
76+ offset = addPointField(ros_msg, " x" , 1 , sensor_msgs::PointField::FLOAT32, offset);
77+ offset = addPointField(ros_msg, " y" , 1 , sensor_msgs::PointField::FLOAT32, offset);
78+ offset = addPointField(ros_msg, " z" , 1 , sensor_msgs::PointField::FLOAT32, offset);
79+ offset = addPointField(ros_msg, " intensity" , 1 , sensor_msgs::PointField::FLOAT32, offset);
80+ #if defined(POINT_TYPE_XYZIRT) || defined(POINT_TYPE_XYZIRTF)
81+ offset = addPointField(ros_msg, "ring", 1, sensor_msgs::PointField::UINT16, offset);
82+ offset = addPointField(ros_msg, "timestamp", 1, sensor_msgs::PointField::FLOAT64, offset);
8183#endif
8284
8385 //
@@ -86,4 +88,78 @@ rslidar_sdk transforms point cloud of `PointXYZIRT` to ROS message of `PointClou
8688 ...
8789
8890```
91+ ## 5.4 XYZIF
92+
93+ If ` POINT_TYPE ` is ` XYZIF ` , rslidar_sdk uses the RoboSense defined type as below.
94+
95+ ``` c++
96+ struct PointXYZIF
97+ {
98+ float x;
99+ float y;
100+ float z;
101+ uint8_t intensity;
102+ uint16_t ring;
103+ double timestamp;
104+ };
105+ ```
106+
107+ rslidar_sdk transforms point cloud of ` PointXYZIF ` to ROS message of ` PointCloud2 ` ,and publish it.
108+
109+ ``` c++
110+ sensor_msgs::PointCloud2 ros_msg;
111+ int offset = 0 ;
112+ offset = addPointField(ros_msg, " x" , 1 , sensor_msgs::PointField::FLOAT32, offset);
113+ offset = addPointField(ros_msg, " y" , 1 , sensor_msgs::PointField::FLOAT32, offset);
114+ offset = addPointField(ros_msg, " z" , 1 , sensor_msgs::PointField::FLOAT32, offset);
115+ offset = addPointField(ros_msg, " intensity" , 1 , sensor_msgs::PointField::FLOAT32, offset);
116+ #if defined(POINT_TYPE_XYZIF) || defined(POINT_TYPE_XYZIRTF)
117+ offset = addPointField(ros_msg, "feature", 1, sensor_msgs::PointField::UINT8, offset);
118+ #endif
119+
120+ //
121+ // copy points from point cloud of `PointXYZIF` to `PointCloud2`
122+ //
123+ ...
124+
125+ ```
126+ ## 5.5 XYZIRTF
127+
128+ If ` POINT_TYPE ` is ` XYZIRTF ` , rslidar_sdk uses the RoboSense defined type as below.
129+
130+ ``` c++
131+ struct PointXYZIRTF
132+ {
133+ float x;
134+ float y;
135+ float z;
136+ uint8_t intensity;
137+ uint16_t ring;
138+ double timestamp;
139+ };
140+ ```
141+
142+ rslidar_sdk transforms point cloud of ` PointXYZIRTF ` to ROS message of ` PointCloud2 ` ,and publish it.
143+
144+ ``` c++
145+ sensor_msgs::PointCloud2 ros_msg;
146+ int offset = 0 ;
147+ offset = addPointField(ros_msg, " x" , 1 , sensor_msgs::PointField::FLOAT32, offset);
148+ offset = addPointField(ros_msg, " y" , 1 , sensor_msgs::PointField::FLOAT32, offset);
149+ offset = addPointField(ros_msg, " z" , 1 , sensor_msgs::PointField::FLOAT32, offset);
150+ offset = addPointField(ros_msg, " intensity" , 1 , sensor_msgs::PointField::FLOAT32, offset);
151+ #if defined(POINT_TYPE_XYZIRT) || defined(POINT_TYPE_XYZIRTF)
152+ offset = addPointField(ros_msg, "ring", 1, sensor_msgs::PointField::UINT16, offset);
153+ offset = addPointField(ros_msg, "timestamp", 1, sensor_msgs::PointField::FLOAT64, offset);
154+ #endif
155+ #if defined(POINT_TYPE_XYZIF) || defined(POINT_TYPE_XYZIRTF)
156+ offset = addPointField(ros_msg, "feature", 1, sensor_msgs::PointField::UINT8, offset);
157+ #endif
158+
159+ //
160+ // copy points from point cloud of `PointXYZIRTF` to `PointCloud2`
161+ //
162+ ...
163+
164+ ```
89165
0 commit comments