SET_CAMERA_ZOOM
Summary
The SET_CAMERA_ZOOM command controls the focal length of an onboard camera during a mission. It allows for both incremental (rate-based) and absolute (percentage-based) zoom adjustments, enabling detailed inspections or wide-area reconnaissance from the same mission script.
Status
Supported (All Vehicles with AP_Camera enabled)
Directionality
- RX (Receive): The vehicle receives this command as part of a mission upload or as a direct command from the GCS.
Mission Storage (AP_Mission)
- Zoom Type (Param 1):
- 0: Step (Not supported in storage).
- 1: Continuous (Rate-based).
- 2: Range (Percentage-based 0-100).
- Zoom Value (Param 2): The value corresponding to the requested type.
- Packing: Stored in the
set_camera_zoomcontent struct.
Execution (Engineer's View)
Camera Driver Interaction
The command is routed through the AP_Camera library (AP_Camera.cpp).
- Rate-Based Zoom: If
Continuous (1)is selected, the autopilot commands the lens motor to move at a specific speed. This is typically used with gimbal-integrated cameras where the operator wants to zoom in "until clear." - Percentage Zoom: If
Range (2)is selected, the autopilot maps the 0.0-100.0 input to the camera's internal zoom range ($Z_{min} \to Z_{max}$). - Backend Support: This command works with MAVLink-enabled cameras (like SToRM32 or Tarot), DroneCAN cameras, and specialized drivers (like the Gremsy or Sony cameras). If the camera backend does not support zoom, the command is ignored.
Data Fields (MAVLink)
param1(Type): 0:Step, 1:Continuous, 2:Range.param2(Value): Rate (speed) or Percentage.param3toparam7: Unused.
Theory: Magnification vs. Resolution
Zooming in does not increase the sensor's physical resolution; it changes the Field of View (FOV).
- GSD Impact: Doubling the zoom ($2\times$) effectively halves the Ground Sample Distance (GSD), assuming the altitude remains constant.
- Vibration Sensitivity: As FOV decreases (Zoom increases), the image becomes exponentially more sensitive to high-frequency vibration ($Z_{sens} \propto \frac{1}{\text{FOV}}$). This often requires the gimbal's PID gains to be adjusted dynamically (handled automatically by advanced backends).
Practical Use Cases
- In-Mission Target Detail:
- Scenario: A drone is surveying a fence. It detects a breach at a waypoint.
- Action:
SET_CAMERA_ZOOM (Type: 2, Value: 80%). The drone zooms in to capture high-detail evidence before continuing the survey.
- Dynamic Reconnaissance:
- Scenario: A search-and-rescue plane is looking for a boat.
- Action: The plane orbits at $1\times$ zoom to cover the area. Once a suspect object is found, it uses a script to trigger
SET_CAMERA_ZOOMto $10\times$ for confirmation.
Key Parameters
CAM_TYPE: Selection of camera hardware.MNT1_TYPE: Often required as gimbals handle the physical lens motors.
Key Codebase Locations
- libraries/AP_Camera/AP_Camera.cpp:297: Mission command intake.
- libraries/AP_Camera/AP_Camera_MAVLinkCamV2.cpp: Translation to MAVLink camera protocol.
SET_CAMERA_FOCUS
Summary
The SET_CAMERA_FOCUS command manages the focus state of an onboard camera. It supports triggering Auto-Focus (AF) routines or setting manual focus levels, ensuring sharp imagery for automated inspections where the distance to the subject varies.
Status
Supported (All Vehicles with AP_Camera enabled)
Directionality
- RX (Receive): The vehicle receives this command as part of a mission upload or as a direct command from the GCS.
Mission Storage (AP_Mission)
- Focus Type (Param 1):
- 0: Auto.
- 1: Continuous (Manual rate).
- 2: Range (Manual percentage 0-100).
- Focus Value (Param 2): The value corresponding to the manual types.
- Packing: Stored in the
set_camera_focuscontent struct.
Execution (Engineer's View)
Focus Management
The command is processed by the AP_Camera library (AP_Camera.cpp).
- Auto-Focus Trigger: If
Auto (0)is selected, ArduPilot commands the camera backend to perform a "One-shot AF" or "Continuous AF" depending on the camera's internal capabilities. - Manual Overrides: If
Range (2)is selected, ArduPilot maps the input to the lens's focal range ($F_{min} \to F_{max}$). - Lens Compatibility: This command requires a camera with an electronically controlled focus motor (e.g., Sony block cameras, Gremsy-integrated sensors). Fixed-focus mapping cameras (like those used for photogrammetry) will ignore this command.
Data Fields (MAVLink)
param1(Type): 0:Auto, 1:Continuous, 2:Range, 3:Meters (Rarely supported).param2(Value): Rate or Percentage.param3toparam7: Unused.
Theory: The Circle of Confusion
Focusing is the process of minimizing the Circle of Confusion ($c$) on the image sensor.
- Depth of Field (DOF): At high zoom levels, the DOF becomes extremely shallow.
- Vibration: Out-of-focus images cannot be corrected in post-processing.
SET_CAMERA_FOCUSis used to "Lock" focus before a high-vibration segment to prevent the camera's internal AF from "hunting" due to motion blur.
Practical Use Cases
- Macro Inspection:
- Scenario: A drone is inspecting a weld on a bridge at a distance of 1.5 meters.
- Action:
SET_CAMERA_FOCUS (Auto)followed byIMAGE_START_CAPTURE.
- Infinity Lock:
- Scenario: Mapping from 100m altitude.
- Action: Mission starts with
SET_CAMERA_FOCUS (Range: 100%)to lock the lens at infinity, preventing hunting during flight.
Key Parameters
CAM_TYPE: Selection of camera hardware.
Key Codebase Locations
- libraries/AP_Camera/AP_Camera.cpp:307: Focus control implementation.
SET_CAMERA_SOURCE
Summary
The SET_CAMERA_SOURCE command allows the mission to dynamically switch between different sensors (lenses) on a multi-sensor camera system. This is common on modern dual-sensor payloads that feature both a visual (RGB) and a thermal (EO/IR) sensor.
Status
Supported (All Vehicles with AP_Camera enabled)
Directionality
- RX (Receive): The vehicle receives this command as part of a mission upload or as a direct command.
Mission Storage (AP_Mission)
- Instance (Param 1): The camera ID (1-6). 0 for "All."
- Primary Source (Param 2): Selection for the primary stream (e.g., RGB).
- Secondary Source (Param 3): Selection for the secondary stream (e.g., IR).
- Packing: Stored in the
set_camera_sourcecontent struct.
Execution (Engineer's View)
Multicam Logic
The command is handled by AP_Camera::set_camera_source (AP_Camera.cpp).
- Index Translation: ArduPilot maps "Camera 1" to the first available hardware driver.
- Source Selection: The autopilot sends a command to the camera backend (MAVLink or specialized driver) to reconfigure the video stream or the image capture target.
- Use Cases:
- Switching from Wide-Angle to Telephoto on a triple-lens system.
- Switching from Visual to Night-Vision (Thermal) for a search leg.
Data Fields (MAVLink)
param1(Instance): Camera instance number.param2(Primary): 0:No change, 1:RGB, 2:IR, 3:NDVI.param3(Secondary): Same as above.param4toparam7: Unused.
Theory: Sensor Fusion
In modern autonomous flight, the "Source" is not just a video feed; it defines the vehicle's Primary Intelligence Input.
- RGB: Used for photogrammetry and human monitoring.
- IR: Used for finding heat signatures (SAR) or hot-spots (Industrial Inspection).
- The Switch:
SET_CAMERA_SOURCEallows a single drone to perform two missions in one flight by reconfiguring its brain for the task at hand.
Practical Use Cases
- Thermal Inspection:
- Scenario: Inspecting high-voltage lines.
- Action: Mission flies to the pole.
SET_CAMERA_SOURCE (IR)is used to check for heat, thenSET_CAMERA_SOURCE (RGB)is used to take high-res visual confirmation of the hardware.
- Multi-Spectrally Survey:
- Scenario: Mapping a field for crop health.
- Action: Mission alternates sources to capture both RGB and NDVI (Normalized Difference Vegetation Index) data.
Key Parameters
CAM_TYPE: Selection of camera hardware.
Key Codebase Locations
- libraries/AP_Camera/AP_Camera.cpp:329: Logic for multi-sensor switching.
Summary
The IMAGE_START_CAPTURE and IMAGE_STOP_CAPTURE commands provide precise control over high-resolution still image acquisition. They support single-shot, interval-based (time), and burst-based capture modes, making them the standard choice for professional survey and reconnaissance missions.
Status
Supported (All Vehicles with AP_Camera enabled)
Directionality
- RX (Receive): The vehicle receives this command as part of a mission upload or as a direct command.
Mission Storage (AP_Mission)
- Instance (Param 1): The target camera (1-6). 0 for "All."
- Interval (Param 2): Time between shots in seconds.
- Total Images (Param 3): Number of images to take. 0 for "Continuous/Unlimited."
- Start Seq (Param 4): Sequence number for the first image (often ignored by ArduPilot storage).
- Packing: Stored in the
image_start_capturecontent struct.
Execution (Engineer's View)
Capture Logic
Execution is handled by AP_Camera (AP_Camera.cpp).
- Single vs. Multiple:
- If
Param 3 = 1, ArduPilot triggers a singletake_picture()event. - If
Param 3 > 1or0, it initializes a timer-based looptake_multiple_pictures().
- If
- Hardware Handshake: For MAVLink-enabled cameras (e.g., Sony Airpeak or specialized gimbals), the autopilot sends the
IMAGE_START_CAPTUREpacket down the bus to the camera. For simple cameras, it uses the Relay/PWM shutter trigger. - Termination:
IMAGE_STOP_CAPTURE(2001) instantly kills any running timers and sends a "Stop" packet to MAVLink backends.
Data Fields (MAVLink)
param1(ID): Camera ID.param2(Interval): s.param3(Total): Count.param4(Seq): Start number.
Theory: The Data Pipeline
Still images capture significantly more detail than video frames because they use the sensor's full resolution without compression artifacts.
- Storage Bandwidth: Capturing 42MP images every 1.5 seconds requires a high-speed UHS-II SD card. ArduPilot's mission engine handles the triggering, but the camera backend manages the actual file I/O.
- Feedback: ArduPilot listens for
CAMERA_IMAGE_CAPTUREDmessages from smart backends to log the precise GPS coordinate where each image was actually written to disk.
Practical Use Cases
- High-Res Photogrammetry:
- Scenario: Mapping a construction site.
- Action:
IMAGE_START_CAPTURE (Interval: 2s, Total: 0). The drone flies the grid, snapping every 2 seconds until the mission ends.
- Point of Interest Burst:
- Scenario: Inspecting a cracked turbine blade.
- Action: Mission hovers at the blade.
IMAGE_START_CAPTURE (Interval: 0.5s, Total: 10). The drone captures 10 high-speed shots to ensure a clear image is obtained despite vibration.
Key Parameters
CAM_TRIGG_TYPE: Defines the physical trigger method.CAM_FEEDBACK_PIN: Used to log image coordinates from a camera's "Hot Shoe" signal.
Key Codebase Locations
- libraries/AP_Camera/AP_Camera.cpp:350: Still image capture handler.
- libraries/AP_Camera/AP_Camera_MAVLink.cpp: MAVLink camera bridge.
Summary
The VIDEO_START_CAPTURE and VIDEO_STOP_CAPTURE commands control the recording state of onboard video sensors. They allow a mission to automatically record only the segments of flight that are relevant to the objective, saving storage space and power.
Status
Supported (All Vehicles with AP_Camera enabled)
Directionality
- RX (Receive): The vehicle receives this command as part of a mission upload or as a direct command.
Mission Storage (AP_Mission)
- Stream ID (Param 1): The target video stream or camera instance.
- Packing: Stored in the
video_start_capturecontent struct.
Execution (Engineer's View)
Recording Logic
Execution is handled by AP_Camera::record_video (AP_Camera.cpp).
- Direct Control: If the camera is a simple GoPro-style camera triggered via a PWM signal, ArduPilot moves the servo/pin to the "Record" position.
- MAVLink Control: For high-end cameras (e.g., DJI, Sony), ArduPilot sends the standard MAVLink command to the camera's component ID.
- Conflict Management: If a "Start" is commanded while the camera is already recording, ArduPilot typically ignores the second command to prevent file corruption.
Data Fields (MAVLink)
param1(ID): Video stream/camera ID.param2(Freq): Record frequency (FPS). Typically ignored (set in camera menu).param3toparam7: Unused.
Theory: Bandwidth vs. Detail
Video recording is a continuous energy drain on both the battery and the onboard processor.
- The Overload: Modern 4K/60fps video generates significant electromagnetic interference (EMI).
- Autonomous Recording: By using mission commands to start recording after the takeoff and stop before the landing, the pilot minimizes the noise exposure during the most critical flight phases (where GPS/Compass health is most vital).
Practical Use Cases
- Evidence Collection:
- Scenario: A security drone patrolling a site.
- Action:
WAYPOINT (Start of Patrol)->VIDEO_START_CAPTURE. The drone records the entire patrol leg and stops once it begins its return-to-launch.
- Cinematic Reveal:
- Scenario: A drone flying a specific path for a film shot.
- Action:
VIDEO_START_CAPTUREis triggered precisely at the start of the camera movement.
Key Parameters
CAM_TYPE: Selection of camera hardware.
Key Codebase Locations
- libraries/AP_Camera/AP_Camera.cpp:411: Implementation of video recording logic.
- libraries/AP_Camera/AP_Camera_Gopro.cpp: Specialized GoPro control.