Skip to content

Fix frame consistency, race conditions, missing safety checks, and lifecycle error handling#4

Draft
varadVaidya with Copilot wants to merge 2 commits into
dev/refractor2from
copilot/review-fixes-in-agent-md
Draft

Fix frame consistency, race conditions, missing safety checks, and lifecycle error handling#4
varadVaidya with Copilot wants to merge 2 commits into
dev/refractor2from
copilot/review-fixes-in-agent-md

Conversation

Copilot AI commented Mar 5, 2026

Copy link
Copy Markdown
Contributor

Full codebase review of the peregrine_core ROS2 UAV control stack. Found and fixed bugs across 6 packages related to frame consistency (Issue #3), thread safety, missing safety guards, and incomplete lifecycle error handling.

Frame consistency

  • hardware_abstraction: GPS frame_id was hardcoded as "gps" instead of using parameterized baseLinkFrame_, breaking multi-UAV deployments where frame_prefix namespaces all frames.

Race conditions

  • safety_monitor: odomFrame_ written outside mutex_ in onEstimatedState() while read under lock in updateGeofenceCache(). Moved lock acquisition before the write.
  • uav_manager: active_ set to true before createActionServers() in on_activate() — goal callbacks could see active_==true with no servers. Reordered.

Missing safety checks in uav_manager

onLandAccepted, onGoToAccepted, onExecuteAccepted were all missing the emergency/preemption guard that onTakeoffAccepted had:

if (emergencyCb()) {
  failGoal("EMERGENCY_PREEMPT");
  return;
}
if (preempted()) {
  failGoal("GOAL_PREEMPTED");
  return;
}

Lifecycle on_error() leaving publishers active

on_error() in estimation_manager, control_manager, and trajectory_manager cancelled timers but never deactivated lifecycle publishers — leaving orphaned active publishers. Added deactivation matching the existing on_deactivate() pattern.

Cleanup safety (estimation_manager)

on_cleanup() called .reset() on timers/publishers without cancelling or deactivating first. Added null-guarded cancel + deactivate before reset.

Repo hygiene

Added .gitignore, removed 13 committed __pycache__/ binaries.

Notable design-level issues identified but not fixed

Area Issue
multi_uav_sitl.launch.py Per-PX4 ROS_DOMAIN_ID (1,2,3…) vs stack default (0) — DDS won't connect
single_uav.launch.py 5/7 nodes don't receive frame_prefix param (they derive from upstream messages)
uav_manager Hardcoded 90s land disarm wait and 4s control setpoint wait should be parameters

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

…ks, lifecycle error handling

Co-authored-by: varadVaidya <43097003+varadVaidya@users.noreply.github.com>
Copilot AI changed the title [WIP] Review implementation of fixes from AGENT.md Fix frame consistency, race conditions, missing safety checks, and lifecycle error handling Mar 5, 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