Simple MAVLink Cameras (Camera Protcol v1)
This topic explains how to use PX4 with a MAVLink camera that implements the Camera Protocol v1 (Simple Trigger Protocol) with PX4 and a Ground Station.
WARNING
MAVLink cameras that use the MAVLink Camera Protocol v2 should be used instead when possible! This approach is retained for use with older MAVLink cameras.
개요
Camera Protocol v1 defines a small set of commands that allow triggering of a camera for:
- still image capture at a frequency based on either time or distance
- video capture
- limited camera configuration
PX4 supports this command set for triggering cameras with native support for the protocol (as described in this topic), and also for cameras attached to flight controller outputs.
Ground stations and MAVLink SDKs generally address camera commands to the autopilot, which then forwards them to a connected MAVLink channel of type onboard
. PX4 also re-emits any camera mission items it encouters in a mission as camera commands: commands that aren't accepted are logged. In all cases the commands are sent with the system id of the autopilot and the component ID of 0 (i.e. addressed to all components, including cameras).
PX4 will also emit a CAMERA_TRIGGER whenever an image capture is triggered (the camera itself may also emit this message on triggering).
Controlling the Camera
MAVLink Commands & Messages
The Camera Protocol v1 (Simple Trigger Protocol) defines the following commands:
- MAV_CMD_DO_TRIGGER_CONTROL
- MAV_CMD_NAV_CMD_DO_DIGICAM_CONTROL
- MAV_CMD_DO_SET_CAM_TRIGG_DIST
- MAV_CMD_DO_SET_CAM_TRIGG_INTERVAL
- MAV_CMD_OBLIQUE_SURVEY
- MAV_CMD_DO_CONTROL_VIDEO
A MAVLink camera will support some subset of these commands. As the protocol has no feature discovery process, the only way to know is by inspecting the COMMAND_ACK returned in response.
Cameras should also emit CAMERA_TRIGGER each time an image is captured.
Camera Protocol v1 describes the protocol in more detail.
Ground Stations
Ground stations can use any commands in the Camera Protocol v1 (Simple Trigger Protocol) and should address them to the autopilot component id. If the commands are not supported by the camera, it will return a COMMAND_ACK with an error result.
Generally the commands are addressed to the autopilot, because this works whether the camera is connected via MAVLink or directly to the flight controller. If addressed to the autopilot PX4 will emit CAMERA_TRIGGER each time an image is captured, and may log the camera capture event.
In theory you might also address commands to the camera directly.
Camera Commands in Missions
The following Camera Protocol v1 (Simple Trigger Protocol) commands can be used in missions (this is the same list as above).
- MAV_CMD_DO_TRIGGER_CONTROL
- MAV_CMD_NAV_CMD_DO_DIGICAM_CONTROL
- MAV_CMD_DO_SET_CAM_TRIGG_DIST
- MAV_CMD_DO_SET_CAM_TRIGG_INTERVAL
- MAV_CMD_OBLIQUE_SURVEY
- MAV_CMD_DO_CONTROL_VIDEO
PX4 re-emits them with the same system ID as the autopilot and component ID of MAV_COMP_ID_ALL:
Manual Control
Manual triggering using these cameras is not supported (for either Joystick or RC Controllers).
PX4 설정
MAVLink Port & Forwarding Configuration
Connect PX4 to your MAVLink camera by attaching it to an unused serial port on your flight controller, such as TELEM2
. You can then configure the port as a MAVLink Peripheral. The document explains how, but in summary:
- Modify an unused
MAV_n_CONFIG
parameter, such as MAV_2_CONFIG, so that it is assigned to port to which your camera is connected. - Set the corresponding MAV_2_MODE to
2
(Onboard). This ensures that the right set of MAVLink messages are emitted and forwarded. - You may need to set some of the other parameters, depending on your connection - such as the baud rate.
Then connect and configure the camera as recommended in its user guide.
Camera Mode & Triggering
Configure the PX4 camera driver to enable the MAVLink camera backend, and set the triggering mode to capture on command in survey missions.
Using QGroundControl:
Open Vehicle Setup > Camera.
Set the values as shown:
INFO
You can also set the parameters directly:
- TRIG_MODE —
4
: Distance based, on command (Survey mode) - TRIG_INTERFACE —
3
: MAVLink