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

Commit 419c44d

Browse files
committed
I made it be able to drive
1 parent 9d57ca4 commit 419c44d

File tree

6 files changed

+41
-9
lines changed

6 files changed

+41
-9
lines changed

src/main/java/com/team766/robot/rookie_bot/AutonomousModes.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ public class AutonomousModes {
1515
// new AutonomousMode("DriveSlow", () -> new DriveStraight(0.4)),
1616
new AutonomousMode("TurnRight", () -> new TurnRight()),
1717
new AutonomousMode("DoNothing", () -> new DoNothing()),
18-
new AutonomousMode("DoNothing", () -> new DoNothing()),
1918
new AutonomousMode("DriveStraight", () -> new DriveStraight()),
20-
19+
new AutonomousMode("DriveinaSquare", () -> new DriveinaSquare()),
2120
};
2221
}

src/main/java/com/team766/robot/rookie_bot/OI.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,21 @@ public OI() {
2525
}
2626

2727
public void run(final Context context) {
28+
context.takeOwnership(Robot.drive);
2829
while (true) {
2930
// wait for driver station data (and refresh it using the WPILib APIs)
30-
context.waitFor(() -> RobotProvider.instance.hasNewDriverStationData());
31+
3132
RobotProvider.instance.refreshDriverStationData();
3233

3334
// Add driver controls here - make sure to take/release ownership
3435
// of mechanisms when appropriate.
36+
37+
Robot.drive.setArcadeDrivePower(joystick0.getAxis(1), joystick0.getAxis(3));
38+
context.waitFor(() -> RobotProvider.instance.hasNewDriverStationData());
39+
}
40+
41+
3542
}
43+
3644
}
37-
}
45+

src/main/java/com/team766/robot/rookie_bot/mechanisms/Drive.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,10 @@ public void setDrivePower(double leftPower, double rightPower){
1616
leftMotor.set(leftPower);
1717
rightMotor.set(rightPower);
1818
}
19+
public void setArcadeDrivePower(double forward, double turn) {
20+
double leftMotorPower = turn + forward;
21+
double rightMotorPower = -turn + forward;
22+
setDrivePower(leftMotorPower, rightMotorPower);
23+
}
24+
1925
}

src/main/java/com/team766/robot/rookie_bot/procedures/DriveStraight.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ public class DriveStraight extends Procedure {
99
public void run(final Context context) {
1010
context.takeOwnership(Robot.drive);
1111
Robot.drive.setDrivePower(0.5, 0.5);
12-
context.waitForSeconds(2);
13-
Robot.drive.setDrivePower(0,0);
12+
context.waitForSeconds(1);
13+
Robot.drive.setDrivePower(0, 0);
1414

1515
}
1616
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package com.team766.robot.rookie_bot.procedures;
2+
3+
import com.team766.framework.Context;
4+
import com.team766.framework.Procedure;
5+
6+
public class DriveinaSquare extends Procedure {
7+
public void run(Context context) {
8+
//This loop repeats 4 times
9+
for (int i = 0; i < 4; ++i) {
10+
//Drive along the side of the square
11+
new DriveStraight().run(context);
12+
13+
//Turn at corner
14+
new TurnRight().run(context);
15+
}
16+
}
17+
}
18+
19+

src/main/java/com/team766/robot/rookie_bot/procedures/TurnRight.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
import com.team766.framework.Procedure;
55
import com.team766.robot.rookie_bot.Robot;
66

7-
public class TurnRight extends Procedure{
7+
public class TurnRight extends Procedure {
88
public void run(Context context) {
99
context.takeOwnership(Robot.drive);
1010
Robot.drive.setDrivePower(0.25, -0.25);
11-
context.waitForSeconds(0);
12-
Robot.drive.setDrivePower(0,0);
11+
context.waitForSeconds(0.90);
12+
Robot.drive.setDrivePower(0, 0);
1313

1414
}
1515

0 commit comments

Comments
 (0)