Skip to content

examples: add gimbal_device example#2928

Merged
julianoes merged 4 commits into
mainfrom
pr-gimbal-device-example
Jul 15, 2026
Merged

examples: add gimbal_device example#2928
julianoes merged 4 commits into
mainfrom
pr-gimbal-device-example

Conversation

@julianoes

Copy link
Copy Markdown
Collaborator

Adds a standalone gimbal device example (gimbal protocol v2) — the device-role counterpart to the gimbal_manager example.

gimbal_device

A pure gimbal device: it is driven by a separate gimbal manager (e.g. a PX4 autopilot configured to output MAVLink gimbal protocol v2, MNT_MODE_OUT), so manager and device live on different components — the separate-component case of the gimbal protocol (as opposed to the combined manager+device gimbal_manager example).

  • Identifies as MAV_COMP_ID_GIMBAL.
  • Answers MAV_CMD_REQUEST_MESSAGE for GIMBAL_DEVICE_INFORMATION.
  • Streams GIMBAL_DEVICE_ATTITUDE_STATUS at 10 Hz with gimbal_device_id 0 (a standalone device is identified by its own component id).
  • Accepts GIMBAL_DEVICE_SET_ATTITUDE and simulates a two-axis gimbal slewing at a limited rate.

Besides being a useful example, running it against PX4 SITL exercises the separate-component discovery path that #2926 fixed (manager on compid 1, device on compid 154) end-to-end.

Also: restore the manager example fix

This branch also re-applies examples: fix gimbal_device_id in attitude status, which fixes the gimbal_manager example to advertise a 1–6 gimbal_device_id (same-component case) instead of 0. That commit was written alongside the manager example but didn't make it into the merged #2921, so the example on main regressed to the buggy value — this puts it back.

The gimbal_manager example is both the gimbal manager and the gimbal
device in a single component (MAV_COMP_ID_GIMBAL). Per gimbal protocol
v2, when the manager and device share a component ID the device is
addressed by a small id in the range 1-6, not by its component ID.

GIMBAL_DEVICE_ATTITUDE_STATUS was sending gimbal_device_id 0, which
signals a separate device component identified by its sender compid.
That only matched by luck because the manager advertised its own compid
as the device id. Use a consistent device id of 1 across the manager
information/status, device information, incoming setpoint checks, and
the attitude status.
A standalone MAVLink gimbal device (gimbal protocol v2), the device-role
counterpart to the gimbal_manager example. It is driven by a separate
gimbal manager (e.g. a PX4 autopilot configured to output MAVLink gimbal
protocol v2), so manager and device live on different components — the
separate-component case of the gimbal protocol.

It answers MAV_CMD_REQUEST_MESSAGE for GIMBAL_DEVICE_INFORMATION, streams
GIMBAL_DEVICE_ATTITUDE_STATUS at 10 Hz with gimbal_device_id 0 (the device
is identified by its own component id), and accepts GIMBAL_DEVICE_SET_ATTITUDE
setpoints, simulating a two-axis gimbal that slews at a limited rate.
Print when a gimbal manager requests GIMBAL_DEVICE_INFORMATION and when
one starts driving the device (first GIMBAL_DEVICE_SET_ATTITUDE or a
change of controlling manager). Makes it visible whether an external
manager (e.g. PX4) has actually discovered and adopted the device.
Print the incoming pitch/yaw (and rate) setpoint from GIMBAL_DEVICE_SET_ATTITUDE
whenever it changes by more than a degree, so the control path from the manager
is visible without flooding the console at the streaming rate.
@julianoes
julianoes merged commit fb522ff into main Jul 15, 2026
52 checks passed
@julianoes
julianoes deleted the pr-gimbal-device-example branch July 15, 2026 21:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant