Skip to content

Commit 7b0f32f

Browse files
committed
Added JavaDocs
1 parent 689ec78 commit 7b0f32f

10 files changed

Lines changed: 279 additions & 148 deletions

src/main/java/frc/robot/RobotContainer.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,10 @@ public Command getCoralPathCommand(String chooser) {
261261
}
262262
}
263263

264+
/**
265+
* Sets if YAGSL should put all the motors into brake mode and stop the robot
266+
@param brake Should we brake?
267+
*/
264268
public void setMotorBrake(boolean brake) {
265269
drivebase.setMotorBrake(brake);
266270
}

src/main/java/frc/robot/commands/AlignWithNearest.java

Lines changed: 53 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -68,39 +68,24 @@ public class AlignWithNearest extends Command {
6868

6969
// add vision as a requirement to run
7070
public AlignWithNearest() {
71-
this.xLimiter = new SlewRateLimiter(4);
72-
this.yLimiter = new SlewRateLimiter(4);
73-
this.giroLimiter = new SlewRateLimiter(Units.degreesToRadians(720));
74-
75-
/**
76-
* PID Controllers for the align
77-
*/
78-
this.drivePID = new PIDController(
79-
0.00023,
80-
0.0000002,
81-
2);
82-
83-
this.strafePID = new PIDController(
84-
0.00023,
85-
0.0000002,
86-
2);
87-
88-
this.rotationPID = new PIDController(
89-
0.0020645,
90-
0,
91-
0);
92-
/**
93-
* Boolean for what target to search
94-
*/
95-
96-
/**
97-
* Offsets for the limelight
98-
*/
99-
//this.offsets = limelight.getOffsets(alingToAprilTag);
100-
101-
this.driveOffset = 2.1;
102-
this.strafeOffset = -0.2;
103-
this.rotationOffset = 10.2;
71+
this.xLimiter = new SlewRateLimiter(4);
72+
this.yLimiter = new SlewRateLimiter(4);
73+
this.giroLimiter = new SlewRateLimiter(Units.degreesToRadians(720));
74+
75+
/** PID Controllers for the align */
76+
this.drivePID = new PIDController(0.00023, 0.0000002, 2);
77+
78+
this.strafePID = new PIDController(0.00023, 0.0000002, 2);
79+
80+
this.rotationPID = new PIDController(0.0020645, 0, 0);
81+
/** Boolean for what target to search */
82+
83+
/** Offsets for the limelight */
84+
// this.offsets = limelight.getOffsets(alingToAprilTag);
85+
86+
this.driveOffset = 2.1;
87+
this.strafeOffset = -0.2;
88+
this.rotationOffset = 10.2;
10489
}
10590

10691
@Override
@@ -115,40 +100,42 @@ public void initialize() {
115100
*/
116101
}
117102

118-
public void execute(){
103+
public void execute() {
119104
double velForward = 0;
120-
double velStrafe = 0;
121-
double velGiro = 0;
122-
123-
/**
124-
* If there is a seen target, calculate the PIDs velocities,
125-
* otherwise, rotate so the robot can search the target
126-
*/
127-
if(VisionSubsystem.getTags().length != 0){
128-
129-
velForward = drivePID.calculate(VisionSubsystem.getTagArea(), driveOffset);
130-
velStrafe = strafePID.calculate(VisionSubsystem.getXDistance(), strafeOffset);
131-
velGiro = -rotationPID.calculate(VisionSubsystem.getTagPose2d().getRotation().getDegrees(), rotationOffset);
132-
} else if(VisionSubsystem.getTags().length == 0){
133-
velForward = 0;
134-
velStrafe = 0;
135-
velGiro = 0.4;
136-
} else {
137-
velForward = 0;
138-
velStrafe = 0;
139-
velGiro = 0;
140-
}
141-
142-
// 3. Make the driving smoother
143-
velForward = xLimiter.calculate(velForward) * 3;
144-
velStrafe = yLimiter.calculate(velStrafe) * 3;
145-
velGiro = giroLimiter.calculate(velGiro) * 5;
146-
147-
// 4. Construct desired chassis speeds
148-
ChassisSpeeds chassisSpeeds;
149-
150-
//Relative to robot
151-
chassisSpeeds = new ChassisSpeeds(velForward, velStrafe, velGiro);
105+
double velStrafe = 0;
106+
double velGiro = 0;
107+
108+
/**
109+
* If there is a seen target, calculate the PIDs velocities, otherwise, rotate so the robot can
110+
* search the target
111+
*/
112+
if (VisionSubsystem.getTags().length != 0) {
113+
114+
velForward = drivePID.calculate(VisionSubsystem.getTagArea(), driveOffset);
115+
velStrafe = strafePID.calculate(VisionSubsystem.getXDistance(), strafeOffset);
116+
velGiro =
117+
-rotationPID.calculate(
118+
VisionSubsystem.getTagPose2d().getRotation().getDegrees(), rotationOffset);
119+
} else if (VisionSubsystem.getTags().length == 0) {
120+
velForward = 0;
121+
velStrafe = 0;
122+
velGiro = 0.4;
123+
} else {
124+
velForward = 0;
125+
velStrafe = 0;
126+
velGiro = 0;
127+
}
128+
129+
// 3. Make the driving smoother
130+
velForward = xLimiter.calculate(velForward) * 3;
131+
velStrafe = yLimiter.calculate(velStrafe) * 3;
132+
velGiro = giroLimiter.calculate(velGiro) * 5;
133+
134+
// 4. Construct desired chassis speeds
135+
ChassisSpeeds chassisSpeeds;
136+
137+
// Relative to robot
138+
chassisSpeeds = new ChassisSpeeds(velForward, velStrafe, velGiro);
152139
}
153140

154141
@Override

src/main/java/frc/robot/subsystems/AlgaeSubsystem.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,21 +38,27 @@ public void periodic() {
3838
// Add any periodic tasks here, such as motor feedback or sensor checks.
3939
}
4040

41-
// Shoots the ball (or algae). The claw motor runs in the forward direction.
41+
/**
42+
* Shoots the ball (or algae). The claw motor runs in the forward direction at 1.25x the value
43+
* returned by {@link #setSpeed()}
44+
*/
4245
public void shoot() {
4346
motorConfig.inverted(false);
4447
motor.configure(motorConfig, ResetMode.kResetSafeParameters, PersistMode.kPersistParameters);
4548
motor.set(setSpeed() * 1.25); // Run motor forward to shoot the ball (algae)
4649
}
4750

48-
// Intakes the ball (algae). The claw motor runs in the reverse direction.
51+
/**
52+
* Intakes the ball (algae). The claw motor runs in the reverse direction at the value returned by
53+
* {@link #setSpeed()}
54+
*/
4955
public void intake() {
5056
motorConfig.inverted(true); // Invert motor direction for intake
5157
motor.configure(motorConfig, ResetMode.kResetSafeParameters, PersistMode.kPersistParameters);
5258
motor.set(setSpeed()); // Reverse the motor to pull the algae into the claw
5359
}
5460

55-
// Stops the motor. Useful for stopping the claw at any time.
61+
/** Stops the motor. Useful for stopping the claw at any time. */
5662
public void stop() {
5763
motor.set(0); // Completely stop motor when the claw doesn't need to run
5864
}

src/main/java/frc/robot/subsystems/ClimberSubsystem.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,19 +43,27 @@ public ClimberSubsystem() {
4343
m_config, ResetMode.kResetSafeParameters, PersistMode.kPersistParameters);
4444
}
4545

46+
/** Start extending the higher Climber motor at {@link #EXTENSION_SPEED} */
4647
public void StartExtending() {
4748
m_higherClimber.set(EXTENSION_SPEED);
4849
}
4950

51+
/** Start retracting the lower Climber motor at {@link #RETRACTION_SPEED} */
5052
public void StartRetracting() {
5153
m_lowerClimber.set(RETRACTION_SPEED);
5254
}
5355

56+
/** Stop the climber */
5457
public void stop() {
5558
m_higherClimber.stopMotor();
5659
m_lowerClimber.stopMotor();
5760
}
5861

62+
/**
63+
* Get the left Climber motor encoder
64+
*
65+
* @return left Climber motor encoder position
66+
*/
5967
public double getEncoder() {
6068
return m_leftEncoder.getPosition();
6169
}

src/main/java/frc/robot/subsystems/CoralHoldAngleSubsystem.java

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ private double setSpeed() {
7777
return kP * 1; // Based around elevator's 'calculate speed.' Will be adjusted later on.
7878
}
7979

80-
// Free hand tilt down. Just hold a button and go. Need an if statement
80+
/** Free hand tilt down. Just hold a button and go. Moves at {@link #setSpeed()} */
8181
public void tiltedDown() {
8282
buttonPressed = true;
8383

@@ -87,6 +87,10 @@ public void tiltedDown() {
8787
motor.set(setSpeed());
8888
}
8989

90+
/**
91+
* Move the arm to Intake position or 0.9 at {@link #setSpeed()} When at the position hold it with
92+
* {@link #holdUp(State)}
93+
*/
9094
public void IntakePosition() {
9195
double setPoint = 0.9;
9296
if (setPoint + 0.1 < encoder.getPosition()) {
@@ -102,13 +106,18 @@ public void IntakePosition() {
102106
}
103107
}
104108

109+
/**
110+
* Move the arm to L3 place position or 0.73 using the PIDF commands
111+
*
112+
* @deprecated NEEDS WORK! As of late the PIDF movement doesn't work due to the relative encoder
113+
*/
105114
public void LPosition() {
106115
State setpoint = new State(0.73, 0);
107116
double ff = feedforward.calculate(setpoint.position * 2 * Math.PI, setpoint.velocity);
108117
controller.setReference(0.73, ControlType.kPosition, ClosedLoopSlot.kSlot0, ff);
109118
}
110119

111-
// Free hand tilt up. Just hold a button and go. Need an if statement
120+
/** Free hand tilt up. Just hold a button and go. Moves at {@link #setSpeed()} */
112121
public void tiltUp() {
113122
buttonPressed = true;
114123

@@ -118,6 +127,11 @@ public void tiltUp() {
118127
motor.set(setSpeed());
119128
}
120129

130+
/**
131+
* Gets the relative encoder position of the arm
132+
*
133+
* @return Encoder Position
134+
*/
121135
public double getEncoder() {
122136
return motor.getEncoder().getPosition();
123137
}
@@ -135,6 +149,11 @@ public double getEncoder() {
135149
136150
} */
137151

152+
/**
153+
* Uses the ff calculator to keep the arm in a single place
154+
*
155+
* @param TrapezoidProfile.State Setpoint position to hold
156+
*/
138157
public void holdUp(TrapezoidProfile.State setpoint) {
139158
// motorConfig.closedLoop.velocityFF(feedforward);
140159
double ff = feedforward.calculate(setpoint.position * 2 * Math.PI, setpoint.velocity);
@@ -146,7 +165,7 @@ public void holdUp(TrapezoidProfile.State setpoint) {
146165

147166
}
148167

149-
// When you release a button, this is called to stop the tilt.
168+
/** When you release a button, this is called to stop the tilt. */
150169
public void stopTilt() {
151170
motor.set(0);
152171
buttonPressed = false;

src/main/java/frc/robot/subsystems/CoralHoldSubsystem.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,11 @@ private double setSpeed() {
4040
//Let it go if limit switch is hit
4141
}*/
4242

43-
// When we want to shoot coral from the intake, has to have a coral in the lift
43+
/**
44+
* When we want to shoot coral from the intake. Moves at negative {@link #setSpeed()} x 1.25
45+
*
46+
* @implNote Currently doesn't use the limit switch but can in the future if we have it
47+
*/
4448
public void shoot() {
4549
// if (!limitSwitch.get()) {
4650
// motorConfig.inverted(false);
@@ -51,7 +55,11 @@ public void shoot() {
5155
// }
5256
}
5357

54-
// Intakes coral. Lift has to be empty
58+
/**
59+
* Intakes coral. Moves at {@link #setSpeed()}
60+
*
61+
* @implNote Currently doesn't use the limit switch but can in the future if we have it
62+
*/
5563
public void intake() {
5664
// if (limitSwitch.get()) {
5765
motor.set(setSpeed());
@@ -60,7 +68,7 @@ public void intake() {
6068
// }
6169
}
6270

63-
// Makes the motor stop. Can shut down both functions.
71+
/** Makes the motor stop. */
6472
public void stop() {
6573
motor.set(0);
6674
}

0 commit comments

Comments
 (0)