-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d14c547
commit af7657f
Showing
9 changed files
with
44 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 22 additions & 10 deletions
32
.../test_robot_base/src/main/java/org/snobotv2/examples/base/commands/auton/TurnToAngle.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,39 @@ | ||
package org.snobotv2.examples.base.commands.auton; | ||
|
||
import edu.wpi.first.math.controller.PIDController; | ||
import edu.wpi.first.wpilibj2.command.PIDCommand; | ||
import edu.wpi.first.wpilibj2.command.Command; | ||
import org.snobotv2.examples.base.subsystems.DrivetrainSubsystem; | ||
|
||
public class TurnToAngle extends PIDCommand | ||
public class TurnToAngle extends Command | ||
{ | ||
private final PIDController mController; | ||
private final DrivetrainSubsystem mDrivetrain; | ||
private final double mGoal; | ||
|
||
@SuppressWarnings("PMD.ConstructorCallsOverridableMethod") | ||
public TurnToAngle(DrivetrainSubsystem drivetrain, double goal) | ||
{ | ||
super(new PIDController(.02, 0, 0.001), | ||
drivetrain::getHeadingDegrees, | ||
goal, | ||
(double output) -> drivetrain.arcadeDrive(0, output), | ||
drivetrain); | ||
mController = new PIDController(.02, 0, 0.001); | ||
mController.enableContinuousInput(-180, 180); | ||
mController.setTolerance(3, 1); | ||
|
||
mDrivetrain = drivetrain; | ||
mGoal = goal; | ||
|
||
addRequirements(mDrivetrain); | ||
} | ||
|
||
getController().enableContinuousInput(-180, 180); | ||
getController().setTolerance(3, 1); | ||
@Override | ||
public void execute() | ||
{ | ||
double currentAngle = mDrivetrain.getHeadingDegrees(); | ||
double output = mController.calculate(currentAngle, mGoal); | ||
mDrivetrain.arcadeDrive(0, output); | ||
} | ||
|
||
@Override | ||
public boolean isFinished() | ||
{ | ||
return m_controller.atSetpoint(); | ||
return mController.atSetpoint(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters