Package yams.core.motorcontrollers.local


package yams.core.motorcontrollers.local
REV Robotics motor controller wrappers whose closed-loop control runs on the roboRIO.

This package contains adapters for REV SPARK MAX and SPARK FLEX motor controllers. Because the REV hardware offloads PID execution to the roboRIO (rather than to the motor controller itself), these wrappers are classified as local: the control loop runs on the robot controller and sends periodic duty-cycle or voltage commands to the hardware.

Core type

  • SparkWrapper unified adapter for both the SPARK MAX (NEO, NEO 550) and SPARK FLEX (NEO Vortex).

Absolute encoder discontinuity

When a SparkAbsoluteEncoder (REV Through Bore Encoder) is used as the feedback device, a discontinuity point must be configured so the SPARK firmware knows where the sensor wraps around. Set this via SmartMotorControllerConfig.withExternalEncoderDiscontinuityPoint(Angle):

  • 0.5 sensor range [-0.5, 0.5): useful when the mechanism travels through zero and must not have a wrap at the midpoint of travel.
  • 1.0 sensor range [0, 1): useful when the mechanism only moves in the positive direction and zero is never crossed.
Omitting this setting when an absolute encoder is attached will produce a configuration warning and may cause erratic position readings near the wrap boundary.

Construction

SmartMotorControllerConfig config = new SmartMotorControllerConfig()
    .withExternalEncoderDiscontinuityPoint(0.5);
SmartMotorController motor = new SparkWrapper(
    new SparkMax(5, MotorType.kBrushless), DCMotor.getNEO(1), config);
See Also: