mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-29 20:18:31 -04:00
Copter: set tradheli rotor speed using 0 to 1 range
This commit is contained in:
parent
7fc37e7801
commit
3eaf7a4582
@ -545,8 +545,6 @@ private:
|
|||||||
// governor. Even a single "off" frame can cause the rotor to slow dramatically and take a long time to restart.
|
// governor. Even a single "off" frame can cause the rotor to slow dramatically and take a long time to restart.
|
||||||
ModeFilterInt16_Size5 rotor_speed_deglitch_filter {4};
|
ModeFilterInt16_Size5 rotor_speed_deglitch_filter {4};
|
||||||
|
|
||||||
int16_t rsc_control_deglitched;
|
|
||||||
|
|
||||||
// Tradheli flags
|
// Tradheli flags
|
||||||
struct {
|
struct {
|
||||||
uint8_t dynamic_flight : 1; // 0 // true if we are moving at a significant speed (used to turn on/off leaky I terms)
|
uint8_t dynamic_flight : 1; // 0 // true if we are moving at a significant speed (used to turn on/off leaky I terms)
|
||||||
|
@ -93,7 +93,7 @@ void Copter::update_heli_control_dynamics(void)
|
|||||||
// Use Leaky_I if we are not moving fast
|
// Use Leaky_I if we are not moving fast
|
||||||
attitude_control.use_leaky_i(!heli_flags.dynamic_flight);
|
attitude_control.use_leaky_i(!heli_flags.dynamic_flight);
|
||||||
|
|
||||||
if (ap.land_complete || (motors.get_desired_rotor_speed() == 0)){
|
if (ap.land_complete || (is_zero(motors.get_desired_rotor_speed()))){
|
||||||
// if we are landed or there is no rotor power demanded, decrement slew scalar
|
// if we are landed or there is no rotor power demanded, decrement slew scalar
|
||||||
hover_roll_trim_scalar_slew--;
|
hover_roll_trim_scalar_slew--;
|
||||||
} else {
|
} else {
|
||||||
@ -156,18 +156,17 @@ void Copter::heli_update_rotor_speed_targets()
|
|||||||
// get rotor control method
|
// get rotor control method
|
||||||
uint8_t rsc_control_mode = motors.get_rsc_mode();
|
uint8_t rsc_control_mode = motors.get_rsc_mode();
|
||||||
|
|
||||||
rsc_control_deglitched = rotor_speed_deglitch_filter.apply(g.rc_8.control_in);
|
float rsc_control_deglitched = rotor_speed_deglitch_filter.apply((float)g.rc_8.control_in/1000.0f);
|
||||||
|
|
||||||
|
|
||||||
switch (rsc_control_mode) {
|
switch (rsc_control_mode) {
|
||||||
case ROTOR_CONTROL_MODE_SPEED_PASSTHROUGH:
|
case ROTOR_CONTROL_MODE_SPEED_PASSTHROUGH:
|
||||||
// pass through pilot desired rotor speed if control input is higher than 10, creating a deadband at the bottom
|
// pass through pilot desired rotor speed if control input is higher than 10, creating a deadband at the bottom
|
||||||
if (rsc_control_deglitched > 10) {
|
if (rsc_control_deglitched > 0.01f) {
|
||||||
motors.set_interlock(true);
|
motors.set_interlock(true);
|
||||||
motors.set_desired_rotor_speed(rsc_control_deglitched);
|
motors.set_desired_rotor_speed(rsc_control_deglitched);
|
||||||
} else {
|
} else {
|
||||||
motors.set_interlock(false);
|
motors.set_interlock(false);
|
||||||
motors.set_desired_rotor_speed(0);
|
motors.set_desired_rotor_speed(0.0f);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ROTOR_CONTROL_MODE_SPEED_SETPOINT:
|
case ROTOR_CONTROL_MODE_SPEED_SETPOINT:
|
||||||
@ -175,12 +174,12 @@ void Copter::heli_update_rotor_speed_targets()
|
|||||||
case ROTOR_CONTROL_MODE_CLOSED_LOOP_POWER_OUTPUT:
|
case ROTOR_CONTROL_MODE_CLOSED_LOOP_POWER_OUTPUT:
|
||||||
// pass setpoint through as desired rotor speed, this is almost pointless as the Setpoint serves no function in this mode
|
// pass setpoint through as desired rotor speed, this is almost pointless as the Setpoint serves no function in this mode
|
||||||
// other than being used to create a crude estimate of rotor speed
|
// other than being used to create a crude estimate of rotor speed
|
||||||
if (rsc_control_deglitched > 0) {
|
if (rsc_control_deglitched > 0.0f) {
|
||||||
motors.set_interlock(true);
|
motors.set_interlock(true);
|
||||||
motors.set_desired_rotor_speed(motors.get_rsc_setpoint());
|
motors.set_desired_rotor_speed(motors.get_rsc_setpoint());
|
||||||
}else{
|
}else{
|
||||||
motors.set_interlock(false);
|
motors.set_interlock(false);
|
||||||
motors.set_desired_rotor_speed(0);
|
motors.set_desired_rotor_speed(0.0f);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user