Allow the user to provide the motor/channel numbers that should be disabled in fixed wing mode in the airframe config.

This commit is contained in:
Simon Wilks
2015-08-11 16:11:53 +02:00
committed by tumbili
parent c21dd735ed
commit e7364d302a
4 changed files with 50 additions and 2 deletions
@@ -46,5 +46,6 @@ set PWM_AUX_MAX 2000
set MAV_TYPE 21 set MAV_TYPE 21
param set VT_MOT_COUNT 6 param set VT_MOT_COUNT 6
param set VT_FW_MOT_OFF 23
param set VT_IDLE_PWM_MC 1080 param set VT_IDLE_PWM_MC 1080
param set VT_TYPE 1 param set VT_TYPE 1
+27 -2
View File
@@ -67,6 +67,7 @@ _min_front_trans_dur(0.5f)
_params_handles_tiltrotor.airspeed_blend_start = param_find("VT_ARSP_BLEND"); _params_handles_tiltrotor.airspeed_blend_start = param_find("VT_ARSP_BLEND");
_params_handles_tiltrotor.elevons_mc_lock = param_find("VT_ELEV_MC_LOCK"); _params_handles_tiltrotor.elevons_mc_lock = param_find("VT_ELEV_MC_LOCK");
_params_handles_tiltrotor.front_trans_dur_p2 = param_find("VT_TRANS_P2_DUR"); _params_handles_tiltrotor.front_trans_dur_p2 = param_find("VT_TRANS_P2_DUR");
_params_handles_tiltrotor.fw_motors_off = param_find("VT_FW_MOT_OFF");
} }
Tiltrotor::~Tiltrotor() Tiltrotor::~Tiltrotor()
@@ -80,6 +81,11 @@ Tiltrotor::parameters_update()
float v; float v;
int l; int l;
/* motors that must be turned off when in fixed wing mode */
param_get(_params_handles_tiltrotor.fw_motors_off, &l);
_params_tiltrotor.fw_motors_off = get_motor_off_channels(l);
/* vtol duration of a front transition */ /* vtol duration of a front transition */
param_get(_params_handles_tiltrotor.front_trans_dur, &v); param_get(_params_handles_tiltrotor.front_trans_dur, &v);
_params_tiltrotor.front_trans_dur = math::constrain(v,1.0f,5.0f); _params_tiltrotor.front_trans_dur = math::constrain(v,1.0f,5.0f);
@@ -126,6 +132,22 @@ Tiltrotor::parameters_update()
return OK; return OK;
} }
int Tiltrotor::get_motor_off_channels(int channels) {
int channel_bitmap = 0;
int channel;
for (int i = 0; i < _params->vtol_motor_count; ++i) {
channel = channels % 10;
if (channel == 0) {
break;
}
channel_bitmap |= 1 << channel;
channels = channels / 10;
}
return channel_bitmap;
}
void Tiltrotor::update_vtol_state() void Tiltrotor::update_vtol_state()
{ {
parameters_update(); parameters_update();
@@ -357,7 +379,7 @@ void Tiltrotor::set_rear_motor_state(rear_motor_state state) {
memset(&pwm_values, 0, sizeof(pwm_values)); memset(&pwm_values, 0, sizeof(pwm_values));
for (int i = 0; i < _params->vtol_motor_count; i++) { for (int i = 0; i < _params->vtol_motor_count; i++) {
if (i == 2 || i == 3) { if (is_motor_off_channel(i)) {
pwm_values.values[i] = pwm_value; pwm_values.values[i] = pwm_value;
} else { } else {
pwm_values.values[i] = PWM_DEFAULT_MAX; pwm_values.values[i] = PWM_DEFAULT_MAX;
@@ -370,5 +392,8 @@ void Tiltrotor::set_rear_motor_state(rear_motor_state state) {
if (ret != OK) {errx(ret, "failed setting max values");} if (ret != OK) {errx(ret, "failed setting max values");}
close(fd); close(fd);
}
bool Tiltrotor::is_motor_off_channel(const int channel) {
return (_params_tiltrotor.fw_motors_off >> channel) & 1;
} }
+12
View File
@@ -89,6 +89,7 @@ private:
float airspeed_blend_start; /**< airspeed at which we start blending mc/fw controls */ float airspeed_blend_start; /**< airspeed at which we start blending mc/fw controls */
int elevons_mc_lock; /**< lock elevons in multicopter mode */ int elevons_mc_lock; /**< lock elevons in multicopter mode */
float front_trans_dur_p2; float front_trans_dur_p2;
int fw_motors_off; /**< bitmask of all motors that should be off in fixed wing mode */
} _params_tiltrotor; } _params_tiltrotor;
struct { struct {
@@ -101,6 +102,7 @@ private:
param_t airspeed_blend_start; param_t airspeed_blend_start;
param_t elevons_mc_lock; param_t elevons_mc_lock;
param_t front_trans_dur_p2; param_t front_trans_dur_p2;
param_t fw_motors_off;
} _params_handles_tiltrotor; } _params_handles_tiltrotor;
enum vtol_mode { enum vtol_mode {
@@ -133,6 +135,16 @@ private:
const float _min_front_trans_dur; /**< min possible time in which rotors are rotated into the first position */ const float _min_front_trans_dur; /**< min possible time in which rotors are rotated into the first position */
/**
* Return a bitmap of channels that should be turned off in fixed wing mode.
*/
int get_motor_off_channels(const int channels);
/**
* Return true if the motor channel is off in fixed wing mode.
*/
bool is_motor_off_channel(const int channel);
/** /**
* Write control values to actuator output topics. * Write control values to actuator output topics.
*/ */
@@ -84,3 +84,13 @@ PARAM_DEFINE_FLOAT(VT_TILT_FW, 1.0f);
* @group VTOL Attitude Control * @group VTOL Attitude Control
*/ */
PARAM_DEFINE_FLOAT(VT_TRANS_P2_DUR, 0.5f); PARAM_DEFINE_FLOAT(VT_TRANS_P2_DUR, 0.5f);
/**
* The channel number of motors that must be turned off in fixed wing mode.
*
*
* @min 0
* @max 123456
* @group VTOL Attitude Control
*/
PARAM_DEFINE_INT32(VT_FW_MOT_OFF, 0);