Class SparkWrapper

java.lang.Object
yams.core.motorcontrollers.SmartMotorController
yams.core.motorcontrollers.local.SparkWrapper

public class SparkWrapper extends SmartMotorController
Spark wrapper for REV Spark Motor controllers.

External encoder discontinuity point support (SparkAbsoluteEncoder):

  • 0.5 rotations sensor range is [-0.5, 0.5), rangeOffset(0)
  • 1.0 rotations sensor range is [0, 1), rangeOffset(0.5)
REVLib's zeroCentered is deprecated for removal in 2027, so the SPARK's absolute encoder is given a range offset. An absolute encoder read over CAN has no range offset, and is still given dutyCycleZeroCentered.

A discontinuity point must be configured via SmartMotorControllerConfig.withExternalEncoderDiscontinuityPoint(Angle) whenever a SparkAbsoluteEncoder is used as the external encoder.

Example

// Configure and create a SPARK MAX (NEO motor) on CAN ID 3
SmartMotorControllerConfig config = new SmartMotorControllerConfig()
    .withMotorInverted(false)
    .withStatorCurrentLimit(Amps.of(40))
    .withClosedLoopController(0.2,0,0)
    .withExternalEncoderDiscontinuityPoint(Rotations.of(0.5)); // required for
SparkAbsoluteEncoder SmartMotorController motor = new SparkWrapper( new SparkMax(3,
MotorType.kBrushless), DCMotor.getNEO(1), config); Arm arm = new Arm(new
ArmConfig(motor).withLength(Meters.of(0.6)));