Skip to content

Commit

Permalink
Intake tutorial
Browse files Browse the repository at this point in the history
  • Loading branch information
rcahoon committed Feb 9, 2024
1 parent a1f92bb commit 9b282f4
Show file tree
Hide file tree
Showing 7 changed files with 86 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/main/java/com/team766/robot/AutonomousModes.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public class AutonomousModes {
// new AutonomousMode("DriveFast", () -> new DriveStraight(1.0)),
// new AutonomousMode("DriveSlow", () -> new DriveStraight(0.4)),

new AutonomousMode("CollectBalls", () -> new CollectBalls()),
new AutonomousMode("Launch", () -> new Launch()),
new AutonomousMode("DriveSquare", () -> new DriveSquare()),
new AutonomousMode("TurnRight", () -> new TurnRight()),
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/com/team766/robot/OI.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@ public void run(final Context context) {
if (joystick0.getButtonPressed(1)) {
context.startAsync(new Launch());
}

if (joystick1.getButtonPressed(2)) {
context.startAsync(new StartIntake());
}
if (joystick1.getButtonPressed(3)) {
context.startAsync(new StopIntake());
}
}
}
}
2 changes: 2 additions & 0 deletions src/main/java/com/team766/robot/Robot.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ public class Robot {
// Declare mechanisms here
public static Drive drive;
public static Launcher launcher;
public static Intake intake;

public static void robotInit() {
// Initialize mechanisms here
drive = new Drive();
launcher = new Launcher();
intake = new Intake();
}
}
28 changes: 28 additions & 0 deletions src/main/java/com/team766/robot/mechanisms/Intake.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.team766.robot.mechanisms;

import com.team766.framework.Mechanism;
import com.team766.hal.RobotProvider;
import com.team766.hal.SolenoidController;
import com.team766.hal.MotorController;

public class Intake extends Mechanism {
private SolenoidController m_extend;
private MotorController m_wheels;

public Intake() {
m_extend = RobotProvider.instance.getSolenoid("intakeArm");
m_wheels = RobotProvider.instance.getMotor("intakeWheels");
}

public void setExtended(boolean extended) {
checkContextOwnership();

m_extend.set(extended);
}

public void setWheelPower(double power) {
checkContextOwnership();

m_wheels.set(power);
}
}
16 changes: 16 additions & 0 deletions src/main/java/com/team766/robot/procedures/CollectBalls.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.team766.robot.procedures;

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

public class CollectBalls extends Procedure {

public void run(Context context) {
new StartIntake().run(context);

new DriveStraight().run(context);

new StopIntake().run(context);
}

}
16 changes: 16 additions & 0 deletions src/main/java/com/team766/robot/procedures/StartIntake.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.team766.robot.procedures;

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

public class StartIntake extends Procedure {

public void run(Context context) {
context.takeOwnership(Robot.intake);

Robot.intake.setWheelPower(1.0);
Robot.intake.setExtended(true);
}

}
16 changes: 16 additions & 0 deletions src/main/java/com/team766/robot/procedures/StopIntake.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.team766.robot.procedures;

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

public class StopIntake extends Procedure {

public void run(Context context) {
context.takeOwnership(Robot.intake);

Robot.intake.setWheelPower(0.0);
Robot.intake.setExtended(false);
}

}

0 comments on commit 9b282f4

Please sign in to comment.