Skip to content
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.

Commit

Permalink
I made it be able to drive
Browse files Browse the repository at this point in the history
  • Loading branch information
XavierCraw committed Oct 26, 2024
1 parent 9d57ca4 commit 419c44d
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ public class AutonomousModes {
// new AutonomousMode("DriveSlow", () -> new DriveStraight(0.4)),
new AutonomousMode("TurnRight", () -> new TurnRight()),
new AutonomousMode("DoNothing", () -> new DoNothing()),
new AutonomousMode("DoNothing", () -> new DoNothing()),
new AutonomousMode("DriveStraight", () -> new DriveStraight()),

new AutonomousMode("DriveinaSquare", () -> new DriveinaSquare()),
};
}
12 changes: 10 additions & 2 deletions src/main/java/com/team766/robot/rookie_bot/OI.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,21 @@ public OI() {
}

public void run(final Context context) {
context.takeOwnership(Robot.drive);
while (true) {
// wait for driver station data (and refresh it using the WPILib APIs)
context.waitFor(() -> RobotProvider.instance.hasNewDriverStationData());

RobotProvider.instance.refreshDriverStationData();

// Add driver controls here - make sure to take/release ownership
// of mechanisms when appropriate.

Robot.drive.setArcadeDrivePower(joystick0.getAxis(1), joystick0.getAxis(3));
context.waitFor(() -> RobotProvider.instance.hasNewDriverStationData());
}


}

}
}

Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,10 @@ public void setDrivePower(double leftPower, double rightPower){
leftMotor.set(leftPower);
rightMotor.set(rightPower);
}
public void setArcadeDrivePower(double forward, double turn) {
double leftMotorPower = turn + forward;
double rightMotorPower = -turn + forward;
setDrivePower(leftMotorPower, rightMotorPower);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ public class DriveStraight extends Procedure {
public void run(final Context context) {
context.takeOwnership(Robot.drive);
Robot.drive.setDrivePower(0.5, 0.5);
context.waitForSeconds(2);
Robot.drive.setDrivePower(0,0);
context.waitForSeconds(1);
Robot.drive.setDrivePower(0, 0);

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.team766.robot.rookie_bot.procedures;

import com.team766.framework.Context;
import com.team766.framework.Procedure;

public class DriveinaSquare extends Procedure {
public void run(Context context) {
//This loop repeats 4 times
for (int i = 0; i < 4; ++i) {
//Drive along the side of the square
new DriveStraight().run(context);

//Turn at corner
new TurnRight().run(context);
}
}
}


Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
import com.team766.framework.Procedure;
import com.team766.robot.rookie_bot.Robot;

public class TurnRight extends Procedure{
public class TurnRight extends Procedure {
public void run(Context context) {
context.takeOwnership(Robot.drive);
Robot.drive.setDrivePower(0.25, -0.25);
context.waitForSeconds(0);
Robot.drive.setDrivePower(0,0);
context.waitForSeconds(0.90);
Robot.drive.setDrivePower(0, 0);

}

Expand Down

0 comments on commit 419c44d

Please sign in to comment.