mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-19 03:33:34 +08:00
implemented mapping between desired thrust and applied pwm in
multirotor mixer. Signed-off-by: Roman <bapstroman@gmail.com>
This commit is contained in:
@@ -248,7 +248,13 @@ mixer_tick(void)
|
||||
}
|
||||
|
||||
/* mix */
|
||||
/* update parameter for mc thrust model if it updated */
|
||||
if (update_mc_thrust_param) {
|
||||
mixer_group.set_thrust_factor(REG_TO_FLOAT(r_setup_thr_fac));
|
||||
update_mc_thrust_param = false;
|
||||
}
|
||||
|
||||
/* mix */
|
||||
/* poor mans mutex */
|
||||
in_mixer = true;
|
||||
mixed = mixer_group.mix(&outputs[0], PX4IO_SERVO_COUNT, &r_mixer_limits);
|
||||
@@ -536,6 +542,12 @@ mixer_set_failsafe()
|
||||
mixer_group.set_max_delta_out_once(delta_out_max);
|
||||
}
|
||||
|
||||
/* update parameter for mc thrust model if it updated */
|
||||
if (update_mc_thrust_param) {
|
||||
mixer_group.set_thrust_factor(REG_TO_FLOAT(r_setup_thr_fac));
|
||||
update_mc_thrust_param = false;
|
||||
}
|
||||
|
||||
/* mix */
|
||||
mixed = mixer_group.mix(&outputs[0], PX4IO_SERVO_COUNT, &r_mixer_limits);
|
||||
|
||||
|
||||
@@ -241,7 +241,9 @@ enum { /* DSM bind states */
|
||||
|
||||
#define PX4IO_P_SETUP_MOTOR_SLEW_MAX 24 /* max motor slew rate */
|
||||
|
||||
#define PX4IO_P_SETUP_THERMAL 25 /* thermal management */
|
||||
#define PX4IO_P_SETUP_THR_MDL_FAC 25 /* factor for modelling static pwm output to thrust relationship */
|
||||
|
||||
#define PX4IO_P_SETUP_THERMAL 26 /* thermal management */
|
||||
#define PX4IO_THERMAL_IGNORE UINT16_MAX
|
||||
#define PX4IO_THERMAL_OFF 0
|
||||
#define PX4IO_THERMAL_FULL 10000
|
||||
|
||||
@@ -127,6 +127,7 @@ extern uint16_t r_page_servo_disarmed[]; /* PX4IO_PAGE_DISARMED_PWM */
|
||||
#define r_setup_scale_pitch r_page_setup[PX4IO_P_SETUP_SCALE_PITCH]
|
||||
#define r_setup_scale_yaw r_page_setup[PX4IO_P_SETUP_SCALE_YAW]
|
||||
#define r_setup_sbus_rate r_page_setup[PX4IO_P_SETUP_SBUS_RATE]
|
||||
#define r_setup_thr_fac r_page_setup[PX4IO_P_SETUP_THR_MDL_FAC]
|
||||
#define r_setup_slew_max r_page_setup[PX4IO_P_SETUP_MOTOR_SLEW_MAX]
|
||||
|
||||
#define r_control_values (&r_page_controls[0])
|
||||
@@ -148,6 +149,7 @@ struct sys_state_s {
|
||||
|
||||
extern struct sys_state_s system_state;
|
||||
extern float dt;
|
||||
extern bool update_mc_thrust_param;
|
||||
|
||||
/*
|
||||
* PWM limit structure
|
||||
|
||||
@@ -56,6 +56,7 @@
|
||||
static int registers_set_one(uint8_t page, uint8_t offset, uint16_t value);
|
||||
static void pwm_configure_rates(uint16_t map, uint16_t defaultrate, uint16_t altrate);
|
||||
|
||||
bool update_mc_thrust_param;
|
||||
/**
|
||||
* PAGE 0
|
||||
*
|
||||
@@ -182,6 +183,7 @@ volatile uint16_t r_page_setup[] = {
|
||||
[PX4IO_P_SETUP_SCALE_PITCH] = 10000,
|
||||
[PX4IO_P_SETUP_SCALE_YAW] = 10000,
|
||||
[PX4IO_P_SETUP_MOTOR_SLEW_MAX] = 0,
|
||||
[PX4IO_P_SETUP_THR_MDL_FAC] = 0,
|
||||
[PX4IO_P_SETUP_THERMAL] = PX4IO_THERMAL_IGNORE
|
||||
};
|
||||
|
||||
@@ -709,12 +711,14 @@ registers_set_one(uint8_t page, uint8_t offset, uint16_t value)
|
||||
case PX4IO_P_SETUP_SCALE_ROLL:
|
||||
case PX4IO_P_SETUP_SCALE_PITCH:
|
||||
case PX4IO_P_SETUP_SCALE_YAW:
|
||||
case PX4IO_P_SETUP_MOTOR_SLEW_MAX:
|
||||
case PX4IO_P_SETUP_SBUS_RATE:
|
||||
r_page_setup[offset] = value;
|
||||
sbus1_set_output_rate_hz(value);
|
||||
break;
|
||||
|
||||
case PX4IO_P_SETUP_MOTOR_SLEW_MAX:
|
||||
case PX4IO_P_SETUP_THR_MDL_FAC:
|
||||
update_mc_thrust_param = true;
|
||||
r_page_setup[offset] = value;
|
||||
break;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user