Skip to content

Commit

Permalink
VTOL: add parameter to set the PWM_OUTPUT_DEVICE_PATH (#14732)
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
sfuhrer authored Apr 22, 2020
1 parent d29344c commit 172e435
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/drivers/drv_pwm_output.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 4 additions & 0 deletions src/modules/vtol_att_control/vtol_att_control_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down
1 change: 1 addition & 0 deletions src/modules/vtol_att_control/vtol_att_control_main.h
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ class VtolAttitudeControl : public ModuleBase<VtolAttitudeControl>, public px4::
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
Expand Down
12 changes: 12 additions & 0 deletions src/modules/vtol_att_control/vtol_att_control_params.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
3 changes: 2 additions & 1 deletion src/modules/vtol_att_control/vtol_type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions src/modules/vtol_att_control/vtol_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 172e435

Please sign in to comment.