examples: add gimbal_device example#2928
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a standalone gimbal device example (gimbal protocol v2) — the device-role counterpart to the
gimbal_managerexample.gimbal_deviceA 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+devicegimbal_managerexample).MAV_COMP_ID_GIMBAL.MAV_CMD_REQUEST_MESSAGEforGIMBAL_DEVICE_INFORMATION.GIMBAL_DEVICE_ATTITUDE_STATUSat 10 Hz withgimbal_device_id 0(a standalone device is identified by its own component id).GIMBAL_DEVICE_SET_ATTITUDEand 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 thegimbal_managerexample to advertise a 1–6gimbal_device_id(same-component case) instead of0. That commit was written alongside the manager example but didn't make it into the merged #2921, so the example onmainregressed to the buggy value — this puts it back.