Skip to content
This repository was archived by the owner on May 19, 2024. It is now read-only.

Commit 28b5981

Browse files
committed
chore: Format.
1 parent e7508c7 commit 28b5981

14 files changed

+241
-226
lines changed

Diff for: src/main/java/frc/lib/ControllerConstants.java

+4-3
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,19 @@ public class ControllerConstants {
1111

1212
/**
1313
* Modifies these controller constants to use the feedforward controller constants.
14-
*
14+
*
1515
* @param feedforwardControllerConstants the feedforward controller constants to use.
1616
* @return these controller constants.
1717
*/
18-
public ControllerConstants withFeedforward(FeedforwardControllerConstants feedforwardControllerConstants) {
18+
public ControllerConstants withFeedforward(
19+
FeedforwardControllerConstants feedforwardControllerConstants) {
1920
this.feedforward = feedforwardControllerConstants;
2021
return this;
2122
}
2223

2324
/**
2425
* Modifies these controller constants to use the feedback controller constants.
25-
*
26+
*
2627
* @param feedbackControllerConstants the feedback controller constants to use.
2728
* @return these controller constants.
2829
*/

Diff for: src/main/java/frc/lib/FeedbackControllerConstants.java

+73-74
Original file line numberDiff line numberDiff line change
@@ -3,90 +3,89 @@
33
import edu.wpi.first.math.controller.PIDController;
44

55
/** Feedback controller constants. */
6-
public class FeedbackControllerConstants {
7-
/** Feedback controller proportional gain. */
8-
private double kP = 0.0;
6+
public class FeedbackControllerConstants {
7+
/** Feedback controller proportional gain. */
8+
private double kP = 0.0;
99

10-
/** Feedback controller integral gain. */
11-
private double kI = 0.0;
10+
/** Feedback controller integral gain. */
11+
private double kI = 0.0;
1212

13-
/** Feedback controller derivative gain. */
14-
private double kD = 0.0;
13+
/** Feedback controller derivative gain. */
14+
private double kD = 0.0;
1515

16-
/** Feedback controller position tolerance. */
17-
private double kPositionTolerance = 0.0;
16+
/** Feedback controller position tolerance. */
17+
private double kPositionTolerance = 0.0;
1818

19-
/** Feedback controller velocity tolerance. */
20-
private double kVelocityTolerance = 0.0;
21-
22-
// TODO Add velocity / acceleration constraints, profiled PID controller?
19+
/** Feedback controller velocity tolerance. */
20+
private double kVelocityTolerance = 0.0;
2321

24-
/**
25-
* Modifies these controller constants' proportional gain.
26-
*
27-
* @param kP the proportional gain.
28-
* @return these controller constants.
29-
*/
30-
public FeedbackControllerConstants withProportionalGain(double kP) {
31-
this.kP = kP;
32-
return this;
33-
}
22+
// TODO Add velocity / acceleration constraints, profiled PID controller?
3423

35-
/**
36-
* Modifies these controller constants' integral gain.
37-
*
38-
* @param kI the integral gain.
39-
* @return these controller constants.
40-
*/
41-
public FeedbackControllerConstants withIntegralGain(double kI) {
42-
this.kI = kI;
43-
return this;
44-
}
24+
/**
25+
* Modifies these controller constants' proportional gain.
26+
*
27+
* @param kP the proportional gain.
28+
* @return these controller constants.
29+
*/
30+
public FeedbackControllerConstants withProportionalGain(double kP) {
31+
this.kP = kP;
32+
return this;
33+
}
4534

46-
/**
47-
* Modifies these controller constants' derivative gain.
48-
*
49-
* @param kD the derivative gain.
50-
* @return these controller constants.
51-
*/
52-
public FeedbackControllerConstants withDerivativeGain(double kD) {
53-
this.kD = kD;
54-
return this;
55-
}
35+
/**
36+
* Modifies these controller constants' integral gain.
37+
*
38+
* @param kI the integral gain.
39+
* @return these controller constants.
40+
*/
41+
public FeedbackControllerConstants withIntegralGain(double kI) {
42+
this.kI = kI;
43+
return this;
44+
}
5645

57-
/**
58-
* Modifies these controller constants' position tolerance.
59-
*
60-
* @param kPositionTolerance the position tolerance.
61-
* @return these controller constants.
62-
*/
63-
public FeedbackControllerConstants withPositionTolerance(double kPositionTolerance) {
64-
this.kPositionTolerance = kPositionTolerance;
65-
return this;
66-
}
46+
/**
47+
* Modifies these controller constants' derivative gain.
48+
*
49+
* @param kD the derivative gain.
50+
* @return these controller constants.
51+
*/
52+
public FeedbackControllerConstants withDerivativeGain(double kD) {
53+
this.kD = kD;
54+
return this;
55+
}
6756

68-
/**
69-
* Modifies these controller constants' velocity tolerance.
70-
*
71-
* @param kVelocityTolerance the velocity tolerance.
72-
* @return these controller constants.
73-
*/
74-
public FeedbackControllerConstants withVelocityTolerance(double kVelocityTolerance) {
75-
this.kVelocityTolerance = kVelocityTolerance;
76-
return this;
77-
}
57+
/**
58+
* Modifies these controller constants' position tolerance.
59+
*
60+
* @param kPositionTolerance the position tolerance.
61+
* @return these controller constants.
62+
*/
63+
public FeedbackControllerConstants withPositionTolerance(double kPositionTolerance) {
64+
this.kPositionTolerance = kPositionTolerance;
65+
return this;
66+
}
7867

79-
/**
80-
* Creates a new PID controller using these feedback constants.
81-
*
82-
* @return a new PID controller using these feedback constants.
83-
*/
84-
public PIDController createPIDController() {
85-
PIDController pidController = new PIDController(kP, kI, kD);
68+
/**
69+
* Modifies these controller constants' velocity tolerance.
70+
*
71+
* @param kVelocityTolerance the velocity tolerance.
72+
* @return these controller constants.
73+
*/
74+
public FeedbackControllerConstants withVelocityTolerance(double kVelocityTolerance) {
75+
this.kVelocityTolerance = kVelocityTolerance;
76+
return this;
77+
}
8678

87-
pidController.setTolerance(kPositionTolerance, kVelocityTolerance);
79+
/**
80+
* Creates a new PID controller using these feedback constants.
81+
*
82+
* @return a new PID controller using these feedback constants.
83+
*/
84+
public PIDController createPIDController() {
85+
PIDController pidController = new PIDController(kP, kI, kD);
8886

89-
return pidController;
90-
}
91-
}
87+
pidController.setTolerance(kPositionTolerance, kVelocityTolerance);
9288

89+
return pidController;
90+
}
91+
}

Diff for: src/main/java/frc/lib/FeedforwardControllerConstants.java

+67-67
Original file line numberDiff line numberDiff line change
@@ -5,81 +5,81 @@
55

66
/** Feedforward controller constants. */
77
public class FeedforwardControllerConstants {
8-
/** Feedforward controller static gain. */
9-
private double kS = 0.0;
8+
/** Feedforward controller static gain. */
9+
private double kS = 0.0;
1010

11-
/** Feedforward controller gravity gain. */
12-
private double kG = 0.0;
11+
/** Feedforward controller gravity gain. */
12+
private double kG = 0.0;
1313

14-
/** Feedforward controller velocity gain. */
15-
private double kV = 0.0;
14+
/** Feedforward controller velocity gain. */
15+
private double kV = 0.0;
1616

17-
/** Feedforward controller acceleration gain. */
18-
private double kA = 0.0;
17+
/** Feedforward controller acceleration gain. */
18+
private double kA = 0.0;
1919

20-
/**
21-
* Modifies these controller constants' static feedforward.
22-
*
23-
* @param kS the static feedforward.
24-
* @return these controller constants.
25-
*/
26-
public FeedforwardControllerConstants withStaticFeedforward(double kS) {
27-
this.kS = kS;
28-
return this;
29-
}
20+
/**
21+
* Modifies these controller constants' static feedforward.
22+
*
23+
* @param kS the static feedforward.
24+
* @return these controller constants.
25+
*/
26+
public FeedforwardControllerConstants withStaticFeedforward(double kS) {
27+
this.kS = kS;
28+
return this;
29+
}
3030

31-
/**
32-
* Modifies these controller constants' gravity feedforward.
33-
*
34-
* @param kG the gravity feedforward.
35-
* @return these controller constants.
36-
*/
37-
public FeedforwardControllerConstants withGravityFeedforward(double kG) {
38-
this.kG = kG;
39-
return this;
40-
}
31+
/**
32+
* Modifies these controller constants' gravity feedforward.
33+
*
34+
* @param kG the gravity feedforward.
35+
* @return these controller constants.
36+
*/
37+
public FeedforwardControllerConstants withGravityFeedforward(double kG) {
38+
this.kG = kG;
39+
return this;
40+
}
4141

42-
/**
43-
* Modifies these controller constants' velocity feedforward.
44-
*
45-
* @param kV the velocity feedforward.
46-
* @return these controller constants.
47-
*/
48-
public FeedforwardControllerConstants withVelocityFeedforward(double kV) {
49-
this.kV = kV;
50-
return this;
51-
}
42+
/**
43+
* Modifies these controller constants' velocity feedforward.
44+
*
45+
* @param kV the velocity feedforward.
46+
* @return these controller constants.
47+
*/
48+
public FeedforwardControllerConstants withVelocityFeedforward(double kV) {
49+
this.kV = kV;
50+
return this;
51+
}
5252

53-
/**
54-
* Modifies these controller constants' acceleration feedforward.
55-
*
56-
* @param kA the acceleration feedforward.
57-
* @return these controller constants.
58-
*/
59-
public FeedforwardControllerConstants withAccelerationFeedfoward(double kA) {
60-
this.kA = kA;
61-
return this;
62-
}
53+
/**
54+
* Modifies these controller constants' acceleration feedforward.
55+
*
56+
* @param kA the acceleration feedforward.
57+
* @return these controller constants.
58+
*/
59+
public FeedforwardControllerConstants withAccelerationFeedfoward(double kA) {
60+
this.kA = kA;
61+
return this;
62+
}
6363

64-
/**
65-
* Creates a simple motor feedforward using these feedforward constants.
66-
*
67-
* @return a simple motor feedforward using these feedforward constants.
68-
*/
69-
public SimpleMotorFeedforward createSimpleMotorFeedforward() {
70-
if (kG != 0.0) {
71-
// TODO Non-zero gravity feedforward means that simple motor feedforward is not best
72-
}
73-
74-
return new SimpleMotorFeedforward(kS, kV, kA);
64+
/**
65+
* Creates a simple motor feedforward using these feedforward constants.
66+
*
67+
* @return a simple motor feedforward using these feedforward constants.
68+
*/
69+
public SimpleMotorFeedforward createSimpleMotorFeedforward() {
70+
if (kG != 0.0) {
71+
// TODO Non-zero gravity feedforward means that simple motor feedforward is not best
7572
}
7673

77-
/**
78-
* Creates an arm feedforward using these feedforward constants.
79-
*
80-
* @return an arm feedforward using these feedforward constants.
81-
*/
82-
public ArmFeedforward createArmFeedforward() {
83-
return new ArmFeedforward(kS, kG, kV, kA);
84-
}
74+
return new SimpleMotorFeedforward(kS, kV, kA);
75+
}
76+
77+
/**
78+
* Creates an arm feedforward using these feedforward constants.
79+
*
80+
* @return an arm feedforward using these feedforward constants.
81+
*/
82+
public ArmFeedforward createArmFeedforward() {
83+
return new ArmFeedforward(kS, kG, kV, kA);
84+
}
8585
}

Diff for: src/main/java/frc/robot/arm/Arm.java

+8-5
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,10 @@ public class Arm extends Subsystem {
2828
/** Arm's setpoint. Updated periodically to reach goal within constraints. */
2929
private ArmState setpoint;
3030

31-
/** Time of the previous periodic call. Used for calculating the time elapsed between generating setpoints. */
31+
/**
32+
* Time of the previous periodic call. Used for calculating the time elapsed between generating
33+
* setpoints.
34+
*/
3235
private double previousTimeSeconds;
3336

3437
/** Creates the arm subsystem and configures arm hardware. */
@@ -90,7 +93,7 @@ public void addToShuffleboard(ShuffleboardTab tab) {
9093

9194
/**
9295
* Returns the arm's state.
93-
*
96+
*
9497
* @return the arm's state.
9598
*/
9699
public ArmState getState() {
@@ -101,7 +104,7 @@ public ArmState getState() {
101104

102105
/**
103106
* Sets the arm's goal state.
104-
*
107+
*
105108
* @param goal the arm's goal state.
106109
*/
107110
public void setGoal(ArmState goal) {
@@ -110,7 +113,7 @@ public void setGoal(ArmState goal) {
110113

111114
/**
112115
* Returns true if the arm is at the goal state.
113-
*
116+
*
114117
* @return true if the arm is at the goal state.
115118
*/
116119
public boolean atGoal() {
@@ -119,7 +122,7 @@ public boolean atGoal() {
119122

120123
/**
121124
* Sets the position.
122-
*
125+
*
123126
* @param state the state to use as position.
124127
*/
125128
public void setPosition(ArmState state) {

0 commit comments

Comments
 (0)