feat(control_allocator): allow overriding tiltrotor collective tilt

- Expose overrideCollectiveTilt in ActuatorEffectiveness, empty base, only overridden for Tiltrotor
 - Allow giving collective tilt that is used in updateSetpoint in place
   of command from tiltrotor_extra_controls
 - Needs to be called with do_override = false to clear override
 - add comment explaining technical debt
This commit is contained in:
Balduin authored and Silvan Fuhrer committed 2026-05-18 16:14:31 +02:00
1 parent 7261e064c7
commit da2b23e57e
3 files changed
+48 -3

No files matched your search

@@ -124,14 +124,45 @@ void ActuatorEffectivenessTiltrotorVTOL::allocateAuxilaryControls(const float dt
}
void ActuatorEffectivenessTiltrotorVTOL::overrideCollectiveTilt(bool do_override, float collective_tilt)
{
// When set, updateSetpoint() takes the collective tilt from
// _collective_tilt_normalized_setpoint instead of the uORB message and
// drives the tilt actuators even when motors are not yet spooled up. Used
// by the actuator-group preflight check.
// TODO: revise. This is a pretty hacky way to pass around the
// collective tilt setpoint.
// The main flaw is that overrideCollectiveTilt(false, ...) is
// explicitly needed to clear the override.
// Ideally we would send a separate tiltrotor_extra_controls style
// message that contains a flag which enables the necessary override
// here, and stop the override if only the usual tiltrotor controls
// arrive.
// But tiltrotor_extra_controls is a hack in the first place and I am
// noting this technical debt for the time when it is replaced by a
// better way.
_do_override_collective_tilt = do_override;
_collective_tilt_normalized_setpoint = collective_tilt;
}
void ActuatorEffectivenessTiltrotorVTOL::updateSetpoint(const matrix::Vector<float, NUM_AXES> &control_sp,
int matrix_index, ActuatorVector &actuator_sp, const ActuatorVector &actuator_min, const ActuatorVector &actuator_max)
{
// apply tilt
if (matrix_index == 0) {
tiltrotor_extra_controls_s tiltrotor_extra_controls;
tiltrotor_extra_controls_s tiltrotor_extra_controls{};
const bool has_tiltrotor_extra_controls = _tiltrotor_extra_controls_sub.copy(&tiltrotor_extra_controls);
if (has_tiltrotor_extra_controls || _do_override_collective_tilt) {
if (_do_override_collective_tilt) {
tiltrotor_extra_controls.collective_tilt_normalized_setpoint = _collective_tilt_normalized_setpoint;
}
if (_tiltrotor_extra_controls_sub.copy(&tiltrotor_extra_controls)) {
float control_collective_tilt = tiltrotor_extra_controls.collective_tilt_normalized_setpoint * 2.f - 1.f;
// set control_collective_tilt to exactly -1 or 1 if close to these end points
@@ -165,7 +196,7 @@ void ActuatorEffectivenessTiltrotorVTOL::updateSetpoint(const matrix::Vector<flo
if (_tilts.config(i).tilt_direction == ActuatorEffectivenessTilts::TiltDirection::TowardsFront) {
// as long as throttle spoolup is not completed, leave the tilts in the disarmed position (in hover)
if (throttleSpoolupFinished() || _flight_phase != FlightPhase::HOVER_FLIGHT) {
if (throttleSpoolupFinished() || _flight_phase != FlightPhase::HOVER_FLIGHT || _do_override_collective_tilt) {
actuator_sp(i + _first_tilt_idx) += control_collective_tilt;
} else {
@@ -87,6 +87,8 @@ public:
void getUnallocatedControl(int matrix_index, control_allocator_status_s &status) override;
void overrideCollectiveTilt(bool do_override, float collective_tilt) override;
protected:
bool _collective_tilt_updated{true};
ActuatorEffectivenessRotors _mc_rotors;
@@ -113,6 +115,9 @@ protected:
uORB::Subscription _tiltrotor_extra_controls_sub{ORB_ID(tiltrotor_extra_controls)};
bool _do_override_collective_tilt{false};
float _collective_tilt_normalized_setpoint{0.5f};
private:
void updateParams() override;