-
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.
* Created baseline auto * fixed something * Updated the auto baseline * small fix * Update DriveTimeCommand.java * Fixed end command in auto drive * fixed driving time * fixed formatting * added sim support * Fixed implimentation * Add default option for baseline auto. * Switch to fieldRelative false --------- Co-authored-by: Luhan Wang <[email protected]> Co-authored-by: m10653 <[email protected]>
- Loading branch information
1 parent
5fc08f3
commit dd8e515
Showing
2 changed files
with
57 additions
and
3 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
52 changes: 52 additions & 0 deletions
52
src/main/java/org/jmhsrobotics/frc2024/subsystems/drive/commands/auto/DriveTimeCommand.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 |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package org.jmhsrobotics.frc2024.subsystems.drive.commands.auto; | ||
|
||
import org.jmhsrobotics.frc2024.subsystems.drive.DriveSubsystem; | ||
|
||
import edu.wpi.first.wpilibj.Timer; | ||
import edu.wpi.first.wpilibj2.command.Command; | ||
|
||
public class DriveTimeCommand extends Command { | ||
|
||
private DriveSubsystem drive; | ||
|
||
private double driveSeconds; | ||
private double drivePower; | ||
|
||
private Timer timer = new Timer(); | ||
|
||
public DriveTimeCommand(double seconds, double power, DriveSubsystem subsystem) { | ||
|
||
driveSeconds = seconds; | ||
drivePower = power; | ||
|
||
drive = subsystem; | ||
|
||
} | ||
|
||
public void initialize() { | ||
|
||
timer.start(); | ||
timer.reset(); | ||
|
||
} | ||
|
||
@Override | ||
public void execute() { | ||
|
||
this.drive.drive(drivePower, 0, 0, false, false); | ||
|
||
} | ||
|
||
@Override | ||
public boolean isFinished() { | ||
|
||
return timer.get() >= driveSeconds; | ||
|
||
} | ||
|
||
public void end() { | ||
this.drive.drive(0, 0, 0, false, false); | ||
|
||
} | ||
|
||
} |