mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-04-14 10:07:39 +08:00
final piece, from allocator set actuators nan before slew limiting
This commit is contained in:
parent
0fe15801b9
commit
189bdf05f7
@ -222,6 +222,24 @@ public:
|
||||
ActuatorVector normalizeActuatorSetpoint(const ActuatorVector &actuator)
|
||||
const;
|
||||
|
||||
/**
|
||||
* Apply a mask of actuators to be set to NaN.
|
||||
*
|
||||
* A NaN value in _actuator_sp represents a disabled or stopped actuator.
|
||||
* This mask is typically used to stop motors in specific flight phases or when certain thrust components are NaN.
|
||||
*
|
||||
* @param nan_actuators_mask Bitmask indicating which actuators to set to NaN.
|
||||
* If (nan_actuators_mask & (1 << i)), _actuator_sp(i) becomes NaN.
|
||||
*/
|
||||
void applyNanToActuators(uint32_t nan_actuators_mask)
|
||||
{
|
||||
for (int i = 0; i < _num_actuators && i < 32; i++) {
|
||||
if (nan_actuators_mask & (1u << i)) {
|
||||
_actuator_sp(i) = NAN;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
virtual void updateParameters() {}
|
||||
|
||||
int numConfiguredActuators() const { return _num_actuators; }
|
||||
|
||||
@ -456,6 +456,10 @@ ControlAllocator::Run()
|
||||
_actuator_effectiveness->updateSetpoint(c[i], i, _control_allocation[i]->_actuator_sp,
|
||||
_control_allocation[i]->getActuatorMin(), _control_allocation[i]->getActuatorMax());
|
||||
|
||||
if (i == 0) {
|
||||
_control_allocation[i]->applyNanToActuators(_actuator_effectiveness->getStoppedMotors());
|
||||
}
|
||||
|
||||
if (_has_slew_rate) {
|
||||
_control_allocation[i]->applySlewRateLimit(dt);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user