Skip to content

Support new MRPT 2.15.11 GPS data fields#5

Merged
jlblancoc merged 2 commits intoros2from
feat/new-gps-obs-fields
Mar 8, 2026
Merged

Support new MRPT 2.15.11 GPS data fields#5
jlblancoc merged 2 commits intoros2from
feat/new-gps-obs-fields

Conversation

@jlblancoc
Copy link
Member

@jlblancoc jlblancoc commented Mar 8, 2026

Summary by CodeRabbit

Release Notes

  • New Features

    • Enhanced GPS/GNSS status data mapping for improved accuracy
    • Added version-aware compatibility layer for different system configurations
  • Improvements

    • Better cross-platform GPS time conversion handling
    • Maintained backward compatibility while supporting advanced GNSS features

@coderabbitai
Copy link

coderabbitai bot commented Mar 8, 2026

Warning

Rate limit exceeded

@jlblancoc has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 4 minutes and 50 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 83999242-5a6d-499c-a1ba-44b9f5d55ebd

📥 Commits

Reviewing files that changed from the base of the PR and between c2bd057 and d5360ba.

📒 Files selected for processing (2)
  • formatter.sh
  • ros2bridge/src/gps.cpp
📝 Walkthrough

Walkthrough

This PR enhances the GPS conversion functions in ros2bridge/src/gps.cpp by adding version-conditional blocks to support GnssFixType-based handling when MRPT version 0x020f0b or newer is available, while maintaining backward compatibility with older versions through improved GNSS fix type and service mask mappings.

Changes

Cohort / File(s) Summary
GNSS Fix Type Versioning & Conversion
ros2bridge/src/gps.cpp
Added MRPT version header include with conditional compilation blocks throughout fromROS/toROS functions. Implemented GnssFixType-based mapping for MRPT >= 0x020f0b, including fix type conversions, gnss_service_mask propagation, and cross-platform GPS time handling with struct tm initialization. Preserved existing fix_quality-based behavior for older MRPT versions.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Poem

🐰 Hoppy hops through versions with grace,
GnssFixType finds its proper place,
GPS signals mapped with care,
Cross-platform time beyond compare,
New MRPT support, old paths still there!

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and directly reflects the main change: adding support for new MRPT 2.15.11 GPS data fields, which aligns with the conditional compilation for GnssFixType-based handling and gnss_service_mask propagation introduced in the changeset.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/new-gps-obs-fields

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
ros2bridge/src/gps.cpp (1)

310-326: ⚠️ Potential issue | 🟠 Major

Add validation guards for msg.time before casting to time_t.

The check if (msg.time > 0) allows +inf and oversized doubles through. Casting these to time_t is undefined behavior when the value doesn't fit. Both the GGA block (lines 310–326) and RMC block (lines 408–424) need to validate with std::isfinite() and a range check against std::numeric_limits<time_t>::max():

Suggested fix
+#include <limits>
...
-    if (msg.time > 0)
+    if (std::isfinite(msg.time) && msg.time > 0 &&
+        msg.time <= static_cast<double>(std::numeric_limits<time_t>::max()))
     {
       const auto time_t_val = static_cast<time_t>(msg.time);

Apply to both the GGA (lines 310–326) and RMC (lines 408–424) blocks.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@ros2bridge/src/gps.cpp` around lines 310 - 326, Validate msg.time for
finiteness and range before casting to time_t: replace the simple if (msg.time >
0) guard in both the GGA block (where time_t_val, utc_tm and gga.fields.UTCTime
are set) and the RMC block with a check that std::isfinite(msg.time) && msg.time
> 0 && msg.time <= static_cast<double>(std::numeric_limits<time_t>::max()); only
perform the static_cast<time_t>(msg.time) and call gmtime_r/gmtime_s after that
validation to avoid undefined behavior for +inf/oversized values.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@ros2bridge/src/gps.cpp`:
- Around line 217-219: The code only assigns msg.status.service =
obj.gnss_service_mask when fix_type != UNKNOWN, causing the fallback GGA mapping
to overwrite any valid gnss_service_mask; move or duplicate the logic that sets
msg.status.service from obj.gnss_service_mask (using the nonzero
check/static_cast<uint16_t> fallback to 1) so it runs regardless of fix_type
(e.g., assign msg.status.service from obj.gnss_service_mask before the fix_type
conditional or apply the same nonzero check in both branches); update the same
pattern for the other occurrence mentioned (the block around the second instance
analogous to lines 246-248) so gnss_service_mask is always propagated
independently of fix_type.
- Around line 238-240: The PPS fix (fix_quality == 3) is mapped inconsistently:
update the switch that sets msg.status.status (the case 3 branch in gps.cpp) so
it uses the same status value as ggaFixQualityToGpsStatus() does for case 3
(i.e., use STATUS_FIX instead of STATUS_SBAS_FIX) to make NavSatFix and GPSFix
exports agree for PPS observations; locate the case 3 branch that sets
msg.status.status and change it to the same enum/constant used by
ggaFixQualityToGpsStatus().

---

Outside diff comments:
In `@ros2bridge/src/gps.cpp`:
- Around line 310-326: Validate msg.time for finiteness and range before casting
to time_t: replace the simple if (msg.time > 0) guard in both the GGA block
(where time_t_val, utc_tm and gga.fields.UTCTime are set) and the RMC block with
a check that std::isfinite(msg.time) && msg.time > 0 && msg.time <=
static_cast<double>(std::numeric_limits<time_t>::max()); only perform the
static_cast<time_t>(msg.time) and call gmtime_r/gmtime_s after that validation
to avoid undefined behavior for +inf/oversized values.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 819d54a1-043b-4c28-b30b-cee035f660b9

📥 Commits

Reviewing files that changed from the base of the PR and between 9662ec7 and c2bd057.

📒 Files selected for processing (1)
  • ros2bridge/src/gps.cpp

@jlblancoc jlblancoc force-pushed the feat/new-gps-obs-fields branch 2 times, most recently from fb57572 to 8c47bef Compare March 8, 2026 17:48
@jlblancoc jlblancoc force-pushed the feat/new-gps-obs-fields branch from 8c47bef to d5360ba Compare March 8, 2026 17:49
@jlblancoc jlblancoc enabled auto-merge March 8, 2026 17:51
@jlblancoc jlblancoc merged commit a59259c into ros2 Mar 8, 2026
6 checks passed
@jlblancoc jlblancoc deleted the feat/new-gps-obs-fields branch March 8, 2026 17:55
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.

1 participant