Skip to content

Commit

Permalink
lib/mixer_module: added a constant instance start so that when instan…
Browse files Browse the repository at this point in the history
…ce start is changed in actuator yaml files they parameters are able to be used (#23616)

Co-authored-by: Luca Scheuer <[email protected]>
  • Loading branch information
lucascheuer and vertiq-luca authored Aug 26, 2024
1 parent 16c77be commit ca47f6f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
16 changes: 8 additions & 8 deletions src/lib/mixer_module/mixer_module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ static const FunctionProvider all_function_providers[] = {
};

MixingOutput::MixingOutput(const char *param_prefix, uint8_t max_num_outputs, OutputModuleInterface &interface,
SchedulingPolicy scheduling_policy, bool support_esc_calibration, bool ramp_up) :
SchedulingPolicy scheduling_policy, bool support_esc_calibration, bool ramp_up, const uint8_t instance_start) :
ModuleParams(&interface),
_output_ramp_up(ramp_up),
_scheduling_policy(scheduling_policy),
Expand All @@ -87,7 +87,7 @@ MixingOutput::MixingOutput(const char *param_prefix, uint8_t max_num_outputs, Ou

px4_sem_init(&_lock, 0, 1);

initParamHandles();
initParamHandles(instance_start);

for (unsigned i = 0; i < MAX_ACTUATORS; i++) {
_failsafe_value[i] = UINT16_MAX;
Expand All @@ -108,20 +108,20 @@ MixingOutput::~MixingOutput()
_outputs_pub.unadvertise();
}

void MixingOutput::initParamHandles()
void MixingOutput::initParamHandles(const uint8_t instance_start)
{
char param_name[17];

for (unsigned i = 0; i < _max_num_outputs; ++i) {
snprintf(param_name, sizeof(param_name), "%s_%s%d", _param_prefix, "FUNC", i + 1);
snprintf(param_name, sizeof(param_name), "%s_%s%d", _param_prefix, "FUNC", i + instance_start);
_param_handles[i].function = param_find(param_name);
snprintf(param_name, sizeof(param_name), "%s_%s%d", _param_prefix, "DIS", i + 1);
snprintf(param_name, sizeof(param_name), "%s_%s%d", _param_prefix, "DIS", i + instance_start);
_param_handles[i].disarmed = param_find(param_name);
snprintf(param_name, sizeof(param_name), "%s_%s%d", _param_prefix, "MIN", i + 1);
snprintf(param_name, sizeof(param_name), "%s_%s%d", _param_prefix, "MIN", i + instance_start);
_param_handles[i].min = param_find(param_name);
snprintf(param_name, sizeof(param_name), "%s_%s%d", _param_prefix, "MAX", i + 1);
snprintf(param_name, sizeof(param_name), "%s_%s%d", _param_prefix, "MAX", i + instance_start);
_param_handles[i].max = param_find(param_name);
snprintf(param_name, sizeof(param_name), "%s_%s%d", _param_prefix, "FAIL", i + 1);
snprintf(param_name, sizeof(param_name), "%s_%s%d", _param_prefix, "FAIL", i + instance_start);
_param_handles[i].failsafe = param_find(param_name);
}

Expand Down
4 changes: 2 additions & 2 deletions src/lib/mixer_module/mixer_module.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ class MixingOutput : public ModuleParams
*/
MixingOutput(const char *param_prefix, uint8_t max_num_outputs, OutputModuleInterface &interface,
SchedulingPolicy scheduling_policy,
bool support_esc_calibration, bool ramp_up = true);
bool support_esc_calibration, bool ramp_up = true, const uint8_t instance_start = 1);

~MixingOutput();

Expand Down Expand Up @@ -221,7 +221,7 @@ class MixingOutput : public ModuleParams

void cleanupFunctions();

void initParamHandles();
void initParamHandles(const uint8_t instance_start);

void limitAndUpdateOutputs(float outputs[MAX_ACTUATORS], bool has_updates);

Expand Down

0 comments on commit ca47f6f

Please sign in to comment.