Class MotorNotPresentException

All Implemented Interfaces:
Serializable

public class MotorNotPresentException extends RuntimeException
Thrown by a SmartMechanism subclass when the primary SmartMotorController has not been set before the mechanism attempts to use it.

This exception signals that the mechanism's motor slot is null either because no motor was ever assigned, or because the mechanism was constructed before the motor was initialized.

Common triggers include:

  • Constructing or activating a mechanism without calling the appropriate withSmartMotorController() builder method on its config
  • Passing null as the motor argument to setMotor() or the config builder

Resolution: Provide a valid motor controller before constructing the mechanism:

SmartMotorController motor = SmartMotorController.create(
    SPARK_MAX, DCMotor.getNEO(1));
// Then pass the motor to the relevant mechanism config, e.g.:
ArmConfig config = new ArmConfig().withSmartMotorController(motor);
See Also:
  • Constructor Details