Open
Conversation
Reviewer's GuideImplements gating for single-armor SP matches so that candidates exceeding configured distance/yaw error thresholds are rejected without updating tracker state, while preserving candidate_debug info and adding detailed logging for accepted vs rejected matches. Sequence diagram for ArmorTracker single-armor SP gating decisionsequenceDiagram
actor Detector
participant ArmorTracker
participant EKF
participant Logger
Detector->>ArmorTracker: Update(armors_msg, imu_msg, time)
ArmorTracker->>ArmorTracker: find best_armor and best_match
ArmorTracker->>ArmorTracker: set candidate_debug.count and items[0]
ArmorTracker->>ArmorTracker: compute accepted = (best_match.xyz_error < max_match_distance && best_match.angle_error < max_match_yaw_diff)
ArmorTracker->>ArmorTracker: rt_.info_position_diff = best_match.xyz_error
ArmorTracker->>ArmorTracker: rt_.info_yaw_diff = best_match.angle_error
alt match rejected (not accepted)
ArmorTracker->>Logger: XR_LOG_DEBUG("SP tracker reject match ...")
ArmorTracker-->>Detector: return without updating rt_ or EKF
else match accepted
ArmorTracker->>ArmorTracker: matched = true
ArmorTracker->>ArmorTracker: candidate_debug.matched = 1
ArmorTracker->>ArmorTracker: candidate_debug.accepted_mode = 1
ArmorTracker->>ArmorTracker: candidate_debug.selected_index = 0
ArmorTracker->>ArmorTracker: candidate_debug.same_face_matched = 1
ArmorTracker->>ArmorTracker: previous_face = rt_.tracked_face_index
ArmorTracker->>ArmorTracker: SpUpdate(best_armor, best_match, pair_delta_z_mode)
ArmorTracker->>ArmorTracker: update rt_.tracked_armor, tracked_id, tracked_armors_num, tracked_face_index, last_yaw
ArmorTracker->>ArmorTracker: rt_.update_count++
opt face switched
ArmorTracker->>ArmorTracker: rt_.switch_count++
end
ArmorTracker->>ArmorTracker: SyncGeometryRuntimeFromState()
ArmorTracker->>EKF: ekf_.ekf.SetState(ekf_.state)
ArmorTracker->>Logger: XR_LOG_DEBUG("SP tracker update ...")
ArmorTracker-->>Detector: return with updated tracker state
end
Class diagram for updated ArmorTracker SP gating logicclassDiagram
class ArmorTracker {
+cfg_ : TrackerConfig
+ekf_ : EkfWrapper
+rt_ : RuntimeState
+Update(armors_msg, imu_msg, time)
+SpUpdate(best_armor, best_match, pair_delta_z_mode)
+SpArmorCountFor(best_armor) int
+SyncGeometryRuntimeFromState()
}
class TrackerConfig {
+match : MatchConfig
}
class MatchConfig {
+max_match_distance : float
+max_match_yaw_diff : float
}
class BestMatch {
+id : int
+score : float
+yaw_error : float
+pitch_error : float
+distance_error : float
+angle_error : float
+xyz_error : float
+measured_yaw : float
}
class RuntimeState {
+tracked_armor : Armor
+tracked_id : int
+tracked_armors_num : ArmorsNum
+tracked_face_index : int
+last_yaw : float
+info_position_diff : float
+info_yaw_diff : float
+update_count : int
+switch_count : int
}
class CandidateDebug {
+matched : int
+accepted_mode : int
+selected_index : int
+same_face_matched : int
+count : int
+items : CandidateDebugItem[]
+best_same_face_score : float
}
class CandidateDebugItem {
+armor_index : uint8_t
+id : int
+pred_yaw : float
+measured_yaw : float
}
class EkfWrapper {
+state : EkfState
+ekf : EkfCore
}
class EkfCore {
+SetState(state)
}
ArmorTracker --> TrackerConfig : uses
TrackerConfig --> MatchConfig : has
ArmorTracker --> RuntimeState : updates
ArmorTracker --> BestMatch : evaluates
ArmorTracker --> CandidateDebug : fills
ArmorTracker --> EkfWrapper : synchronizes
EkfWrapper --> EkfCore : wraps
CandidateDebug --> CandidateDebugItem : contains
class Armor {
+number : int
+type : int
}
class ArmorsNum {
}
RuntimeState --> Armor : tracks
RuntimeState --> ArmorsNum : tracks
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- The gating condition uses
best_match.angle_errorbut the log message and config name refer toyaw(andmax_match_yaw_diff), so it would be good to double‑check whetherangle_erroris really the intended quantity here or ifyaw_errorshould be used for consistency. - The new reject path logs every failed SP match at
XR_LOG_DEBUG, which could become quite noisy in dense scenes; consider adding a rate limit, a verbosity flag, or promoting only particularly bad rejections (e.g., beyond some margin) to logs.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The gating condition uses `best_match.angle_error` but the log message and config name refer to `yaw` (and `max_match_yaw_diff`), so it would be good to double‑check whether `angle_error` is really the intended quantity here or if `yaw_error` should be used for consistency.
- The new reject path logs every failed SP match at `XR_LOG_DEBUG`, which could become quite noisy in dense scenes; consider adding a rate limit, a verbosity flag, or promoting only particularly bad rejections (e.g., beyond some margin) to logs.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary\n- reject single-armor SP candidates outside max_match_distance / max_match_yaw_diff\n- keep rejected candidate_debug data for preview/audit without updating tracker state\n\n## Validation\n- Ubuntu24 BSP capturefile runtime reached EOF and SYNCED LATEST_IMU\n- capturefile/hik BSP builds passed with this tracker tar\n- branch CI passed: https://github.com/QDU-Robomaster/ArmorTracker/actions/runs/25174223503\n
Summary by Sourcery
Gate single-armor SP tracker updates on position and yaw error thresholds and only update tracker state when a same-target match passes these limits.
Bug Fixes:
Enhancements: