Skip to content

Commit

Permalink
Spam warnings if a WsSpark is configured as a follower
Browse files Browse the repository at this point in the history
  • Loading branch information
fruzyna committed Feb 23, 2024
1 parent 78dd530 commit af7cf1a
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions src/main/java/org/wildstang/hardware/roborio/outputs/WsSpark.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,17 @@ public WsSpark(String name, int channel, WsMotorControllers controller, double p
isUsingController = false;
isChanged = true;
controlType = ControlType.kDutyCycle;

warnFollower();
}

/**
* WsSpark should never be a follower. It is possible that follower state can get burned into the flash, this warns in that case.
*/
public void warnFollower() {
if (motor.isFollower()) {
Log.error("WsSpark is set as a follower!");
}
}

/**
Expand Down Expand Up @@ -209,18 +220,20 @@ public void sendDataToOutput() {
}

/**
* Wraps setValue().
* Wraps CANSparkBase.setSpeed().
* @param value New motor percent speed, from -1.0 to 1.0.
*/
@Override
public void setSpeed(double value){
if (controlType == ControlType.kDutyCycle && super.getValue()==value){
if (controlType == ControlType.kDutyCycle && super.getValue() == value){
isChanged = false;
} else {
isChanged = true;
}
controlType = ControlType.kDutyCycle;
super.setSpeed(value);

warnFollower();
}

/**
Expand Down Expand Up @@ -284,6 +297,10 @@ public void initClosedLoop(double P, double I, double D, double FF, AbsoluteEnco
slotID = 0;
}

/**
* Returns the motor controller's PID controller.
* @return PID Controller object
*/
public SparkPIDController getPIDController(){
return motor.getPIDController();
}
Expand Down

0 comments on commit af7cf1a

Please sign in to comment.