#$ TITLE: Karate Race 6s 5"
#$ FIRMWARE_VERSION: 4.3
#$ CATEGORY: TUNE
#$ STATUS: OFFICIAL
#$ KEYWORDS: karate, 6S, race, world champion, 5 inch, 5", sugarK, limon, ctzsnooze, KarateBrot
#$ AUTHOR: sugarK

#$ PARSER: MARKED

#$ DESCRIPTION:
#$ DESCRIPTION: <img src="https://user-images.githubusercontent.com/19867640/174759844-ffd85f42-1f1c-42bf-9032-d9f96d4d9619.svg" width="90px" style="display: block; float: left; margin-right: 10px; margin-top: 20px"/>
#$ DESCRIPTION: <h1>Karate Race 6S 5"</h1>
#$ DESCRIPTION: <br>
#$ DESCRIPTION:
#$ DESCRIPTION: This 6S racing tune was developed with the help of **@ctzsnooze** around **@KarateBrot**'s [RPM Crossfade code](https://github.com/betaflight/betaflight/pull/10757) allowing for a pretty aggressive filter tune, which is called the [Karate Array](https://github.com/betaflight/firmware-presets/blob/master/presets/4.3/filters/karate_array.txt).
#$ DESCRIPTION:
#$ DESCRIPTION: <br>
#$ DESCRIPTION:
#$ DESCRIPTION: This tune works well on any quality airframes and has been flown on the Viper racer (where it was developed), BMS Js1, 533 Switchback, HGLRC Wind and of course **@limon**'s OpenRacer.
#$ DESCRIPTION:
#$ DESCRIPTION: <br>
#$ DESCRIPTION:
#$ DESCRIPTION: It should also work on other quality racing frames but use at your own risk as it is an aggressive tune. This tune so far has won a good number of events, including the **2021 MultiGP International Open**.
#$ DESCRIPTION:
#$ DESCRIPTION: <br>
#$ DESCRIPTION:
#$ DESCRIPTION: ## Things to note:
#$ DESCRIPTION: - **YOU HAVE TO USE RPM FILTERING WITH THIS TUNE!** Failure to do so might result in fire 🔥
#$ DESCRIPTION: - Regarding DShot600: if your setup has errors in the motor tab using bidirectional DShot, change to **8k/4k and DShot300**
#$ DESCRIPTION: - Also this should be applied to a clean flash after you've setup your rates, swtiches, vtx tables etc.
#$ DESCRIPTION: - To test arm the quad with props on, it should **sound clean with no grinding**. If it passes that then hover test and check motor temps.
#$ DESCRIPTION: - **If anything is off, don't fly it!!**
#$ DESCRIPTION:
#$ DESCRIPTION: <br>
#$ DESCRIPTION:
#$ DESCRIPTION: ## Second note... Radio links:
#$ DESCRIPTION: 1. Make sure your radio firmware is up to date using either EdgeTX or OpenTX
#$ DESCRIPTION: 1. Make sure your **ADC Filter is OFF** in the hardware page
#$ DESCRIPTION: 1. Go to the radio (RC_LINK) presets and apply the correct setup for your system and link speed

#$ DISCUSSION: https://github.com/betaflight/firmware-presets/pull/41

#$ INCLUDE_WARNING: misc/warnings/en/rpm_filters.txt
#$ INCLUDE: presets/4.3/tune/defaults.txt
#$ INCLUDE: presets/4.3/filters/defaults.txt

# -- Gyro lowpass filters --
set gyro_lpf1_static_hz = 0
set gyro_lpf1_dyn_min_hz = 500
set gyro_lpf1_dyn_max_hz = 1000
set simplified_gyro_filter = OFF

#$ OPTION BEGIN (UNCHECKED): Bosch (BMI) gyro - experimantal
    set gyro_lpf1_dyn_min_hz = 0
    set gyro_lpf1_dyn_max_hz = 0
#$ OPTION END

# -- Gyro Dynamic Notches --
set dyn_notch_count = 2
set dyn_notch_q = 450
set dyn_notch_min_hz = 200
set dyn_notch_max_hz = 650

# -- Dterm filtering --
set dterm_lpf1_dyn_expo = 7

# -- RPM filtering --
set dshot_bidir = ON
set rpm_filter_fade_range_hz = 100

# -- Misc --
set yaw_spin_recovery = AUTO
set thrust_linear = 0
set throttle_boost = 2

# -- Antigravity --
set anti_gravity_gain = 3000

# -- iTerm  --
set iterm_relax_cutoff = 20

# -- PIDsum limits --
set iterm_limit = 500
set pidsum_limit_yaw = 1000


# -- PID values --
set p_pitch = 42
set i_pitch = 85
set d_pitch = 42
set f_pitch = 135

set p_roll = 37
set d_roll = 36

set f_yaw = 80

set d_min_roll = 22
set d_min_pitch = 22
set d_max_gain = 35
set d_max_advance = 0
set simplified_pids_mode = OFF

# -- Feedforward --
set feedforward_max_rate_limit = 100

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

#$ OPTION BEGIN (CHECKED): Dshot600
    set dshot_bidir = ON
    set motor_pwm_protocol = DSHOT600
#$ OPTION END

#$ OPTION BEGIN (UNCHECKED): Dshot300
    set dshot_bidir = ON
    set motor_pwm_protocol = Dshot300
#$ OPTION END

#$ OPTION BEGIN (UNCHECKED): Dynamic idle for 2000kv 6s
    #dynamic idle for 6s 2000kv
    set dyn_idle_min_rpm = 40
    set dyn_idle_p_gain = 35
#$ OPTION END

#$ OPTION BEGIN (UNCHECKED): Spicy tune

    #spicy tune use with care
    # -- Gyro Dynamic Notches --
    set dyn_notch_count = 1
    set dyn_notch_q = 600
    set dyn_notch_min_hz = 250
    set dyn_notch_max_hz = 650

    # -- Dterm filtering --
    set dterm_lpf1_dyn_expo = 10

    # -- RPM filtering --
    set rpm_filter_harmonics = 2
    set rpm_filter_min_hz = 150

    # -- PID values --
    set p_pitch = 42
    set i_pitch = 85
    set d_pitch = 42
    set f_pitch = 135
    set p_roll = 37
    set i_roll = 80
    set d_roll = 36
    set f_roll = 120
    set p_yaw = 45
    set i_yaw = 80
    set d_yaw = 0
    set f_yaw = 80

    set d_min_roll = 26
    set d_min_pitch = 26
    set d_max_gain = 25
    set d_max_advance = 0
    set simplified_pids_mode = OFF
#$ OPTION END

#$ OPTION BEGIN (UNCHECKED): Noisy airframe (can be used with Spicy)

    # -- Gyro lowpass filters --
    set gyro_lpf1_static_hz = 0
    set gyro_lpf2_static_hz = 0
    set gyro_lpf1_dyn_min_hz = 0
    set gyro_lpf1_dyn_max_hz = 0

    # -- Dterm filtering --
    set dterm_lpf1_dyn_expo = 10
    set dterm_lpf1_type = BIQUAD
#$ OPTION END

#$ OPTION_GROUP BEGIN: Some popular RC Links

    #$ OPTION BEGIN (UNCHECKED): Tracer/ELRS 250Hz
        # Tracer/ELRS 250Hz
        #$ INCLUDE: presets/4.3/rc_link/defaults.txt
        feature RX_SERIAL
        set serialrx_provider = CRSF

        set feedforward_averaging = 2_POINT
        set feedforward_smooth_factor = 35
        set feedforward_jitter_factor = 4
        set feedforward_boost = 18

        set rc_smoothing_auto_factor = 25
        set rc_smoothing_auto_factor_throttle = 25
    #$ OPTION END

    #$ OPTION BEGIN (UNCHECKED): ELRS 500Hz
        # ERLS 500Hz
        #$ INCLUDE: presets/4.3/rc_link/defaults.txt
        feature RX_SERIAL
        set serialrx_provider = CRSF

        set feedforward_averaging = 2_POINT
        set feedforward_smooth_factor = 65
        set feedforward_jitter_factor = 3
        set feedforward_boost = 18

        set rc_smoothing_auto_factor = 25
        set rc_smoothing_auto_factor_throttle = 25
    #$ OPTION END

    #$ OPTION BEGIN (UNCHECKED): Ghost 250Hz
        # Ghost 250Hz
        #$ INCLUDE: presets/4.3/rc_link/defaults.txt
        feature RX_SERIAL
        set serialrx_provider = GHST

        set feedforward_averaging = 2_POINT
        set feedforward_smooth_factor = 35
        set feedforward_jitter_factor = 4
        set feedforward_boost = 18

        set rc_smoothing_auto_factor = 25
        set rc_smoothing_auto_factor_throttle = 25
    #$ OPTION END

    #$ OPTION BEGIN (UNCHECKED): Ghost 500Hz
        # Ghost 500Hz
        #$ INCLUDE: presets/4.3/rc_link/defaults.txt
        feature RX_SERIAL

        set feedforward_averaging = 2_POINT
        set feedforward_smooth_factor = 65
        set feedforward_jitter_factor = 3
        set feedforward_boost = 18

        set rc_smoothing_auto_factor = 25
        set rc_smoothing_auto_factor_throttle = 25
    #$ OPTION END

#$ OPTION_GROUP END

#$ OPTION_GROUP BEGIN: Optional rates

    #$ OPTION BEGIN (UNCHECKED): sugarK's rates
        set thr_mid = 25
        set thr_expo = 65
        set roll_expo = 54
        set pitch_expo = 54
        set yaw_expo = 54
        set roll_srate = 40
        set pitch_srate = 40
        set yaw_srate = 42
    #$ OPTION END

#$ OPTION_GROUP END
