Skip to content

Commit 6cbb07b

Browse files
Fixed null pointer exception.
Signed-off-by: thenetworkgrinch <thenetworkgrinch@users.noreply.github.com>
1 parent 07d7995 commit 6cbb07b

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

src/main/java/swervelib/motors/SparkMaxBrushedMotorSwerve.java

+11-9
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,17 @@ public class SparkMaxBrushedMotorSwerve extends SwerveMotor
6868
public SparkMaxBrushedMotorSwerve(CANSparkMax motor, boolean isDriveMotor, Type encoderType, int countsPerRevolution,
6969
boolean useDataPortQuadEncoder)
7070
{
71+
72+
noEncoderAlert = new Alert("Motors",
73+
"Cannot use motor without encoder.",
74+
Alert.AlertType.ERROR_TRACE);
75+
failureConfiguringAlert = new Alert("Motors",
76+
"Failure configuring motor " + motor.getDeviceId(),
77+
Alert.AlertType.WARNING_TRACE);
78+
noEncoderDefinedAlert = new Alert("Motors",
79+
"An encoder MUST be defined to work with a SparkMAX",
80+
Alert.AlertType.ERROR_TRACE);
81+
7182
// Drive motors **MUST** have an encoder attached.
7283
if (isDriveMotor && encoderType == Type.kNoSensor)
7384
{
@@ -103,15 +114,6 @@ public SparkMaxBrushedMotorSwerve(CANSparkMax motor, boolean isDriveMotor, Type
103114
// Spin off configurations in a different thread.
104115
// configureSparkMax(() -> motor.setCANTimeout(0)); // Commented it out because it prevents feedback.
105116

106-
noEncoderAlert = new Alert("Motors",
107-
"Cannot use motor without encoder.",
108-
Alert.AlertType.ERROR_TRACE);
109-
failureConfiguringAlert = new Alert("Motors",
110-
"Failure configuring motor " + motor.getDeviceId(),
111-
Alert.AlertType.WARNING_TRACE);
112-
noEncoderDefinedAlert = new Alert("Motors",
113-
"An encoder MUST be defined to work with a SparkMAX",
114-
Alert.AlertType.ERROR_TRACE);
115117
}
116118

117119
/**

0 commit comments

Comments
 (0)