Skip to content

Commit

Permalink
ActuatorEffectivenessRotors: Use modern parameter interface for rotor…
Browse files Browse the repository at this point in the history
… count

This lead to a compiler warning with arm-none-eabi-gcc 12+
about the variable count potentially being a dangling pointer.
  • Loading branch information
MaEtUgR authored and dagar committed Dec 5, 2023
1 parent b71c6fb commit 14c4257
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,23 +79,14 @@ ActuatorEffectivenessRotors::ActuatorEffectivenessRotors(ModuleParams *parent, A
}
}

_count_handle = param_find("CA_ROTOR_COUNT");

updateParams();
}

void ActuatorEffectivenessRotors::updateParams()
{
ModuleParams::updateParams();

int32_t count = 0;

if (param_get(_count_handle, &count) != 0) {
PX4_ERR("param_get failed");
return;
}

_geometry.num_rotors = math::min(NUM_ROTORS_MAX, (int)count);
_geometry.num_rotors = math::min(NUM_ROTORS_MAX, static_cast<int>(_param_ca_rotor_count.get()));

for (int i = 0; i < _geometry.num_rotors; ++i) {
Vector3f &position = _geometry.rotors[i].position;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,10 @@ class ActuatorEffectivenessRotors : public ModuleParams, public ActuatorEffectiv
param_t tilt_index;
};
ParamHandles _param_handles[NUM_ROTORS_MAX];
param_t _count_handle;

Geometry _geometry{};

DEFINE_PARAMETERS(
(ParamInt<px4::params::CA_ROTOR_COUNT>) _param_ca_rotor_count
)
};

0 comments on commit 14c4257

Please sign in to comment.