fix(gimbal): hold AUX gimbal axes without an output function at zero

Rate setpoints on an axis with no actuator were integrated anyway, so a
pitch-only gimbal reported a yaw angle stuck at the MNT_RANGE_YAW limit.

Signed-off-by: bresch <brescianimathieu@gmail.com>
This commit is contained in:
bresch authored and Marco Hauswirth committed 2026-11-05 18:41:46 +01:00
1 parent 8e8f8c2960
commit ecafa37dad
4 files changed
+21 -8

No files matched your search

+5 -2
View File
@@ -249,14 +249,17 @@ void OutputBase::_calculate_angle_output(const hrt_abstime &t)
for (int i = 0; i < 3; ++i) {
if (PX4_ISFINITE(euler_gimbal(i)) && compensate[i] && PX4_ISFINITE(euler_vehicle(i))) {
if (!_axis_actuated[i]) {
_angle_outputs[i] = 0.f;
} else if (PX4_ISFINITE(euler_gimbal(i)) && compensate[i] && PX4_ISFINITE(euler_vehicle(i))) {
_angle_outputs[i] = euler_gimbal(i) - euler_vehicle(i);
} else if (PX4_ISFINITE(euler_gimbal(i)) && !compensate[i]) {
_angle_outputs[i] = euler_gimbal(i);
}
if (PX4_ISFINITE(_angle_velocity[i])) {
if (_axis_actuated[i] && PX4_ISFINITE(_angle_velocity[i])) {
_angle_outputs[i] += dt * _angle_velocity[i];
}
+4
View File
@@ -101,6 +101,10 @@ protected:
// Pitch and role are by default aligned with the horizon.
// Yaw follows the vehicle (not lock/absolute mode).
bool _absolute_angle[3] = {true, true, false };
// Axes without an actuator are held at zero, whatever the setpoint.
bool _axis_actuated[3] = {true, true, true};
AlphaFilter<matrix::Vector3f> _angle_outputs_filtered;
/** calculate the _angle_outputs (with speed) and stabilize if needed */
+12 -5
View File
@@ -91,7 +91,7 @@ void OutputRC::_check_gimbal_output_functions_assigned()
_gimbal_output_functions_assigned = false;
for (int i = 0; i < 3; ++i) {
_axis_assigned[i] = false;
_axis_actuated[i] = false;
}
for (unsigned i = 0; i < param_count(); ++i) {
@@ -125,7 +125,14 @@ void OutputRC::_check_gimbal_output_functions_assigned()
if (function >= (int32_t)OutputFunction::Gimbal_Roll && function <= (int32_t)OutputFunction::Gimbal_Yaw) {
_gimbal_output_functions_assigned = true;
_axis_assigned[function - (int32_t)OutputFunction::Gimbal_Roll] = true;
_axis_actuated[function - (int32_t)OutputFunction::Gimbal_Roll] = true;
}
}
// gimbal_controls may still be consumed without an output function, so keep driving every axis.
if (!_gimbal_output_functions_assigned) {
for (int i = 0; i < 3; ++i) {
_axis_actuated[i] = true;
}
}
}
@@ -154,17 +161,17 @@ void OutputRC::_publish_device_information()
info.cap_flags = gimbal_device_information_s::GIMBAL_DEVICE_CAP_FLAGS_HAS_NEUTRAL;
if (_axis_assigned[0]) {
if (_axis_actuated[0]) {
info.cap_flags |= gimbal_device_information_s::GIMBAL_DEVICE_CAP_FLAGS_HAS_ROLL_AXIS
| gimbal_device_information_s::GIMBAL_DEVICE_CAP_FLAGS_HAS_ROLL_LOCK;
}
if (_axis_assigned[1]) {
if (_axis_actuated[1]) {
info.cap_flags |= gimbal_device_information_s::GIMBAL_DEVICE_CAP_FLAGS_HAS_PITCH_AXIS
| gimbal_device_information_s::GIMBAL_DEVICE_CAP_FLAGS_HAS_PITCH_LOCK;
}
if (_axis_assigned[2]) {
if (_axis_actuated[2]) {
info.cap_flags |= gimbal_device_information_s::GIMBAL_DEVICE_CAP_FLAGS_HAS_YAW_AXIS
| gimbal_device_information_s::GIMBAL_DEVICE_CAP_FLAGS_HAS_YAW_LOCK;
}
-1
View File
@@ -68,7 +68,6 @@ private:
uORB::Publication <gimbal_device_information_s> _device_information_pub{ORB_ID(gimbal_device_information)};
bool _gimbal_output_functions_assigned{false};
bool _axis_assigned[3] {};
gimbal_device_information_s _device_information{};
};