mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-19 09:23:35 +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.
|
||||
:::
|
||||
|
||||
## 综述
|
||||
|
||||
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.
|
||||
|
||||
## 日志
|
||||
|
||||
`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).
|
||||
:::
|
||||
|
||||

|
||||
|
||||
## 购买渠道
|
||||
|
||||
[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,316 @@
|
||||
# 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.
|
||||
:::
|
||||
|
||||
## 综述
|
||||
|
||||
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 | 描述 |
|
||||
| ----------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
||||
| 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 | 描述 |
|
||||
| ----------------- | ------------------------------------------------------------------------------------------------------- |
|
||||
| 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 | 描述 |
|
||||
| ---- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| 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 | 描述 |
|
||||
| ------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| 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).
|
||||
|
||||
:::
|
||||
|
||||
### 其他参数
|
||||
|
||||
| 参数 | 描述 |
|
||||
| ------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| [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
|
||||
```
|
||||
|
||||
2. 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
|
||||
|
||||
相机对许多[有效载荷使用](../payloads/use_cases.md)很重要,包括绘图和勘测、监视、搜索和救援、作物健康和虫害检测等等。
|
||||
它们通常安装在一个 [云台](../advanced/gimbal_control.md)上,它能够提供相机稳定性、点跟踪和独立运动。
|
||||
|
||||
## 相机类型
|
||||
|
||||
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 摄像头](../camera/mavlink_v2_camera.md),因为它们使用简单一致的命令/消息集提供了最广泛的相机功能访问。
|
||||
如果相机不支持该协议,则可以在一台机载计算机上运行[摄像机管理器](../camera/mavlink_v2_camera.md#camera-managers)以在 MAVLink 和相机的本机协议之间进行接口交互。
|
||||
|
||||
## See Also
|
||||
|
||||
- [云台(相机支架)](../advanced/gimbal_control.md)
|
||||
- [相机集成/架构](../camera/camera_architecture.md) ( PX4 开发者)
|
||||
@@ -0,0 +1,115 @@
|
||||
# 简单的 MAVLink 摄像头(Camera Protcol v1)
|
||||
|
||||
本节说明了如何使用 PX4 的 MAVLink [相机](../camera/index.md), 实现了 [Camera Protocol v1 (简单触发协议)](https://mavlink.io/en/services/camera_v1.html) 的 PX4 和地面站。
|
||||
|
||||
:::warning
|
||||
[MAVLink 相机](../camera/mavlink_v2_camera.md) 在可能的情况下应该使用 [MAVLink Camera Protocol v2](https://mavlink.io/en/services/camera.html) 代替!
|
||||
此方法保留用于旧的 MAVLink 相机。
|
||||
:::
|
||||
|
||||
## 综述
|
||||
|
||||
[相机协议v1](https://mavlink.io/zh/services/camera_v1.html) 定义了一小组命令,允许用于触发相机进行拍摄:
|
||||
|
||||
- 仍然根据时间或距离以频率捕获图像
|
||||
- 视频捕获
|
||||
- 有限的相机配置
|
||||
|
||||
PX4 支持此命令集以触发通过原生支持协议的相机(如本节所述),以及连接到飞控输出的相机。
|
||||
|
||||
地面站和 MAVLink SDK 通常将相机命令发送给自动驾驶仪,然后转发给连接的类型为 '板载' 的 MAVLink 通道。
|
||||
PX4 还会将其在任务中遇到的任何相机任务项重新发出为相机命令:未被接受的命令将被记录。
|
||||
在所有情况下,命令都是使用自动驾驶仪的系统 ID 和组件 ID 为0(即发送给所有组件,包括摄像头)。
|
||||
|
||||
每次触发图像捕获时 PX4 也会发出一个 [CAMERA_TRIGGER](https://mavlink.io/en/messages/common.html#CAMERA_TRIGGER) (相机本身也可能在触发时发出此消息)。
|
||||
|
||||
## 控制相机
|
||||
|
||||
### MAVLink 命令和消息
|
||||
|
||||
[相机协议v1(简单触发协议)](https://mavlink.io/en/services/camera_v1.html)定义了以下命令:
|
||||
|
||||
- [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)
|
||||
|
||||
MAVLink 摄像头将支持这些命令的一些子集。
|
||||
由于协议没有发现过程的功能,唯一的方法是检查响应中返回的[COMMAND_ACK](https://mavlink.io/en/messages/common.html#COMMAND_ACK)。
|
||||
|
||||
相机在每次拍摄图像时也应发出[CAMERA_TRIGGER](https://mavlink.io/en/messages/common.html#CAMERA_TRIGGER)。
|
||||
|
||||
[Camera Protocol v1](https://mavlink.io/zh/services/camera_v1.html) 更详细地描述了协议。
|
||||
|
||||
### 地面站
|
||||
|
||||
地面站可以使用 [Camera Protocol v1(简单触发协议)](https://mavlink.io/en/services/camera_v1.html) 中的任何命令,并且应该将这些命令发送给自驾仪组件 id。
|
||||
如果相机不支持命令,它将返回带有错误结果的[COMMAND_ACK](https://mavlink.io/en/messages/common.html#COMMAND_ACK)。
|
||||
|
||||
通常命令是针对自驾仪的,因为这样无论相机是通过 MAVLink 连接还是直接连接飞控都能工作。
|
||||
如果发送给自驾仪 PX4,每次拍摄图像时 PX4 都会发出[CAMERA_TRIGGER](https://mavlink.io/en/messages/common.html#CAMERA_TRIGGER),并可能记录相机拍摄事件。
|
||||
|
||||
<!-- "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 -->
|
||||
|
||||
理论上,您也可以直接向相机发送命令。
|
||||
|
||||
### Camera Commands in Missions
|
||||
|
||||
以下[Camera Protocol v1 (简单触发协议)](https://mavlink.io/en/services/camera_v1.html)命令可在任务中使用(这与上面的命令列表相同)。
|
||||
|
||||
- [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 重新使用与自驾仪相同的系统 ID 和组件 ID [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
|
||||
|
||||
这些相机不支持手动触发(无论是摇杆还是遥控器)。
|
||||
|
||||
## PX4 配置
|
||||
|
||||
<!-- set up the mode and triggering -->
|
||||
|
||||
### MAVLink 端口和转发配置
|
||||
|
||||
将 PX4 连接到您的 MAVLink 相机上,将它连接到您飞控上一个未使用的串口,如`TELEM2`。
|
||||
然后,您可以将端口配置为[MAVLink 外设](../peripherals/mavlink_peripherals.md).
|
||||
本文件解释了如何做,总的来说:
|
||||
|
||||
1. 修改一个未使用的 `MAV_n_CONFIG` 参数,例如[MAV_2_CONFIG](../advanced_config/parameter_reference.md#MAV_2_CONFIG),使其分配给相机连接的端口。
|
||||
2. 将对应的 [MAV_2_MODE](../advanced_config/parameter_reference.md#MAV_2_MODE) 设置为 `2` (板载)。
|
||||
这确保正确的 MAVLink 消息集被发出和转发。
|
||||
3. 您可能需要设置一些其他参数,取决于您的连接 - 例如波特率。
|
||||
|
||||
然后按照其用户指南中的建议连接和配置相机。
|
||||
|
||||
<!-- 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.
|
||||
-->
|
||||
|
||||
### 相机模式和触发
|
||||
|
||||
配置 PX4 相机驱动器以启用 MAVLink 相机后端,并设置触发模式为在勘测任务中按命令捕获。
|
||||
|
||||
使用 _QGroundControl_:
|
||||
|
||||
- 打开 [Vehicle Setup > Camera](https://docs.qgroundcontrol.com/master/zh/qgc-user-guide/setup_view/camera.html#px4-camera-setup)。
|
||||
- 按照所示设置数值:
|
||||
|
||||

|
||||
|
||||
:::info
|
||||
You can also [set the parameters directly](../advanced_config/parameters.md):
|
||||
|
||||
- [TRIG_MODE](../advanced_config/parameter_reference.md#TRIG_MODE) — `4`: 基于距离,按命令触发 (勘测模式)
|
||||
- [TRIG_INTERFACE](../advanced_config/parameter_reference.md#TRIG_INTERFACE) — `3`: MAVLink
|
||||
|
||||
:::
|
||||
@@ -0,0 +1,155 @@
|
||||
# MAVLink Cameras (Camera Protocol v2)
|
||||
|
||||
本节说明了如何使用 PX4 的 MAVLink [相机](../camera/index.md) 实现了 [MAVLink Camera Protocol v2](https://mavlink.io/en/services/camera.html) 的 PX4 和地面站。
|
||||
|
||||
:::tip
|
||||
这是与 PX4 集成相机的推荐方式!
|
||||
:::
|
||||
|
||||
## 综述
|
||||
|
||||
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.
|
||||
:::
|
||||
|
||||
## 控制相机
|
||||
|
||||
### MAVLink 命令和消息
|
||||
|
||||
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.
|
||||
|
||||
### 地面站和 MAVLink SDK
|
||||
|
||||
地面站和 MAVLink SDK 会像前一节所述那样发现相机及其功能。
|
||||
|
||||
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
|
||||
-->
|
||||
|
||||
### 手动控制器
|
||||
|
||||
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 配置
|
||||
|
||||
### MAVLink 端口和转发
|
||||
|
||||
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.
|
||||
2. 将对应的 [MAV_2_MODE](../advanced_config/parameter_reference.md#MAV_2_MODE) 设置为 `2` (板载)。
|
||||
This ensures that the right set of MAVLink messages are emitted for a companion computer (or camera).
|
||||
3. 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.
|
||||
4. 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 -->
|
||||
|
||||
## 相机管理器
|
||||
|
||||
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