Skip to content
Merged
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
35 changes: 21 additions & 14 deletions Robot2019/src/main/java/frc/robot/RobotMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,19 +102,18 @@ private static BaseMotorController createConfiguredMotorController(int port) {

private static WPI_TalonSRX createConfiguredTalon(int port) {
WPI_TalonSRX tsrx = new WPI_TalonSRX(port);

// Put all configurations for the talon motor controllers in here.
// All values are from last year's code.
tsrx.configNominalOutputForward(0, 10);
tsrx.configNominalOutputReverse(0, 10);
tsrx.configPeakOutputForward(1, 10);
tsrx.configPeakOutputReverse(-1, 10);
tsrx.configPeakCurrentLimit(0, 0);
tsrx.configPeakCurrentDuration(0, 0);
catchError(tsrx.configNominalOutputForward(0, 10));
catchError(tsrx.configNominalOutputReverse(0, 10));
catchError(tsrx.configPeakOutputForward(1, 10));
catchError(tsrx.configPeakOutputReverse(-1, 10));
catchError(tsrx.configPeakCurrentLimit(0, 0));
catchError(tsrx.configPeakCurrentDuration(0, 0));
// 40 Amps is the amp limit of a CIM. lThe PDP has 40 amp circuit breakers,
tsrx.configContinuousCurrentLimit(40, 0);
catchError(tsrx.configContinuousCurrentLimit(40, 0));
tsrx.enableCurrentLimit(true);
tsrx.configNeutralDeadband(0.001, 10);
catchError(tsrx.configNeutralDeadband(0.001, 10));
tsrx.setNeutralMode(NeutralMode.Brake);

return tsrx;
Expand All @@ -124,11 +123,11 @@ private static WPI_VictorSPX createConfiguredVictor(int port) {
WPI_VictorSPX vspx = new WPI_VictorSPX(port);

// Put all configurations for the victor motor controllers in here.
vspx.configNominalOutputForward(0, 10);
vspx.configNominalOutputReverse(0, 10);
vspx.configPeakOutputForward(1, 10);
vspx.configPeakOutputReverse(-1, 10);
vspx.configNeutralDeadband(0.001, 10);
catchError(vspx.configNominalOutputForward(0, 10));
catchError(vspx.configNominalOutputReverse(0, 10));
catchError(vspx.configPeakOutputForward(1, 10));
catchError(vspx.configPeakOutputReverse(-1, 10));
catchError(vspx.configNeutralDeadband(0.001, 10));
vspx.setNeutralMode(NeutralMode.Brake);

return vspx;
Expand All @@ -139,4 +138,12 @@ private static UsbCamera configureCamera(int port) {
camera.setConnectionStrategy(VideoSource.ConnectionStrategy.kKeepOpen);
return camera;
}

/**
* Checks an error code and prints it to standard out if it is not ok
* @param ec The error code to check
*/
private static void catchError(ErrorCode ec) {
if(ec != ErrorCode.OK) System.out.println("Error configuring in RobotMap.java at line: " + new Throwable().getStackTrace()[1].getLineNumber());
}
}