mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-26 05:33:33 +08:00
final piece, from allocator set actuators nan before slew limiting
This commit is contained in:
@@ -222,6 +222,24 @@ public:
|
|||||||
ActuatorVector normalizeActuatorSetpoint(const ActuatorVector &actuator)
|
ActuatorVector normalizeActuatorSetpoint(const ActuatorVector &actuator)
|
||||||
const;
|
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() {}
|
virtual void updateParameters() {}
|
||||||
|
|
||||||
int numConfiguredActuators() const { return _num_actuators; }
|
int numConfiguredActuators() const { return _num_actuators; }
|
||||||
|
|||||||
@@ -456,6 +456,10 @@ ControlAllocator::Run()
|
|||||||
_actuator_effectiveness->updateSetpoint(c[i], i, _control_allocation[i]->_actuator_sp,
|
_actuator_effectiveness->updateSetpoint(c[i], i, _control_allocation[i]->_actuator_sp,
|
||||||
_control_allocation[i]->getActuatorMin(), _control_allocation[i]->getActuatorMax());
|
_control_allocation[i]->getActuatorMin(), _control_allocation[i]->getActuatorMax());
|
||||||
|
|
||||||
|
if (i == 0) {
|
||||||
|
_control_allocation[i]->applyNanToActuators(_actuator_effectiveness->getStoppedMotors());
|
||||||
|
}
|
||||||
|
|
||||||
if (_has_slew_rate) {
|
if (_has_slew_rate) {
|
||||||
_control_allocation[i]->applySlewRateLimit(dt);
|
_control_allocation[i]->applySlewRateLimit(dt);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user