MAVLINKHUD

Mission Scenario: Precision Crop Spraying

Objective

Spray a rectangular cornfield with liquid fertilizer. The drone must maintain a consistent flow rate per hectare and automatically return to the refill station when the tank is empty.

Vehicle Configuration

  • Type: Octocopter (Agri-class).
  • Payload: Pump and Boom system controlled by AC_Sprayer.
  • Sensors: Radar Altimeter for terrain following.

Key Concepts

  • Flow Compensation: DO_SPRAYER automatically adjusts pump PWM based on groundspeed. As the drone slows down for a turn, the pump slows down to prevent burning the crop.
  • Terrain Awareness: Using TERRAIN altitude frames ensures the boom height stays constant over rolling hills.

Mission Plan

Seq Command Parameters Description
1 DO_SET_HOME Current: 1 Set Refill Station as Home.
2 NAV_TAKEOFF Alt: 5m Low altitude takeoff.
3 DO_CHANGE_SPEED Speed: 6 m/s Set optimal spray speed.
4 NAV_WAYPOINT Lat/Lon: [Field Corner 1] Transit to start.
5 DO_SPRAYER Enable: 1 Pump ON.
6 NAV_WAYPOINT Lat/Lon: [Field Corner 2] Spray Leg 1.
7 DO_SPRAYER Enable: 0 Pump OFF for turn.
8 NAV_WAYPOINT Lat/Lon: [Field Corner 3] Move to next row.
9 DO_SPRAYER Enable: 1 Pump ON.
10 NAV_WAYPOINT Lat/Lon: [Field Corner 4] Spray Leg 2.
... ... ... Repeat for entire grid...
50 NAV_RETURN_TO_LAUNCH - Return to refill station.

Advanced Logic: The "Empty Tank" Failsafe

Instead of guessing when the tank is empty, use a Lua script or a flow meter:

  1. Detection: When the flow sensor indicates 0L remaining.
  2. Action: The script triggers NAV_RETURN_TO_LAUNCH.
  3. Resume: After refilling, the operator uses the "Resume Mission" function. Because we documented DO_SET_RESUME_REPEAT_DIST, the drone will fly back to the exact point it left off, back up 10 meters, and resume spraying to ensure no crop is missed.

Pro-Tips

  • Turn Radius: Use NAV_SPLINE_WAYPOINT for turns. Smooth turns maintain momentum, allowing the sprayer logic to keep the pump running more consistently than stop-and-go 90-degree turns.