Skip to content

Commit

Permalink
Task 3 Completion
Browse files Browse the repository at this point in the history
  • Loading branch information
PriyanshuK-ACL committed Oct 23, 2024
1 parent 593c01c commit cdecd30
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
20 changes: 16 additions & 4 deletions src/main/java/frc/robot/commands/DriveCommands.java
Original file line number Diff line number Diff line change
Expand Up @@ -234,10 +234,22 @@ public static Command TurnDegrees (double m_degrees, double m_speed){
//arcadeDriveCommand(rename as tankDriveCommand)
//Bonus(optional):TurnDegrees(either class or function, choose 1)
public static Command driveDistance1(double m_distance){
return driveDistance{m_distance};
}


XRPDrivetrain m_diffDrive=RobotContainer.m_xrpDrivetrain;

return new FunctionalCommand(() -> {
m_diffDrive.tankDrive(0,0);
m_diffDrive.resetEncoders();},
() ->{m_diffDrive.tankDrive(1,1);},
interrupt -> {m_diffDrive.tankDrive(0,0);},
() -> {return Math.abs(m_diffDrive.getAverageDistanceInch()) >=m_distance;},m_diffDrive);

}
public static Command tankDriveCommand1(Supplier<Double>m_leftMotor, Supplier<Double>m_RightMotor){
XRPDrivetrain m_diffDrive=RobotContainer.m_xrpDrivetrain;
return new InstandCommand(()-> {
m_diffDrive.tankDrive{m_leftMotor.get(), m_rightMotor.get()}, m_diffDrive
}
);}



Expand Down
2 changes: 1 addition & 1 deletion src/main/java/frc/robot/subsystems/XRPDrivetrain.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public void arcadeDrive(double xaxisSpeed, double zaxisRotate) {
//TODO:Task 2-Write a function that makes the robot take in a left wheel speed and a right wheel speed, and move at those speeds.
//HINT:This is called a tank drive, maybe there is a function that can easily allow for it?
//HINT:To see all the functions that the drivetrain has, type "m_diffDrive." without the quotes and look at the options generated by auto complete.
public void tankDriveCommand(double m_leftMotor, double m_rightMotor){
public void tankDrive(double m_leftMotor, double m_rightMotor){
m_diffDrive.tankDrive(m_leftMotor, m_rightMotor);

}
Expand Down

0 comments on commit cdecd30

Please sign in to comment.