control_allocator: param update avoid temporary

- this is a harmless workaround for a GCC warning (-Wdangling-pointer) false positive
This commit is contained in:
Daniel Agar 2025-02-17 14:35:15 -05:00 committed by GitHub
parent 024dd701fb
commit e12c3c00a4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 10 additions and 16 deletions

View File

@ -69,15 +69,11 @@ void ActuatorEffectivenessControlSurfaces::updateParams()
{
ModuleParams::updateParams();
int32_t count = 0;
if (param_get(_count_handle, &count) != 0) {
if (param_get(_count_handle, &_count) != PX4_OK) {
PX4_ERR("param_get failed");
return;
}
_count = count;
for (int i = 0; i < _count; i++) {
param_get(_param_handles[i].type, (int32_t *)&_params[i].type);

View File

@ -107,7 +107,7 @@ private:
param_t _count_handle;
Params _params[MAX_COUNT] {};
int _count{0};
int32_t _count{0};
SlewRate<float> _flaps_setpoint_with_slewrate;
SlewRate<float> _spoilers_setpoint_with_slewrate;

View File

@ -73,14 +73,13 @@ void ActuatorEffectivenessHelicopter::updateParams()
{
ModuleParams::updateParams();
int32_t count = 0;
if (param_get(_param_handles.num_swash_plate_servos, &count) != 0) {
if (param_get(_param_handles.num_swash_plate_servos, &_geometry.num_swash_plate_servos) != PX4_OK) {
PX4_ERR("param_get failed");
return;
}
_geometry.num_swash_plate_servos = math::constrain((int)count, 3, NUM_SWASH_PLATE_SERVOS_MAX);
_geometry.num_swash_plate_servos = math::constrain(_geometry.num_swash_plate_servos,
(int32_t)3, (int32_t)NUM_SWASH_PLATE_SERVOS_MAX);
for (int i = 0; i < _geometry.num_swash_plate_servos; ++i) {
float angle_deg{};

View File

@ -58,7 +58,7 @@ public:
struct Geometry {
SwashPlateGeometry swash_plate_servos[NUM_SWASH_PLATE_SERVOS_MAX];
int num_swash_plate_servos{0};
int32_t num_swash_plate_servos{0};
float throttle_curve[NUM_CURVE_POINTS];
float pitch_curve[NUM_CURVE_POINTS];
float yaw_collective_pitch_scale;

View File

@ -60,14 +60,13 @@ void ActuatorEffectivenessHelicopterCoaxial::updateParams()
{
ModuleParams::updateParams();
int32_t count = 0;
if (param_get(_param_handles.num_swash_plate_servos, &count) != 0) {
if (param_get(_param_handles.num_swash_plate_servos, &_geometry.num_swash_plate_servos) != PX4_OK) {
PX4_ERR("param_get failed");
return;
}
_geometry.num_swash_plate_servos = math::constrain((int)count, 2, NUM_SWASH_PLATE_SERVOS_MAX);
_geometry.num_swash_plate_servos = math::constrain(_geometry.num_swash_plate_servos,
(int32_t)2, (int32_t)NUM_SWASH_PLATE_SERVOS_MAX);
for (int i = 0; i < _geometry.num_swash_plate_servos; ++i) {
float angle_deg{};

View File

@ -55,7 +55,7 @@ public:
struct Geometry {
SwashPlateGeometry swash_plate_servos[NUM_SWASH_PLATE_SERVOS_MAX];
int num_swash_plate_servos{0};
int32_t num_swash_plate_servos{0};
float spoolup_time;
};