Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 9 additions & 11 deletions lib/src/main/java/com/team2813/lib2813/control/ControlMode.java
Original file line number Diff line number Diff line change
@@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Loading