mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-11-01 13:31:36 +08:00
lib/mixer_module: added a constant instance start so that when instance start is changed in actuator yaml files they parameters are able to be used (#23616)
Co-authored-by: Luca Scheuer <luca.scheuer@iq-control.com>
This commit is contained in:
@@ -67,7 +67,7 @@ static const FunctionProvider all_function_providers[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
MixingOutput::MixingOutput(const char *param_prefix, uint8_t max_num_outputs, OutputModuleInterface &interface,
|
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),
|
ModuleParams(&interface),
|
||||||
_output_ramp_up(ramp_up),
|
_output_ramp_up(ramp_up),
|
||||||
_scheduling_policy(scheduling_policy),
|
_scheduling_policy(scheduling_policy),
|
||||||
@@ -87,7 +87,7 @@ MixingOutput::MixingOutput(const char *param_prefix, uint8_t max_num_outputs, Ou
|
|||||||
|
|
||||||
px4_sem_init(&_lock, 0, 1);
|
px4_sem_init(&_lock, 0, 1);
|
||||||
|
|
||||||
initParamHandles();
|
initParamHandles(instance_start);
|
||||||
|
|
||||||
for (unsigned i = 0; i < MAX_ACTUATORS; i++) {
|
for (unsigned i = 0; i < MAX_ACTUATORS; i++) {
|
||||||
_failsafe_value[i] = UINT16_MAX;
|
_failsafe_value[i] = UINT16_MAX;
|
||||||
@@ -108,20 +108,20 @@ MixingOutput::~MixingOutput()
|
|||||||
_outputs_pub.unadvertise();
|
_outputs_pub.unadvertise();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MixingOutput::initParamHandles()
|
void MixingOutput::initParamHandles(const uint8_t instance_start)
|
||||||
{
|
{
|
||||||
char param_name[17];
|
char param_name[17];
|
||||||
|
|
||||||
for (unsigned i = 0; i < _max_num_outputs; ++i) {
|
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);
|
_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);
|
_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);
|
_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);
|
_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);
|
_param_handles[i].failsafe = param_find(param_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -120,7 +120,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
MixingOutput(const char *param_prefix, uint8_t max_num_outputs, OutputModuleInterface &interface,
|
MixingOutput(const char *param_prefix, uint8_t max_num_outputs, OutputModuleInterface &interface,
|
||||||
SchedulingPolicy scheduling_policy,
|
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();
|
~MixingOutput();
|
||||||
|
|
||||||
@@ -221,7 +221,7 @@ private:
|
|||||||
|
|
||||||
void cleanupFunctions();
|
void cleanupFunctions();
|
||||||
|
|
||||||
void initParamHandles();
|
void initParamHandles(const uint8_t instance_start);
|
||||||
|
|
||||||
void limitAndUpdateOutputs(float outputs[MAX_ACTUATORS], bool has_updates);
|
void limitAndUpdateOutputs(float outputs[MAX_ACTUATORS], bool has_updates);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user