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 :doc:`/docs/api-reference/api-usage/configuration`. Applying Configs ---------------- .. list-table:: :width: 100% :widths: 1 99 * - .. centered:: v5 - .. tab-set:: .. tab-item:: Java :sync: Java .. code-block:: Java // 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); .. tab-item:: C++ :sync: C++ .. code-block:: cpp // 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); * - .. centered:: v6 - .. tab-set:: .. tab-item:: Java :sync: Java .. code-block:: java 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); .. tab-item:: C++ :sync: C++ .. code-block:: cpp 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 ^^^^^^^^^^^^^^^^^^^^^^^^^^ .. list-table:: :width: 100% :widths: 1 99 * - .. centered:: v5 - .. tab-set:: .. tab-item:: Java :sync: Java .. code-block:: Java // user must remember to explicitly factory default if they configure devices in code m_motor.configFactoryDefault(); .. tab-item:: C++ :sync: C++ .. code-block:: cpp // user must remember to explicitly factory default if they configure devices in code m_motor.ConfigFactoryDefault(); * - .. centered:: v6 - .. tab-set:: .. tab-item:: Java :sync: Java .. code-block:: Java // 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()); .. tab-item:: C++ :sync: C++ .. code-block:: cpp // 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 ------------------ .. list-table:: :width: 100% :widths: 1 99 * - .. centered:: v5 - .. tab-set:: .. tab-item:: Java :sync: Java .. code-block:: Java // 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); .. tab-item:: C++ :sync: C++ .. code-block:: cpp // a limited number of configs have ConfigGet* methods; // for example, you can get the supply current limits SupplyCurrentLimitConfiguration supplyCurLim{}; m_motor.ConfigGetSupplyCurrentLimit(supplyCurLim); * - .. centered:: v6 - .. tab-set:: .. tab-item:: Java :sync: Java .. code-block:: Java var fx_cfg = new TalonFXConfiguration(); // fetch *all* configs currently applied to the device m_motor.getConfigurator().refresh(fx_cfg); .. tab-item:: C++ :sync: C++ .. code-block:: cpp configs::TalonFXConfiguration fx_cfg{}; // fetch *all* configs currently applied to the device m_motor.GetConfigurator().Refresh(fx_cfg);