fix(gimbal): release manager control again while still reported in control

A DO_GIMBAL_MANAGER_CONFIGURE acquire and release can be in flight at the
same time, and COMMAND_ACK can't tell which of the two it answers. If acks
are lost or late, a retried acquire can reach the external gimbal manager
after the release, leaving PX4 in primary control with no onboard intent.
The release was only sent when the intent ended, so nothing undid this and
other clients stayed locked out until they took control themselves.

Mirror the existing "re-acquire while nobody is in control" case: while
there is no onboard intent and the manager's status reports us as primary
control, send the release again every CONFIGURE_RETRY_INTERVAL. Sending -3
only removes control if we hold it, so this can't take control from another
client.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Miguel Moreira <miguel.moreira@auterion.com>
This commit is contained in:
Miguel Moreira authored and Julian Oes committed 2026-11-27 13:43:20 +13:00
1 parent 3463f7dd1e
commit 5db2ed76c6
2 files changed
+18 -1

No files matched your search

@@ -85,6 +85,14 @@ void OutputToGimbalManager::update(const ControlData &control_data, bool new_set
// This can't take control away from anyone, so it's still up to the
// manager to arbitrate between its clients.
_send_configure(true);
} else if (!onboard_intent && _we_are_in_control()
&& hrt_elapsed_time(&_last_configure) > CONFIGURE_RETRY_INTERVAL) {
// We don't want control but the manager reports that we have it, e.g.
// because our release got lost, or a retry of an earlier acquire reached
// the manager after the release (COMMAND_ACK can't tell which of the two
// it answers). Release again. This only removes control if we hold it.
_send_configure(false);
}
_onboard_intent = onboard_intent;
@@ -123,6 +131,12 @@ bool OutputToGimbalManager::_nobody_in_control() const
return _status.primary_control_sysid == 0 && _status.primary_control_compid == 0;
}
bool OutputToGimbalManager::_we_are_in_control() const
{
return _status.primary_control_sysid == (uint8_t)_parameters.mav_sysid
&& _status.primary_control_compid == (uint8_t)_parameters.mav_compid;
}
void OutputToGimbalManager::_send_configure(bool acquire)
{
_last_configure = hrt_absolute_time();
+4 -1
View File
@@ -53,7 +53,9 @@ namespace gimbal
// for control, while it lasts we stream GIMBAL_MANAGER_SET_PITCHYAW, and when
// it ends we release control. If another client has taken control, the manager
// ignores our setpoints. We only ask again while the manager reports that nobody
// is in control (e.g. after it restarted).
// is in control (e.g. after it restarted), and release again while it reports
// that we are in control without onboard intent (e.g. a lost release, or a
// retried acquire that reached the manager after the release).
class OutputToGimbalManager : public OutputBase
{
public:
@@ -68,6 +70,7 @@ private:
void _update_manager_status();
void _send_configure(bool acquire);
bool _nobody_in_control() const;
bool _we_are_in_control() const;
void _publish_set_pitchyaw();
uORB::Subscription _status_sub{ORB_ID(external_gimbal_manager_status)};