Configuration#

Phoenix 6 simplifies the configuration process through the use of device-specific Configuration classes, as well as configuration groups.

Note

For more information about configuration in Phoenix 6, see Configuration.

Applying Configs#

v5

// set slot 0 gains
// 50 ms timeout on each config call
m_motor.config_kF(0, 0.05, 50);
m_motor.config_kP(0, 0.046, 50);
m_motor.config_kI(0, 0.0002, 50);
m_motor.config_kD(0, 0.42, 50);
// set slot 0 gains
// 50 ms timeout on each config call
m_motor.Config_kF(0, 0.05, 50);
m_motor.Config_kP(0, 0.046, 50);
m_motor.Config_kI(0, 0.0002, 50);
m_motor.Config_kD(0, 0.42, 50);

v6

var talonFXConfigs = new TalonFXConfiguration();

// set slot 0 gains and leave every other config factory-default
var slot0Configs = talonFXConfigs.Slot0;
slot0Configs.kV = 0.12;
slot0Configs.kP = 0.11;
slot0Configs.kI = 0.5;
slot0Configs.kD = 0.001;

// apply all configs, 50 ms total timeout
m_talonFX.getConfigurator().apply(talonFXConfigs, 0.050);
configs::TalonFXConfiguration talonFXConfigs{};

// set slot 0 gains and leave every other config factory-default
configs::Slot0Configs& slot0Configs = talonFXConfigs.Slot0;
slot0Configs.kV = 0.12;
slot0Configs.kP = 0.11;
slot0Configs.kI = 0.5;
slot0Configs.kD = 0.001;

// apply all configs, 50 ms total timeout
m_talonFX.GetConfigurator().Apply(talonFXConfigs, 50_ms);

Factory Defaulting Configs#

v5

// user must remember to explicitly factory default if they configure devices in code
m_motor.configFactoryDefault();
// user must remember to explicitly factory default if they configure devices in code
m_motor.ConfigFactoryDefault();

v6

// Any unmodified configs in a configuration object are *automatically* factory-defaulted.
// As a result, factory-defaulting before applying configs is *unnecessary* when using a
// full device configuration object, such as TalonFXConfiguration.

// Users can perform a full factory default by passing a new device configuration object.
m_motor.getConfigurator().apply(new TalonFXConfiguration());
// Any unmodified configs in a configuration object are *automatically* factory-defaulted;
// As a result, factory-defaulting before applying configs is *unnecessary* when using a
// full device configuration object, such as TalonFXConfiguration.

// Users can perform a full factory default by passing a new device configuration object.
m_motor.GetConfigurator().Apply(configs::TalonFXConfiguration{});

Retrieving Configs#

v5

// a limited number of configs have configGet* methods;
// for example, you can get the supply current limits
var supplyCurLim = new SupplyCurrentLimitConfiguration();
m_motor.configGetSupplyCurrentLimit(supplyCurLim);
// a limited number of configs have ConfigGet* methods;
// for example, you can get the supply current limits
SupplyCurrentLimitConfiguration supplyCurLim{};
m_motor.ConfigGetSupplyCurrentLimit(supplyCurLim);

v6

var fx_cfg = new TalonFXConfiguration();
// fetch *all* configs currently applied to the device
m_motor.getConfigurator().refresh(fx_cfg);
configs::TalonFXConfiguration fx_cfg{};
// fetch *all* configs currently applied to the device
m_motor.GetConfigurator().Refresh(fx_cfg);