Create Hatch Failsafe to Prevent Arm from Hitting the Hatch Intake When Using Preset Positions

This commit is contained in:
HFocus
2019-03-18 21:14:06 -06:00
parent 7589de6bd6
commit 03ee08c395
9 changed files with 42 additions and 6 deletions
@@ -8,6 +8,7 @@ import org.usfirst.frc4388.controller.IHandController;
import org.usfirst.frc4388.controller.XboxController; import org.usfirst.frc4388.controller.XboxController;
import org.usfirst.frc4388.robot.commands.*; import org.usfirst.frc4388.robot.commands.*;
import org.usfirst.frc4388.robot.commands.presets.SetPositionArmWrist; import org.usfirst.frc4388.robot.commands.presets.SetPositionArmWrist;
import org.usfirst.frc4388.robot.commands.presets.StowArm;
import org.usfirst.frc4388.robot.constants.LEDPatterns; import org.usfirst.frc4388.robot.constants.LEDPatterns;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
@@ -7,7 +7,9 @@
package org.usfirst.frc4388.robot.commands.presets; package org.usfirst.frc4388.robot.commands.presets;
import org.usfirst.frc4388.robot.Robot;
import org.usfirst.frc4388.robot.commands.ArmSetPositionMM; import org.usfirst.frc4388.robot.commands.ArmSetPositionMM;
import org.usfirst.frc4388.robot.commands.HatchFlip;
import org.usfirst.frc4388.robot.commands.WristSetPositionPID; import org.usfirst.frc4388.robot.commands.WristSetPositionPID;
import edu.wpi.first.wpilibj.command.CommandGroup; import edu.wpi.first.wpilibj.command.CommandGroup;
@@ -17,9 +19,11 @@ public class CargoHigh extends CommandGroup {
* Add your docs here. * Add your docs here.
*/ */
public CargoHigh() { public CargoHigh() {
boolean HatchFlipStatus = Robot.pnumatics.hatchIntakeState;
addSequential(new HatchFlip(false));
addParallel(new WristSetPositionPID(3243)); addParallel(new WristSetPositionPID(3243));
addSequential(new ArmSetPositionMM(4298)); addSequential(new ArmSetPositionMM(4298));
addSequential(new HatchFlip(HatchFlipStatus));
// Add Commands here: // Add Commands here:
// e.g. addSequential(new Command1()); // e.g. addSequential(new Command1());
@@ -7,7 +7,9 @@
package org.usfirst.frc4388.robot.commands.presets; package org.usfirst.frc4388.robot.commands.presets;
import org.usfirst.frc4388.robot.Robot;
import org.usfirst.frc4388.robot.commands.ArmSetPositionMM; import org.usfirst.frc4388.robot.commands.ArmSetPositionMM;
import org.usfirst.frc4388.robot.commands.HatchFlip;
import org.usfirst.frc4388.robot.commands.WristSetPositionPID; import org.usfirst.frc4388.robot.commands.WristSetPositionPID;
import edu.wpi.first.wpilibj.command.CommandGroup; import edu.wpi.first.wpilibj.command.CommandGroup;
@@ -17,9 +19,11 @@ public class CargoLow extends CommandGroup {
* Add your docs here. * Add your docs here.
*/ */
public CargoLow() { public CargoLow() {
boolean HatchFlipStatus = Robot.pnumatics.hatchIntakeState;
addSequential(new HatchFlip(false));
addParallel(new WristSetPositionPID(2500)); addParallel(new WristSetPositionPID(2500));
addSequential(new ArmSetPositionMM(1388)); addSequential(new ArmSetPositionMM(1388));
addSequential(new HatchFlip(HatchFlipStatus));
// Add Commands here: // Add Commands here:
// e.g. addSequential(new Command1()); // e.g. addSequential(new Command1());
@@ -7,7 +7,9 @@
package org.usfirst.frc4388.robot.commands.presets; package org.usfirst.frc4388.robot.commands.presets;
import org.usfirst.frc4388.robot.Robot;
import org.usfirst.frc4388.robot.commands.ArmSetPositionMM; import org.usfirst.frc4388.robot.commands.ArmSetPositionMM;
import org.usfirst.frc4388.robot.commands.HatchFlip;
import org.usfirst.frc4388.robot.commands.WristSetPositionPID; import org.usfirst.frc4388.robot.commands.WristSetPositionPID;
import edu.wpi.first.wpilibj.command.CommandGroup; import edu.wpi.first.wpilibj.command.CommandGroup;
@@ -17,9 +19,11 @@ public class CargoMid extends CommandGroup {
* Add your docs here. * Add your docs here.
*/ */
public CargoMid() { public CargoMid() {
boolean HatchFlipStatus = Robot.pnumatics.hatchIntakeState;
addSequential(new HatchFlip(false));
addParallel(new WristSetPositionPID(2830)); addParallel(new WristSetPositionPID(2830));
addSequential(new ArmSetPositionMM(2830)); addSequential(new ArmSetPositionMM(2830));
addSequential(new HatchFlip(HatchFlipStatus));
// Add Commands here: // Add Commands here:
// e.g. addSequential(new Command1()); // e.g. addSequential(new Command1());
@@ -7,7 +7,9 @@
package org.usfirst.frc4388.robot.commands.presets; package org.usfirst.frc4388.robot.commands.presets;
import org.usfirst.frc4388.robot.Robot;
import org.usfirst.frc4388.robot.commands.ArmSetPositionMM; import org.usfirst.frc4388.robot.commands.ArmSetPositionMM;
import org.usfirst.frc4388.robot.commands.HatchFlip;
import org.usfirst.frc4388.robot.commands.WristSetPositionPID; import org.usfirst.frc4388.robot.commands.WristSetPositionPID;
import edu.wpi.first.wpilibj.command.CommandGroup; import edu.wpi.first.wpilibj.command.CommandGroup;
@@ -17,9 +19,11 @@ public class HatchHigh extends CommandGroup {
* Add your docs here. * Add your docs here.
*/ */
public HatchHigh() { public HatchHigh() {
boolean HatchFlipStatus = Robot.pnumatics.hatchIntakeState;
addSequential(new HatchFlip(false));
addParallel(new WristSetPositionPID(1144)); addParallel(new WristSetPositionPID(1144));
addSequential(new ArmSetPositionMM(3605)); addSequential(new ArmSetPositionMM(3605));
addSequential(new HatchFlip(HatchFlipStatus));
// Add Commands here: // Add Commands here:
// e.g. addSequential(new Command1()); // e.g. addSequential(new Command1());
@@ -7,7 +7,9 @@
package org.usfirst.frc4388.robot.commands.presets; package org.usfirst.frc4388.robot.commands.presets;
import org.usfirst.frc4388.robot.Robot;
import org.usfirst.frc4388.robot.commands.ArmSetPositionMM; import org.usfirst.frc4388.robot.commands.ArmSetPositionMM;
import org.usfirst.frc4388.robot.commands.HatchFlip;
import org.usfirst.frc4388.robot.commands.WristSetPositionPID; import org.usfirst.frc4388.robot.commands.WristSetPositionPID;
import edu.wpi.first.wpilibj.command.CommandGroup; import edu.wpi.first.wpilibj.command.CommandGroup;
@@ -17,9 +19,11 @@ public class HatchLow extends CommandGroup {
* Add your docs here. * Add your docs here.
*/ */
public HatchLow() { public HatchLow() {
boolean HatchFlipStatus = Robot.pnumatics.hatchIntakeState;
addSequential(new HatchFlip(false));
addParallel(new WristSetPositionPID(450)); addParallel(new WristSetPositionPID(450));
addSequential(new ArmSetPositionMM(590)); addSequential(new ArmSetPositionMM(590));
addSequential(new HatchFlip(HatchFlipStatus));
// Add Commands here: // Add Commands here:
// e.g. addSequential(new Command1()); // e.g. addSequential(new Command1());
@@ -7,7 +7,9 @@
package org.usfirst.frc4388.robot.commands.presets; package org.usfirst.frc4388.robot.commands.presets;
import org.usfirst.frc4388.robot.Robot;
import org.usfirst.frc4388.robot.commands.ArmSetPositionMM; import org.usfirst.frc4388.robot.commands.ArmSetPositionMM;
import org.usfirst.frc4388.robot.commands.HatchFlip;
import org.usfirst.frc4388.robot.commands.WristSetPositionPID; import org.usfirst.frc4388.robot.commands.WristSetPositionPID;
import edu.wpi.first.wpilibj.command.CommandGroup; import edu.wpi.first.wpilibj.command.CommandGroup;
@@ -17,9 +19,11 @@ public class HatchMid extends CommandGroup {
* Add your docs here. * Add your docs here.
*/ */
public HatchMid() { public HatchMid() {
boolean HatchFlipStatus = Robot.pnumatics.hatchIntakeState;
addSequential(new HatchFlip(false));
addParallel(new WristSetPositionPID(750)); addParallel(new WristSetPositionPID(750));
addSequential(new ArmSetPositionMM(2000)); addSequential(new ArmSetPositionMM(2000));
addSequential(new HatchFlip(HatchFlipStatus));
// Add Commands here: // Add Commands here:
// e.g. addSequential(new Command1()); // e.g. addSequential(new Command1());
@@ -7,6 +7,7 @@
package org.usfirst.frc4388.robot.commands.presets; package org.usfirst.frc4388.robot.commands.presets;
import org.usfirst.frc4388.robot.Robot;
import org.usfirst.frc4388.robot.commands.ArmSetPositionMM; import org.usfirst.frc4388.robot.commands.ArmSetPositionMM;
import org.usfirst.frc4388.robot.commands.HatchFlip; import org.usfirst.frc4388.robot.commands.HatchFlip;
import org.usfirst.frc4388.robot.commands.WristPlacement; import org.usfirst.frc4388.robot.commands.WristPlacement;
@@ -19,11 +20,13 @@ public class StowArm extends CommandGroup {
/** /**
* Add your docs here. * Add your docs here.
*/ */
public StowArm() { public StowArm() {
addSequential(new HatchFlip(false)); addSequential(new HatchFlip(false));
addParallel(new WristPlacement(true)); addParallel(new WristPlacement(true));
addParallel(new WristSetPositionPID(110), 2); addParallel(new WristSetPositionPID(110), 2);
addSequential(new ArmSetPositionMM(10)); addSequential(new ArmSetPositionMM(10));
// Add Commands here: // Add Commands here:
// e.g. addSequential(new Command1()); // e.g. addSequential(new Command1());
// addSequential(new Command2()); // addSequential(new Command2());
@@ -14,6 +14,10 @@ public class Pneumatics extends Subsystem {
private DoubleSolenoid ballIntake; private DoubleSolenoid ballIntake;
private DoubleSolenoid wrist; private DoubleSolenoid wrist;
public boolean hatchIntakeState = false;
public boolean ballIntakeState = false;
public boolean speedShiftState = false;
public boolean wristState = false;
public Pneumatics() { public Pneumatics() {
try { try {
@@ -34,6 +38,7 @@ public class Pneumatics extends Subsystem {
if (state==false) { if (state==false) {
speedShift.set(DoubleSolenoid.Value.kReverse); speedShift.set(DoubleSolenoid.Value.kReverse);
} }
speedShiftState = state;
} }
public void setHatchIntakeState(boolean state) { public void setHatchIntakeState(boolean state) {
if (state==true) { if (state==true) {
@@ -42,6 +47,7 @@ public class Pneumatics extends Subsystem {
if (state==false) { if (state==false) {
hatchIntake.set(DoubleSolenoid.Value.kReverse); hatchIntake.set(DoubleSolenoid.Value.kReverse);
} }
hatchIntakeState = state;
} }
public void setBallIntake(boolean state) { public void setBallIntake(boolean state) {
if (state==true) { if (state==true) {
@@ -50,6 +56,7 @@ public class Pneumatics extends Subsystem {
if (state==false) { if (state==false) {
ballIntake.set(DoubleSolenoid.Value.kReverse); ballIntake.set(DoubleSolenoid.Value.kReverse);
} }
ballIntakeState = state;
} }
public void setWrist(boolean state) { public void setWrist(boolean state) {
if (state==true) { if (state==true) {
@@ -58,6 +65,7 @@ public class Pneumatics extends Subsystem {
if (state==false) { if (state==false) {
wrist.set(DoubleSolenoid.Value.kReverse); wrist.set(DoubleSolenoid.Value.kReverse);
} }
wristState = state;
} }
public void initDefaultCommand() { public void initDefaultCommand() {