Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VTOL: add parameter to set the PWM_OUTPUT_DEVICE_PATH #14732

Merged
merged 1 commit into from
Apr 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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