WIP: ROMFS: explicitly configure airframe outputs

This commit is contained in:
Daniel Agar
2021-02-12 10:33:48 -05:00
parent 89f19fd657
commit 6598a82a71
122 changed files with 735 additions and 1013 deletions
@@ -558,11 +558,6 @@ int linux_pwm_out_main(int argc, char *argv[])
}
}
/** gets the parameters for the esc's pwm */
param_get(param_find("PWM_MAIN_DISARM"), &linux_pwm_out::_pwm_disarmed);
param_get(param_find("PWM_MAIN_MIN"), &linux_pwm_out::_pwm_min);
param_get(param_find("PWM_MAIN_MAX"), &linux_pwm_out::_pwm_max);
/*
* Start/load the driver.
*/
+38 -57
View File
@@ -578,37 +578,17 @@ void PWMOut::update_params()
return;
}
int32_t pwm_min_default = PWM_DEFAULT_MIN;
int32_t pwm_max_default = PWM_DEFAULT_MAX;
int32_t pwm_disarmed_default = 0;
int32_t pwm_rate_default = 50;
const char *prefix;
if (_class_instance == CLASS_DEVICE_PRIMARY) {
prefix = "PWM_MAIN";
param_get(param_find("PWM_MAIN_MIN"), &pwm_min_default);
param_get(param_find("PWM_MAIN_MAX"), &pwm_max_default);
param_get(param_find("PWM_MAIN_DISARM"), &pwm_disarmed_default);
param_get(param_find("PWM_MAIN_RATE"), &pwm_rate_default);
} else if (_class_instance == CLASS_DEVICE_SECONDARY) {
prefix = "PWM_AUX";
param_get(param_find("PWM_AUX_MIN"), &pwm_min_default);
param_get(param_find("PWM_AUX_MAX"), &pwm_max_default);
param_get(param_find("PWM_AUX_DISARM"), &pwm_disarmed_default);
param_get(param_find("PWM_AUX_RATE"), &pwm_rate_default);
} else if (_class_instance == CLASS_DEVICE_TERTIARY) {
prefix = "PWM_EXTRA";
param_get(param_find("PWM_EXTRA_MIN"), &pwm_min_default);
param_get(param_find("PWM_EXTRA_MAX"), &pwm_max_default);
param_get(param_find("PWM_EXTRA_DISARM"), &pwm_disarmed_default);
param_get(param_find("PWM_EXTRA_RATE"), &pwm_rate_default);
} else {
PX4_ERR("invalid class instance %d", _class_instance);
return;
@@ -624,19 +604,14 @@ void PWMOut::update_params()
// PWM_MAIN_MINx
{
sprintf(str, "%s_MIN%u", prefix, i + 1);
int32_t pwm_min = -1;
int32_t pwm_min = PWM_DEFAULT_MIN;
if (param_get(param_find(str), &pwm_min) == PX4_OK) {
if (pwm_min >= 0) {
_mixing_output.minValue(i) = math::constrain(pwm_min, PWM_LOWEST_MIN, PWM_HIGHEST_MIN);
_mixing_output.minValue(i) = math::constrain(pwm_min, PWM_LOWEST_MIN, PWM_HIGHEST_MIN);
if (pwm_min != _mixing_output.minValue(i)) {
int32_t pwm_min_new = _mixing_output.minValue(i);
param_set(param_find(str), &pwm_min_new);
}
} else {
_mixing_output.minValue(i) = pwm_min_default;
if (pwm_min != _mixing_output.minValue(i)) {
int32_t pwm_min_new = _mixing_output.minValue(i);
param_set(param_find(str), &pwm_min_new);
}
}
}
@@ -644,19 +619,14 @@ void PWMOut::update_params()
// PWM_MAIN_MAXx
{
sprintf(str, "%s_MAX%u", prefix, i + 1);
int32_t pwm_max = -1;
int32_t pwm_max = PWM_DEFAULT_MAX;
if (param_get(param_find(str), &pwm_max) == PX4_OK) {
if (pwm_max >= 0) {
_mixing_output.maxValue(i) = math::constrain(pwm_max, PWM_LOWEST_MAX, PWM_HIGHEST_MAX);
_mixing_output.maxValue(i) = math::constrain(pwm_max, PWM_LOWEST_MAX, PWM_HIGHEST_MAX);
if (pwm_max != _mixing_output.maxValue(i)) {
int32_t pwm_max_new = _mixing_output.maxValue(i);
param_set(param_find(str), &pwm_max_new);
}
} else {
_mixing_output.maxValue(i) = pwm_max_default;
if (pwm_max != _mixing_output.maxValue(i)) {
int32_t pwm_max_new = _mixing_output.maxValue(i);
param_set(param_find(str), &pwm_max_new);
}
}
}
@@ -664,16 +634,14 @@ void PWMOut::update_params()
// PWM_MAIN_FAILx
{
sprintf(str, "%s_FAIL%u", prefix, i + 1);
int32_t pwm_failsafe = -1;
int32_t pwm_failsafe = 0;
if (param_get(param_find(str), &pwm_failsafe) == PX4_OK) {
if (pwm_failsafe >= 0) {
_mixing_output.failsafeValue(i) = math::constrain(pwm_failsafe, 0, PWM_HIGHEST_MAX);
_mixing_output.failsafeValue(i) = math::constrain(pwm_failsafe, 0, PWM_HIGHEST_MAX);
if (pwm_failsafe != _mixing_output.failsafeValue(i)) {
int32_t pwm_fail_new = _mixing_output.failsafeValue(i);
param_set(param_find(str), &pwm_fail_new);
}
if (pwm_failsafe != _mixing_output.failsafeValue(i)) {
int32_t pwm_fail_new = _mixing_output.failsafeValue(i);
param_set(param_find(str), &pwm_fail_new);
}
}
}
@@ -681,19 +649,14 @@ void PWMOut::update_params()
// PWM_MAIN_DISx
{
sprintf(str, "%s_DIS%u", prefix, i + 1);
int32_t pwm_dis = -1;
int32_t pwm_dis = 0;
if (param_get(param_find(str), &pwm_dis) == PX4_OK) {
if (pwm_dis >= 0) {
_mixing_output.disarmedValue(i) = math::constrain(pwm_dis, 0, PWM_HIGHEST_MAX);
_mixing_output.disarmedValue(i) = math::constrain(pwm_dis, 0, PWM_HIGHEST_MAX);
if (pwm_dis != _mixing_output.disarmedValue(i)) {
int32_t pwm_dis_new = _mixing_output.disarmedValue(i);
param_set(param_find(str), &pwm_dis_new);
}
} else {
_mixing_output.disarmedValue(i) = pwm_disarmed_default;
if (pwm_dis != _mixing_output.disarmedValue(i)) {
int32_t pwm_dis_new = _mixing_output.disarmedValue(i);
param_set(param_find(str), &pwm_dis_new);
}
}
@@ -720,6 +683,24 @@ void PWMOut::update_params()
}
}
// PWM_MAIN_RATEx
{
//uint32_t rate_map = 0;
for (unsigned i = 0; i < _num_outputs; i++) {
sprintf(str, "%s_RATE%u", prefix, i + 1);
int32_t pwm_rate = 50;
if (param_get(param_find(str), &pwm_rate) == PX4_OK) {
//rate_map |=
}
}
// set_pwm_rate(uint32_t rate_map, unsigned default_rate, unsigned alt_rate)
}
if (_mixing_output.mixers()) {
int16_t values[FMU_MAX_ACTUATORS] {};
+21 -49
View File
@@ -1199,21 +1199,10 @@ void PX4IO::update_params()
return;
}
int32_t pwm_min_default = PWM_DEFAULT_MIN;
int32_t pwm_max_default = PWM_DEFAULT_MAX;
int32_t pwm_disarmed_default = 0;
int32_t pwm_rate_default = 50;
const char *prefix = "PWM_MAIN";
param_get(param_find("PWM_MAIN_MIN"), &pwm_min_default);
param_get(param_find("PWM_MAIN_MAX"), &pwm_max_default);
param_get(param_find("PWM_MAIN_DISARM"), &pwm_disarmed_default);
param_get(param_find("PWM_MAIN_RATE"), &pwm_rate_default);
char str[17];
// PWM_MAIN_MINx
{
pwm_output_values pwm{};
@@ -1221,19 +1210,14 @@ void PX4IO::update_params()
for (unsigned i = 0; i < _max_actuators; i++) {
sprintf(str, "%s_MIN%u", prefix, i + 1);
int32_t pwm_min = -1;
int32_t pwm_min = PWM_DEFAULT_MIN;
if (param_get(param_find(str), &pwm_min) == PX4_OK) {
if (pwm_min >= 0) {
pwm.values[i] = math::constrain(pwm_min, PWM_LOWEST_MIN, PWM_HIGHEST_MIN);
pwm.values[i] = math::constrain(pwm_min, PWM_LOWEST_MIN, PWM_HIGHEST_MIN);
if (pwm_min != pwm.values[i]) {
int32_t pwm_min_new = pwm.values[i];
param_set(param_find(str), &pwm_min_new);
}
} else {
pwm.values[i] = pwm_min_default;
if (pwm_min != pwm.values[i]) {
int32_t pwm_min_new = pwm.values[i];
param_set(param_find(str), &pwm_min_new);
}
}
}
@@ -1248,19 +1232,14 @@ void PX4IO::update_params()
for (unsigned i = 0; i < _max_actuators; i++) {
sprintf(str, "%s_MAX%u", prefix, i + 1);
int32_t pwm_max = -1;
int32_t pwm_max = PWM_DEFAULT_MAX;
if (param_get(param_find(str), &pwm_max) == PX4_OK) {
if (pwm_max >= 0) {
pwm.values[i] = math::constrain(pwm_max, PWM_LOWEST_MAX, PWM_HIGHEST_MAX);
pwm.values[i] = math::constrain(pwm_max, PWM_LOWEST_MAX, PWM_HIGHEST_MAX);
if (pwm_max != pwm.values[i]) {
int32_t pwm_max_new = pwm.values[i];
param_set(param_find(str), &pwm_max_new);
}
} else {
pwm.values[i] = pwm_max_default;
if (pwm_max != pwm.values[i]) {
int32_t pwm_max_new = pwm.values[i];
param_set(param_find(str), &pwm_max_new);
}
}
}
@@ -1275,16 +1254,14 @@ void PX4IO::update_params()
for (unsigned i = 0; i < _max_actuators; i++) {
sprintf(str, "%s_FAIL%u", prefix, i + 1);
int32_t pwm_fail = -1;
int32_t pwm_fail = 0;
if (param_get(param_find(str), &pwm_fail) == PX4_OK) {
if (pwm_fail >= 0) {
pwm.values[i] = math::constrain(pwm_fail, 0, PWM_HIGHEST_MAX);
pwm.values[i] = math::constrain(pwm_fail, 0, PWM_HIGHEST_MAX);
if (pwm_fail != pwm.values[i]) {
int32_t pwm_fail_new = pwm.values[i];
param_set(param_find(str), &pwm_fail_new);
}
if (pwm_fail != pwm.values[i]) {
int32_t pwm_fail_new = pwm.values[i];
param_set(param_find(str), &pwm_fail_new);
}
}
}
@@ -1299,19 +1276,14 @@ void PX4IO::update_params()
for (unsigned i = 0; i < _max_actuators; i++) {
sprintf(str, "%s_DIS%u", prefix, i + 1);
int32_t pwm_dis = -1;
int32_t pwm_dis = 0;
if (param_get(param_find(str), &pwm_dis) == PX4_OK) {
if (pwm_dis >= 0) {
pwm.values[i] = math::constrain(pwm_dis, 0, PWM_HIGHEST_MAX);
pwm.values[i] = math::constrain(pwm_dis, 0, PWM_HIGHEST_MAX);
if (pwm_dis != pwm.values[i]) {
int32_t pwm_dis_new = pwm.values[i];
param_set(param_find(str), &pwm_dis_new);
}
} else {
pwm.values[i] = pwm_disarmed_default;
if (pwm_dis != pwm.values[i]) {
int32_t pwm_dis_new = pwm.values[i];
param_set(param_find(str), &pwm_dis_new);
}
}
}
@@ -1325,7 +1297,7 @@ void PX4IO::update_params()
for (unsigned i = 0; i < _max_actuators; i++) {
sprintf(str, "%s_REV%u", prefix, i + 1);
int32_t pwm_rev = -1;
int32_t pwm_rev = 0;
if (param_get(param_find(str), &pwm_rev) == PX4_OK) {
if (pwm_rev >= 1) {
@@ -556,11 +556,6 @@ int snapdragon_pwm_out_main(int argc, char *argv[])
}
}
// gets the parameters for the esc's pwm
param_get(param_find("PWM_MAIN_DISARM"), &snapdragon_pwm::_pwm_disarmed);
param_get(param_find("PWM_MAIN_MIN"), &snapdragon_pwm::_pwm_min);
param_get(param_find("PWM_MAIN_MAX"), &snapdragon_pwm::_pwm_max);
/*
* Start/load the driver.
*/
-23
View File
@@ -141,29 +141,6 @@ bool param_modify_on_import(bson_node_t node)
}
}
// 2021-01-31 (v1.12 alpha): translate PWM_MIN/PWM_MAX/PWM_DISARMED to PWM_MAIN
{
if (strcmp("PWM_MIN", node->name) == 0) {
strcpy(node->name, "PWM_MAIN_MIN");
PX4_INFO("copying %s -> %s", "PWM_MIN", "PWM_MAIN_MIN");
}
if (strcmp("PWM_MAX", node->name) == 0) {
strcpy(node->name, "PWM_MAIN_MAX");
PX4_INFO("copying %s -> %s", "PWM_MAX", "PWM_MAIN_MAX");
}
if (strcmp("PWM_RATE", node->name) == 0) {
strcpy(node->name, "PWM_MAIN_RATE");
PX4_INFO("copying %s -> %s", "PWM_RATE", "PWM_MAIN_RATE");
}
if (strcmp("PWM_DISARMED", node->name) == 0) {
strcpy(node->name, "PWM_MAIN_DISARM");
PX4_INFO("copying %s -> %s", "PWM_DISARMED", "PWM_MAIN_DISARM");
}
}
// translate (SPI) calibration ID parameters. This can be removed after the next release (current release=1.10)
if (node->type != BSON_INT32) {
+5 -57
View File
@@ -6,87 +6,37 @@ parameters:
- group: PWM Outputs
definitions:
PWM_AUX_RATE:
description:
short: PWM aux output frequency
long: |
Set to 400 for industry default or 1000 for high frequency ESCs.
Set to 0 for Oneshot125.
type: int32
unit: Hz
min: -1
max: 2000
default: 50
PWM_AUX_MIN:
description:
short: PWM aux minimum value
long: |
Set to 1000 for industry default or 900 to increase servo travel.
type: int32
unit: us
min: 800
max: 1400
default: 1000
PWM_AUX_MAX:
description:
short: PWM aux maximum value
long: |
Set to 2000 for industry default or 2100 to increase servo travel.
type: int32
unit: us
min: 1600
max: 2200
default: 2000
PWM_AUX_DISARM:
description:
short: PWM aux disarmed value
long: |
This is the PWM pulse the autopilot is outputting if not armed.
The main use of this parameter is to silence ESCs when they are disarmed.
type: int32
unit: us
min: 0
max: 2200
default: 1500
PWM_AUX_MIN${i}:
description:
short: PWM aux ${i} minimum value
long: |
This is the minimum PWM pulse the autopilot is allowed to output.
When set to -1 the value for PWM_AUX_MIN will be used
type: int32
unit: us
min: -1
min: 800
max: 1600
num_instances: *max_num_config_instances
instance_start: 1
default: -1
default: 1000
PWM_AUX_MAX${i}:
description:
short: PWM aux ${i} maximum value
long: |
This is the maximum PWM pulse the autopilot is allowed to output.
When set to -1 the value for PWM_AUX_MAX will be used
type: int32
unit: us
min: -1
min: 1400
max: 2150
num_instances: *max_num_config_instances
instance_start: 1
default: -1
default: 2000
PWM_AUX_FAIL${i}:
description:
short: PWM aux ${i} failsafe value
long: |
This is the PWM pulse the autopilot is outputting if in failsafe mode.
When set to -1 the value is set automatically depending if the actuator
is a motor (900us) or a servo (1500us)
type: int32
unit: us
min: 0
@@ -100,10 +50,9 @@ parameters:
short: PWM aux ${i} disarmed value
long: |
This is the PWM pulse the autopilot is outputting if not armed.
When set to -1 the value for PWM_AUX_DISARMED will be used
type: int32
unit: us
min: -1
min: 0
max: 2150
num_instances: *max_num_config_instances
instance_start: 1
@@ -128,7 +77,6 @@ parameters:
long: |
Enable to invert the channel.
Warning: Use this parameter when connected to a servo only.
For a brushless motor, invert manually two phases to reverse the direction.
type: boolean
num_instances: *max_num_config_instances
instance_start: 1
+7 -59
View File
@@ -6,87 +6,37 @@ parameters:
- group: PWM Outputs
definitions:
PWM_EXTRA_RATE:
description:
short: PWM extra output frequency
long: |
Set to 400 for industry default or 1000 for high frequency ESCs.
Set to 0 for Oneshot125.
type: int32
unit: Hz
min: -1
max: 2000
default: 50
PWM_EXTRA_MIN:
description:
short: PWM extra minimum value
long: |
Set to 1000 for industry default or 900 to increase servo travel.
type: int32
unit: us
min: 800
max: 1400
default: 1000
PWM_EXTRA_MAX:
description:
short: PWM extra maximum value
long: |
Set to 2000 for industry default or 2100 to increase servo travel.
type: int32
unit: us
min: 1600
max: 2200
default: 2000
PWM_EXTRA_DISARM:
description:
short: PWM extra disarmed value
long: |
This is the PWM pulse the autopilot is outputting if not armed.
The main use of this parameter is to silence ESCs when they are disarmed.
type: int32
unit: us
min: 0
max: 2200
default: 1500
PWM_EXTRA_MIN${i}:
description:
short: PWM extra ${i} minimum value
long: |
This is the minimum PWM pulse the autopilot is allowed to output.
When set to -1 the value for PWM_EXTRA_MIN will be used
type: int32
unit: us
min: -1
min: 800
max: 1600
num_instances: *max_num_config_instances
instance_start: 1
default: -1
default: 1000
PWM_EXTRA_MAX${i}:
description:
short: PWM extra ${i} maximum value
long: |
This is the maximum PWM pulse the autopilot is allowed to output.
When set to -1 the value for PWM_EXTRA_MAX will be used
type: int32
unit: us
min: -1
min: 1400
max: 2150
num_instances: *max_num_config_instances
instance_start: 1
default: -1
default: 2000
PWM_EXTRA_FAIL${i}:
description:
short: PWM extra ${i} failsafe value
long: |
This is the PWM pulse the autopilot is outputting if in failsafe mode.
When set to -1 the value is set automatically depending if the actuator
is a motor (900us) or a servo (1500us)
type: int32
unit: us
min: 0
@@ -100,14 +50,13 @@ parameters:
short: PWM extra ${i} disarmed value
long: |
This is the PWM pulse the autopilot is outputting if not armed.
When set to -1 the value for PWM_EXTRA_DISARM will be used
type: int32
unit: us
min: -1
min: 0
max: 2150
num_instances: *max_num_config_instances
instance_start: 1
default: -1
default: 0
PWM_EXTRA_TRIM${i}:
description:
@@ -128,7 +77,6 @@ parameters:
long: |
Enable to invert the channel.
Warning: Use this parameter when connected to a servo only.
For a brushless motor, invert manually two phases to reverse the direction.
type: boolean
num_instances: *max_num_config_instances
instance_start: 1
@@ -138,7 +86,7 @@ parameters:
description:
short: PWM extra ${i} rate
long: |
Set the default PWM output frequency for the main outputs
Set the default PWM output frequency for the extra outputs
type: int32
unit: Hz
min: 0
+6 -58
View File
@@ -6,87 +6,37 @@ parameters:
- group: PWM Outputs
definitions:
PWM_MAIN_RATE:
description:
short: PWM main output frequency
long: |
Set to 400 for industry default or 1000 for high frequency ESCs.
Set to 0 for Oneshot125.
type: int32
unit: Hz
min: -1
max: 2000
default: 400
PWM_MAIN_MIN:
description:
short: PWM main minimum value
long: |
Set to 1000 for industry default or 900 to increase servo travel.
type: int32
unit: us
min: 800
max: 1400
default: 1000
PWM_MAIN_MAX:
description:
short: PWM main maximum value
long: |
Set to 2000 for industry default or 2100 to increase servo travel.
type: int32
unit: us
min: 1600
max: 2200
default: 2000
PWM_MAIN_DISARM:
description:
short: PWM main disarmed value
long: |
This is the PWM pulse the autopilot is outputting if not armed.
The main use of this parameter is to silence ESCs when they are disarmed.
type: int32
unit: us
min: 0
max: 2200
default: 900
PWM_MAIN_MIN${i}:
description:
short: PWM main ${i} minimum value
long: |
This is the minimum PWM pulse the autopilot is allowed to output.
When set to -1 the value for PWM_MIN will be used
type: int32
unit: us
min: -1
min: 800
max: 1600
num_instances: *max_num_config_instances
instance_start: 1
default: -1
default: 1000
PWM_MAIN_MAX${i}:
description:
short: PWM main ${i} maximum value
long: |
This is the maximum PWM pulse the autopilot is allowed to output.
When set to -1 the value for PWM_MAX will be used
type: int32
unit: us
min: -1
min: 1400
max: 2150
num_instances: *max_num_config_instances
instance_start: 1
default: -1
default: 2000
PWM_MAIN_FAIL${i}:
description:
short: PWM main ${i} failsafe value
long: |
This is the PWM pulse the autopilot is outputting if in failsafe mode.
When set to -1 the value is set automatically depending if the actuator
is a motor (900us) or a servo (1500us)
type: int32
unit: us
min: 0
@@ -100,14 +50,13 @@ parameters:
short: PWM main ${i} disarmed value
long: |
This is the PWM pulse the autopilot is outputting if not armed.
When set to -1 the value for PWM_DISARMED will be used
type: int32
unit: us
min: -1
min: 0
max: 2150
num_instances: *max_num_config_instances
instance_start: 1
default: -1
default: 0
PWM_MAIN_TRIM${i}:
description:
@@ -128,7 +77,6 @@ parameters:
long: |
Enable to invert the channel.
Warning: Use this parameter when connected to a servo only.
For a brushless motor, invert manually two phases to reverse the direction.
type: boolean
num_instances: *max_num_config_instances
instance_start: 1