Skip to content

Reasonable message checker for buggy state converter#101

Open
the-beast-coder wants to merge 3 commits into
rollsfrom
reasonable-checker-for-Buggy-State-Converter
Open

Reasonable message checker for buggy state converter#101
the-beast-coder wants to merge 3 commits into
rollsfrom
reasonable-checker-for-Buggy-State-Converter

Conversation

@the-beast-coder

Copy link
Copy Markdown

Overview

Added a reasonable checker to the buggy state converter. Whenever messages first come in, they are checked by the is_reasonable_msg (with params needing to be checked over and customized for each buggy). If the message seems reasonable, the buggy state converter proceeds as normal. If not, then the message is ignored altogether.

Tasks

  • Cross-check the current min max values passed into is_reasonable_msg for each of the buggies.
  • Test in sim
  • Test during mock rolls
  • Merge main into this branch

Comment on lines +244 to +246
# if opt.mode < 2 and not opt.output_avi_file.endswith(".avi"):
# print("--output_avi_file parameter should be a .avi file but is not : ",opt.output_avi_file,"Exit program.")
# exit()

from util.constants import Constants

from ukf_utils import *
@saransh323
saransh323 changed the base branch from main to rolls April 3, 2026 17:59
@saransh323
saransh323 requested a review from Copilot April 3, 2026 17:59

Copilot AI 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.

Pull request overview

Adds a “reasonable message” sanity-check layer to BuggyStateConverter so that clearly corrupt/invalid nav_msgs/Odometry inputs can be rejected before conversion and republishing.

Changes:

  • Introduces is_reasonable(...) and is_reasonable_msg(...) helpers to validate odometry position/orientation/twist against configurable bounds.
  • Applies sanity checks in both convert_SC_state(...) (ECEF/quaternion source) and convert_NAND_state(...) (UTM/radians source).
  • Updates .gitignore to ignore .robobuggy/ (and normalizes the .vscode entry).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
rb_ws/src/buggy/scripts/buggy_state_converter.py Adds odometry sanity-check helpers and uses them to gate SC/NAND state conversions.
rb_ws/.gitignore Ignores .robobuggy/ directory and adjusts .vscode ignore line.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +140 to 142
return
converted_msg = Odometry()
converted_msg.header = msg.header

Copilot AI Apr 3, 2026

Copy link

Choose a reason for hiding this comment

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

convert_SC_state now returns None when the message is deemed unreasonable, but convert_SC_state_callback always publishes the return value. Publishing None will raise at runtime and potentially kill the node. Consider returning the last valid Odometry, or have the callback skip publishing when conversion returns None (and ideally log a throttled warning when discarding).

Suggested change
return
converted_msg = Odometry()
converted_msg.header = msg.header
now = time.monotonic()
last_warn_time = getattr(self, "_last_invalid_sc_state_warning_time", 0.0)
if now - last_warn_time >= 1.0:
self.get_logger().warning(
"Discarding unreasonable SC state message; reusing last valid converted odometry when available."
)
self._last_invalid_sc_state_warning_time = now
last_valid_msg = getattr(self, "_last_valid_sc_odometry", None)
if last_valid_msg is not None:
return last_valid_msg
fallback_msg = Odometry()
fallback_msg.header = msg.header
return fallback_msg
converted_msg = Odometry()
converted_msg.header = msg.header
self._last_valid_sc_odometry = converted_msg

Copilot uses AI. Check for mistakes.
Comment on lines +205 to +206
):
return

Copilot AI Apr 3, 2026

Copy link

Choose a reason for hiding this comment

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

convert_NAND_state now returns None when the message is deemed unreasonable, but convert_NAND_state_callback always publishes the return value. Publishing None will raise at runtime and potentially kill the node. Consider returning the last valid Odometry, or have the callback skip publishing when conversion returns None (and ideally log a throttled warning when discarding).

Copilot uses AI. Check for mistakes.
Comment on lines +42 to +43
per-axis tuples. Covariance limits are scalar bounds applied to every
covariance entry. The defaults are intentionally broad and meant to catch

Copilot AI Apr 3, 2026

Copy link

Choose a reason for hiding this comment

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

The is_reasonable_msg docstring says covariance bounds are checked/applied, but the function currently only validates pose position/orientation and twist. Either update the docstring to match the implementation or add the intended covariance checks.

Suggested change
per-axis tuples. Covariance limits are scalar bounds applied to every
covariance entry. The defaults are intentionally broad and meant to catch
per-axis tuples. The defaults are intentionally broad and meant to catch

Copilot uses AI. Check for mistakes.
"""
if not is_reasonable_msg(
msg,
# UTM (easting, northing, altitude) for Pittsburgbh

Copilot AI Apr 3, 2026

Copy link

Choose a reason for hiding this comment

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

Typo in comment: "Pittsburgbh" should be "Pittsburgh".

Suggested change
# UTM (easting, northing, altitude) for Pittsburgbh
# UTM (easting, northing, altitude) for Pittsburgh

Copilot uses AI. Check for mistakes.
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