mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-03 15:38:52 +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;
|
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;
|
||||||
|
|||||||
Reference in New Issue
Block a user