VTOL: add parameter to set the PWM_OUTPUT_DEVICE_PATH (#14732)

The device path is needed to apply PWM limits on the motors that are not
used for FW flight (switch them off). With this parameter the device path can be set
to either IO or FMU, depending on whether the motors are on the IO or FMU port.

Signed-off-by: Silvan Fuhrer <silvan@auterion.com>
This commit is contained in:
Silvan Fuhrer 2020-04-22 20:42:23 +02:00 committed by GitHub
parent d29344cb9c
commit 172e435ec0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 21 additions and 1 deletions

View File

@ -61,6 +61,7 @@ __BEGIN_DECLS
*/
#define PWM_OUTPUT_BASE_DEVICE_PATH "/dev/pwm_output"
#define PWM_OUTPUT0_DEVICE_PATH "/dev/pwm_output0"
#define PWM_OUTPUT1_DEVICE_PATH "/dev/pwm_output1"
#define PWM_OUTPUT_MAX_CHANNELS 16

View File

@ -92,6 +92,7 @@ VtolAttitudeControl::VtolAttitudeControl() :
_params_handles.down_pitch_max = param_find("VT_DWN_PITCH_MAX");
_params_handles.forward_thrust_scale = param_find("VT_FWD_THRUST_SC");
_params_handles.vt_mc_on_fmu = param_find("VT_MC_ON_FMU");
/* fetch initial parameter values */
parameters_update();
@ -297,6 +298,9 @@ VtolAttitudeControl::parameters_update()
param_get(_params_handles.dec_to_pitch_ff, &_params.dec_to_pitch_ff);
param_get(_params_handles.dec_to_pitch_i, &_params.dec_to_pitch_i);
param_get(_params_handles.vt_mc_on_fmu, &l);
_params.vt_mc_on_fmu = l;
// update the parameters of the instances of base VtolType
if (_vtol_type != nullptr) {
_vtol_type->parameters_update();

View File

@ -206,6 +206,7 @@ private:
param_t dec_to_pitch_ff;
param_t dec_to_pitch_i;
param_t back_trans_dec_sp;
param_t vt_mc_on_fmu;
} _params_handles{};
/* for multicopters it is usual to have a non-zero idle speed of the engines

View File

@ -342,3 +342,15 @@ PARAM_DEFINE_FLOAT(VT_B_DEC_FF, 0.12f);
* @group VTOL Attitude Control
*/
PARAM_DEFINE_FLOAT(VT_B_DEC_I, 0.1f);
/**
* Enable the usage of AUX outputs for hover motors.
*
* Set this parameter to true if the vehicle's hover motors are connected to the FMU (AUX) port.
* Not required for boards that only have a FMU, and no IO.
* Only applies for standard VTOL and tiltrotor.
*
* @boolean
* @group VTOL Attitude Control
*/
PARAM_DEFINE_INT32(VT_MC_ON_FMU, 0);

View File

@ -317,7 +317,8 @@ bool VtolType::set_idle_fw()
bool VtolType::apply_pwm_limits(struct pwm_output_values &pwm_values, pwm_limit_type type)
{
const char *dev = PWM_OUTPUT0_DEVICE_PATH;
const char *dev = _params->vt_mc_on_fmu ? PWM_OUTPUT1_DEVICE_PATH : PWM_OUTPUT0_DEVICE_PATH;
int fd = px4_open(dev, 0);
if (fd < 0) {

View File

@ -75,6 +75,7 @@ struct Params {
float dec_to_pitch_ff;
float dec_to_pitch_i;
float back_trans_dec_sp;
bool vt_mc_on_fmu;
};
// Has to match 1:1 msg/vtol_vehicle_status.msg