How do I use a vendor hardware config?
Goal: use a motor controller option that YAMS does not have a method for, such as beep settings, peak voltages or status frame rates.
YAMS configures your motor controller from your SmartMotorControllerConfig. For anything else, build the vendor's own config object and pass it to SmartMotorControllerConfig.withVendorConfig(...). YAMS starts from it and applies its own settings on top, so anything you set in SmartMotorControllerConfig wins, and everything else in the vendor object is kept.
Each example below is a fragment for your subsystem's fields or constructor.
CTRE TalonFX
Pass a TalonFXConfiguration object:
TalonFXConfiguration talonConfig = new TalonFXConfiguration()
.withAudio(new AudioConfigs().withBeepOnBoot(false).withBeepOnConfig(false))
.withVoltage(new VoltageConfigs().withPeakReverseVoltage(-10).withPeakForwardVoltage(10));
SmartMotorControllerConfig motorConfig = new SmartMotorControllerConfig(this)
.withVendorConfig(talonConfig)
.withControlMode(ControlMode.CLOSED_LOOP)
.withClosedLoopController(4, 0, 0)
.withGearing(new MechanismGearing(GearBox.fromReductionStages(3, 4)))
.withZeroPower(MotorMode.BRAKE);
TalonFX talonFX = new TalonFX(1, new CANBus(CANPort.CAN_S0));
SmartMotorController smc = new TalonFXWrapper(talonFX, DCMotor.getKrakenX60(1), motorConfig);CTRE TalonFXS
Pass a TalonFXSConfiguration object:
TalonFXSWrapper sets the motor arrangement (Minion, NEO, NEO 550, NEO Vortex, Thrifty Pulsar from YMotors.getThriftyPulsar(1)) from the DCMotor you pass, so you do not set it in the vendor config. A DCMotor it does not recognize, such as DCMotor.getKrakenX60(1), throws an IllegalArgumentException ("Unknown motor for TalonFXS"), because a Kraken X60 cannot run on a TalonFXS.
REV SparkMax
Pass a SparkMaxConfig object:
REV SparkFlex
Pass a SparkFlexConfig object:
Thrifty Nova
Pass a ThriftyLib NovaConfig.Config, usually a NovaConfigBatch holding one or more NovaConfig options. The vendor config is applied to the Nova before the YAMS config:
Any other vendor config type throws a SmartMotorControllerConfigurationException.
FIRST A301
The A301 has no vendor config. A301Wrapper throws a SmartMotorControllerConfigurationException for any withVendorConfig, so everything it supports is set through SmartMotorControllerConfig.
Factory reset: withResetPreviousConfig
Motor controllers keep their settings in flash, across power cycles and code deploys. With withResetPreviousConfig(true), the default, YAMS clears them before applying your config, so settings left over from last season, or from someone clicking around in the vendor's tool, cannot sneak in: a TalonFX or TalonFXS gets a complete config (your vendor config, or the defaults) with the YAMS options on top, a SPARK resets its parameters first (ResetMode.kResetSafeParameters), and a Nova is sent a factory reset first. A301Wrapper ignores the option.
Turn the reset off only when you configured something on purpose in the vendor's tool (Phoenix Tuner X or REV Hardware Client) and want to keep it. With the reset off, any old setting you did not set yourself stays, which is a common cause of a motor that behaves differently from its twin.
A vendor config passed to withVendorConfig is applied either way, and its settings win over the ones saved on the controller. On a SPARK or a Nova, only the settings the vendor config sets change. A TalonFXConfiguration or TalonFXSConfiguration holds every setting, so on a TalonFX or TalonFXS a vendor config replaces all the saved settings, even with the reset off: to keep a setting saved on a Talon, leave out the vendor config, or set that setting in it too.

Check it
Open the controller in Phoenix Tuner X or REV Hardware Client after the robot code has started, and check that the vendor setting you added is there (for example, the TalonFX no longer beeps on boot), and that the settings from your SmartMotorControllerConfig (gear ratio, current limit, brake mode) are there too.
If it did not work
SmartMotorControllerConfigurationExceptionabout the vendor config. The object is the wrong type for the wrapper: a TalonFX needs aTalonFXConfiguration, a TalonFXS aTalonFXSConfiguration, a SPARK MAX aSparkMaxConfig, a SPARK Flex aSparkFlexConfig, and a Nova aNovaConfig.Configsuch as aNovaConfigBatch. An A301 takes none: remove the vendor config.Your vendor setting is gone.
SmartMotorControllerConfigsets the same option, and it wins. Set it there instead.Something else. See Troubleshooting.
Read more
To see every option SmartMotorControllerConfig does have, see SmartMotorControllerConfig.
Last updated
Was this helpful?
