ActuatorEffectivenessRotors: fix motor count check

Check during init to avoid out-of-bound access.
This commit is contained in:
Beat Küng
2022-05-10 08:57:39 +02:00
parent 15296ab453
commit 9f5c5591a2
@@ -95,7 +95,7 @@ void ActuatorEffectivenessRotors::updateParams()
return; return;
} }
_geometry.num_rotors = count; _geometry.num_rotors = math::min(NUM_ROTORS_MAX, (int)count);
for (int i = 0; i < _geometry.num_rotors; ++i) { for (int i = 0; i < _geometry.num_rotors; ++i) {
Vector3f &position = _geometry.rotors[i].position; Vector3f &position = _geometry.rotors[i].position;
@@ -156,7 +156,7 @@ ActuatorEffectivenessRotors::computeEffectivenessMatrix(const Geometry &geometry
{ {
int num_actuators = 0; 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) { if (i + actuator_start_index >= NUM_ACTUATORS) {
break; break;