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
8 changes: 4 additions & 4 deletions Robot2019/src/main/java/frc/robot/OI.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
import frc.robot.commands.ActuateClimberRails;
import frc.robot.commands.Climb;
import frc.robot.commands.EjectCargo;
import frc.robot.commands.EjectHatch;
import frc.robot.commands.ToggleHatchEject;
import frc.robot.commands.IntakeCargo;
import frc.robot.commands.IntakeHatch;
import frc.robot.commands.ToggleHatchIntake;
import frc.robot.commands.ManualClimb;
import frc.robot.commands.NormalDrive;
import frc.robot.commands.ResetWobble;
Expand Down Expand Up @@ -70,9 +70,9 @@ public class OI {
normDriveBtn.whileHeld(new NormalDrive());

hatchIntakeBtn = new JoystickButton(manipulator, Manip.X);
hatchIntakeBtn.whenPressed(new IntakeHatch(hp));
hatchIntakeBtn.whenPressed(new ToggleHatchIntake(hp));
hatchEjectBtn = new JoystickButton(manipulator, Manip.Y);
hatchEjectBtn.whenPressed(new EjectHatch(hp));
hatchEjectBtn.whenPressed(new ToggleHatchEject(hp));

cargoIntakeBtn = new JoystickButton(manipulator, Manip.A); // TODO: set ports to correct values
cargoIntakeBtn.whenPressed(new IntakeCargo(cargo));
Expand Down
67 changes: 0 additions & 67 deletions Robot2019/src/main/java/frc/robot/commands/EjectHatch.java

This file was deleted.

36 changes: 36 additions & 0 deletions Robot2019/src/main/java/frc/robot/commands/ToggleHatchEject.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/

package frc.robot.commands;

import edu.wpi.first.wpilibj.command.InstantCommand;
import frc.robot.subsystems.HatchPanel;

public class ToggleHatchEject extends InstantCommand {
private HatchPanel hp;

/**
* Toggles the eject pistons of the hatch panel mechanism, also closes the
* grabbing piston when ejecting
*/
public ToggleHatchEject(HatchPanel hp) {
requires(hp);
this.hp = hp;
}

@Override
protected void initialize() {
// If the pistons are currently extend them, retract them back, otherwise
// release and then eject
if (hp.state == HatchPanel.State.EJECTING) {
hp.reset();
} else {
hp.reset();
hp.eject();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
import edu.wpi.first.wpilibj.command.InstantCommand;
import frc.robot.subsystems.HatchPanel;

public class IntakeHatch extends InstantCommand {
public class ToggleHatchIntake extends InstantCommand {
private HatchPanel hp;

/**
* Toggles the grabbing piston of the hatch mechanism
*/
public IntakeHatch(HatchPanel hp) {
public ToggleHatchIntake(HatchPanel hp) {
requires(hp);
this.hp = hp;
}
Expand Down
3 changes: 3 additions & 0 deletions Robot2019/src/main/java/frc/robot/subsystems/HatchPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,21 @@ public void reset() {
grabPiston.set(DoubleSolenoid.Value.kReverse);
ejectPistons.set(DoubleSolenoid.Value.kReverse);
state = State.DEFAULT;
SmartDashboard.putString("Hatch Piston State", state.name());
}

public void grab() {
grabPiston.set(DoubleSolenoid.Value.kForward);
ejectPistons.set(DoubleSolenoid.Value.kReverse);
state = State.GRABBING;
SmartDashboard.putString("Hatch Piston State", state.name());
}

public void eject() {
grabPiston.set(DoubleSolenoid.Value.kReverse);
ejectPistons.set(DoubleSolenoid.Value.kForward);
state = State.EJECTING;
SmartDashboard.putString("Hatch Piston State", state.name());
}

@Override
Expand Down