Rotorflight 2 CLI Changes - rotorflight/rotorflight GitHub Wiki

❗ This page is outdated

Rotorflight Wiki is replaced by www.rotorflight.org.


CLI Changes in Rotorflight-2 (RF2)

This page lists the changes in the CLI in RF2.

Configuration

Hardware Config

Should be the same as in RF1.

All hardware related CLI commands (dump hardware) should work.

Features

Currently there are no changes to feature flags.

Servos

The servo configuration has been refactored, and has slightly different parameters.

Servo Configuration

The CLI servo command has now the following syntax:

servo <center> <min> <max> <neg-scale> <pos-scale> <update-rate> <flags>

<center>       zero position in us (servo arm level position)
<min>          minimum pulse length (for avoiding binding)
<max>          maximum pulse length (for avoiding binding)
<neg-scale>    scaling factor on negative side (below center level)
<pos-scale>    scaling factor on positive side (above center level)
<update-rate>  PWM update rate in Hz
<flags>        flags (binary values)

Servo Flags

The servo flags has the following binary values:

1             Servo reverse
2             Geometry correction

Servo geometry correction for correcting the rotational geometry. It is not needed with linear servos.

Motors

motor_rpm_factor = <value,value,value,value>

This is a correction factor for any systematic scaling error on the Dshot RPM reading. The value of 0 is no correction, 1000 is +1.000% correction, -2000 is -2.000%, etc.

There is a separate value for each motor.

Modes / AUX

The CLI commands are the same, but the range (PWM) resolution has been increased from 25 to 5us.

Adjustment Functions

Adjustment functions have been totally rewritten.

There are now two new ranges in each adjustment, for setting the Rx ranges where the increment/decrement step is triggered, respectively.

With the continuous adjustment, the first range sets the input range of the control channel.

In RF1, the decrement range was 1000..1300, and the increment range was 1700..2000. The continuous input range was 1000..2000.

The CLI command format is:

adjfunc <index> <func> <enable channel> <start> <end>
        <value channel> <dec start> <dec end> <inc start> <inc end>
        <step size> <value min> <value max>

If <enable channel> is within <start>..<end> then the adjustment is enabled.

Then two choices depending on the value in <step size>

  1. Continuous adjustment if <step size> is zero. The channel <value channel> is used to directly control the selected adjustment. The range in <dec start>..<dec end> is stretched into <value min>..<value max>. The range <inc start>..<inc end> is not used.

  2. Stepped adjustment if <step size> is non-zero. The channel <value channel> is used to decide whether the adjustment should be incremented or decremented. If the channel is within <dec start>..<dec end> then the adjustment is decremented by <step>. If the channel is within <inc start>..<inc end> then the adjustment is incremented by <step>. While keeping the adjustment value in the range <value min>..<value max>.

This allows one channel to inc/dec at least 8 different adjustment functions.

Functions numbers (as in 4.3.0-20230912):

    // Profile change
    ADJUSTMENT_RATE_PROFILE             = 1,
    ADJUSTMENT_PID_PROFILE              = 2,
    ADJUSTMENT_LED_PROFILE              = 3,
    ADJUSTMENT_OSD_PROFILE              = 4,

    // Rates
    ADJUSTMENT_PITCH_RATE               = 5,
    ADJUSTMENT_ROLL_RATE                = 6,
    ADJUSTMENT_YAW_RATE                 = 7,
    ADJUSTMENT_PITCH_RC_RATE            = 8,
    ADJUSTMENT_ROLL_RC_RATE             = 9,
    ADJUSTMENT_YAW_RC_RATE              = 10,
    ADJUSTMENT_PITCH_RC_EXPO            = 11,
    ADJUSTMENT_ROLL_RC_EXPO             = 12,
    ADJUSTMENT_YAW_RC_EXPO              = 13,

    // PID
    ADJUSTMENT_PITCH_P_GAIN             = 14,
    ADJUSTMENT_PITCH_I_GAIN             = 15,
    ADJUSTMENT_PITCH_D_GAIN             = 16,
    ADJUSTMENT_PITCH_F_GAIN             = 17,
    ADJUSTMENT_ROLL_P_GAIN              = 18,
    ADJUSTMENT_ROLL_I_GAIN              = 19,
    ADJUSTMENT_ROLL_D_GAIN              = 20,
    ADJUSTMENT_ROLL_F_GAIN              = 21,
    ADJUSTMENT_YAW_P_GAIN               = 22,
    ADJUSTMENT_YAW_I_GAIN               = 23,
    ADJUSTMENT_YAW_D_GAIN               = 24,
    ADJUSTMENT_YAW_F_GAIN               = 25,

    ADJUSTMENT_YAW_CW_GAIN              = 26,
    ADJUSTMENT_YAW_CCW_GAIN             = 27,
    ADJUSTMENT_YAW_CYCLIC_FF            = 28,
    ADJUSTMENT_YAW_COLLECTIVE_FF        = 29,
    ADJUSTMENT_YAW_COLLECTIVE_DYN       = 30,
    ADJUSTMENT_YAW_COLLECTIVE_DECAY     = 31,
    ADJUSTMENT_PITCH_COLLECTIVE_FF      = 32,

    // Gyro cutoffs
    ADJUSTMENT_PITCH_GYRO_CUTOFF        = 33,
    ADJUSTMENT_ROLL_GYRO_CUTOFF         = 34,
    ADJUSTMENT_YAW_GYRO_CUTOFF          = 35,

    // Dterm cutoffs
    ADJUSTMENT_PITCH_DTERM_CUTOFF       = 36,
    ADJUSTMENT_ROLL_DTERM_CUTOFF        = 37,
    ADJUSTMENT_YAW_DTERM_CUTOFF         = 38,

    // Rescue
    ADJUSTMENT_RESCUE_CLIMB_COLLECTIVE  = 39,
    ADJUSTMENT_RESCUE_HOVER_COLLECTIVE  = 40,
    ADJUSTMENT_RESCUE_HOVER_ALTITUDE    = 41,
    ADJUSTMENT_RESCUE_ALT_P_GAIN        = 42,
    ADJUSTMENT_RESCUE_ALT_I_GAIN        = 43,
    ADJUSTMENT_RESCUE_ALT_D_GAIN        = 44,

    // Leveling
    ADJUSTMENT_ANGLE_LEVEL_GAIN         = 45,
    ADJUSTMENT_HORIZON_LEVEL_GAIN       = 46,
    ADJUSTMENT_ACRO_TRAINER_GAIN        = 47,

    // Governor
    ADJUSTMENT_GOV_GAIN                 = 48,
    ADJUSTMENT_GOV_P_GAIN               = 49,
    ADJUSTMENT_GOV_I_GAIN               = 50,
    ADJUSTMENT_GOV_D_GAIN               = 51,
    ADJUSTMENT_GOV_F_GAIN               = 52,
    ADJUSTMENT_GOV_TTA_GAIN             = 53,
    ADJUSTMENT_GOV_CYCLIC_FF            = 54,
    ADJUSTMENT_GOV_COLLECTIVE_FF        = 55,

    // Boost gains
    ADJUSTMENT_PITCH_B_GAIN             = 56,
    ADJUSTMENT_ROLL_B_GAIN              = 57,
    ADJUSTMENT_YAW_B_GAIN               = 58,

    // Offset gains
    ADJUSTMENT_PITCH_O_GAIN             = 59,
    ADJUSTMENT_ROLL_O_GAIN              = 60,

    // Cross-coupling
    ADJUSTMENT_CROSS_COUPLING_GAIN      = 61,
    ADJUSTMENT_CROSS_COUPLING_RATIO     = 62,
    ADJUSTMENT_CROSS_COUPLING_CUTOFF    = 63,

Gyro Filtering

Most gyro filtering related CLI commands have been renamed in BF4.3. There are further changes in Rotorflight.

Filter Task Speed

It is now possible to run the filtering task at a different speed from the PID loop. This is needed if the PID loop is running at a low speed (1Khz or lower).

There is a new parameter filter_process_denom that works the same as pid_process_denom. A special value 0 indicates that the filter task is running at the PID loop speed. Other values are relative to the gyro speed.

The filter task can't be slower than the PID task. Usually there are 2 or 3 valid values for this parameter, typically 1..4.

Filter Configuration

CLI commands listed below.

set gyro_decimation_hz = 250
set gyro_lpf1_type = FIRST_ORDER
set gyro_lpf1_static_hz = 125
set gyro_lpf1_dyn_min_hz = 25
set gyro_lpf1_dyn_max_hz = 150
set gyro_lpf2_type = NONE
set gyro_lpf2_static_hz = 0
set gyro_notch1_hz = 0
set gyro_notch1_cutoff = 0
set gyro_notch2_hz = 0
set gyro_notch2_cutoff = 0

Blackbox

Blackbox has been refactored in BF4.3, and further in RF2.

blackbox_mode = <OFF|NORMAL|ARMED|SWITCH>

OFF     = No logging
NORMAL  = logging when both ARMED and BLACKBOX switch active
ARMED   = logging when ARMED
SWITCH  = logging when BLACKBOX switch active

In NORMAL mode, logging is paused if BLACKBOX switch is inactive.

blackbox_rate_denom = <N>

Blackbox sampling is now locked to the PID loop, and can be reduced by a factor of N.

blackbox_log_XYZ = <ON|OFF>

Each blackbox field can be now separately enabled/disabled.

set blackbox_log_command = ON
set blackbox_log_setpoint = ON
set blackbox_log_mixer = ON
set blackbox_log_pid = ON
set blackbox_log_gyro_raw = ON
set blackbox_log_gyro = ON
set blackbox_log_acc = ON
set blackbox_log_mag = OFF
set blackbox_log_alt = ON
set blackbox_log_battery = ON
set blackbox_log_rssi = ON
set blackbox_log_rpm = ON
set blackbox_log_motors = ON
set blackbox_log_servos = ON
set blackbox_log_gps = OFF

Debug

Debug has now eight 32bit values, instead of four 16bit values.

This will require changes in the Blackbox Explorer eventually.

Some debug modes are logging only one axis, which is selected with the debug_axis parameter.

This parameter replaces the following BF parameters:

  • gyro_filter_debug_axis
  • acro_trainer_debug_axis
  • rc_smoothing_debug_axis

Sensors

New settings for sensor update speed:

set vbat_update_hz = 100
set ibat_update_hz = 100
set esc_sensor_update_hz = 100

Profile (PID Profile)

PID control has been totally rewritten.

There are now multiple PID controllers to choose from.

pid_mode = 0

This is a test mode with the FF term only. Useful for debugging the firmware.

pid_mode = 1

Rotorflight-1.0 compatibility mode. This is exactly the same as RF1. Parameters have different names, unfortunately.

pid_mode = 2

New PID mode under development. This is the current idea what RF2 could be.

pid_mode = 3

Test PID mode with a ridiculous number of parameters. Used for testing High-Speed Integral.

pid_dterm_mode = <GYRO|ERROR>

Selects between D-term on gyro signal vs. on error signal for cyclic.

Available in mode 2.

pid_dterm_mode_yaw = <GYRO|ERROR>

Selects between D-term on gyro signal vs. on error signal for yaw.

Available in mode 2.

PID Gains

The PID gain parameters have been renamed. Should be obvious.

yaw_[c]cw_stop_gain = <N>

Stop gain for yaw. Works differently in each mode.

Mode 1: Same as RF1.0. Both P and D gains multiplied by stop gain.

Mode 2: Only P gain multiplied by stop gain.

Mode 3: Only P gain multiplied by stop gain.

PID Filters

There are a few extra filters in the PID controller (for evaluation).

pitch_d_cutoff = <Hz>

D-term bandwidth limit, separate for each axis.

Available in modes 2 and 3. Equivalent to RF1 D-term PT1 filter. Must be set to a reasonable value for D-term to work. Typical values 10..40.

pitch_error_cutoff = <Hz>

Error term bandwidth limit. 0 = disabled.

Available in mode 1.

pitch_gyro_cutoff = <Hz>

Gyro signal bandwidth limit, separate for each axis. 0 = disabled. This is an extra First Order filter for each gyro axis.

Available in modes 1, 2 and 3.

iterm_relax_type = <OFF|RP|RPY>

Selects the I-term relax type, i.e. which axis to apply to.

iterm_relax_level = <N>

Sets the setpoint limit/level for I-term relax. This is fixed to 40 in BF and RF1.

iterm_relax_cutoff = <R,P,Y>

I-term relax filter cutoffs for roll, pitch, and yaw.

Rates

The rates system has been rewritten for RF2.0.

There is now a curve also for collective. It is mostly useful for setting the collective min/max, but also expo.

collective_rc_rate = <N>

collective_srate = <N>

collective_expo = <N>

In addition to the rate curves, it is now possible to set limits, acceleration, and smoothness.

yaw_rate_accel = <N>

Set waw setpoint max acceleration.

yaw_rate_limit = <N>

Set absolute maximum for yaw setpoint. The curve will usually control what to value is at the stick extreme, so this is an extra limit.

rates_smoothness = <N>

Set overall smoothness for setpoint changes. This is equivalent to "Style" or "Smoothness" in some FBLs. Higher is smoother. Typical values 25-200.

cyclic_ring = <N>

Set a ring limiter for cyclic setpoints. Range 0 = no limit ... 100 = round circle

Governor

gov_yaw_ff_weight = <N>

A new parameter for yaw-to-throttle precompensation. This is only for main motor driven tails. For motorised tails, this parameter must be set to zero.

gov_startup_time = <N>

A time constant for throttle rampup during start. This is applied only until the motor has started up and the RPM signal is detected.

ESC Telemetry

esc_sensor_protocol = <NONE|KISS|HOBBYWINGV4|KONTRONIK>

esc_sensor_hw4_current_offset = <N>

An offset value for calibrating the zero current with Hobbywing V4 ESCs.

esc_sensor_hw4_voltage_gain = <N>

Voltage gain - different for each HW V4 model.

 *
 * Voltage Gain:
 *   3-6S  (LV):    gain = 110
 *   3-8S  (LVv2):  gain = 154
 *   5-12s (HV):    gain = 210
 *

esc_sensor_hw4_current_gain = <N>

Current gain - different for each HW V4 model.

 *
 * Current Gain:
 *   60A:           gain = 60
 *   80A:           gain = 78
 *   100A:          gain = 90
 *   120A:          gain = 100
 *   130A:          gain = 113
 *   150A:          gain = 129
 *   160A:          gain = 137
 *   200A:          gain = 169
 *

Rescue

rescue_mode = <OFF|CLIMB|ALT_HOLD>

Rescue mode. Climb or Altitude Hold.

Altitude Hold requires a good quality barometer.

rescue_flip = <OFF|ON>

Enable flipping the heli upright, if rescue started inverted.

rescue_flip_gain = <N>

Gain for initial pull up and for flipping the heli upright.

rescue_level_gain = <N>

Gain for leveling the heli.

This is 2.5x less effective vs. RF1, e.g. you had 40, now you need 100.

rescue_pull_up_time = <N>

Time for the initial pull-up. (1/10s steps)

rescue_climb_time = <N>

Time for climbing. (1/10s steps)

rescue_flip_time = <N>

Time(out) for flipping. (1/10s steps) If flip did not complete withint this time, climb state is entered regardless.

rescue_exit_time = <N>

Time for slowly exiting rescue. (1/10s steps)

rescue_pull_up_collective = <N>

Collective value for pull-up. (1/1000 steps)

rescue_max_rate = <N>

Maximum cyclic rate for any rescue action.

rescue_max_accel = <N>

Maximum cyclic acceleration for any rescue action.

Rescue Climb Mode parametes

rescue_climb_collective = <N>

Collective value for climb.

rescue_hover_collective = <N>

Collective value for hover.

Rescue Altitude Hold Mode parameters

rescue_hover_altitude = <N>

Hovering altitude in cm.

rescue_alt_p_gain = <N>

Altitude P-gain.

rescue_alt_i_gain = <N>

Altitude I-gain.

rescue_alt_d_gain = <N>

Altitude D-gain.

⚠️ **GitHub.com Fallback** ⚠️