safety fixes

WIP
This commit is contained in:
ryan123rudder
2019-02-12 20:35:09 -07:00
parent 288fef00d0
commit 40271c4d04
5 changed files with 64 additions and 18 deletions
+1 -2
View File
@@ -1,6 +1,6 @@
plugins { plugins {
id "java" id "java"
id "edu.wpi.first.GradleRIO" version "2019.1.1" id "edu.wpi.first.GradleRIO" version "2019.2.1"
} }
def ROBOT_MAIN_CLASS = "org.usfirst.frc4388.robot.Main" def ROBOT_MAIN_CLASS = "org.usfirst.frc4388.robot.Main"
@@ -50,7 +50,6 @@ dependencies {
nativeZip wpi.deps.vendor.jni(wpi.platforms.roborio) nativeZip wpi.deps.vendor.jni(wpi.platforms.roborio)
nativeDesktopZip wpi.deps.vendor.jni(wpi.platforms.desktop) nativeDesktopZip wpi.deps.vendor.jni(wpi.platforms.desktop)
testCompile 'junit:junit:4.12' testCompile 'junit:junit:4.12'
compile pathfinder()
} }
// Setting up my Jar File. In this case, adding all libraries into the main jar ('fat jar') // Setting up my Jar File. In this case, adding all libraries into the main jar ('fat jar')
@@ -26,6 +26,7 @@ import jaci.pathfinder.Pathfinder;
public class OI public class OI
{ {
private static OI instance; private static OI instance;
@@ -49,7 +50,7 @@ public class OI
CarriageEject.whenPressed(new IntakeSetSpeed(Carriage.CUBE_INTAKE_SPEED)); CarriageEject.whenPressed(new IntakeSetSpeed(Carriage.CUBE_INTAKE_SPEED));
CarriageEject.whenReleased(new IntakeSetSpeed(0.0)); CarriageEject.whenReleased(new IntakeSetSpeed(0.0));
*/ */
JoystickButton climbUp = new XBoxTriggerButton(m_operatorXbox, XboxController.RIGHT_TRIGGER); JoystickButton climbUp = new JoystickButton(m_operatorXbox.getJoyStick(), XboxController.RIGHT_TRIGGER_AXIS);
float speed = XboxController.RIGHT_TRIGGER_AXIS; float speed = XboxController.RIGHT_TRIGGER_AXIS;
climbUp.whenPressed(new InitiateClimber(true, speed)); climbUp.whenPressed(new InitiateClimber(true, speed));
climbUp.whenReleased(new InitiateClimber(false, speed)); climbUp.whenReleased(new InitiateClimber(false, speed));
@@ -72,10 +73,10 @@ public class OI
CloseIntake.whenPressed(new IntakePosition(false)); CloseIntake.whenPressed(new IntakePosition(false));
*/ */
JoystickButton safteySwitch = new JoystickButton(m_operatorXbox.getJoyStick(), XboxController.START_BUTTON); JoystickButton safteySwitch = new JoystickButton(m_operatorXbox.getJoyStick(), XboxController.START_BUTTON);
safteySwitch.whenPressed(new startSaftey(true)); safteySwitch.whenPressed(new setClimberSafety(true));
safteySwitch.whenReleased(new startSaftey(false)); safteySwitch.whenReleased(new setClimberSafety(false));
SmartDashboard.putData("PRE GAME!!!!", new PreGame()); //SmartDashboard.putData("PRE GAME!!!!", new PreGame());
} catch (Exception e) { } catch (Exception e) {
System.err.println("An error occurred in the OI constructor"); System.err.println("An error occurred in the OI constructor");
@@ -8,27 +8,21 @@ import edu.wpi.first.wpilibj.command.Command;
public class InitiateClimber extends Command public class InitiateClimber extends Command
{ {
boolean climb; boolean climb;
boolean saftey;
float speed; float speed;
public InitiateClimber(boolean Climb, int speed) { public InitiateClimber(boolean Climb, float speed) {
requires(Robot.climber); requires(Robot.climber);
this.climb = Climb; this.climb = Climb;
this.speed = speed; this.speed = speed;
} }
public startSaftey(boolean saftey){
requires(Robot.climber);
this.saftey = saftey;
}
@Override @Override
protected void initialize() { protected void initialize() {
} }
@Override @Override
protected void execute() { protected void execute() {
if(climb && saftey){ //If climb and saftey button are pressed if(climb){ //If climb and saftey button are pressed
Robot.climber.setClimbSpeed(climb, speed); Robot.climber.setClimbSpeed(climb, speed);
} }
else{ else{
@@ -0,0 +1,47 @@
package org.usfirst.frc4388.robot.commands;
import org.usfirst.frc4388.robot.Robot;
import org.usfirst.frc4388.robot.Constants;
import edu.wpi.first.wpilibj.command.Command;
public class setClimberSafety extends Command {
boolean safety;
public setClimberSafety(boolean safety) {
requires(Robot.climber);
this.safety = safety;
}
// Called just before this Command runs the first time
@Override
protected void initialize() {
}
// Called repeatedly when this Command is scheduled to run
@Override
protected void execute() {
if(safety){
Robot.climber.safetySwitch(true);
}
else{
Robot.climber.safetySwitch(false);
}
}
// Make this return true when this Command no longer needs to run execute()
@Override
protected boolean isFinished() {
return false;
}
// Called once after isFinished returns true
@Override
protected void end() {
}
// Called when another command which requires one or more of the same
// subsystems is scheduled to run
@Override
protected void interrupted() {
}
}
@@ -50,7 +50,7 @@ public class Climber extends Subsystem{
//Limit and Saftey vars //Limit and Saftey vars
LimitSwitchSource limitSwitchSource; LimitSwitchSource limitSwitchSource;
SensorCollection isPressed; SensorCollection isPressed;
boolean safteySwitch; boolean safetySwitch;
public Climber(){ public Climber(){
try{ try{
@@ -79,7 +79,8 @@ public class Climber extends Subsystem{
} }
public void setClimbSpeed(boolean Climb, float speed) { public void setClimbSpeed(boolean Climb, float speed) {
if (Climb) { if (Climb && safetySwitch) {
System.out.println("TriggerVal = " + speed);
if(isPressed.isFwdLimitSwitchClosed()){ //If back at max height if(isPressed.isFwdLimitSwitchClosed()){ //If back at max height
climberBack.set(0); climberBack.set(0);
climberFront.set(FRONT_FREQ * speed); climberFront.set(FRONT_FREQ * speed);
@@ -89,14 +90,18 @@ public class Climber extends Subsystem{
climberFront.set(FRONT_FREQ * speed); climberFront.set(FRONT_FREQ * speed);
} }
} }
if (Climb == false) { if (Climb == false || safetySwitch == false) {
climberBack.set(0); climberBack.set(0);
climberFront.set(0); climberFront.set(0);
} }
} }
public flipRatchet(){ public void safetySwitch(boolean safetySwitch){
this.safetySwitch = safetySwitch;
}
public void flipRatchet(){
//Code to flip out the front arms of the climber WIP //Code to flip out the front arms of the climber WIP
} }
} }