MAVLINKHUD

ADS-B Collision Avoidance

Executive Summary

ADS-B (Automatic Dependent Surveillance–Broadcast) allows the drone to see manned aircraft. ArduPilot doesn't just display these on the GCS; it can actively dodge them.

Unlike Lidar/Radar avoidance which is short-range and reactive, ADS-B avoidance is long-range and strategic, triggering specific failsafe flight modes.

Theory & Concepts

1. The Threat Cylinder

ArduPilot defines a safety cylinder around the vehicle:

  • Radius: ADSB_LIST_RADIUS (e.g., 2km).
  • Altitude: ADSB_LIST_ALT (e.g., 1000m).
  • Collision Zone: If an aircraft is projected to enter a smaller, critical zone within a certain time, an avoidance action is triggered.

2. Evasive Maneuvers

Unlike simple obstacle avoidance (Stop/Slide), ADS-B avoidance triggers a dedicated flight mode (AVOID_ADSB for Copter) or overrides the path.

  • Climb/Descend: The most common reaction.
  • Perpendicular: Fly 90 degrees away from the threat's velocity vector.

Codebase Investigation

1. The Sensor Driver: AP_ADSB::update()

Located in libraries/AP_ADSB/AP_ADSB.cpp.

  • Maintains a list of adsb_vehicle_t.
  • Handles timeouts (VEHICLE_TIMEOUT_MS) to remove stale targets.
  • Pushes data to the GCS via SRx_ADSB.

2. Copter Avoidance Logic: AP_Avoidance_Copter::handle_avoidance()

Located in ArduCopter/avoidance_adsb.cpp.

  • State Change: When a threat is confirmed, it switches the flight mode:
    copter.set_mode(Mode::Number::AVOID_ADSB, ModeReason::AVOIDANCE)
    
  • Vertical Evasion: Checks if the aircraft is above or below.
    • If above, descend (but not below ADSB_ALT_MIN).
    • If below, climb.

Source Code Reference

Practical Guide: Setting Up ADS-B

1. Hardware

You need an ADS-B Receiver.

  • uAvionix PingRX: Standard for small drones.
  • Cube Orange: Has ADS-B In built into the carrier board (check your version).

2. Key Parameters

  • ADSB_ENABLE: 1.
  • ADSB_BEHAVIOR: Controls the reaction. 0 = None (Report only), 1 = Loiter/Hover, 2 = Avoid (Climb/Descend).
  • ADSB_ALT_MIN: Critical. Set this to your Minimum Safe Altitude (e.g., 20m). You do NOT want the drone to descend into the trees to avoid a plane at 500ft.

3. Testing

  • Simulator: You can simulate ADS-B traffic in SITL using sim_vehicle.py.
  • Real World: Do not test this with real planes. Trust the simulation or use a second drone broadcasting ADS-B Out (if legally permitted).

How To: Configure ADS-B Avoidance

This is a "Set and Forget" safety feature.

1. Enable the Hardware

  • ADSB_ENABLE: 1.
  • Reboot. Check MAVLink Inspector for ADSB_VEHICLE messages (if any traffic is nearby).

2. Configure the Avoidance Logic

The avoidance logic is separate from the driver.

  • AVD_ENABLE: 1. (Enables the avoidance library).
  • AVD_F_DIST_XY: 1000 (Meters). If a plane gets within 1km horizontally...
  • AVD_F_DIST_Z: 100 (Meters). ...AND within 100m vertically...
  • AVD_F_TIME: 10 (Seconds). ...AND will collide within 10 seconds.
  • AVD_F_ACTION: 1 (Climb). The drone will immediately climb to AVD_F_ALT_MIN or maintain altitude if higher.

Verification: In Mission Planner simulation, use the "ADSB Simulation" tab to inject a fake aircraft on a collision course. Your drone should switch to AVOID_ADSB mode and climb/descend automatically.