refactor(gimbal): support multiple outputs in parallel

Generalize the single output backend into a list of up to two outputs,
driven with the same setpoints each cycle. A new MNT_MODE_OUT2 parameter
selects an optional second output (disabled by default).

This is behavior-preserving groundwork: with MNT_MODE_OUT2 disabled the
driver runs exactly one output as before. It enables driving a second
gimbal in addition to the primary one, e.g. forwarding to an external
gimbal manager.

The two outputs must use different modes to avoid two instances fighting
over the same device or uORB topic. Whether the estimated mount
orientation is published is now decided per output via a virtual, since a
MAVLink gimbal reports its own orientation while an AUX gimbal does not.

Signed-off-by: Julian Oes <julian@oes.ch>
This commit is contained in:
Julian Oes
2026-09-22 15:15:30 +12:00
parent e034dd91c5
commit 0ff8d3270c
5 changed files with 130 additions and 61 deletions
File diff suppressed because it is too large Load Diff
+3
View File
@@ -51,6 +51,7 @@ enum MntModeIn {
};
enum MntModeOut {
MNT_MODE_OUT_DISABLED = -1, // Only valid for the secondary output (MNT_MODE_OUT2)
MNT_MODE_OUT_AUX = 0,
MNT_MODE_OUT_MAVLINK_V1, // MAVLink gimbal protocol v1 (to be deprecated)
MNT_MODE_OUT_MAVLINK_V2 // MAVLink gimbal protocol v2
@@ -59,6 +60,7 @@ enum MntModeOut {
struct Parameters {
int32_t mnt_mode_in;
int32_t mnt_mode_out;
int32_t mnt_mode_out2;
int32_t mnt_mav_sysid_v1;
int32_t mnt_mav_compid_v1;
int32_t mnt_man_pitch;
@@ -83,6 +85,7 @@ struct Parameters {
struct ParameterHandles {
param_t mnt_mode_in;
param_t mnt_mode_out;
param_t mnt_mode_out2;
param_t mnt_mav_sysid_v1;
param_t mnt_mav_compid_v1;
param_t mnt_man_pitch;
+19
View File
@@ -44,6 +44,25 @@ parameters:
min: 0
max: 2
reboot_required: true
MNT_MODE_OUT2:
description:
short: Second mount output mode
long: |-
Optional second output, driven in parallel to MNT_MODE_OUT with the
same setpoints. This allows the gimbal driver to talk to a second
gimbal in addition to the primary one.
Set to Disabled if not used. The two outputs must use different modes.
type: enum
values:
-1: Disabled
0: AUX
1: MAVLink gimbal protocol v1
2: MAVLink gimbal protocol v2
default: -1
min: -1
max: 2
reboot_required: true
MNT_MAV_SYSID:
description:
short: Mavlink System ID of the mount
+7
View File
@@ -61,6 +61,13 @@ public:
virtual void print_status() const = 0;
/**
* Whether this output publishes the estimated mount orientation itself.
* MAVLink gimbals report their own orientation, so only non-MAVLink
* outputs (e.g. AUX) need the driver to publish it.
*/
virtual bool publishes_mount_orientation() const { return false; }
void publish();
void set_stabilize(bool roll_stabilize, bool pitch_stabilize, bool yaw_stabilize);
+3
View File
@@ -53,6 +53,9 @@ public:
virtual void update(const ControlData &control_data, bool new_setpoints, uint8_t &gimbal_device_id);
virtual void print_status() const;
// AUX gimbals cannot report their own orientation, so the driver publishes it.
bool publishes_mount_orientation() const override { return true; }
private:
void _stream_device_attitude_status();
float anglesMappedToOutput(const uint8_t index);