CONDITION_DELAY
Summary
The CONDITION_DELAY command pauses the mission state machine for a specific number of seconds. Unlike a NAV_DELAY or a loiter with time, which are navigation-level commands, CONDITION_DELAY is a flow-control item that prevents the next mission item from starting until the timer expires.
Status
Supported (All Vehicles)
Directionality
- RX (Receive): The vehicle receives this command as part of a mission upload.
Mission Storage (AP_Mission)
- Packet Param 1 (Time): Stored in the internal
condition_valuefield (seconds). - Mechanism: When the mission reaches this item, it records the current system time in
condition_start.
Execution (Engineer's View)
State Machine Logic
ArduPilot's mission engine treats "Condition" commands as gates.
-
Verification: Every loop, the
verify_wait_delay()function is called (mode_auto.cpp). -
Comparison: The function checks if the elapsed time since the command started exceeds the target delay.
$$ \mathrm{current\_time} - \mathrm{condition\_start} > \mathrm{condition\_value} \cdot 1000 $$
-
Completion: Once the condition is met, the gate opens, and the mission state machine increments to the next command ID.
Vehicle Behavior during Delay
It is critical to understand that CONDITION_DELAY does not stop the vehicle's movement if it was already performing a navigation task that supports concurrent execution (though typically conditions are placed between nav points).
- Copter: If placed after a
NAV_WAYPOINT, the drone will hover at that waypoint while the delay runs. - Plane: The aircraft will continue its previous navigation state (e.g., loitering) while the condition timer counts down.
Data Fields (MAVLink)
param1(Time): Delay time in seconds.param2toparam7: Unused.
Theory: Synchronous vs. Asynchronous Delays
In computer science, a delay can be blocking or non-blocking.
- MAVLink HUD Context:
CONDITION_DELAYis a non-blocking delay for the flight controller (it still stabilizes the airframe), but a blocking delay for the Mission Script. - Race Conditions: If a GCS sends a "Set Current Waypoint" command while a
CONDITION_DELAYis active, the timer is typically reset or abandoned as the mission engine jumps to the new index.
Practical Use Cases
- Camera Boot-up:
- Scenario: A high-end mapping camera takes 10 seconds to initialize after being powered on via a relay.
- Action:
DO_SET_RELAY->CONDITION_DELAY (10s)->NAV_WAYPOINT.
- Safety Buffer:
- Scenario: Ensuring a drone has come to a complete, stable hover before dropping a payload.
- Action:
NAV_WAYPOINT->CONDITION_DELAY (3s)->DO_GRIPPER.
Key Parameters
MIS_OPTIONS: Can affect how the mission engine handles pauses and restarts.
Key Codebase Locations
- ArduCopter/mode_auto.cpp:2192:
verify_wait_delayimplementation. - ArduPlane/commands_logic.cpp: Plane condition handling.
CONDITION_DISTANCE
Summary
The CONDITION_DISTANCE command creates a proximity-based gate in the mission. It prevents the next mission item from starting until the vehicle is within a specific distance (meters) of the next navigation waypoint.
Status
Supported (All Vehicles)
Directionality
- RX (Receive): The vehicle receives this command as part of a mission upload.
Mission Storage (AP_Mission)
- Packet Param 1 (Distance): Stored in the internal
condition_valuefield (meters).
Execution (Engineer's View)
Verification Logic
The mission engine checks the proximity in every loop cycle using verify_within_distance() (mode_auto.cpp).
-
Distance Calculation: The flight controller calculates the 2D (horizontal) distance between the current GPS coordinate and the coordinate of the
NAV_WAYPOINTimmediately following the condition. -
Comparison:
$$ \mathrm{dist\_to\_wp} < \mathrm{condition\_value} $$
-
Completion: As soon as the vehicle crosses the "distance threshold," the condition returns true, and the next command (which is usually a "Do" command like
DO_DIGICAM_CONTROL) is executed.
Data Fields (MAVLink)
param1(Distance): Distance in meters.param2toparam7: Unused.
Theory: The "Inner Circle"
CONDITION_DISTANCE allows for spatial triggering that is more precise than simple waypoint arrival.
- Waypoint Acceptance: Standard waypoints use a radius (e.g.,
WP_RADIUS) to determine when to turn. - Condition Precision: By using
CONDITION_DISTANCE, you can trigger an action (like a laser fire or camera snap) at a much tighter distance (e.g., 1 meter) than the navigation waypoint's acceptance radius (e.g., 5 meters).
Practical Use Cases
- Precise Photo Capture:
- Scenario: A surveyor needs a photo taken exactly as the drone passes over a marker.
- Action:
NAV_WAYPOINT (Marker)->CONDITION_DISTANCE (0.5m)->DO_DIGICAM_CONTROL.
- Obstacle Proximity Actions:
- Scenario: A drone needs to turn on high-intensity landing lights as it approaches a narrow dock.
- Action:
NAV_WAYPOINT (Dock)->CONDITION_DISTANCE (10m)->[DO_SET_SERVO](/mission-planning/do-commands.html#DO_SET_SERVO) (Lights ON).
Key Parameters
WPNAV_RADIUS: (Copter) The horizontal radius used for waypoint completion; often used in conjunction withCONDITION_DISTANCE.
Key Codebase Locations
- ArduCopter/mode_auto.cpp:2201:
verify_within_distanceimplementation. - ArduPlane/commands_logic.cpp: Plane condition handler.
CONDITION_YAW
Summary
The CONDITION_YAW command forces the vehicle to rotate to a specific heading. This command is a "blocking" mission item; the mission will not advance to the next item until the aircraft has successfully achieved the target yaw angle within a small tolerance.
Status
Supported (ArduCopter and QuadPlane Only)
Directionality
- RX (Receive): The vehicle receives this command as part of a mission upload.
Mission Storage (AP_Mission)
- Angle (Param 1): Target angle in degrees.
- Rate (Param 2): Rotation speed in deg/s.
- Direction (Param 3): -1 for Counter-Clockwise, 1 for Clockwise.
- Relative (Param 4): 0 for Absolute (North-up), 1 for Relative (Offset from current heading).
Execution (Engineer's View)
ArduCopter Implementation
In Copter, the command triggers ModeAuto::do_yaw (mode_auto.cpp).
-
Request: The command is passed to the
auto_yawcontroller, which sets aFIXEDyaw target. -
Tracking: The autopilot calculates the shortest path (or the path requested by the direction parameter) to the new heading.
-
Completion: The verification function
ModeAuto::verify_yaw()checks if the current heading matches the target:$$ |\text{Yaw}_{current} - \text{Yaw}_{target}| < 2^\circ $$
-
Priority: Note that if a subsequent
NAV_WAYPOINTcommand has a different yaw requirement (like "Face Next Waypoint"), it will override theCONDITION_YAWonce the condition is met and the mission advances.
Data Fields (MAVLink)
param1(Angle): Target angle in degrees [0-360].param2(Rate): Desired turn rate in deg/s.param3(Direction): -1: CCW, 1: CW.param4(Relative): 0: Absolute, 1: Relative.param5toparam7: Unused.
Theory: The Singularity of North
Yaw management in ArduPilot must account for the 360/0 degree wrap-around.
- Angular Error: The autopilot uses the
wrap_180()function to calculate the smallest error. - Magnetic vs. True: Mission angles are typically relative to Magnetic North unless the system has been configured with a high-precision GPS (Moving Baseline) or a specific declination offset.
Practical Use Cases
- Fixed-Camera Alignment:
- Scenario: A drone is inspecting a solar panel array. The camera is fixed (no gimbal).
- Action:
CONDITION_YAWis used to point the entire drone airframe at the panels before the next survey leg.
- Antenna Tracking:
- Scenario: A drone needs to point a high-gain directional antenna back at the GCS for a data burst.
- Action:
CONDITION_YAWtargets the bearing to the Home point.
Key Parameters
ATC_SLEW_YAW: Limits the maximum rate of change for yaw to prevent mechanical stress on the frame.WP_YAW_BEHAVE: Determines how the drone handles yaw during navigation betweenCONDITION_YAWcommands.
Key Codebase Locations
- ArduCopter/mode_auto.cpp:1928:
do_yawimplementation. - ArduCopter/mode_auto.cpp:2211:
verify_yawcompletion check.