add geofence manager#7
Conversation
|
Zone config is in ros2 run diff_drive_robot geofence_manager.py --ros-args -p geofence_file:=/path/to/geofences.yamlMonitor breach alerts: ros2 topic echo /geofence/breach
ros2 topic echo /geofence/current_zone |
Geofence Manager for Nav2Problem Nav2 has no built-in mechanism to define virtual boundaries or forbidden zones on the map. Without geofencing, robots can freely enter restricted areas — charging bays, hazard zones, or off-limits corridors — with no alerting or enforcement. Solution Adds a lightweight # before — no boundary enforcement, robot goes anywhere
# Nav2 sends robot to goal, no zone awareness
# after — breach published instantly when robot enters forbidden zone
ros2 topic echo /geofence/breach # Bool
ros2 topic echo /geofence/current_zone # StringWhat changed
Test Plan
|
Usage & IntegrationLaunch the node ros2 run diff_drive_robot geofence_manager.py --ros-args -p geofence_file:=$(ros2 pkg prefix diff_drive_robot)/share/diff_drive_robot/config/geofences.yamlMonitor in real time ros2 topic echo /geofence/breach # True when in a forbidden zone
ros2 topic echo /geofence/current_zone # active zone nameIntegration with Nav2 Hook self.breach_sub = self.create_subscription(Bool, '/geofence/breach', self._on_breach, 10)
def _on_breach(self, msg):
if msg.data:
self.nav.cancelTask()How it fits the stackWorks alongside the existing Planned improvements
|
Adds a polygon-based geofence manager node for Nav2.
What it does:
/amcl_poseand checks if the robot is inside any defined zone/geofence/breach(Bool) when inside a forbidden zone/geofence/current_zone(String) with the active zone nameconfig/geofences.yaml— no external deps, pure ray-castingNew files:
scripts/geofence_manager.pyconfig/geofences.yaml