Skip to content

Commit

Permalink
Copter: don't pass channel_yaw->norm_input_dz() into `get_pilot_des…
Browse files Browse the repository at this point in the history
…ired_yaw_rate`
  • Loading branch information
IamPete1 authored and rmackay9 committed Sep 21, 2024
1 parent cb1a156 commit a72182a
Show file tree
Hide file tree
Showing 15 changed files with 19 additions and 16 deletions.
2 changes: 1 addition & 1 deletion ArduCopter/autoyaw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ AC_AttitudeControl::HeadingCommand Mode::AutoYaw::get_heading()
_pilot_yaw_rate_cds = 0.0;
if (!copter.failsafe.radio && copter.flightmode->use_pilot_yaw()) {
// get pilot's desired yaw rate
_pilot_yaw_rate_cds = copter.flightmode->get_pilot_desired_yaw_rate(copter.channel_yaw->norm_input_dz());
_pilot_yaw_rate_cds = copter.flightmode->get_pilot_desired_yaw_rate();
if (!is_zero(_pilot_yaw_rate_cds)) {
auto_yaw.set_mode(AutoYaw::Mode::PILOT_RATE);
}
Expand Down
5 changes: 4 additions & 1 deletion ArduCopter/mode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1035,13 +1035,16 @@ Mode::AltHoldModeState Mode::get_alt_hold_state(float target_climb_rate_cms)

// transform pilot's yaw input into a desired yaw rate
// returns desired yaw rate in centi-degrees per second
float Mode::get_pilot_desired_yaw_rate(float yaw_in)
float Mode::get_pilot_desired_yaw_rate() const
{
// throttle failsafe check
if (copter.failsafe.radio || !rc().has_ever_seen_rc_input()) {
return 0.0f;
}

// Get yaw input
const float yaw_in = channel_yaw->norm_input_dz();

// convert pilot input to the desired yaw rate
return g2.command_model_pilot.get_rate() * 100.0 * input_expo(yaw_in, g2.command_model_pilot.get_expo());
}
Expand Down
2 changes: 1 addition & 1 deletion ArduCopter/mode.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ class Mode {
// pilot input processing
void get_pilot_desired_lean_angles(float &roll_out_cd, float &pitch_out_cd, float angle_max_cd, float angle_limit_cd) const;
Vector2f get_pilot_desired_velocity(float vel_max) const;
float get_pilot_desired_yaw_rate(float yaw_in);
float get_pilot_desired_yaw_rate() const;
float get_pilot_desired_throttle() const;

// returns climb target_rate reduced to avoid obstacles and
Expand Down
2 changes: 1 addition & 1 deletion ArduCopter/mode_acro_heli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ void ModeAcro_Heli::run()
// if there is no external gyro then run the usual
// ACRO_YAW_P gain on the input control, including
// deadzone
yaw_in = get_pilot_desired_yaw_rate(channel_yaw->norm_input_dz());
yaw_in = get_pilot_desired_yaw_rate();
}

// run attitude controller
Expand Down
2 changes: 1 addition & 1 deletion ArduCopter/mode_althold.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ void ModeAltHold::run()
get_pilot_desired_lean_angles(target_roll, target_pitch, copter.aparm.angle_max, attitude_control->get_althold_lean_angle_max_cd());

// get pilot's desired yaw rate
float target_yaw_rate = get_pilot_desired_yaw_rate(channel_yaw->norm_input_dz());
float target_yaw_rate = get_pilot_desired_yaw_rate();

// get pilot desired climb rate
float target_climb_rate = get_pilot_desired_climb_rate(channel_throttle->get_control_in());
Expand Down
2 changes: 1 addition & 1 deletion ArduCopter/mode_autorotate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ void ModeAutorotate::run()
get_pilot_desired_lean_angles(pilot_roll, pilot_pitch, copter.aparm.angle_max, copter.aparm.angle_max);

// Get pilot's desired yaw rate
float pilot_yaw_rate = get_pilot_desired_yaw_rate(channel_yaw->norm_input_dz());
float pilot_yaw_rate = get_pilot_desired_yaw_rate();

// Pitch target is calculated in autorotation phase switch above
attitude_control->input_euler_angle_roll_pitch_euler_rate_yaw(pilot_roll, _pitch_target, pilot_yaw_rate);
Expand Down
2 changes: 1 addition & 1 deletion ArduCopter/mode_autotune.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ void AutoTune::get_pilot_desired_rp_yrate_cd(float &des_roll_cd, float &des_pitc
{
copter.mode_autotune.get_pilot_desired_lean_angles(des_roll_cd, des_pitch_cd, copter.aparm.angle_max,
copter.attitude_control->get_althold_lean_angle_max_cd());
yaw_rate_cds = copter.mode_autotune.get_pilot_desired_yaw_rate(copter.channel_yaw->norm_input_dz());
yaw_rate_cds = copter.mode_autotune.get_pilot_desired_yaw_rate();
}

/*
Expand Down
2 changes: 1 addition & 1 deletion ArduCopter/mode_flowhold.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ void ModeFlowHold::run()
target_climb_rate = constrain_float(target_climb_rate, -get_pilot_speed_dn(), copter.g.pilot_speed_up);

// get pilot's desired yaw rate
float target_yaw_rate = get_pilot_desired_yaw_rate(copter.channel_yaw->norm_input_dz());
float target_yaw_rate = get_pilot_desired_yaw_rate();

// Flow Hold State Machine Determination
AltHoldModeState flowhold_state = get_alt_hold_state(target_climb_rate);
Expand Down
2 changes: 1 addition & 1 deletion ArduCopter/mode_loiter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ void ModeLoiter::run()
loiter_nav->set_pilot_desired_acceleration(target_roll, target_pitch);

// get pilot's desired yaw rate
target_yaw_rate = get_pilot_desired_yaw_rate(channel_yaw->norm_input_dz());
target_yaw_rate = get_pilot_desired_yaw_rate();

// get pilot desired climb rate
target_climb_rate = get_pilot_desired_climb_rate(channel_throttle->get_control_in());
Expand Down
2 changes: 1 addition & 1 deletion ArduCopter/mode_poshold.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ void ModePosHold::run()
get_pilot_desired_lean_angles(target_roll, target_pitch, copter.aparm.angle_max, attitude_control->get_althold_lean_angle_max_cd());

// get pilot's desired yaw rate
float target_yaw_rate = get_pilot_desired_yaw_rate(channel_yaw->norm_input_dz());
float target_yaw_rate = get_pilot_desired_yaw_rate();

// get pilot desired climb rate (for alt-hold mode and take-off)
float target_climb_rate = get_pilot_desired_climb_rate(channel_throttle->get_control_in());
Expand Down
2 changes: 1 addition & 1 deletion ArduCopter/mode_sport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ void ModeSport::run()
}

// get pilot's desired yaw rate
float target_yaw_rate = get_pilot_desired_yaw_rate(channel_yaw->norm_input_dz());
float target_yaw_rate = get_pilot_desired_yaw_rate();

// get pilot desired climb rate
float target_climb_rate = get_pilot_desired_climb_rate(channel_throttle->get_control_in());
Expand Down
2 changes: 1 addition & 1 deletion ArduCopter/mode_stabilize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ void ModeStabilize::run()
get_pilot_desired_lean_angles(target_roll, target_pitch, copter.aparm.angle_max, copter.aparm.angle_max);

// get pilot's desired yaw rate
float target_yaw_rate = get_pilot_desired_yaw_rate(channel_yaw->norm_input_dz());
float target_yaw_rate = get_pilot_desired_yaw_rate();

if (!motors->armed()) {
// Motors should be Stopped
Expand Down
2 changes: 1 addition & 1 deletion ArduCopter/mode_stabilize_heli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ void ModeStabilize_Heli::run()
get_pilot_desired_lean_angles(target_roll, target_pitch, copter.aparm.angle_max, copter.aparm.angle_max);

// get pilot's desired yaw rate
float target_yaw_rate = get_pilot_desired_yaw_rate(channel_yaw->norm_input_dz());
float target_yaw_rate = get_pilot_desired_yaw_rate();

// get pilot's desired throttle
pilot_throttle_scaled = copter.input_manager.get_pilot_desired_collective(channel_throttle->get_control_in());
Expand Down
2 changes: 1 addition & 1 deletion ArduCopter/mode_systemid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ void ModeSystemId::run()
get_pilot_desired_lean_angles(target_roll, target_pitch, copter.aparm.angle_max, copter.aparm.angle_max);

// get pilot's desired yaw rate
target_yaw_rate = get_pilot_desired_yaw_rate(channel_yaw->norm_input_dz());
target_yaw_rate = get_pilot_desired_yaw_rate();

if (!motors->armed()) {
// Motors should be Stopped
Expand Down
4 changes: 2 additions & 2 deletions ArduCopter/mode_zigzag.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ void ModeZigZag::auto_control()
float target_yaw_rate = 0;
if (!copter.failsafe.radio) {
// get pilot's desired yaw rate
target_yaw_rate = get_pilot_desired_yaw_rate(channel_yaw->norm_input_dz());
target_yaw_rate = get_pilot_desired_yaw_rate();
}

// set motors to full range
Expand Down Expand Up @@ -305,7 +305,7 @@ void ModeZigZag::manual_control()
// process pilot's roll and pitch input
loiter_nav->set_pilot_desired_acceleration(target_roll, target_pitch);
// get pilot's desired yaw rate
target_yaw_rate = get_pilot_desired_yaw_rate(channel_yaw->norm_input_dz());
target_yaw_rate = get_pilot_desired_yaw_rate();

// get pilot desired climb rate
target_climb_rate = get_pilot_desired_climb_rate(channel_throttle->get_control_in());
Expand Down

0 comments on commit a72182a

Please sign in to comment.