mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-23 09:08:30 -04:00
Plane: Allow center throttle to be trim airspeed in cruise
This commit is contained in:
parent
20c56f3e06
commit
f150cae75a
@ -1173,7 +1173,7 @@ const AP_Param::GroupInfo ParametersG2::var_info[] = {
|
||||
// @Param: FLIGHT_OPTIONS
|
||||
// @DisplayName: Flight mode options
|
||||
// @Description: Flight mode specific options
|
||||
// @Bitmask: 0:Rudder mixing in direct flight modes only (Manual, Stabilize, Acro)
|
||||
// @Bitmask: 0:Rudder mixing in direct flight modes only (Manual, Stabilize, Acro),1:Use centered throttle in Cruise or FBWB to indicate trim airspeed
|
||||
// @User: Advanced
|
||||
AP_GROUPINFO("FLIGHT_OPTIONS", 13, ParametersG2, flight_options, 0),
|
||||
|
||||
|
@ -200,4 +200,5 @@ enum {
|
||||
|
||||
enum FlightOptions {
|
||||
DIRECT_RUDDER_ONLY = (1 << 0),
|
||||
CRUISE_TRIM_THROTTLE = (1 << 1),
|
||||
};
|
||||
|
@ -109,10 +109,32 @@ void Plane::calc_airspeed_errors()
|
||||
|
||||
// FBW_B/cruise airspeed target
|
||||
if (!failsafe.rc_failsafe && (control_mode == FLY_BY_WIRE_B || control_mode == CRUISE)) {
|
||||
target_airspeed_cm = ((int32_t)(aparm.airspeed_max -
|
||||
aparm.airspeed_min) *
|
||||
channel_throttle->get_control_in()) +
|
||||
((int32_t)aparm.airspeed_min * 100);
|
||||
if (g2.flight_options & FlightOptions::CRUISE_TRIM_THROTTLE) {
|
||||
float control_min = 0.0f;
|
||||
float control_mid = 0.0f;
|
||||
const float control_max = channel_throttle->get_range();
|
||||
const float control_in = channel_throttle->get_control_in();
|
||||
switch (channel_throttle->get_type()) {
|
||||
case RC_Channel::RC_CHANNEL_TYPE_ANGLE:
|
||||
control_min = -control_max;
|
||||
break;
|
||||
case RC_Channel::RC_CHANNEL_TYPE_RANGE:
|
||||
control_mid = channel_throttle->get_control_mid();
|
||||
break;
|
||||
}
|
||||
if (control_in <= control_mid) {
|
||||
target_airspeed_cm = linear_interpolate(aparm.airspeed_min * 100, aparm.airspeed_cruise_cm,
|
||||
control_in,
|
||||
control_min, control_mid);
|
||||
} else {
|
||||
target_airspeed_cm = linear_interpolate(aparm.airspeed_cruise_cm, aparm.airspeed_max * 100,
|
||||
control_in,
|
||||
control_mid, control_max);
|
||||
}
|
||||
} else {
|
||||
target_airspeed_cm = ((int32_t)(aparm.airspeed_max - aparm.airspeed_min) *
|
||||
channel_throttle->get_control_in()) + ((int32_t)aparm.airspeed_min * 100);
|
||||
}
|
||||
|
||||
} else if (flight_stage == AP_Vehicle::FixedWing::FLIGHT_LAND) {
|
||||
// Landing airspeed target
|
||||
|
Loading…
Reference in New Issue
Block a user