Add latest channel support in schema_tracker.#389
Conversation
- Enable pedals to write the latest channel
📝 WalkthroughWalkthroughThis pull request adds optional support for writing an additional "latest-only" MCAP sample per Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/core/live_trackers/cpp/inc/live_trackers/schema_tracker.hpp (1)
84-111:⚠️ Potential issue | 🟠 MajorGuard latest-channel write on a valid decoded sample from this frame.
Line 84 initializes
last_timestampto a default value, and Line 108 only checks pointer presence. If all current samples failGetRoot(Lines 88-91), this can write staleout_latestwith an invalid timestamp.Proposed fix
- DeviceDataTimestamp last_timestamp{}; + std::optional<DeviceDataTimestamp> last_timestamp; for (const auto& sample : samples_) { auto fb = flatbuffers::GetRoot<DataTableT>(sample.buffer.data()); if (!fb) { continue; } @@ - last_timestamp = sample.timestamp; + last_timestamp = sample.timestamp; @@ - if (mcap_channel_latest_index_ && mcap_channels_ && out_latest) + if (mcap_channel_latest_index_ && mcap_channels_ && out_latest && last_timestamp.has_value()) { - mcap_channels_->write(*mcap_channel_latest_index_, last_timestamp, out_latest); + mcap_channels_->write(*mcap_channel_latest_index_, *last_timestamp, out_latest); }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/core/live_trackers/cpp/inc/live_trackers/schema_tracker.hpp` around lines 84 - 111, The loop may call mcap_channels_->write for the "latest" channel even when every sample failed decoding, causing a stale out_latest/last_timestamp to be written; introduce a validity flag (e.g., bool have_decoded = false) set to true only after a successful GetRoot/UnPackTo and update last_timestamp there, then change the final guard to require have_decoded && mcap_channel_latest_index_ && mcap_channels_ && out_latest before calling mcap_channels_->write; refer to symbols samples_, GetRoot<DataTableT>, UnPackTo(out_latest.get()), out_latest, last_timestamp, mcap_channel_latest_index_, and mcap_channels_->write.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In `@src/core/live_trackers/cpp/inc/live_trackers/schema_tracker.hpp`:
- Around line 84-111: The loop may call mcap_channels_->write for the "latest"
channel even when every sample failed decoding, causing a stale
out_latest/last_timestamp to be written; introduce a validity flag (e.g., bool
have_decoded = false) set to true only after a successful GetRoot/UnPackTo and
update last_timestamp there, then change the final guard to require have_decoded
&& mcap_channel_latest_index_ && mcap_channels_ && out_latest before calling
mcap_channels_->write; refer to symbols samples_, GetRoot<DataTableT>,
UnPackTo(out_latest.get()), out_latest, last_timestamp,
mcap_channel_latest_index_, and mcap_channels_->write.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 0b6bbe72-229e-4bea-be5b-88455c2c2a06
📒 Files selected for processing (3)
src/core/live_trackers/cpp/inc/live_trackers/schema_tracker.hppsrc/core/live_trackers/cpp/live_generic_3axis_pedal_tracker_impl.cppsrc/core/mcap/cpp/inc/mcap/recording_traits.hpp
Summary by CodeRabbit