Package yams.core.motorcontrollers


package yams.core.motorcontrollers
Hardware-agnostic motor controller abstractions for FRC mechanisms.

This package provides a unified API for controlling brushless motor controllers from multiple vendors. All concrete wrappers extend SmartMotorController, which exposes position, velocity, and voltage control modes without reference to any vendor-specific types.

Core types

  • SmartMotorController the hardware-agnostic abstract base that all vendor wrappers extend. Defines the lifecycle methods (configure, periodic, stop) and the control interface (position, velocity, voltage, duty-cycle setpoints).
  • SmartMotorControllerConfig a fluent builder used to configure every aspect of a motor before it is applied. Settings include PID gains, feedforward constants, position and velocity software limits, ramp rates, current limits, encoder resolution and offsets, and gear ratios. Call SmartMotorController.configure(config) to push all settings to hardware.
  • SmartMotorControllerCommandRegistry registers WPILib Command objects that operate a specific motor so they can be discovered and scheduled by a mechanism.

Usage example

SmartMotorControllerConfig config = new SmartMotorControllerConfig()
    .withPID(0.1, 0.0, 0.001)
    .withCurrentLimit(40)
    .withPositionConversionFactor(2 * Math.PI / 42.0);

SmartMotorController motor = new SparkWrapper(
    new SparkMax(1, MotorType.kBrushless), DCMotor.getNEO(1), config);
motor.setPositionSetpoint(Math.PI / 2);

Sub-packages

  • yams.core.motorcontrollers.local REV Robotics SPARK MAX and SPARK FLEX wrappers that run closed-loop control on the roboRIO.
  • yams.core.motorcontrollers.remote CTRE TalonFX and TalonFXS wrappers that run closed-loop control on the motor controller itself via the Phoenix 6 API.
  • yams.core.motorcontrollers.simulation simulation-only implementations used in unit tests and the WPILib simulation GUI.