mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-05-22 06:14:14 +08:00
ActuatorEffectivenessRotors: fix motor count check
Check during init to avoid out-of-bound access.
This commit is contained in:
@@ -95,7 +95,7 @@ void ActuatorEffectivenessRotors::updateParams()
|
||||
return;
|
||||
}
|
||||
|
||||
_geometry.num_rotors = count;
|
||||
_geometry.num_rotors = math::min(NUM_ROTORS_MAX, (int)count);
|
||||
|
||||
for (int i = 0; i < _geometry.num_rotors; ++i) {
|
||||
Vector3f &position = _geometry.rotors[i].position;
|
||||
@@ -156,7 +156,7 @@ ActuatorEffectivenessRotors::computeEffectivenessMatrix(const Geometry &geometry
|
||||
{
|
||||
int num_actuators = 0;
|
||||
|
||||
for (int i = 0; i < math::min(NUM_ROTORS_MAX, geometry.num_rotors); i++) {
|
||||
for (int i = 0; i < geometry.num_rotors; i++) {
|
||||
|
||||
if (i + actuator_start_index >= NUM_ACTUATORS) {
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user