diff --git a/lib/src/main/java/com/team2813/lib2813/control/ControlMode.java b/lib/src/main/java/com/team2813/lib2813/control/ControlMode.java index 0ae960c7..4bbc194c 100644 --- a/lib/src/main/java/com/team2813/lib2813/control/ControlMode.java +++ b/lib/src/main/java/com/team2813/lib2813/control/ControlMode.java @@ -1,20 +1,18 @@ package com.team2813.lib2813.control; -import com.revrobotics.spark.SparkBase.ControlType; - public enum ControlMode { - DUTY_CYCLE(ControlType.kDutyCycle), - VELOCITY(ControlType.kVelocity), - MOTION_MAGIC(ControlType.kPosition), - VOLTAGE(ControlType.kVoltage); + DUTY_CYCLE(false), + VELOCITY(false), + MOTION_MAGIC(true), + VOLTAGE(false); - private final ControlType sparkMode; + private final boolean isPositionalControl; - ControlMode(ControlType sparkMode) { - this.sparkMode = sparkMode; + ControlMode(boolean isPositionalControl) { + this.isPositionalControl = isPositionalControl; } - public ControlType getSparkMode() { - return sparkMode; + public boolean isPositionalControl() { + return isPositionalControl; } } diff --git a/lib/src/main/java/com/team2813/lib2813/subsystems/MotorSubsystem.java b/lib/src/main/java/com/team2813/lib2813/subsystems/MotorSubsystem.java index d2e76276..c33a905f 100644 --- a/lib/src/main/java/com/team2813/lib2813/subsystems/MotorSubsystem.java +++ b/lib/src/main/java/com/team2813/lib2813/subsystems/MotorSubsystem.java @@ -311,8 +311,16 @@ public MotorSubsystemConfiguration controller(PIDController controller) { * * @param controlMode The mode to use when controlling the motor * @return {@code this} for chaining + * @throws IllegalArgumentException If {@code controlMode} is for positional control */ public MotorSubsystemConfiguration controlMode(ControlMode controlMode) { + if (controlMode.isPositionalControl()) { + throw new IllegalArgumentException( + String.format( + "Control mode %s is for positional control. This is invalid! Please use a different" + + " control mode", + controlMode)); + } this.controlMode = controlMode; return this; }