Skip to content

feat(ros2): support legacy vehicle boxes and timestamp tolerance in recording readers - #21

Merged
xtk8532704 merged 8 commits into
mainfrom
kem/ros-recording-box-expansion
Dec 1, 2026
Merged

xtk8532704 merged 8 commits into
mainfrom
kem/ros-recording-box-expansion

Conversation

@xtk8532704

@xtk8532704 xtk8532704 commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Description

The DP2 H5 exporter and the Devkit rosbag reader both convert Autoware tracked objects into Scene annotations. Older Perception recordings contain vehicle boxes that exclude mirrors. Devkit can also receive objects in a sensor frame. This PR lets both readers use the ROS2 generator for the geometry while each reader chooses the settings for its recording. Downstream callers are in DiffusionPlanner2 #6 and e2e-devkit #271.

  • Vehicle geometry. Box dimensions are preserved by default. A reader can pass a per-class width and front extension to open_bag() or SceneBuilder. The Python legacy preset covers cars, trucks and buses. For a single message, convert_tracked_objects() returns an annotation batch and accepts the reader’s message-to-Scene transform. It applies the box correction before transforming and projecting into Scene XY. Python examples
  • Sampling. A reader that ingests its own messages can supply a complete profile as a Python dictionary or as YAML text in C++. The previous and previous_per_group rules can tolerate a small forward timestamp offset. The default is zero and decision-time cutoffs still apply. The loader checks topic names and reports missing topic/rule pairs. Sampling rules

The shipped range example explicitly shows its three fixed settings. Custom profiles can omit them. The range still starts at its first odometry measurement and uses all observations for resampling. Range configuration

Validation

  • On ROS 2 Humble, the installed C++ consumer and all 35 Python generator tests (46 subtests) passed. Coverage includes box expansion with unusable or ambiguous orientation, frame transforms, timestamp tolerance at a decision cutoff, and range profile defaults.
  • Ruff formatting and lint passed. Twenty combinations of timestamp tolerance and age limits, including per-group traffic lights, and 50 random 3D transforms matched independent reference calculations.
  • On Humble, the documented legacy-box example produced a 117-row window from a real rosbag. The standalone example returned an Annotations batch, and the installed builder loaded all three YAML examples in the configuration guide.

@xtk8532704 xtk8532704 changed the title feat(ros2): share recorded object conversion and sampling policies feat(ros2): support legacy vehicle boxes and timestamp tolerance in recording readers Dec 1, 2026

@Max-Bin Max-Bin left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 23b276e against PR #16. This adds opt-in box expansion and sensor-frame conversion for recording readers, plus forward timestamp tolerance for previous and previous_per_group.

Please fix the previous selection issue before merging. I reproduced it by compiling the selector from this commit. Humble CI passed the installed C++ consumer and all 34 Python tests. CI results

if (rule.method == Method::Previous && rule.tolerance_ns) {
auto end = std::upper_bound(
rows.begin(), rows.end(),
latest_tolerated_stamp(time, rule.tolerance_ns),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keep an eligible observation when the newest stamp exceeds the age limit. With max_age_ns=1000, timestamp_tolerance_ns=2000, and visible observations at t and t + 1500 ns, this selects the second observation and then returns missing for row t. The exact sample at t is still within both limits. Cap the search tolerance at max_age_ns when it is set, as previous_per_group already does, and add this two-observation case to the installed test. Per-group implementation

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 92758e4. previous and previous_per_group now both cap the forward search at min(timestamp_tolerance_ns, max_age_ns) when an age limit is set. In your example the sample at t + 1500 ns falls outside the search and the row keeps the sample at t. I added that exact two-observation case to the installed Python tests. The test now uses a profile dictionary so it also runs in CI’s isolated environment. All 35 generator tests passed locally on Humble and Jazzy. Regression test

// ROS ObjectClassification label -> (total width added, front extension), in
// metres.
using BoxExpansion = std::map<uint8_t, std::pair<double, double>>;
Annotations convert_tracked_objects(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please document the new C++ entry points in the generator's C++ guide. A short example can show SceneBuilder::from_yaml(), the BoxExpansion argument, and how to pass the row-major message-to-Scene transform to convert_tracked_objects(). C++ guide

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added both examples to the C++ guide. The first builds a SceneBuilder from YAML text with per-class BoxExpansion values in metres. The second passes a row-major 4×4 message-to-Scene transform to convert_tracked_objects() and shows where the sensor translation goes. C++ examples

@xtk8532704
xtk8532704 requested a review from Max-Bin December 1, 2026 09:24
@xtk8532704
xtk8532704 force-pushed the kem/ros-recording-box-expansion branch from f2a38bc to e9cea6e Compare December 1, 2026 13:35
@xtk8532704
xtk8532704 changed the base branch from kem/ml-planner-forward-only to main December 1, 2026 13:36

@Max-Bin Max-Bin left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-reviewed e9cea6e. Both previous and previous_per_group now cap the forward search at the age limit. The regression test keeps the exact sample when the newer stamp exceeds that limit. The C++ guide now has examples for YAML profiles, box expansion, and sensor-frame conversion. Regression test · C++ examples

I built the rebased commit on Humble and ran the installed C++ consumer and all 35 Python generator tests. The 42 SDK window-decoding tests also passed.

For e2e-devkit #271, I reproduced the same edge case in the Python fallback. It still returns missing when a newer stamp exceeds the age limit and an exact sample is available. Please align that fallback when updating the T4Scene pin so both paths return the same observation. Devkit selector

@xtk8532704
xtk8532704 merged commit c2fd3b0 into main Dec 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants