Skip to content
This repository was archived by the owner on Sep 14, 2019. It is now read-only.

Commit 4a8dbdb

Browse files
committed
add documentation
1 parent d5b2f81 commit 4a8dbdb

2 files changed

Lines changed: 23 additions & 5 deletions

File tree

Robot2018/src/org/usfirst/frc/team199/Robot2018/commands/PIDMove.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ protected void end() {
144144
moveController.disable();
145145
System.out.println("End");
146146
// moveController.free();
147-
147+
148148
double angle = Math.toRadians(AutoUtils.position.getRot());
149149
double dist = avg.pidGet();
150150
double x = Math.cos(angle) * dist;

Robot2018/src/org/usfirst/frc/team199/Robot2018/commands/PIDTurn.java

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,16 +61,34 @@ public PIDTurn(double targ, DrivetrainInterface dt, SmartDashboardInterface sd,
6161
// tim = new Timer();
6262
}
6363

64+
/**
65+
* Constructs this command with a new PIDController. Sets all of the
66+
* controller's PID constants based on SD prefs. Sets the controller's PIDSource
67+
* to the AHRS (gyro) object and sets its PIDOutput to this command which
68+
* implements PIDOutput's pidWrite() method.
69+
*
70+
* @param point
71+
* the target point (in inches) to turn to, relative to the starting
72+
* position
73+
* @param dt
74+
* the Drivetrain (for actual code) or a DrivetrainInterface (for
75+
* testing)
76+
* @param ahrs
77+
* the AHRS (gyro)
78+
* @param sd
79+
* the Smart Dashboard reference, or a SmartDashboardInterface for
80+
* testing
81+
*/
6482
public PIDTurn(double[] point, DrivetrainInterface dt, SmartDashboardInterface sd, PIDSource ahrs) {
6583
this.dt = dt;
6684
this.ahrs = ahrs;
67-
85+
6886
double dx = point[0] - AutoUtils.position.getX();
6987
double dy = point[1] - AutoUtils.position.getY();
70-
88+
7189
double absTurn = Math.toDegrees(Math.atan(dx / dy));
7290
target = absTurn - AutoUtils.position.getRot();
73-
91+
7492
if (Robot.dt != null) {
7593
requires(Robot.dt);
7694
}
@@ -160,7 +178,7 @@ protected void end() {
160178
SmartDashboard.putNumber("Turn PID Result", turnController.get());
161179
SmartDashboard.putNumber("Turn PID Error", turnController.getError());
162180
// turnController.free();
163-
181+
164182
AutoUtils.position.changeRot(dt.getAHRSAngle());
165183
}
166184

0 commit comments

Comments
 (0)