Class MotorNotPresentException
java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
yams.core.exceptions.MotorNotPresentException
- All Implemented Interfaces:
Serializable
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
nullas the motor argument tosetMotor()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 Summary
ConstructorsConstructorDescriptionMotorNotPresentException(String mechanismType) CreateRuntimeExceptionforSmartMechanism -
Method Summary
Methods inherited from class Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
Constructor Details
-
MotorNotPresentException
CreateRuntimeExceptionforSmartMechanism- Parameters:
mechanismType- Name of the mechanism
-