Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions Robot2019/src/main/java/frc/robot/OI.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ public class OI {
Joystick rightJoy;
Joystick manipulator;

JoystickButton leftSlowButton;
JoystickButton rightSlowButton;
JoystickButton leftSlowBtn;
JoystickButton rightSlowBtn;

JoystickButton cargoIn;
JoystickButton cargoOut;
JoystickButton cargoIntakeBtn;
JoystickButton cargoEjectBtn;

JoystickButton toggleCameraBtn;

Expand All @@ -43,15 +43,15 @@ public class OI {
leftJoy = new Joystick(0); // TODO: set ports to correct values
rightJoy = new Joystick(1); // TODO: set ports to correct values

leftSlowButton = new JoystickButton(leftJoy, 1);
leftSlowButton.whileHeld(new SlowDrive(SlowDrive.Side.LEFT));
rightSlowButton = new JoystickButton(rightJoy, 1);
rightSlowButton.whileHeld(new SlowDrive(SlowDrive.Side.RIGHT));
leftSlowBtn = new JoystickButton(leftJoy, 1);
leftSlowBtn.whileHeld(new SlowDrive(SlowDrive.Side.LEFT));
rightSlowBtn = new JoystickButton(rightJoy, 1);
rightSlowBtn.whileHeld(new SlowDrive(SlowDrive.Side.RIGHT));

cargoIn = new JoystickButton(manipulator, 0);
cargoIn.whenPressed(new IntakeCargo(cargo));
cargoOut = new JoystickButton(manipulator, 1);
cargoOut.whenPressed(new EjectCargo(cargo));
cargoIntakeBtn = new JoystickButton(manipulator, 0);
cargoIntakeBtn.whenPressed(new IntakeCargo(cargo));
cargoEjectBtn = new JoystickButton(manipulator, 1);
cargoEjectBtn.whenPressed(new EjectCargo(cargo));

toggleCameraBtn = new JoystickButton(leftJoy, 2);
toggleCameraBtn.whenPressed(new ToggleCamera(driveCamera, hatchCamera, cameraServer));
Expand Down
3 changes: 2 additions & 1 deletion Robot2019/src/main/java/frc/robot/Robot.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ public void robotInit() {
dt = new Drivetrain(RobotMap.leftMaster, RobotMap.leftSlave1, RobotMap.leftSlave2, RobotMap.rightMaster,
RobotMap.rightSlave1, RobotMap.rightSlave2, oi.leftJoy, oi.rightJoy, RobotMap.leftEnc, RobotMap.rightEnc,
RobotMap.gyro);
cargo = new Cargo(RobotMap.cargo, RobotMap.pdp);
cargo = new Cargo(RobotMap.cargoRoller, RobotMap.pdp);
oi = new OI(cargo, RobotMap.driveCamera, RobotMap.hatchCamera, RobotMap.cameraServer);

chooser.setDefaultOption("Default Auto", new TeleopDrive(dt));
SmartDashboard.putData("Auto Mode", chooser);
}
Expand Down
4 changes: 2 additions & 2 deletions Robot2019/src/main/java/frc/robot/RobotMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
public class RobotMap {
static WPI_TalonSRX leftMaster, rightMaster;
static WPI_VictorSPX leftSlave1, leftSlave2, rightSlave1, rightSlave2;
static VictorSP cargo;
static VictorSP cargoRoller;
static Encoder leftEnc, rightEnc;
static String driveMode;
static AHRS gyro;
Expand All @@ -51,7 +51,7 @@ public class RobotMap {
rightSlave2 = createConfiguredVictor(7);

// Initialize motors on the cargo mech
cargo = new VictorSP(4); // TODO: Set this to the actual correct values
cargoRoller = new VictorSP(0);

leftEnc = new Encoder(new DigitalInput(0), new DigitalInput(1)); // TODO: set ports to correct values
rightEnc = new Encoder(new DigitalInput(2), new DigitalInput(3)); // TODO: set ports to correct values
Expand Down
14 changes: 8 additions & 6 deletions Robot2019/src/main/java/frc/robot/commands/EjectCargo.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@
import frc.robot.subsystems.Cargo;

public class EjectCargo extends Command {
Timer tim;

final double ejectDuration = 0.5; // seconds

Timer timer;
Cargo cargo;

public EjectCargo(Cargo cargo) {
Expand All @@ -22,19 +25,18 @@ public EjectCargo(Cargo cargo) {

@Override
protected void initialize() {
tim.reset();
tim.start();
timer.reset();
timer.start();
}

@Override
protected void execute() {
cargo.runIntake(-1);
// TODO: Make sure this is correct direction
cargo.runEject();
}

@Override
protected boolean isFinished() {
return (tim.get() > 0.5);
return (timer.get() > ejectDuration);
}

@Override
Expand Down
14 changes: 7 additions & 7 deletions Robot2019/src/main/java/frc/robot/commands/IntakeCargo.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import frc.robot.subsystems.Cargo;

public class IntakeCargo extends Command {
Timer tim;
Timer timer;
Cargo cargo;
boolean overdraw;

Expand All @@ -24,27 +24,27 @@ public IntakeCargo(Cargo cargo) {

@Override
protected void initialize() {
tim.reset();
timer.reset();
}

@Override
protected void execute() {
cargo.runIntake(1.0);
cargo.runIntake();
if (cargo.hasCargo()) {
if (!overdraw) {
overdraw = true;
tim.start();
timer.start();
}
} else {
overdraw = false;
tim.stop();
tim.reset();
timer.stop();
timer.reset();
}
}

@Override
protected boolean isFinished() {
return (tim.get() > 0.5);
return (timer.get() > 0.5);
}

@Override
Expand Down
12 changes: 6 additions & 6 deletions Robot2019/src/main/java/frc/robot/subsystems/Cargo.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class Cargo extends Subsystem {
// here. Call these from Commands.

private VictorSP roller;
private final PowerDistributionPanel pdp;
private PowerDistributionPanel pdp;

public Cargo(VictorSP roller, PowerDistributionPanel pdp) {
this.roller = roller;
Expand All @@ -27,16 +27,16 @@ public void stopIntake() {
roller.stopMotor();
}

public void runIntake(double speed) {
roller.set(speed);
public void runIntake() {
roller.set(-1);
}

public void runOutake(double speed) {
roller.set(-speed);
public void runEject() {
roller.set(1);
}

public boolean hasCargo() {
return pdp.getCurrent(4) > 15;
return pdp.getCurrent(roller.getChannel()) > 15;
// TODO: set ports to actual cargo motor port
}

Expand Down