Skip to content

Commit

Permalink
Task 1 Completion
Browse files Browse the repository at this point in the history
  • Loading branch information
Wardah Saeed committed Oct 17, 2024
1 parent c810b1a commit bac4936
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/main/java/frc/robot/commands/DriveCommands.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import edu.wpi.first.wpilibj2.command.InstantCommand;
import edu.wpi.first.wpilibj2.command.ParallelCommandGroup;
import edu.wpi.first.wpilibj2.command.SequentialCommandGroup;
import edu.wpi.first.wpilibj2.command.Subsystem;

/** A file that should contain all the commands that relate to the drivetrain. */
public class DriveCommands {
Expand Down Expand Up @@ -199,6 +200,23 @@ has a wheel placement diameter (163 mm) - width of the wheel (8 mm) = 155 mm

//TODO: Task 1-Rewrite TurnDegrees as a function that returns a functional command
//Code here:
public static Command turnDegrees(double degrees, double speed) {
double inchPerDegree = Math.PI * 6.102 / 360;
return new FunctionalCommand(
() -> {
RobotContainer.m_xrpDrivetrain.arcadeDrive(0, 0);
RobotContainer.m_xrpDrivetrain.resetEncoders();
},

() -> {RobotContainer.m_xrpDrivetrain.arcadeDrive(0, speed);},

interrupted -> RobotContainer.m_xrpDrivetrain.arcadeDrive(0, 0),
() -> {
return RobotContainer.m_xrpDrivetrain.getAverageTurningDistance() >= (inchPerDegree * degrees);
},
RobotContainer.m_xrpDrivetrain
);
}

//TODO: Task 3-Rewrite the following functions to use tank drive
//driveDistance or AltDriveDistance(choose 1)
Expand Down

0 comments on commit bac4936

Please sign in to comment.