|
1 | 1 | # Gimbal Protocol (v2)
|
2 | 2 |
|
3 |
| -> **Note** This version is marked as work-in-progress. |
4 |
| -> This means that it is still subject to change. |
5 |
| -
|
6 |
| -<span></span> |
7 |
| - |
8 | 3 | > **Note** This version supersedes [Gimbal Protocol v1](../services/gimbal.md)
|
| 4 | +> Existing functionality is now fixed, but compatible changes may still be added. |
9 | 5 |
|
10 | 6 | ## Introduction
|
11 | 7 |
|
@@ -101,49 +97,66 @@ Multiple gimbals per drone are supported.
|
101 | 97 |
|
102 | 98 | #### Component IDs
|
103 | 99 |
|
104 |
| -Multiple component IDs are reserved for gimbal devices: `MAV_COMP_ID_GIMBAL`, `MAV_COMP_ID_GIMBAL2`, `MAV_COMP_ID_GIMBAL3`, `MAV_COMP_ID_GIMBAL4`, `MAV_COMP_ID_GIMBAL5`, `MAV_COMP_ID_GIMBAL6`. |
| 100 | +Multiple component IDs are reserved for MAVLink gimbal devices: `MAV_COMP_ID_GIMBAL`, `MAV_COMP_ID_GIMBAL2`, `MAV_COMP_ID_GIMBAL3`, `MAV_COMP_ID_GIMBAL4`, `MAV_COMP_ID_GIMBAL5`, `MAV_COMP_ID_GIMBAL6`. |
105 | 101 |
|
106 |
| -The listed component IDs should be used where possible (other ids may be used as long as the [MAV_TYPE](../messages/common.md#MAV_TYPE) is correctly set to [MAV_TYPE_GIMBAL](../messages/common.md#MAV_TYPE_GIMBAL)). |
| 102 | +The listed component IDs should be used where possible. |
| 103 | +Ids `0-6` may not be used. |
| 104 | +Other ids may be used as long as the [MAV_TYPE](../messages/common.md#MAV_TYPE) is correctly set to [MAV_TYPE_GIMBAL](../messages/common.md#MAV_TYPE_GIMBAL). |
107 | 105 |
|
108 | 106 | #### Mapping from Gimbal Managers to Gimbal Devices
|
109 | 107 |
|
110 |
| -Every _Gimbal Manager_ must to publish its associated _Gimbal Device_ (there is a 1:1 relationship) in its [GIMBAL_MANAGER_INFORMATION](#GIMBAL_MANAGER_INFORMATION) message. |
| 108 | +Every _Gimbal Manager_ has a single associated _Gimbal Device_ that it controls (there is a 1:1 relationship). |
| 109 | +A particular MAVLink component, such as an autopilot, can implement multiple gimbal managers in order to control two or more gimbal devices. |
| 110 | +The identity of a gimbal device and its associated manager, are represented by a "gimbal device id". |
| 111 | +This id is used to differentiate messages from different gimbal managers, and also to target a particular gimbal in commands/messages sent to the component that is hosting its gimbal manager. |
111 | 112 |
|
112 |
| -A particular MAVLink component can implement multiple gimbal managers (e.g. an autopilot can implement two gimbal managers in order to control two gimbal devices). |
| 113 | +A _Gimbal Manager_ publishes the id of its associated device in the `gimbal_device_id` field of the [GIMBAL_MANAGER_INFORMATION](#GIMBAL_MANAGER_INFORMATION) message (this same field name is present in all gimbal manager messages so you can identify the source). |
| 114 | +Similarly, commands that can be sent to a gimbal manager include a parameter with label `Gimbal device ID` that indicates the particular gimbal manager (and device). |
113 | 115 |
|
114 |
| -A gimbal manager can "manage" MAVLink gimbal devices as well as non-MAVLink gimbals such as a gimbal connected with proprietary or custom interface such as PWM or SBUS. A non-MAVLink gimbal is signalled and addressed using 1 to 6 as the `gimbal_device_id` instead of the MAVLink component ID. |
| 116 | +- A system that wants to control a _particular_ gimbal device will send messages to the component that has the manager(s), such as an autopilot, specifying the device id of the gimbal to be controlled. |
| 117 | +- A system that wants to control _all_ gimbal devices managed by gimbal managers on a particular component, would send the command/message to that component and set the device id to `0`. |
115 | 118 |
|
116 | 119 | #### Addressing of Gimbal MAVLink Devices {#gimbal_device_addressing}
|
117 | 120 |
|
118 |
| -_Gimbal Manager_ commands and messages have a param field to indicate the component ID of the _Gimbal Device_ that they intend to control. |
| 121 | +For MAVLink gimbal devices the gimbal device id (`gimbal_device_id`) is the MAVLink [component ID of the gimbal device](#component-ids) controlled by the gimbal manager. |
119 | 122 |
|
120 |
| -A system that wants to control a _particular_ gimbal device will send messages to the component that has the manager(s), specifying the particular device to be controlled. |
121 |
| - |
122 |
| -If all gimbal devices should be controlled (on the component that has the gimbal managers), this param/field can be set to 0 (signalling "all"). |
| 123 | +The gimbal manager processes commands for its associated device, sending appropriate/corresponding _gimbal device commands_ to the MAVLink gimbal device. |
123 | 124 |
|
124 | 125 | #### Addressing of non-MAVLink gimbal devices {#non_mavlink_gimbal_device_addressing}
|
125 | 126 |
|
126 |
| -Non-MAVLink gimbal devices are gimbals that don't expose the MAVLink API, but instead are connected to the gimbal manager using some other protocol. |
| 127 | +Non-MAVLink gimbal devices are gimbals that don't expose a MAVLink Gimbal Device (or manager) API, but instead are connected to the gimbal manager using some other protocol. |
127 | 128 | For instance, this could be a PWM gimbal connected to an autopilot.
|
| 129 | +Since the gimbal device is not a MAVLink component, it does not have a unique MAVLink component ID that can be used for the gimbal device id. |
| 130 | +Therefore you either have to make it into a MAVLink component (so it has an id) or assign it a particular non-MAVLink id. |
128 | 131 |
|
129 |
| -For these cases, there needs to be a way to address such a gimbal specifically, and a way to send out the `GIMBAL_DEVICE_` messages, so that they can re mapped back to the respective gimbal manager. |
130 |
| - |
131 |
| -The solution chosen for this case is to use the numbers 1 to 6 as magic numbers for the `gimbal_device_id`. This means that the numbers 1 to 6 can't be used as MAVLink component IDs for any components involved as gimbal managers or gimbal devices. |
| 132 | +Autopilots are expected to implement gimbal managers for each attached gimbal and assign each a unique gimbal device id between `1` and `6` (which is why these values can't be used as MAVLink component IDs for gimbal devices). |
| 133 | +This id would then be used in gimbal manager messages sent by the autopilot, and for addressing the particular gimbal in commands. |
| 134 | +The autopilot would directly control attached gimbals in response to gimbal manager commands. |
| 135 | +In addition to sending _gimbal manager messages_ when appropriate, it should also send/stream required _gimbal device messages_, such as [GIMBAL_DEVICE_ATTITUDE_STATUS](#GIMBAL_DEVICE_ATTITUDE_STATUS). |
132 | 136 |
|
133 |
| -- A **gimbal manager** advertises that it implements the gimbal device "itself" by setting `gimbal_device_id` to 1 to 6. It will also send out the requested gimbal device messages from the same component ID. It will set the field in `gimbal_device_id` of [GIMBAL_DEVICE_ATTITUDE_STATUS](#GIMBAL_DEVICE_ATTITUDE_STATUS). |
| 137 | +All other hardware with attached gimbal devices, such as a companion computers, are expected to implement them as separate MAVLink components, with their own MAVLink component ID that can be used for addressing. |
| 138 | +For example, a companion computer with an attached gimbal would appear as two MAVLink components: a companion computer and a gimbal. |
| 139 | +The gimbal component would identify as a type `MAV_TYPE_GIMBAL` and assert that it implements the gimbal manager protocol. |
| 140 | +As with autopilot-attached cameras it would need to respond as a gimbal manager, and also stream required gimbal device messages. |
134 | 141 |
|
135 |
| -- A **ground station** addresses a gimbal device by sending commands to the gimbal manager and specifying the `gimbal_device_id` 1 to 6. |
| 142 | +> **Note** Implementing each attached camera as a separate MAVLink component allows cameras attached to a companion computer to be separately addressed in missions executed on the autopilot. |
136 | 143 |
|
137 | 144 | ## Implementation and Messages
|
138 | 145 |
|
139 | 146 | ### Messages between Ground Station and Gimbal Manager
|
140 | 147 |
|
141 | 148 | #### Discovery of Gimbal Manager
|
142 | 149 |
|
143 |
| -A ground station should monitor for HEARTBEAT messages from all new components, and send a [MAV_CMD_REQUEST_MESSAGE](#MAV_CMD_REQUEST_MESSAGE) for [GIMBAL_MANAGER_INFORMATION](#GIMBAL_MANAGER_INFORMATION). |
144 |
| -Gimbal managers should respond with `GIMBAL_MANAGER_INFORMATION`. |
| 150 | +A ground station should monitor for `HEARTBEAT` messages from all new components and check their capabilities by requesting [AUTOPILOT_VERSION](../messages/common.md#AUTOPILOT_VERSION) for autopilots and [COMPONENT_INFORMATION_BASIC](../messages/common.md#COMPONENT_INFORMATION_BASIC) for other components (see [HEARTBEAT/Connection protocol](../services/heartbeat.md)). |
| 151 | + |
| 152 | +If the `capabilities` field of the above message(s) has the flag [MAV_PROTOCOL_CAPABILITY_COMPONENT_IMPLEMENTS_GIMBAL_MANAGER](../messages/common.md#MAV_PROTOCOL_CAPABILITY_COMPONENT_IMPLEMENTS_GIMBAL_MANAGER) set: |
| 153 | + |
| 154 | +- GCS should send a [MAV_CMD_REQUEST_MESSAGE](#MAV_CMD_REQUEST_MESSAGE) to the component for [GIMBAL_MANAGER_INFORMATION](#GIMBAL_MANAGER_INFORMATION). |
| 155 | +- Component should respond by emitting a `GIMBAL_MANAGER_INFORMATION` message for each gimbal manager that it implements. |
| 156 | + |
| 157 | +The `GIMBAL_MANAGER_INFORMATION` contains important information a particular gimbal, such as its capabilities ([GIMBAL_MANAGER_CAP_FLAGS](#GIMBAL_MANAGER_CAP_FLAGS)), maximum angles and angle rates, as well as the `gimbal_device_id` which identifies the specific gimbal device controlled by a particular _Gimbal Manager_. |
145 | 158 |
|
146 |
| -The `GIMBAL_MANAGER_INFORMATION` contains important information such as gimbal capabilities ([GIMBAL_MANAGER_CAP_FLAGS](#GIMBAL_MANAGER_CAP_FLAGS)), maximum angles and angle rates, as well as the `gimbal_component` which is the component ID of the _Gimbal Device_ controlled by this _Gimbal Manager_. |
| 159 | +> **Warning** A GCS should always request `GIMBAL_MANAGER_INFORMATION` from autopilot components prior to: PX4 v1.16, ArduPilot-4.5 (when the protocol bit was added). |
147 | 160 |
|
148 | 161 | #### Gimbal Manager Status
|
149 | 162 |
|
|
0 commit comments