Skip to content

Commit 1deec9e

Browse files
authored
refactor!: remove deprecated t_us field from xyzit and en_xyzit point types (#95)
* refactor!: remove deprecated t_us field from xyzit and en_xyzit point types Drop the `t_us` field from `PointXYZIT` and `PointEnXYZIT` (struct definitions and PCL registrations), stop populating it in the Seyond decoder, and remove README / script references to it. `time_stamp` (uint32, nanoseconds from scan start) is now the sole per-point relative timestamp. BREAKING CHANGE: output PointCloud2 messages for `xyzit` and `en_xyzit` no longer contain a `t_us` field. Downstream consumers must read `time_stamp` (uint32 ns) instead. This was previously announced as "Will be removed in v1.0.0". * style: reformat PCL_REGISTER_POINT_STRUCT layout for PointXYZIT and PointEnXYZIT
1 parent ff6979d commit 1deec9e

5 files changed

Lines changed: 24 additions & 37 deletions

File tree

‎README.md‎

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,6 @@ The output bag file contains `sensor_msgs::msg::PointCloud2` messages on topics
193193
- `y` (float32): Y coordinate in meters
194194
- `z` (float32): Z coordinate in meters
195195
- `intensity` (float32): Intensity value in [0, 255]. Robin W uses packet-version-dependent scaling; see [docs/seyond_intensity_scaling.md](docs/seyond_intensity_scaling.md).
196-
- `t_us` (uint32): Relative timestamp in microseconds from the scan start time (xyzit, en_xyzit only). **Will be removed in v1.0.0**; use `time_stamp` instead.
197196
- `time_stamp` (uint32): Relative timestamp in nanoseconds from the scan start time (xyzit, en_xyzit only)
198197

199198
**Extended fields** (en_xyzit only): availability mask, refl_type, elongation, lidar_status, lidar_mode, packet version, lidar_type, is_2nd_return, multi_return_mode, and use_reflectance. Full layout, flag semantics, and value tables are in [docs/en_xyzit.md](docs/en_xyzit.md).
@@ -203,7 +202,6 @@ The output bag file contains `sensor_msgs::msg::PointCloud2` messages on topics
203202
All timestamps in PointCloud2 messages are based on UTC (Coordinated Universal Time).
204203

205204
- **`header.stamp`**: Absolute timestamp representing the scan start time in UTC. This timestamp is generated by the LiDAR and represents when the scan began.
206-
- **`t_us` field**: Relative timestamp in microseconds from the scan start time (`header.stamp`). **Will be removed in v1.0.0**; use `time_stamp` instead.
207205
- **`time_stamp` field**: Relative timestamp in nanoseconds from the scan start time (`header.stamp`)
208206

209207
The absolute timestamp for each point (in nanoseconds, UTC) can be calculated as:
@@ -212,12 +210,6 @@ The absolute timestamp for each point (in nanoseconds, UTC) can be calculated as
212210
absolute_timestamp_ns = (header.stamp.sec * 1,000,000,000 + header.stamp.nanosec) + time_stamp
213211
```
214212

215-
Or, using `t_us` (until v1.0.0):
216-
217-
```text
218-
absolute_timestamp_ns = (header.stamp.sec * 1,000,000,000 + header.stamp.nanosec) + (t_us * 1,000)
219-
```
220-
221213
## Utility Scripts
222214

223215
The `scripts/` directory contains Python scripts for inspecting and debugging rosbag files. See [scripts/README.md](scripts/README.md) for details.

‎scripts/decode_pointcloud2.py‎

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
- Reading PointCloud2 messages from rosbag2 files
88
- Automatic field detection and decoding
99
- Displaying point data with configurable number of points per message
10-
- Handling relative timestamps (e.g., t_us field) and calculating absolute timestamps
10+
- Handling relative timestamps (e.g., time_stamp field) and calculating absolute timestamps
1111
"""
1212

1313
import argparse
@@ -120,10 +120,10 @@ def decode_pointcloud2(bag_path: str, point_step: int = 10000, delay: float | No
120120
if num_points == 0:
121121
continue
122122

123-
# Calculate base timestamp in microseconds (if t_us field exists)
124-
base_time_us = None
125-
if 't_us' in points and len(points['t_us']) > 0:
126-
base_time_us = msg.header.stamp.sec * 1_000_000 + msg.header.stamp.nanosec // 1_000
123+
# Calculate base timestamp in nanoseconds (if time_stamp field exists)
124+
base_time_ns = None
125+
if 'time_stamp' in points and len(points['time_stamp']) > 0:
126+
base_time_ns = msg.header.stamp.sec * 1_000_000_000 + msg.header.stamp.nanosec
127127

128128
# Convert timestamp from nanoseconds to seconds and nanoseconds
129129
received_sec = timestamp // 1_000_000_000
@@ -148,12 +148,12 @@ def decode_pointcloud2(bag_path: str, point_step: int = 10000, delay: float | No
148148
for field_name in field_names:
149149
field_data = points[field_name]
150150
if len(field_data) > i:
151-
if field_name == 't_us' and base_time_us is not None:
152-
# Calculate absolute timestamp for t_us
153-
abs_time_us = base_time_us + int(field_data[i])
154-
abs_time_sec = abs_time_us / 1_000_000.0
155-
stamp_str = f"stamp={abs_time_sec:.6f}"
156-
# Add t_us as a regular field
151+
if field_name == 'time_stamp' and base_time_ns is not None:
152+
# Calculate absolute timestamp for time_stamp (nanoseconds)
153+
abs_time_ns = base_time_ns + int(field_data[i])
154+
abs_time_sec = abs_time_ns / 1_000_000_000.0
155+
stamp_str = f"stamp={abs_time_sec:.9f}"
156+
# Add time_stamp as a regular field
157157
point_info_parts.append(f"{field_name}={field_data[i]}")
158158
elif field_name == 'intensity' and isinstance(field_data[i], (float, np.floating)):
159159
point_info_parts.append(f"{field_name}={field_data[i]:.1f}")
@@ -235,8 +235,8 @@ def decode_point(msg: PointCloud2) -> dict:
235235
236236
Note:
237237
msg.header.stamp represents the scan start timestamp (absolute time).
238-
If a field named 't_us' exists, it contains relative timestamps from
239-
the scan start in microseconds.
238+
If a field named 'time_stamp' exists, it contains relative timestamps
239+
from the scan start in nanoseconds.
240240
241241
Args:
242242
msg: PointCloud2 message (msg.header.stamp is the scan start timestamp)

‎scripts/plot_field_distribution.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ def main():
198198
)
199199

200200
parser.add_argument('bag_path', type=str, help='Path to the rosbag2 file')
201-
parser.add_argument('field', type=str, help='PointCloud2 field name to plot (e.g., intensity, x, t_us)')
201+
parser.add_argument('field', type=str, help='PointCloud2 field name to plot (e.g., intensity, x, time_stamp)')
202202

203203
parser.add_argument('--bins', type=int, default=50, help='Number of bins (default: 50)')
204204

‎src/bag_converter/include/point_types.hpp‎

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,12 @@ struct EIGEN_ALIGN16 PointXYZI
5555
* It includes:
5656
* - x, y, z coordinates (float)
5757
* - intensity (float, 0–255)
58-
* - t_us: [DEPRECATED, will be removed in v0.6.0] Replaced by `time_stamp`.
59-
* Relative timestamp from scan start in microseconds (uint32_t)
6058
* - time_stamp: relative timestamp from scan start in nanoseconds (uint32_t)
6159
*/
6260
struct EIGEN_ALIGN16 PointXYZIT
6361
{
6462
PCL_ADD_POINT4D;
6563
float intensity;
66-
uint32_t t_us; ///< @deprecated Will be removed in v1.0.0. Replaced by `time_stamp`.
6764
uint32_t time_stamp;
6865
EIGEN_MAKE_ALIGNED_OPERATOR_NEW
6966
};
@@ -90,7 +87,7 @@ constexpr uint16_t HAS_USE_REFLECTANCE = 1u << 9;
9087
* Experimental. Extended fields use an availability mask (flags) and minimal unsigned types.
9188
* When a property is not supported, its flag bit is 0 and the value is 0 (must be ignored).
9289
*
93-
* Base: x, y, z (float), intensity (float, 0–255), t_us (deprecated), time_stamp (uint32_t).
90+
* Base: x, y, z (float), intensity (float, 0–255), time_stamp (uint32_t).
9491
* Extended (all uint8_t except flags): flags, refl_type (0-2), elongation (0-15),
9592
* lidar_status (0-3), lidar_mode (0-9), pkt_version_major/minor (0-255), lidar_type (0-7),
9693
* is_2nd_return (0-1), multi_return_mode (0-3), use_reflectance (0-1).
@@ -100,7 +97,6 @@ struct EIGEN_ALIGN16 PointEnXYZIT
10097
{
10198
PCL_ADD_POINT4D;
10299
float intensity;
103-
uint32_t t_us; ///< @deprecated Will be removed in v1.0.0. Replaced by `time_stamp`.
104100
uint32_t time_stamp;
105101
uint16_t flags; ///< en_xyzit_flags: which extended fields are valid
106102
uint8_t refl_type; ///< 0=normal, 1=ground, 2=fog. When not supported: 0.
@@ -145,17 +141,18 @@ POINT_CLOUD_REGISTER_POINT_STRUCT(
145141

146142
POINT_CLOUD_REGISTER_POINT_STRUCT(
147143
bag_converter::point::PointXYZIT,
148-
(float, x, x)(float, y, y)(float, z, z)(float, intensity, intensity)(uint32_t, t_us, t_us)(
149-
uint32_t, time_stamp, time_stamp))
144+
(float, x,
145+
x)(float, y, y)(float, z, z)(float, intensity, intensity)(uint32_t, time_stamp, time_stamp))
150146

151147
POINT_CLOUD_REGISTER_POINT_STRUCT(
152148
bag_converter::point::PointEnXYZIT,
153-
(float, x, x)(float, y, y)(float, z, z)(float, intensity, intensity)(uint32_t, t_us, t_us)(
154-
uint32_t, time_stamp, time_stamp)(uint16_t, flags, flags)(uint8_t, refl_type, refl_type)(
155-
uint8_t, elongation,
156-
elongation)(uint8_t, lidar_status, lidar_status)(uint8_t, lidar_mode, lidar_mode)(
157-
uint8_t, pkt_version_major, pkt_version_major)(uint8_t, pkt_version_minor, pkt_version_minor)(
158-
uint8_t, lidar_type, lidar_type)(uint8_t, is_2nd_return, is_2nd_return)(
149+
(float, x,
150+
x)(float, y, y)(float, z, z)(float, intensity, intensity)(uint32_t, time_stamp, time_stamp)(
151+
uint16_t, flags, flags)(uint8_t, refl_type, refl_type)(uint8_t, elongation, elongation)(
152+
uint8_t, lidar_status,
153+
lidar_status)(uint8_t, lidar_mode, lidar_mode)(uint8_t, pkt_version_major, pkt_version_major)(
154+
uint8_t, pkt_version_minor,
155+
pkt_version_minor)(uint8_t, lidar_type, lidar_type)(uint8_t, is_2nd_return, is_2nd_return)(
159156
uint8_t, multi_return_mode, multi_return_mode)(uint8_t, use_reflectance, use_reflectance))
160157

161158
#endif // BAG_CONVERTER__POINT_TYPES_HPP

‎src/bag_converter/src/seyond_decoder.cpp‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,12 +203,10 @@ void SeyondPCDDecoder<OutputPointT>::point_xyz_data_parse(
203203
// point_ptr->ts_10us is relative to the packet's ts_start_us (in 10us units)
204204
// pkt_offset_us_ is the packet's offset from scan start (in us)
205205
// point.time_stamp = (pkt_offset_us_ + ts_10us * 10) * 1000 = time from scan start in ns
206-
// point.t_us = time_stamp / 1000 = time from scan start in us (deprecated)
207206
if constexpr (
208207
std::is_same_v<OutputPointT, bag_converter::point::PointXYZIT> ||
209208
std::is_same_v<OutputPointT, bag_converter::point::PointEnXYZIT>) {
210209
point.time_stamp = static_cast<uint32_t>((pkt_offset_us_ + point_ptr->ts_10us * 10) * 1000);
211-
point.t_us = point.time_stamp / 1000;
212210
}
213211
if constexpr (std::is_same_v<OutputPointT, bag_converter::point::PointEnXYZIT>) {
214212
namespace fl = bag_converter::point::en_xyzit_flags;

0 commit comments

Comments
 (0)