mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-03 14:48:54 +08:00
Move PX4 Guide source into /docs (#24490)
* Add vitepress tree * Update existing workflows so they dont trigger on changes in the docs path * Add nojekyll, package.json, LICENCE etc * Add crowdin docs upload/download scripts * Add docs flaw checker workflows * Used docs prefix for docs workflows * Crowdin obvious fixes * ci: docs move to self hosted runner runs on a beefy server for faster builds Signed-off-by: Ramon Roche <mrpollo@gmail.com> * ci: don't run build action for docs or ci changes Signed-off-by: Ramon Roche <mrpollo@gmail.com> * ci: update runners Signed-off-by: Ramon Roche <mrpollo@gmail.com> * Add docs/en * Add docs assets and scripts * Fix up editlinks to point to PX4 sources * Download just the translations that are supported * Add translation sources for zh, uk, ko * Update latest tranlsation and uorb graphs * update vitepress to latest --------- Signed-off-by: Ramon Roche <mrpollo@gmail.com> Co-authored-by: Ramon Roche <mrpollo@gmail.com>
This commit is contained in:
co-authored by
Ramon Roche
parent
8e6d2ebe4a
commit
88d623bedb
@@ -0,0 +1,113 @@
|
||||
# PX4 Camera Architecture/Integration
|
||||
|
||||
This topic provides a brief overview of how PX4 camera support is **implemented**.
|
||||
|
||||
::: info
|
||||
See [Camera](../camera/index.md) for information about _using_ cameras.
|
||||
:::
|
||||
|
||||
## Overview
|
||||
|
||||
PX4 integrates with three types of cameras:
|
||||
|
||||
- [MAVLink cameras](../camera/mavlink_v2_camera.md) that support the [Camera Protocol v2](https://mavlink.io/en/services/camera.html) (**RECOMMENDED**).
|
||||
- [Simple MAVLink cameras](../camera/mavlink_v1_camera.md) that support the older [Camera Protocol v1](https://mavlink.io/en/services/camera.html).
|
||||
- [Cameras attached to flight controller outputs](../camera/fc_connected_camera.md), which are controlled using the [Camera Protocol v1](https://mavlink.io/en/services/camera.html).
|
||||
|
||||
All of these cameras need to respond to MAVLink commands received over MAVLink or found in missions (the specific protocol depends on the camera).
|
||||
|
||||
The broad architecture used is described below.
|
||||
|
||||
## MAVLink Cameras (Camera Protocol v2)
|
||||
|
||||
PX4 does not have specific handling for [MAVLink cameras](../camera/mavlink_v2_camera.md) that support the [Camera Protocol v2](https://mavlink.io/en/services/camera.html), other than [re-emitting camera items in missions as commands](#camera-commands-in-missions)
|
||||
|
||||
Ground stations are expected to communicate with these cameras directly in order to send commands.
|
||||
PX4 must be configured to route MAVLink traffic between the camera and ground stations if needed.
|
||||
|
||||
::: info
|
||||
The `camera_trigger`, `camera_capture` and `camera_feedback` modules are not used with this camera.
|
||||
:::
|
||||
|
||||
## FC-connected Cameras
|
||||
|
||||
[Cameras attached to flight controller outputs](../camera/fc_connected_camera.md) need PX4 to activate the outputs to trigger the camera, and may need PX4 to detect when a [camera capture pin](../camera/fc_connected_camera.md#camera-capture-configuration) has been triggered by the camera hotshoe (in order to improve the logged camera-capture time).
|
||||
|
||||
This work is handled by three PX4 components: [`camera_trigger` driver](https://github.com/PX4/PX4-Autopilot/tree/main/src/drivers/camera_trigger), [`camera_capture` driver](https://github.com/PX4/PX4-Autopilot/tree/main/src/drivers/camera_capture), [`camera-feedback` module](../modules/modules_system.md#camera-feedback).
|
||||
|
||||
`camera_trigger` subscribes to the [VehicleCommand](../msg_docs/VehicleCommand.md) topic and monitors for updates to its [supported commands](../camera/fc_connected_camera.md#mavlink-command-interface).
|
||||
Thes updates occur when either a command is received via MAVLink or when a [camera item is reached in a mission](#camera-commands-in-missions).
|
||||
|
||||
The commands enable and disable triggering, and configure triggering at time and distance intervals.
|
||||
The driver tracks these intervals, and when needed triggers the outputs.
|
||||
The driver publishes a [CameraTrigger](../msg_docs/CameraTrigger.md) topic (with `feedback` field set to `false`) that causes a [CAMERA_TRIGGER](https://mavlink.io/en/messages/common.html#CAMERA_TRIGGER) MAVLink message to be emitted.
|
||||
|
||||
The `camera_capture` driver, if enabled, monitors the camera capture pin and on triggering publishes a [CameraTrigger](../msg_docs/CameraTrigger.md) topic (with `feedback` field set to `true`) which also causes a [CAMERA_TRIGGER](https://mavlink.io/en/messages/common.html#CAMERA_TRIGGER) MAVLink message to be emitted.
|
||||
|
||||
The `camera_feedback` module monitors for updates to the [CameraTrigger](../msg_docs/CameraTrigger.md) topic, and publishes a [CameraCapture](../msg_docs/CameraCapture.md) topic for `CameraTrigger` updates from _either_ `camera_trigger` or `camera_capture`.
|
||||
The information that is used depends on whether the camera capture pin is enabled and the value is of the `CameraTrigger.feedback` field.
|
||||
This `CameraCapture` topic is logged, and can be used to get the time of the capture.
|
||||
|
||||
## MAVLink Cameras (Camera Protocol v1)
|
||||
|
||||
[MAVLink cameras that support the older Camera Protocol v1](../camera/mavlink_v1_camera.md) are integrated in much the same way as [FC-connected cameras](#fc-connected-cameras).
|
||||
|
||||
`camera_trigger` subscribes to the [VehicleCommand](../msg_docs/VehicleCommand.md) topic and monitors for updates in the [commands it supports](../camera/fc_connected_camera.md#mavlink-command-interface).
|
||||
This happens when either a command is received via MAVLink or when a [camera item is found in a missions](#camera-commands-in-missions).
|
||||
|
||||
The commands enable and disable triggering, and configure triggering at time and distance intervals.
|
||||
The driver tracks these intervals, but with the "MAVLink backend" does not need to actually trigger any outputs (since the commands are forwarded to the camera).
|
||||
When the camera would trigger the driver publishes a [CameraTrigger](../msg_docs/CameraTrigger.md) topic (with `feedback` field set to `false`) that causes a [CAMERA_TRIGGER](https://mavlink.io/en/messages/common.html#CAMERA_TRIGGER) MAVLink message to be emitted.
|
||||
The `camera_feedback` module should then log a corresponding `CameraCapture` topic.
|
||||
|
||||
## Camera Commands in Missions
|
||||
|
||||
PX4 re-emits camera items found in missions as MAVLink commands for all supported [Camera Protocol v2](https://mavlink.io/en/services/camera.html) and [Camera Protocol v1](https://mavlink.io/en/services/camera.html) commands.
|
||||
The system id of the emitted commands is the same as the ID of the autopilot.
|
||||
The component id of the commands can vary, but these are usually sent to either [MAV_COMP_ID_CAMERA (100)](https://mavlink.io/en/messages/common.html#MAV_COMP_ID_CAMERA) or [MAV_COMP_ID_ALL](https://mavlink.io/en/messages/common.html#MAV_COMP_ID_ALL) (see the individual camera documents for what ID is used in each case).
|
||||
|
||||
The commands are emitted irrespective of whether or not there is a connected camera of any type, provided there is a MAVLink channel to emit to.
|
||||
|
||||
::: info
|
||||
More generally PX4 re-emits all mission commands that may be consumed by external MAVLink components, such as gimbals.
|
||||
Commands for waypoints and conditional behaviour are not emitted.
|
||||
:::
|
||||
|
||||
The sections below highlight interesting parts of the codebase
|
||||
|
||||
### Commands supported in missions
|
||||
|
||||
Commands supported in missions, including camera commands, are shown in these methods:
|
||||
|
||||
- [`bool FeasibilityChecker::checkMissionItemValidity(mission_item_s &mission_item, const int current_index)`](https://github.com/PX4/PX4-Autopilot/blob/main/src/modules/navigator/MissionFeasibility/FeasibilityChecker.cpp#L257-L306)
|
||||
- [`format_mavlink_mission_item()`](https://github.com/PX4/PX4-Autopilot/blob/main/src/modules/mavlink/mavlink_mission.cpp#L1672-L1693)
|
||||
|
||||
### Flow for re-emitting camera commands found in missions
|
||||
|
||||
- [`void Mission::setActiveMissionItems()`](https://github.com/PX4/PX4-Autopilot/blob/main/src/modules/navigator/mission.cpp#L187-L281)
|
||||
- Mission items are executed when set active.
|
||||
- `issue_command(_mission_item)` is called at the end of this to send the current non-waypoint command
|
||||
- [`MissionBlock::issue_command(const mission_item_s &item)`](https://github.com/PX4/PX4-Autopilot/blob/main/src/modules/navigator/mission_block.cpp#L543-L562)
|
||||
- Creates a vehicle command for the mission item then calls `publish_vehicle_cmd` to publish it (`_navigator->publish_vehicle_cmd(&vcmd);`)
|
||||
- [`void Navigator::publish_vehicle_cmd(vehicle_command_s *vcmd)`](https://github.com/PX4/PX4-Autopilot/blob/main/src/modules/navigator/navigator_main.cpp#L1358)
|
||||
- For some camera commands it sets the component ID to the camera component id (`vcmd->target_component = 100; // MAV_COMP_ID_CAMERA`)
|
||||
- All others just get published to default component ID.
|
||||
- The `VehicleCommand` UORB topic is published.
|
||||
|
||||
The MAVLink streaming code monitors for changes to the `VehicleCommand` topic and publishes them over MAVLink.
|
||||
The MAVLink command is sent irrespective of whether the camera is a MAVLink camera, or connected to the flight controller.
|
||||
|
||||
The `camera_trigger` driver, if enabled, also monitors for changes to the `VehicleCommand`.
|
||||
If it is configured with a backend for a camera connected to the flight controller outputs, it will trigger those outputs appropriately.
|
||||
|
||||
## Logging
|
||||
|
||||
`CameraCapture` topics are logged when there is a `CameraTrigger` update.
|
||||
The logged topic will depend on whether or not the camera capture pin is enabled.
|
||||
|
||||
Note that camera capture events are not logged when using the [MAVLink cameras that support Camera Protocol v2](../camera/mavlink_v2_camera.md), because the corresponding trigger events are not generated within PX4.
|
||||
|
||||
## See Also
|
||||
|
||||
- Camera trigger driver: [source code](https://github.com/PX4/PX4-Autopilot/tree/main/src/drivers/camera_trigger) <!-- no module doc -->
|
||||
- Camera capture driver: [source code](https://github.com/PX4/PX4-Autopilot/tree/main/src/drivers/camera_capture) <!-- no module doc -->
|
||||
@@ -0,0 +1,32 @@
|
||||
# Intel® RealSense™ Tracking Camera T265 (VIO)
|
||||
|
||||
The [Intel® RealSense™ Tracking Camera T265](https://www.intelrealsense.com/tracking-camera-t265/) provides odometry information that can be used for [VIO](../computer_vision/visual_inertial_odometry.md), augmenting or replacing other positioning systems on PX4.
|
||||
|
||||
:::tip
|
||||
This camera is recommended, and is used in the [Visual Inertial Odometry (VIO) > Suggested Setup](../computer_vision/visual_inertial_odometry.md#suggested-setup).
|
||||
:::
|
||||
|
||||

|
||||
|
||||
## Where to Buy
|
||||
|
||||
[Intel® RealSense™ Tracking Camera T265](https://www.intelrealsense.com/tracking-camera-t265/) (store.intelrealsense.com)
|
||||
|
||||
## Setup Instructions
|
||||
|
||||
At a high level:
|
||||
|
||||
- The [`realsense-ros` wrapper](https://github.com/IntelRealSense/realsense-ros) provided by Intel should be used to extract the raw data from the camera.
|
||||
- The camera should be mounted with lenses facing down (default).
|
||||
Be sure to specify the camera orientation by publishing the static transform between the `base_link` and `camera_pose_frame` in a ROS launch file, for example:
|
||||
```xml
|
||||
<node pkg="tf" type="static_transform_publisher" name="tf_baseLink_cameraPose"
|
||||
args="0 0 0 0 1.5708 0 base_link camera_pose_frame 1000"/>
|
||||
```
|
||||
This is a static transform that links the camera ROS frame `camera_pose_frame` to the MAVROS drone frame `base_link`.
|
||||
- the first three `args` specify _translation_ x,y,z in metres from the center of the flight controller to the camera.
|
||||
For example, if the camera is 10cm in front of the controller and 4cm up, the first three numbers would be : [0.1, 0, 0.04,...]
|
||||
- the next three `args` specify rotation in radians (yaw, pitch, roll).
|
||||
So `[... 0, 1.5708, 0]` means pitch down by 90° (facing the ground). Facing straight forward would be [... 0 0 0].
|
||||
- The camera is sensitive to high-frequency vibrations!
|
||||
It should be soft-mounted with, for example, vibration isolation foam.
|
||||
@@ -0,0 +1,315 @@
|
||||
# Cameras Connected to Flight Controller Outputs
|
||||
|
||||
This topic explains how to use PX4 with a [camera](../camera/index.md) that is attached to flight controller outputs.
|
||||
|
||||
::: warning
|
||||
[MAVLink cameras](../camera/mavlink_v2_camera.md) that use the [MAVLink Camera Protocol v2](https://mavlink.io/en/services/camera.html) are recommended.
|
||||
:::
|
||||
|
||||
## Overview
|
||||
|
||||
PX4 can trigger a [camera](../camera/index.md) connected to flight controller outputs using [camera commands](#mavlink-command-interface) in missions or sent by a ground control stations.
|
||||
The supported commands are a subset of those defined in the MAVLink [Camera Protocol v1](https://mavlink.io/en/services/camera.html).
|
||||
|
||||
Whenever a camera is triggered, the MAVLink [CAMERA_TRIGGER](https://mavlink.io/en/messages/common.html#CAMERA_TRIGGER) message is published containing the current session's image _sequence number_ and the corresponding timestamp.
|
||||
This timestamp can be used for several purposes, including: timestamping photos for aerial surveying and reconstruction, synchronising a multi-camera system or visual-inertial navigation.
|
||||
|
||||
The camera can be connected to different outputs, including PWM outputs, GPIO outputs, and a Seagull MAP2 via PWM outputs.
|
||||
|
||||
Cameras can also (optionally) signal PX4 at the exact moment that a photo/frame is taken using a [camera capture pin](#camera-capture-configuration) that is attached to their hot shoe.
|
||||
This allows more precise mapping of images to GPS position for geotagging, or the right IMU sample for VIO synchronization, etc.
|
||||
|
||||
<!-- Camera trigger driver: https://github.com/PX4/PX4-Autopilot/tree/main/src/drivers/camera_trigger -->
|
||||
<!-- Camera capture driver: https://github.com/PX4/PX4-Autopilot/tree/main/src/drivers/camera_capture -->
|
||||
|
||||
## MAVLink Command Interface
|
||||
|
||||
PX4 supports the following MAVLink commands for FC-connected cameras, in both missions and if received from a GCS:
|
||||
|
||||
- [MAV_CMD_DO_SET_CAM_TRIGG_INTERVAL](#mav-cmd-do-set-cam-trigg-interval) — set time interval between captures.
|
||||
- [MAV_CMD_DO_SET_CAM_TRIGG_DIST](#mav-cmd-do-set-cam-trigg-dist) — set distance between captures
|
||||
- [MAV_CMD_DO_TRIGGER_CONTROL](#mav-cmd-do-trigger-control) — start/stop capturing (using distance or time, as defined using above messages).
|
||||
- [MAV_CMD_OBLIQUE_SURVEY](#mav-cmd-oblique-survey) — start/stop oblique survey
|
||||
- [MAV_CMD_DO_DIGICAM_CONTROL](#mav-cmd-do-digicam-control) — test-shoot the camera from the GCS.
|
||||
|
||||
The supported behaviour is listed below (these do not precisely match the MAVLink specification).
|
||||
|
||||
### MAV_CMD_DO_TRIGGER_CONTROL
|
||||
|
||||
[MAV_CMD_DO_TRIGGER_CONTROL](https://mavlink.io/en/messages/common.html#MAV_CMD_DO_TRIGGER_CONTROL) - Accepted in "command controlled" mode (`TRIG_MODE` 1).
|
||||
|
||||
| Command Parameter | Description |
|
||||
| ----------------- | -------------------------------------------------------------------------------------------------- |
|
||||
| Param #1 | Trigger enable/disable. `1`: enable (start), `0`: disable. |
|
||||
| Param #2 | Reset trigger sequence. `1`: reset, any other value does nothing. |
|
||||
| Param #3 | Pause triggering, but without switching the camera off or retracting it. `1`: pause, `0`: restart. |
|
||||
|
||||
<!-- https://github.com/PX4/PX4-Autopilot/blob/main/src/drivers/camera_trigger/camera_trigger.cpp#L549 -->
|
||||
|
||||
### MAV_CMD_DO_DIGICAM_CONTROL
|
||||
|
||||
[MAV_CMD_DO_DIGICAM_CONTROL](https://mavlink.io/en/messages/common.html#MAV_CMD_DO_DIGICAM_CONTROL) - Accepted in all modes.
|
||||
|
||||
This is used by the GCS to test-shoot the camera from the user interface.
|
||||
The trigger driver does not support all camera control parameters defined by the MAVLink spec.
|
||||
|
||||
| Command Parameter | Description |
|
||||
| ----------------- | -------------------------------------------------------------------- |
|
||||
| Param #5 | Trigger one-shot command (set to 1 to trigger a single image frame). |
|
||||
|
||||
### MAV_CMD_DO_SET_CAM_TRIGG_DIST
|
||||
|
||||
[MAV_CMD_DO_SET_CAM_TRIGG_DIST](https://mavlink.io/en/messages/common.html#MAV_CMD_DO_SET_CAM_TRIGG_DIST) - Accepted in "mission controlled" mode (`TRIG_MODE` 4)
|
||||
|
||||
This command is autogenerated during missions to trigger the camera based on survey missions from the GCS.
|
||||
|
||||
### MAV_CMD_DO_SET_CAM_TRIGG_INTERVAL
|
||||
|
||||
[MAV_CMD_DO_SET_CAM_TRIGG_INTERVAL](https://mavlink.io/en/messages/common.html#MAV_CMD_DO_SET_CAM_TRIGG_INTERVAL)
|
||||
|
||||
### MAV_CMD_OBLIQUE_SURVEY
|
||||
|
||||
[MAV_CMD_OBLIQUE_SURVEY](https://mavlink.io/en/messages/common.html#MAV_CMD_OBLIQUE_SURVEY) - Mission command to set a camera auto mount pivoting oblique survey.
|
||||
|
||||
This accepts `param1` to `param4` as defined in the MAVLink message definition.
|
||||
The shutter integration setting (`param2`) is only obeyed with a GPIO backend.
|
||||
|
||||
<!-- https://github.com/PX4/PX4-Autopilot/blob/main/src/drivers/camera_trigger/camera_trigger.cpp#L632 -->
|
||||
|
||||
## Trigger Configuration
|
||||
|
||||
Cameras can be connected to the FC for triggering using different intefaces, such as PWM, and GPIO, by specifying the appropriate [trigger interface backend](#trigger-interface-backends).
|
||||
You can also indicate the camera [trigger mode](#trigger-modes).
|
||||
|
||||
This configuration can most easily be done from the _QGroundControl_ [Vehicle Setup > Camera](https://docs.qgroundcontrol.com/master/en/qgc-user-guide/setup_view/camera.html#px4-camera-setup) section.
|
||||
|
||||

|
||||
|
||||
The different [trigger modes](#trigger-modes), [backend interfaces](#trigger-interface-backends) and [trigger output configuration](#trigger-output-pin-configuration) are described below (these can also be set directly from [parameters](../advanced_config/parameters.md)).
|
||||
|
||||
::: info
|
||||
The camera settings section is not available by default for FMUv2-based flight controllers (e.g. 3DR Pixhawk) because the camera module is not automatically included in firmware.
|
||||
For more information see [Finding/Updating Parameters > Parameters Not In Firmware](../advanced_config/parameters.md#parameter-not-in-firmware).
|
||||
:::
|
||||
|
||||
### Trigger Modes
|
||||
|
||||
Four different modes are supported, controlled by the [TRIG_MODE](../advanced_config/parameter_reference.md#TRIG_MODE) parameter:
|
||||
|
||||
| Mode | Description |
|
||||
| ---- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| 0 | Camera triggering is disabled. |
|
||||
| 1 | Works like a basic intervalometer that can be enabled and disabled by using the MAVLink command `MAV_CMD_DO_TRIGGER_CONTROL`. See [command interface](#mavlink-command-interface) for more details. |
|
||||
| 2 | Switches the intervalometer constantly on. |
|
||||
| 3 | Triggers based on distance. A shot is taken every time the set horizontal distance is exceeded. The minimum time interval between two shots is however limited by the set triggering interval. |
|
||||
| 4 | Triggers automatically when flying a survey in Mission mode. |
|
||||
|
||||
::: info
|
||||
If it is your first time enabling the camera trigger app, remember to reboot after changing the `TRIG_MODE` parameter.
|
||||
:::
|
||||
|
||||
### Trigger Interface Backends
|
||||
|
||||
The camera trigger driver supports several backends - each for a specific application, controlled by the [TRIG_INTERFACE](../advanced_config/parameter_reference.md#TRIG_INTERFACE) parameter:
|
||||
|
||||
| Number | Description |
|
||||
| ------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| 1 | Enables the GPIO interface. The AUX outputs are pulsed high or low (depending on the `TRIG_POLARITY` parameter) every [TRIG_INTERVAL](../advanced_config/parameter_reference.md#TRIG_INTERVAL) duration. This can be used to trigger most standard machine vision cameras directly. Note that on PX4FMU series hardware (Pixhawk, Pixracer, etc.), the signal level on the AUX pins is 3.3v. |
|
||||
| 2 | Enables the Seagull MAP2 interface. This allows the use of the [Seagull MAP2](http://www.seagulluav.com/product/seagull-map2/) to interface to a multitude of supported cameras. Pin/Channel 1 (camera trigger) and Pin/Channel 2 (mode selector) of the MAP2 should be connected to the lower and higher mapped [camera trigger pins](#trigger-output-pin-configuration). Using Seagull MAP2, PX4 also supports automatic power control and keep-alive functionalities of Sony Multiport cameras like the QX-1. |
|
||||
| 3 | This mode enables MAVLink cameras that used the legacy [MAVLink interface listed above](#mavlink-command-interface). The messages are automatically emitted on the MAVLink `onboard` channel when found in missions. PX4 emits the `CAMERA_TRIGGER` MAVLink message when a camera is triggered, by default to the `onboard` channel (if this is not used, custom stream will need to be enabled). [Simple MAVLink cameras](../camera/mavlink_v1_camera.md) explains this use case in more detail. |
|
||||
| 4 | Enables the generic PWM interface. This allows the use of [infrared triggers](https://hobbyking.com/en_us/universal-remote-control-infrared-shutter-ir-rc-1g.html) or servos to trigger your camera. |
|
||||
|
||||
### Trigger Output Pin Configuration
|
||||
|
||||
Camera trigger pins are set in the _QGroundControl_ [Actuators](../config/actuators.md) configuration screen.
|
||||
|
||||
The trigger pins can be set by assigning the `Camera_Trigger` function on any FMU output.
|
||||
If using trigger setup that requires two pins (e.g. Seagull MAP2) you can assign to any two outputs.
|
||||
|
||||
Note however that if a _PWM_ output has been used for camera triggering (such as Seagull MAP2), the whole PWM group cannot be used for anything else (you can't use another output in the group for an actuator, motor, or camera capture, because the timer has already been used).
|
||||
|
||||
::: info
|
||||
At time of writing triggering only works on FMU pins:
|
||||
|
||||
- On a Pixhawk flight controller that has both FMU and I/O boards FMU pins map to `AUX` outputs (e.g. Pixhawk 4, CUAV v5+) .
|
||||
- A controller that only has an FMU, the pins map to `MAIN` outputs (e.g. Pixhawk 4 mini, CUAV v5 nano).
|
||||
|
||||
:::
|
||||
|
||||
### Other Parameters
|
||||
|
||||
| Parameter | Description |
|
||||
| ------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| [TRIG_POLARITY](../advanced_config/parameter_reference.md#TRIG_POLARITY) | Relevant only while using the GPIO interface. Sets the polarity of the trigger pin. Active high means that the pin is pulled low normally and pulled high on a trigger event. Active low is vice-versa. |
|
||||
| [TRIG_INTERVAL](../advanced_config/parameter_reference.md#TRIG_INTERVAL) | Defines the time between two consecutive trigger events in milliseconds. |
|
||||
| [TRIG_ACT_TIME](../advanced_config/parameter_reference.md#TRIG_ACT_TIME) | Defines the time in milliseconds the trigger pin is held in the "active" state before returning to neutral. In PWM modes, the minimum is limited to 40 ms to make sure we always fit an activate pulse into the 50Hz PWM signal. |
|
||||
|
||||
The full list of parameters pertaining to the camera trigger module can be found on the [parameter reference](../advanced_config/parameter_reference.md#camera-trigger) page.
|
||||
|
||||
## Camera Capture Configuration
|
||||
|
||||
Cameras can also (optionally) use a camera capture pin to signal the exact moment when a photo/frame is taken.
|
||||
This allows more precise mapping of images to GPS position for geotagging, or the right IMU sample for VIO synchronization, etc.
|
||||
|
||||
Camera capture/feedback is enabled in PX4 by setting [CAM_CAP_FBACK = 1](../advanced_config/parameter_reference.md#CAM_CAP_FBACK).
|
||||
The pin used for camera capture is then set in the _QGroundControl_ [Actuators](../config/actuators.md) configuration screen by assigning the `Camera_Capture` function on any FMU output.
|
||||
|
||||
Note that if a _PWM output_ is used as a camera capture input, the whole PWM group cannot be used for anything else (you can't use another output in the group for an actuator, motor, or camera trigger, because the timer has already been used).
|
||||
|
||||
::: info
|
||||
At time of writing camera capture only works on FMU pins:
|
||||
|
||||
- On a Pixhawk flight controller that has both FMU and I/O boards FMU pins map to `AUX` outputs (e.g. Pixhawk 4, CUAV v5+).
|
||||
- A controller that only has an FMU, the pins map to `MAIN` outputs (e.g. Pixhawk 4 mini, CUAV v5 nano).
|
||||
|
||||
:::
|
||||
|
||||
PX4 detects a rising edge with the appropriate voltage level on the camera capture pin (for Pixhawk flight controllers this is normally 3.3V).
|
||||
If the camera isn't outputting an appropriate voltage, then additional circuitry will be required to make the signal compatible.
|
||||
|
||||
Cameras that have a hotshoe connector (for connecting a flash) can usually be connected via a hotshoe-adaptor.
|
||||
For example, the [Seagull #SYNC2 Universal Camera Hot Shoe Adapter](https://www.seagulluav.com/product/seagull-sync2/) is an optocoupler that decouples and shifts the flash voltage to the Pixhawk voltage.
|
||||
This slides into the flash slot on the top of the camera.
|
||||
The red and black ouptputs are connected to the servo rail/ground and the white wire is connected to the input capture pin.
|
||||
|
||||

|
||||
|
||||
::: info
|
||||
PX4 emits the MAVLink [CAMERA_TRIGGER](https://mavlink.io/en/messages/common.html#CAMERA_TRIGGER) message on both camera trigger and camera capture.
|
||||
If camera capture is configured, the timestamp from the camera capture driver is used, otherwise the triggering timestamp.
|
||||
:::
|
||||
|
||||
## Testing Trigger Functionality
|
||||
|
||||
:::warning
|
||||
The following sections are out of date and need retesting.
|
||||
:::
|
||||
|
||||
1. On the PX4 console:
|
||||
|
||||
```shell
|
||||
camera_trigger test
|
||||
```
|
||||
|
||||
1. From _QGroundControl_:
|
||||
|
||||
Click on **Trigger Camera** in the main instrument panel.
|
||||
These shots are not logged or counted for geotagging.
|
||||
|
||||

|
||||
|
||||
## Sony QX-1 example (Photogrammetry)
|
||||
|
||||

|
||||
|
||||
In this example, we will use a Seagull MAP2 trigger cable to interface to a Sony QX-1 and use the setup to create orthomosaics after flying a fully autonomous survey mission.
|
||||
|
||||
### Trigger Settings
|
||||
|
||||
The recommended camera settings are:
|
||||
|
||||
- `TRIG_INTERFACE=2` (Seagull MAP2).
|
||||
- `TRIG_MODE=4` (Mission controlled).
|
||||
- Leave the remaining parameters at their defaults.
|
||||
|
||||
You will need to connect the Seagull MAP2 to FMU pins on your autopilot.
|
||||
The other end of the MAP2 cable will go into the QX-1's "MULTI" port.
|
||||
|
||||
### Camera Configuration
|
||||
|
||||
We use a Sony QX-1 with a 16-50mm f3.5-5.6 lens for this example.
|
||||
|
||||
To avoid autofocus and metering lag when the camera is triggered, the following guidelines should be followed:
|
||||
|
||||
- Manual focus to infinity
|
||||
- Set camera to continuous shooting mode
|
||||
- Manually set exposure and aperture
|
||||
- ISO should be set as low as possible
|
||||
- Manual white balance suitable for scene
|
||||
|
||||
### Mission Planning
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
### Geotagging
|
||||
|
||||
Download/copy the logfile and images from the flight and point QGroundControl to them.
|
||||
Then click on **Start Tagging**.
|
||||
|
||||

|
||||
|
||||
You can verify the geotagging using a free online service like [Pic2Map](https://www.pic2map.com/).
|
||||
Note that Pic2Map is limited to only 40 images.
|
||||
|
||||
### Reconstruction
|
||||
|
||||
We use [Pix4D](https://pix4d.com/) for 3D reconstruction.
|
||||
|
||||

|
||||
|
||||
## Camera-IMU sync example (VIO)
|
||||
|
||||
In this example, we will go over the basics of synchronising IMU measurements with visual data to build a stereo Visual-Inertial Navigation System (VINS).
|
||||
To be clear, the idea here isn't to take an IMU measurement exactly at the same time as we take a picture but rather to correctly time stamp our images so as to provide accurate data to our VIO algorithm.
|
||||
|
||||
The autopilot and companion have different clock bases (boot-time for the autopilot and UNIX epoch for companion), so instead of skewing either clock, we directly observe the time offset between the clocks.
|
||||
This offset is added or subtracted from the timestamps in the MAVLink messages (e.g. `HIGHRES_IMU`) in the cross-middleware translator component (e.g. MAVROS on the companion and `mavlink_receiver` in PX4).
|
||||
The actual synchronisation algorithm is a modified version of the Network Time Protocol (NTP) algorithm and uses an exponential moving average to smooth the tracked time offset.
|
||||
This synchronisation is done automatically if MAVROS is used with a high-bandwidth onboard link (MAVLink mode `onboard`).
|
||||
|
||||
For acquiring synchronised image frames and inertial measurements, we connect the trigger inputs of the two cameras to a GPIO pin on the autopilot.
|
||||
The timestamp of the inertial measurement from start of exposure and a image sequence number is recorded and sent to the companion computer (`CAMERA_TRIGGER` message), which buffers these packets and the image frames acquired from the camera.
|
||||
They are matched based on the sequence number (first image frame is sequence 0), the images timestamped (with the timestamp from the `CAMERA_TRIGGER` message) and then published.
|
||||
|
||||
The following diagram illustrates the sequence of events which must happen in order to correctly timestamp our images.
|
||||
|
||||
[](https://mermaid.live/edit#pako:eNqNUs9rwjAU_lceOW-3nXIQpIoIVkftZIdCeTbPNqxJXJI6ivi_L1Er6Dzs9kK-H3lfviOrjCDGmaPvjnRFE4m1RVVogKXxBFbWjQezg_fPN-CQS0Xgel3Bj_QNKDxY40A6EEYTYOeNQi8rbNs-SkTS62g04DgkqMgi5EG2JguWUPR_vaoLSlh5CKAb63reGuMdoBbR96Zwz7kzvQylcrXjPDFKBe71BYnR3po2ClzhkXnZNR1vFlJ_cR6GMkkn5WRV5tl8NptmZbJa5tlqEXmtMXuYBtMe4m05X-bTbDNegJJtKx1VRgv3NIybQTJOp9l4EH94zGMY99ugmqcfa49q_zyER3aKvmpg-G3QndqS_R_17AJSYU3n9PfdNuzXFJq0YC8sgBVKEbp0jHoF8w0pKhgPo6Addq0vWKFPARp7sg4lYtzbjl5Ytxfoh-oxvsPW0ekXb8TjxQ)
|
||||
|
||||
<!-- Original
|
||||

|
||||
{/% mermaid %/}
|
||||
sequenceDiagram
|
||||
Note right of PX4 : Time sync with mavros is done automatically
|
||||
PX4 ->> mavros : Camera Trigger ready
|
||||
Note right of camera driver : Camera driver boots and is ready
|
||||
camera driver ->> mavros : mavros_msgs::CommandTriggerControl
|
||||
mavros ->> PX4 : MAVLink::MAV_CMD_DO_TRIGGER_CONTROL
|
||||
loop Every TRIG_INTERVAL milliseconds
|
||||
PX4 ->> mavros : MAVLink::CAMERA_TRIGGER
|
||||
mavros ->> camera driver : mavros_msgs::CamIMUStamp
|
||||
camera driver ->> camera driver : Match sequence number
|
||||
camera driver ->> camera driver : Stamp image and publish
|
||||
end
|
||||
{/% endmermaid %/}
|
||||
-->
|
||||
|
||||
### Step 1
|
||||
|
||||
First, set the TRIG_MODE to 1 to make the driver wait for the start command and reboot your FCU to obtain the remaining parameters.
|
||||
|
||||
### Step 2
|
||||
|
||||
For the purposes of this example we will be configuring the trigger to operate in conjunction with a Point Grey Firefly MV camera running at 30 FPS.
|
||||
|
||||
- `TRIG_INTERVAL`: 33.33 ms
|
||||
- `TRIG_POLARITY`: 0 (active low)
|
||||
- `TRIG_ACT_TIME`: 0.5 ms.
|
||||
The manual specifies it only has to be a minimum of 1 microsecond.
|
||||
- `TRIG_MODE`: 1, because we want our camera driver to be ready to receive images before starting to trigger.
|
||||
This is essential to properly process sequence numbers.
|
||||
|
||||
### Step 3
|
||||
|
||||
Wire up your cameras to your AUX port by connecting the ground and signal pins to the appropriate place.
|
||||
|
||||
### Step 4
|
||||
|
||||
You will have to modify your driver to follow the sequence diagram above.
|
||||
Public reference implementations for [IDS Imaging UEye](https://github.com/ProjectArtemis/ueye_cam) cameras and for [IEEE1394 compliant](https://github.com/andre-nguyen/camera1394) cameras are available.
|
||||
|
||||
## See Also
|
||||
|
||||
- Camera trigger driver: [source code](https://github.com/PX4/PX4-Autopilot/tree/main/src/drivers/camera_trigger) <!-- no module doc -->
|
||||
- Camera capture driver: [source code](https://github.com/PX4/PX4-Autopilot/tree/main/src/drivers/camera_capture) <!-- no module doc -->
|
||||
@@ -0,0 +1,20 @@
|
||||
# Cameras
|
||||
|
||||
Cameras are important for many [payload use cases](../payloads/use_cases.md), including mapping and surveying, surveillance, search & rescue, crop health and pest detection, and so on.
|
||||
They are commonly mounted on a [gimbal](../advanced/gimbal_control.md) that can provide camera stabilisation, point tracking, and movement independent of the hosting vehicle.
|
||||
|
||||
## Camera Types
|
||||
|
||||
PX4 integrates with three types of cameras:
|
||||
|
||||
- [MAVLink cameras](../camera/mavlink_v2_camera.md) that support the [Camera Protocol v2](https://mavlink.io/en/services/camera.html) (**RECOMMENDED**).
|
||||
- [Simple MAVLink cameras](../camera/mavlink_v1_camera.md) that support the older [Camera Protocol v1](https://mavlink.io/en/services/camera.html).
|
||||
- [Cameras attached to flight controller outputs](../camera/fc_connected_camera.md), which are controlled using the [Camera Protocol v1](https://mavlink.io/en/services/camera.html).
|
||||
|
||||
[MAVLink cameras](../camera/mavlink_v2_camera.md) are recommended because they provide the broadest access to camera features using a simple and consistent command/message set.
|
||||
If a camera does not support this prototol, a [camera manager](../camera/mavlink_v2_camera.md#camera-managers) running on a companion computer can be used to interface between MAVLink and the camera's native protocol.
|
||||
|
||||
## See Also
|
||||
|
||||
- [Gimbal (Camera Mount)](../advanced/gimbal_control.md)
|
||||
- [Camera Integration/Architecture](../camera/camera_architecture.md) (PX4 Developers)
|
||||
@@ -0,0 +1,115 @@
|
||||
# Simple MAVLink Cameras (Camera Protcol v1)
|
||||
|
||||
This topic explains how to use PX4 with a MAVLink [camera](../camera/index.md) that implements the [Camera Protocol v1 (Simple Trigger Protocol)](https://mavlink.io/en/services/camera_v1.html) with PX4 and a Ground Station.
|
||||
|
||||
::: warning
|
||||
[MAVLink cameras](../camera/mavlink_v2_camera.md) that use the [MAVLink Camera Protocol v2](https://mavlink.io/en/services/camera.html) should be used instead when possible!
|
||||
This approach is retained for use with older MAVLink cameras.
|
||||
:::
|
||||
|
||||
## Overview
|
||||
|
||||
[Camera Protocol v1](https://mavlink.io/en/services/camera_v1.html) 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](../camera/fc_connected_camera.md).
|
||||
|
||||
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](https://mavlink.io/en/messages/common.html#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)](https://mavlink.io/en/services/camera_v1.html) defines the following commands:
|
||||
|
||||
- [MAV_CMD_DO_TRIGGER_CONTROL](https://mavlink.io/en/messages/common.html#MAV_CMD_DO_TRIGGER_CONTROL)
|
||||
- [MAV_CMD_NAV_CMD_DO_DIGICAM_CONTROL](https://mavlink.io/en/messages/common.html#MAV_CMD_NAV_CMD_DO_DIGICAM_CONTROL)
|
||||
- [MAV_CMD_DO_SET_CAM_TRIGG_DIST](https://mavlink.io/en/messages/common.html#MAV_CMD_DO_SET_CAM_TRIGG_DIST)
|
||||
- [MAV_CMD_DO_SET_CAM_TRIGG_INTERVAL](https://mavlink.io/en/messages/common.html#MAV_CMD_DO_SET_CAM_TRIGG_INTERVAL)
|
||||
- [MAV_CMD_OBLIQUE_SURVEY](https://mavlink.io/en/messages/common.html#MAV_CMD_OBLIQUE_SURVEY)
|
||||
- [MAV_CMD_DO_CONTROL_VIDEO](https://mavlink.io/en/messages/common.html#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](https://mavlink.io/en/messages/common.html#COMMAND_ACK) returned in response.
|
||||
|
||||
Cameras should also emit [CAMERA_TRIGGER](https://mavlink.io/en/messages/common.html#CAMERA_TRIGGER) each time an image is captured.
|
||||
|
||||
[Camera Protocol v1](https://mavlink.io/en/services/camera_v1.html) describes the protocol in more detail.
|
||||
|
||||
### Ground Stations
|
||||
|
||||
Ground stations can use any commands in the [Camera Protocol v1 (Simple Trigger Protocol)](https://mavlink.io/en/services/camera_v1.html) and should address them to the autopilot component id.
|
||||
If the commands are not supported by the camera, it will return a [COMMAND_ACK](https://mavlink.io/en/messages/common.html#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](https://mavlink.io/en/messages/common.html#CAMERA_TRIGGER) each time an image is captured, and may log the camera capture event.
|
||||
|
||||
<!-- "May" because the camera feedback module is "supposed" to log just camera capture from a capture pin connected to camera hotshoe, but currently logs all camera trigger events from the camera trigger driver https://github.com/PX4/PX4-Autopilot/pull/23103 -->
|
||||
|
||||
In theory you might also address commands to the camera directly.
|
||||
|
||||
### Camera Commands in Missions
|
||||
|
||||
The following [Camera Protocol v1 (Simple Trigger Protocol)](https://mavlink.io/en/services/camera_v1.html) commands can be used in missions (this is the same list as above).
|
||||
|
||||
- [MAV_CMD_DO_TRIGGER_CONTROL](https://mavlink.io/en/messages/common.html#MAV_CMD_DO_TRIGGER_CONTROL)
|
||||
- [MAV_CMD_NAV_CMD_DO_DIGICAM_CONTROL](https://mavlink.io/en/messages/common.html#MAV_CMD_NAV_CMD_DO_DIGICAM_CONTROL)
|
||||
- [MAV_CMD_DO_SET_CAM_TRIGG_DIST](https://mavlink.io/en/messages/common.html#MAV_CMD_DO_SET_CAM_TRIGG_DIST)
|
||||
- [MAV_CMD_DO_SET_CAM_TRIGG_INTERVAL](https://mavlink.io/en/messages/common.html#MAV_CMD_DO_SET_CAM_TRIGG_INTERVAL)
|
||||
- [MAV_CMD_OBLIQUE_SURVEY](https://mavlink.io/en/messages/common.html#MAV_CMD_OBLIQUE_SURVEY)
|
||||
- [MAV_CMD_DO_CONTROL_VIDEO](https://mavlink.io/en/messages/common.html#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](https://mavlink.io/en/messages/common.html#MAV_COMP_ID_ALL):
|
||||
|
||||
<!-- See camera_architecture.md topic for detail on how this is implemented -->
|
||||
|
||||
### Manual Control
|
||||
|
||||
Manual triggering using these cameras is not supported (for either Joystick or RC Controllers).
|
||||
|
||||
## PX4 Configuration
|
||||
|
||||
<!-- set up the mode and triggering -->
|
||||
|
||||
### 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](../peripherals/mavlink_peripherals.md).
|
||||
The document explains how, but in summary:
|
||||
|
||||
1. Modify an unused `MAV_n_CONFIG` parameter, such as [MAV_2_CONFIG](../advanced_config/parameter_reference.md#MAV_2_CONFIG), so that it is assigned to port to which your camera is connected.
|
||||
1. Set the corresponding [MAV_2_MODE](../advanced_config/parameter_reference.md#MAV_2_MODE) to `2` (Onboard).
|
||||
This ensures that the right set of MAVLink messages are emitted and forwarded.
|
||||
1. 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.
|
||||
|
||||
<!-- Removed this because I am pretty sure forwarding happens automatically for this set. Keeping it simple.
|
||||
1. Set [MAV_2_FORWARD](../advanced_config/parameter_reference.md#MAV_2_FORWARD) if you want to enable forwarding of MAVLink messages to other ports, such as the one that is connected to the ground station.
|
||||
-->
|
||||
|
||||
### 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](https://docs.qgroundcontrol.com/master/en/qgc-user-guide/setup_view/camera.html#px4-camera-setup).
|
||||
- Set the values as shown:
|
||||
|
||||

|
||||
|
||||
::: info
|
||||
You can also [set the parameters directly](../advanced_config/parameters.md):
|
||||
|
||||
- [TRIG_MODE](../advanced_config/parameter_reference.md#TRIG_MODE) — `4`: Distance based, on command (Survey mode)
|
||||
- [TRIG_INTERFACE](../advanced_config/parameter_reference.md#TRIG_INTERFACE) — `3`: MAVLink
|
||||
|
||||
:::
|
||||
@@ -0,0 +1,154 @@
|
||||
# MAVLink Cameras (Camera Protocol v2)
|
||||
|
||||
This topic explains how to use PX4 with a MAVLink [camera](../camera/index.md) that implements the [MAVLink Camera Protocol v2](https://mavlink.io/en/services/camera.html) with PX4 and a Ground Station.
|
||||
|
||||
::: tip
|
||||
This is the recommended way to integrate a camera with PX4!
|
||||
:::
|
||||
|
||||
## Overview
|
||||
|
||||
The [MAVLink Camera Protocol v2](https://mavlink.io/en/services/camera.html) allows querying of what features are supported by a camera, and provides commands to control image and video capture, stream video, set zoom and focus, select between infrared and visible light feeds, set where captured data is saved, and so on.
|
||||
|
||||
A camera may implement the protocol natively, but most MAVLink camera setups involve PX4 communicating with a [camera manager](#camera-managers) running on a companion computer, which then interfaces between MAVLink and the camera's native protocol.
|
||||
|
||||
Generally speaking PX4's "integration" with a camera is to re-emit camera commands found in missions using the command protocol.
|
||||
Otherwise it may act as a bridge, forwarding commands between a ground station and the camera if there is no direct MAVLink channel.
|
||||
|
||||
::: info
|
||||
PX4 does not support using [MAVLink Camera Protocol v2](https://mavlink.io/en/services/camera.html) commands to control cameras that are attached to flight controller outputs.
|
||||
While this is technically possible, it would require PX4 to implement a camera manager interface.
|
||||
:::
|
||||
|
||||
## Controlling the Camera
|
||||
|
||||
### MAVLink Commands & Messages
|
||||
|
||||
Cameras are discovered using the MAVLink [connection protocol](https://mavlink.io/en/services/heartbeat.html), based on their [HEARTBEAT.type](https://mavlink.io/en/messages/common.html#HEARTBEAT) being set to [MAV_TYPE_CAMERA](https://mavlink.io/en/messages/common.html#MAV_TYPE_CAMERA).
|
||||
|
||||
::: tip
|
||||
Cameras should also use a component ID in the recommended range, such as [MAV_COMP_ID_CAMERA](https://mavlink.io/en/messages/common.html#MAV_COMP_ID_CAMERA), but generally this cannot be relied on to verify that a MAVLink component is a camera.
|
||||
:::
|
||||
|
||||
Once a camera is discovered its properties and capabilities can be queried by using [MAV_CMD_REQUEST_MESSAGE](https://mavlink.io/en/messages/common.html#MAV_CMD_REQUEST_MESSAGE) to request the [CAMERA_INFORMATION](https://mavlink.io/en/messages/common.html#CAMERA_INFORMATION) message, and then inspecting the `flags` field to determine what standard features in [CAMERA_CAP_FLAGS](https://mavlink.io/en/messages/common.html#CAMERA_CAP_FLAGS) are supported.
|
||||
|
||||
Based on the flags, you can determine what other commands and messages are supported by the camera.
|
||||
The full set of messages, commands, and enums are [summarised here](https://mavlink.io/en/services/camera.html#messagecommandenum-summary).
|
||||
|
||||
Additional parameters of a camera _may_ be exposed in a [camera definition file](https://mavlink.io/en/services/camera_def.html) that is linked from `CAMERA_INFORMATION.cam_definition_uri`.
|
||||
A GCS or SDK can expose these settings though a generic UI, without having to understand any context.
|
||||
These parameters cannot directly be set in missions and have no specific setter commands.
|
||||
|
||||
[MAVLink Camera Protocol v2](https://mavlink.io/en/services/camera.html) describes all the interactions in more detail.
|
||||
|
||||
### Ground Stations & MAVLink SDKS
|
||||
|
||||
Ground stations and MAVLink SDKs discover cameras and their capabilities as described in the previous section.
|
||||
|
||||
A ground station can use any feature exposed by the camera.
|
||||
PX4 has no role in this interaction other than forwarding MAVLink traffic between the camera and ground station or SDK, if needed.
|
||||
|
||||
### Camera Commands in Missions
|
||||
|
||||
PX4 allows the following subset of [Camera Protocol v2](https://mavlink.io/en/services/camera.html) commands in missions:
|
||||
|
||||
- [MAV_CMD_IMAGE_START_CAPTURE](https://mavlink.io/en/messages/common.html#MAV_CMD_IMAGE_START_CAPTURE)
|
||||
- [MAV_CMD_IMAGE_STOP_CAPTURE](https://mavlink.io/en/messages/common.html#MMAV_CMD_IMAGE_STOP_CAPTURE)
|
||||
- [MAV_CMD_VIDEO_START_CAPTURE](https://mavlink.io/en/messages/common.html#MAV_CMD_VIDEO_START_CAPTURE)
|
||||
- [MAV_CMD_VIDEO_STOP_CAPTURE](https://mavlink.io/en/messages/common.html#MAV_CMD_VIDEO_STOP_CAPTURE)
|
||||
- [MAV_CMD_SET_CAMERA_MODE](https://mavlink.io/en/messages/common.html#MAV_CMD_SET_CAMERA_MODE)
|
||||
- [MAV_CMD_SET_CAMERA_ZOOM](https://mavlink.io/en/messages/common.html#MAV_CMD_SET_CAMERA_ZOOM)
|
||||
- [MAV_CMD_SET_CAMERA_FOCUS](https://mavlink.io/en/messages/common.html#MAV_CMD_SET_CAMERA_FOCUS)
|
||||
|
||||
PX4 re-emits the camera commands found in missions as MAVLink commands.
|
||||
The system id of the emitted commands is the same as the ID of the autopilot.
|
||||
The component id of the commands can vary.
|
||||
The first four commands are addressed to [MAV_COMP_ID_CAMERA (100)](https://mavlink.io/en/messages/common.html#MAV_COMP_ID_CAMERA) (if a camera has this component ID, it will execute the indicated command).
|
||||
The camera mode, zoom, and focus, commands are sent to a component with id of [MAV_COMP_ID_ALL](https://mavlink.io/en/messages/common.html#MAV_COMP_ID_ALL).
|
||||
|
||||
:::info
|
||||
PX4 currently ignores the target camera `id` in [MAV_CMD_IMAGE_START_CAPTURE](https://mavlink.io/en/messages/common.html#MAV_CMD_IMAGE_START_CAPTURE) and other camera messages.
|
||||
See [PX4-Autopilot#23083](https://github.com/PX4/PX4-Autopilot/issues/23083).
|
||||
:::
|
||||
|
||||
<!--
|
||||
List of all supported commands in missions in:
|
||||
format_mavlink_mission_item() => https://github.com/PX4/PX4-Autopilot/blob/main/src/modules/mavlink/mavlink_mission.cpp#L1672-L1693
|
||||
|
||||
Mission items are executed when set active.
|
||||
void Mission::setActiveMissionItems() => https://github.com/PX4/PX4-Autopilot/blob/main/src/modules/navigator/mission.cpp#L187-L281
|
||||
At end the current non-waypoint command is "issued":
|
||||
note at end => issue_command(_mission_item);
|
||||
|
||||
Issuing command:
|
||||
MissionBlock::issue_command(const mission_item_s &item) => https://github.com/PX4/PX4-Autopilot/blob/main/src/modules/navigator/mission_block.cpp#L543-L562
|
||||
At end this publishes the current vehicle command
|
||||
_navigator->publish_vehicle_cmd(&vcmd);
|
||||
|
||||
Publishing command:
|
||||
void Navigator::publish_vehicle_cmd(vehicle_command_s *vcmd) => https://github.com/PX4/PX4-Autopilot/blob/main/src/modules/navigator/navigator_main.cpp#L1358
|
||||
For camera commands set to vcmd->target_component = 100; // MAV_COMP_ID_CAMERA
|
||||
All others just get published as-is
|
||||
-->
|
||||
|
||||
### Manual Controllers
|
||||
|
||||
Joystick buttons can be configured to trigger image capture or toggle video capture.
|
||||
|
||||
PX4 emits [MAVLink Camera Protocol v2](https://mavlink.io/en/services/camera.html) commands such as `MAV_CMD_IMAGE_START_CAPTURE` when the associated Joystick button is pressed.
|
||||
This feature only works for this kind of camera and joystick - there is no support for RC Controllers.
|
||||
|
||||
## PX4 Configuration
|
||||
|
||||
### MAVLink Port & Forwarding
|
||||
|
||||
You will need to provide a MAVLink channel to any connected cameras so that PX4 can emit any camera commands found in missions.
|
||||
If your MAVLink network is such that PX4 is "between" your camera and your ground station, you will also need to forward communications so that they can communicate.
|
||||
|
||||
First attach the camera to an unused serial port on your flight controller, such as `TELEM2` (you might also use an Ethernet port if present on both your flight controller and the camera).
|
||||
Then configure the selected port as a [MAVLink Peripheral](../peripherals/mavlink_peripherals.md).
|
||||
|
||||
The linked document explains how, but in summary:
|
||||
|
||||
1. Modify an unused `MAV_n_CONFIG` parameter, such as [MAV_2_CONFIG](../advanced_config/parameter_reference.md#MAV_2_CONFIG), so that it is assigned to port to which you connected the camera/companion computer.
|
||||
1. Set the corresponding [MAV_2_MODE](../advanced_config/parameter_reference.md#MAV_2_MODE) to `2` (Onboard).
|
||||
This ensures that the right set of MAVLink messages are emitted for a companion computer (or camera).
|
||||
1. Set [MAV_2_FORWARD](../advanced_config/parameter_reference.md#MAV_2_FORWARD) to enable forwarding of communications from the port to other ports, such as the one that is connected to the ground station.
|
||||
1. You may need to set some of the other parameters, depending on your connection type and any particular requirements of the camera on the expected baud rate, and so on.
|
||||
|
||||
### Manual Control
|
||||
|
||||
Joystick buttons can be mapped to capture images, and to toggle video capture on and off.
|
||||
|
||||
- [Joystick](../config/joystick.md#enabling-px4-joystick-support) explains how to enable Joysticks on PX4.
|
||||
- [QGroundControl > Joystick Setup](https://docs.qgroundcontrol.com/master/en/qgc-user-guide/setup_view/joystick.html) explains how to map buttons to flight stack functions
|
||||
|
||||
<!-- Cameras cannot be controlled from an RC controller as far as I can tell -->
|
||||
|
||||
## Camera Managers
|
||||
|
||||
If you want to use a camera that does not natively support the MAVLink camera protocol you will need a MAVLink camera manager.
|
||||
The camera manager runs on a companion computer and bridges between the MAVLink camera protocol interface and the camera's native interface.
|
||||
|
||||
There are "extensible" camera managers that can be used with many different cameras, camera managers designed to work with a specific camera, and you can also write your own (for example, using MAVSDK server plugins).
|
||||
|
||||
Generic/extensible camera managers:
|
||||
|
||||
- [MAVLink Camera Manager](https://github.com/mavlink/mavlink-camera-manager) - Extensible cross-platform MAVLink Camera Server built on top of GStreamer and Rust-MAVLink.
|
||||
- [Dronecode Camera Manager](https://camera-manager.dronecode.org/en/) - Adds Camera Protocol interface for cameras connected to Linux computer.
|
||||
|
||||
Camera-specfic camera managers:
|
||||
|
||||
- [SIYI A8 mini camera manager](https://github.com/julianoes/siyi-a8-mini-camera-manager) - MAVSDK-plugin based camera manager for the [SIYI A8 mini](https://shop.siyi.biz/products/siyi-a8-mini) (includes tutorial).
|
||||
|
||||
::: tip
|
||||
This is a good example of how MAVSDK can be used to create a MAVLink camera protocol interface for a particular camera.
|
||||
:::
|
||||
|
||||
When using a camera manager you connect the companion computer to the flight controller (rather than directly to the camera), and you'll need additional software on the computer to route MAVLink traffic to the camera manager on the companion computer, such as [mavlink-router](https://github.com/mavlink-router/mavlink-router).
|
||||
|
||||
More information about camera manager and companion computer setups can be found in:
|
||||
|
||||
- [SIYI A8 mini camera manager](https://github.com/julianoes/siyi-a8-mini-camera-manager) - Tutorial for integrating with the [SIYI A8 mini](https://shop.siyi.biz/products/siyi-a8-mini) using a MAVSDK-based camera manager running on a Raspberry Pi companion computer.
|
||||
- [Using a Companion Computer with Pixhawk Controllers](../companion_computer/pixhawk_companion.md)
|
||||
- [Companion Computers > Companion Computer Software](../companion_computer/index.md#companion-computer-software): In particular note [MAVLink-Router](https://github.com/mavlink-router/mavlink-router), which you can setup to route MAVLink traffic between a serial port and an IP link (or other camera manager interface).
|
||||
Reference in New Issue
Block a user