#$ TITLE: Whoop race tune by Justice
#$ FIRMWARE_VERSION: 4.4
#$ CATEGORY: TUNE
#$ STATUS: EXPERIMENTAL
#$ KEYWORDS: whoop, 65mm, 1S, race, acro, tune, justice, meteor
#$ AUTHOR: Justice - Gary Kent
#$ DISCUSSION: https://github.com/betaflight/firmware-presets/pull/142
#$ DESCRIPTION: Hot 65mm whoop tune for racing
#$ DESCRIPTION:
#$ DESCRIPTION: RPM filtering is STRONGLY RECOMMENDED!
#$ DESCRIPTION: PLEASE REVIEW THE OPTIONS IN THE LIST ABOVE!
#$ DESCRIPTION: Check ONE of the three FILTER options!
#$ DESCRIPTION:
#$ DESCRIPTION: The (recommended) options are what Gary uses, you should check all of them.
#$ DESCRIPTION: The others, marked (optional) are not Gary's personal preference, but are for "testing".
#$ DESCRIPTION:
#$ DESCRIPTION: These settings are applied by this Preset:
#$ DESCRIPTION: - Vbat Sag Compensation: 100%,
#$ DESCRIPTION: - VBat warning voltage: 3.5V
#$ DESCRIPTION: - DShot Idle: 6%
#$ DESCRIPTION: - Dynamic Idle: OFF
#$ DESCRIPTION: - Anti-Gravity: 45
#$ DESCRIPTION: - I-Term Relax: 20
#$ DESCRIPTION:
#$ DESCRIPTION: Gary's Race Rates are included too - give them a try!
#$ FORCE_OPTIONS_REVIEW: TRUE

#$ INCLUDE: presets/4.4/tune/defaults.txt

set motor_poles = 12

# -- PID values --
set p_pitch = 71
set i_pitch = 63
set d_pitch = 67
set d_min_pitch = 67
set f_pitch = 249

set p_roll = 68
set i_roll = 60
set d_roll = 62
set d_min_roll = 62
set f_roll = 239

set p_yaw = 68
set i_yaw = 60
set d_yaw = 0
set d_min_yaw = 0
set f_yaw = 239

# -- Sliders --
set simplified_pids_mode = RPY
set simplified_d_gain = 200
set simplified_pi_gain = 145
set simplified_feedforward_gain = 190
set simplified_dmax_gain = 0
set simplified_i_gain = 50
set simplified_pitch_d_gain = 95
set simplified_pitch_pi_gain = 100
set simplified_master_multiplier = 105

# -- iTerm relax --
set iterm_relax_cutoff = 20

# -- iTerm windup (default)--
# -- iTerm rotation (off, default) --

# -- Dmax --
set d_max_advance = 0

# -- TPA --
set tpa_rate = 65
set tpa_breakpoint = 1250

# -- Feedforward --
set feedforward_max_rate_limit = 95
# -- Feedforward averaging (do not change)--

# -- PIDsum limits (default)--

# -- Absolute control (off, default) --
# -- Accecleration limits (off, default) --
# -- Angle and Horizon mode tuning (default) --
# -- PIDs active below min throttle (default) --
# -- Set mixer type to default (legacy) --
# -- Set yaw spin recovery to default, which is auto --
# -- Set integrated yaw to off, so pitch and yaw are independent (default) --
# -- Gyro cal on first arm (off, default) --
# -- Transient throttle limit (off, default) --
# -- Throttle limit (off, default) --
# -- Thrust linear (off, default) --
# -- Throttle boost (on, at default = 5)

# -- DShot Idle --
set dshot_idle_value = 600

# ------ UN-CHECKED OPTIONS ------

# -- Filters --

#$ OPTION_GROUP BEGIN: Filters
    # Filter options
    #$ OPTION BEGIN (UNCHECKED): FILTER: RPM enabled, normal build
        #$ INCLUDE: presets/4.3/filters/basic_rpm_normal.txt
        set dyn_idle_min_rpm = 50
    #$ OPTION END

    #$ OPTION BEGIN (UNCHECKED): FILTER: RPM enabled, noisy build
        #$ INCLUDE: presets/4.3/filters/basic_rpm_noisy.txt
        set dyn_idle_min_rpm = 50
    #$ OPTION END

    #$ OPTION BEGIN (UNCHECKED): FILTER: NON-RPM ESCs, normal build
        #$ INCLUDE: presets/4.3/filters/basic_no_rpm_normal.txt
    #$ OPTION END
#$ OPTION_GROUP END

# -- Fast Rx Link Options --

#$ OPTION_GROUP BEGIN: Your RC link speed, if above 150
    #$ OPTION BEGIN (UNCHECKED): RC_LINK 250Hz
        #$ INCLUDE: presets/4.3/rc_link/generic/250hz_race.txt
    #$ OPTION END

    #$ OPTION BEGIN (UNCHECKED): RC_LINK 500Hz
        #$ INCLUDE: presets/4.3/rc_link/generic/500hz_race.txt
    #$ OPTION END
#$ OPTION_GROUP END


#$ OPTION_GROUP BEGIN: Tune options, check only one
    #$ OPTION BEGIN (UNCHECKED): Normal tune (normal builds)
        # do nothing, it's already applied
    #$ OPTION END

    #$ OPTION BEGIN (UNCHECKED): Spicy tune (clean builds only)
        # -- PID values --
        set p_pitch = 77
        set i_pitch = 69
        set d_pitch = 74
        set d_min_pitch = 74
        set f_pitch = 261

        set p_roll = 74
        set i_roll = 66
        set d_roll = 66
        set d_min_roll = 66
        set f_roll = 250

        set p_yaw = 74
        set i_yaw = 66
        set d_yaw = 0
        set d_min_yaw = 0
        set f_yaw = 250

        # -- Sliders --
        set simplified_pids_mode = RPY
        set simplified_d_gain = 200
        set simplified_pi_gain = 150
        set simplified_feedforward_gain = 190
        set simplified_dmax_gain = 0
        set simplified_i_gain = 50
        set simplified_pitch_d_gain = 100
        set simplified_pitch_pi_gain = 100
        set simplified_master_multiplier = 110
    #$ OPTION END

    #$ OPTION BEGIN (UNCHECKED): Safer tune (older builds)
        # -- PID values --
        set p_pitch = 65
        set i_pitch = 58
        set d_pitch = 61
        set d_min_pitch = 61
        set f_pitch = 237

        set p_roll = 63
        set i_roll = 56
        set d_roll = 57
        set d_min_roll = 57
        set f_roll = 228

        set p_yaw = 63
        set i_yaw = 56
        set d_yaw = 0
        set d_min_yaw = 0
        set f_yaw = 228

        # -- Sliders --
        set simplified_pids_mode = RPY
        set simplified_d_gain = 190
        set simplified_pi_gain = 140
        set simplified_feedforward_gain = 190
        set simplified_dmax_gain = 0
        set simplified_i_gain = 50
        set simplified_pitch_d_gain = 95
        set simplified_pitch_pi_gain = 100
        set simplified_master_multiplier = 100
    #$ OPTION END
#$ OPTION_GROUP END

#$ OPTION_GROUP BEGIN: Recommended settings, please check all of them
    # -- RC_Smoothing --
    #$ OPTION BEGIN (UNCHECKED): Default RC_smoothing
        set rc_smoothing = ON
        set rc_smoothing_auto_factor = 30
        set rc_smoothing_auto_factor_throttle = 30
        set rc_smoothing_setpoint_cutoff = 0
        set rc_smoothing_feedforward_cutoff = 0
        set rc_smoothing_throttle_cutoff = 0
        set rc_smoothing_debug_axis = ROLL
    #$ OPTION END

    # -- VBat warning threshold --
    #$ OPTION BEGIN (UNCHECKED): Default warning voltage
        set vbat_warning_cell_voltage = 350
    #$ OPTION END

    # -- No deadband --
    #$ OPTION BEGIN (UNCHECKED): No deadband
        set deadband = 0
        set yaw_deadband = 0
    #$ OPTION END

    # -- Startup and arming --
    #$ OPTION BEGIN (UNCHECKED): Arm at any angle
        set small_angle = 180
    #$ OPTION END
#$ OPTION_GROUP END

#$ OPTION_GROUP BEGIN: Optional settings to experiment with
    # -- VBat sag compensation --
    #$ OPTION BEGIN (UNCHECKED): 50% Sag compensation
        set vbat_sag_compensation = 50
    #$ OPTION END

    # -- Throttle curve --
    #$ OPTION BEGIN (UNCHECKED): Sharper throttle response curve
        set thr_mid = 100
        set thr_expo = 30
    #$ OPTION END

    # -- Dynamic idle --
    #$ OPTION BEGIN (UNCHECKED): Enable dynamic idle at 40
        set dyn_idle_min_rpm = 40
    #$ OPTION END
#$ OPTION_GROUP END

#$ OPTION_GROUP BEGIN: These are my race rates...
    # -- Rates --
    #$ OPTION BEGIN (UNCHECKED): Try Gary's race rates - go on!
        set rates_type = ACTUAL
        set roll_rc_rate = 20
        set pitch_rc_rate = 20
        set yaw_rc_rate = 20
        set roll_expo = 50
        set pitch_expo = 50
        set yaw_expo = 25
        set roll_srate = 50
        set pitch_srate = 50
        set yaw_srate = 50
    #$ OPTION END
#$ OPTION_GROUP END
