Skip to content

Commit 631fd7d

Browse files
committed
Make methods final that can be final
1 parent 002e2bc commit 631fd7d

1 file changed

Lines changed: 25 additions & 13 deletions

File tree

lib/src/main/java/com/team2813/lib2813/subsystems/MotorSubsystem.java

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ protected MotorSubsystem(MotorSubsystemConfiguration builder) {
5050
*
5151
* @param position the position to go to.
5252
*/
53-
public void setSetpoint(T position) {
53+
public final void setSetpoint(T position) {
5454
if (!isEnabled()) {
5555
enable();
5656
}
@@ -68,12 +68,12 @@ public final Command setSetpointCommand(T setpoint) {
6868
}
6969

7070
/** Returns the current setpoint as an angle. */
71-
public Angle getSetpoint() {
71+
public final Angle getSetpoint() {
7272
return rotationUnit.of(controller.getSetpoint());
7373
}
7474

7575
/** Determines if the motor is at the current setpoint, within the acceptable error. */
76-
public boolean atPosition() {
76+
public final boolean atPosition() {
7777
return Math.abs(getMeasurement() - controller.getSetpoint()) <= acceptableError;
7878
}
7979

@@ -83,23 +83,35 @@ public boolean atPosition() {
8383
* <p>Additionally, this method disables PID control of the subsystem
8484
*/
8585
@Override
86-
public void set(ControlMode mode, double demand, double feedForward) {
86+
public final void set(ControlMode mode, double demand, double feedForward) {
8787
if (isEnabled()) {
8888
disable();
8989
}
9090
motor.set(mode, demand, feedForward);
9191
}
9292

9393
@Override
94-
public Current getAppliedCurrent() {
94+
public final Current getAppliedCurrent() {
9595
return motor.getAppliedCurrent();
9696
}
9797

98-
public void enable() {
98+
/**
99+
* Enables the motor
100+
*
101+
* <p>The motor voltage will be periodically updated to move the motor towards the current
102+
* setupoint.
103+
*/
104+
public final void enable() {
99105
isEnabled = true;
100106
}
101107

102-
public void disable() {
108+
/**
109+
* Stops the motor.
110+
*
111+
* <p>The motor voltage will be set to zero, and the motor will not adjust to move towards the
112+
* current setpoint.
113+
*/
114+
public final void disable() {
103115
isEnabled = false;
104116
motor.set(controlMode, 0);
105117
}
@@ -109,7 +121,7 @@ public void disable() {
109121
*
110122
* @return Whether the controller is enabled.
111123
*/
112-
public boolean isEnabled() {
124+
public final boolean isEnabled() {
113125
return isEnabled;
114126
}
115127

@@ -120,7 +132,7 @@ public boolean isEnabled() {
120132
* the provided value.
121133
*/
122134
@Override
123-
public void set(ControlMode mode, double demand) {
135+
public final void set(ControlMode mode, double demand) {
124136
isEnabled = false;
125137
motor.set(mode, demand);
126138
}
@@ -162,7 +174,7 @@ protected double clampOutput(double output) {
162174
return output;
163175
}
164176

165-
protected double getMeasurement() {
177+
protected final double getMeasurement() {
166178
return encoder.getPositionMeasure().in(rotationUnit);
167179
}
168180

@@ -173,7 +185,7 @@ public double position() {
173185
}
174186

175187
@Override
176-
public Angle getPositionMeasure() {
188+
public final Angle getPositionMeasure() {
177189
return encoder.getPositionMeasure();
178190
}
179191

@@ -184,7 +196,7 @@ public void setPosition(double position) {
184196
}
185197

186198
@Override
187-
public void setPosition(Angle position) {
199+
public final void setPosition(Angle position) {
188200
encoder.setPosition(position);
189201
}
190202

@@ -195,7 +207,7 @@ public double getVelocity() {
195207
}
196208

197209
@Override
198-
public AngularVelocity getVelocityMeasure() {
210+
public final AngularVelocity getVelocityMeasure() {
199211
return encoder.getVelocityMeasure();
200212
}
201213

0 commit comments

Comments
 (0)