mirror of
https://github.com/Team4388/2019-Hit-or-Miss.git
synced 2026-06-09 00:28:05 -06:00
safety fixes
WIP
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
plugins {
|
||||
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"
|
||||
@@ -50,7 +50,6 @@ dependencies {
|
||||
nativeZip wpi.deps.vendor.jni(wpi.platforms.roborio)
|
||||
nativeDesktopZip wpi.deps.vendor.jni(wpi.platforms.desktop)
|
||||
testCompile 'junit:junit:4.12'
|
||||
compile pathfinder()
|
||||
}
|
||||
|
||||
// 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
|
||||
{
|
||||
private static OI instance;
|
||||
@@ -49,7 +50,7 @@ public class OI
|
||||
CarriageEject.whenPressed(new IntakeSetSpeed(Carriage.CUBE_INTAKE_SPEED));
|
||||
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;
|
||||
climbUp.whenPressed(new InitiateClimber(true, speed));
|
||||
climbUp.whenReleased(new InitiateClimber(false, speed));
|
||||
@@ -72,10 +73,10 @@ public class OI
|
||||
CloseIntake.whenPressed(new IntakePosition(false));
|
||||
*/
|
||||
JoystickButton safteySwitch = new JoystickButton(m_operatorXbox.getJoyStick(), XboxController.START_BUTTON);
|
||||
safteySwitch.whenPressed(new startSaftey(true));
|
||||
safteySwitch.whenReleased(new startSaftey(false));
|
||||
safteySwitch.whenPressed(new setClimberSafety(true));
|
||||
safteySwitch.whenReleased(new setClimberSafety(false));
|
||||
|
||||
SmartDashboard.putData("PRE GAME!!!!", new PreGame());
|
||||
//SmartDashboard.putData("PRE GAME!!!!", new PreGame());
|
||||
|
||||
} catch (Exception e) {
|
||||
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
|
||||
{
|
||||
boolean climb;
|
||||
boolean saftey;
|
||||
float speed;
|
||||
|
||||
public InitiateClimber(boolean Climb, int speed) {
|
||||
public InitiateClimber(boolean Climb, float speed) {
|
||||
requires(Robot.climber);
|
||||
this.climb = Climb;
|
||||
this.speed = speed;
|
||||
}
|
||||
|
||||
public startSaftey(boolean saftey){
|
||||
requires(Robot.climber);
|
||||
this.saftey = saftey;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initialize() {
|
||||
}
|
||||
|
||||
@Override
|
||||
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);
|
||||
}
|
||||
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
|
||||
LimitSwitchSource limitSwitchSource;
|
||||
SensorCollection isPressed;
|
||||
boolean safteySwitch;
|
||||
boolean safetySwitch;
|
||||
|
||||
public Climber(){
|
||||
try{
|
||||
@@ -79,7 +79,8 @@ public class Climber extends Subsystem{
|
||||
}
|
||||
|
||||
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
|
||||
climberBack.set(0);
|
||||
climberFront.set(FRONT_FREQ * speed);
|
||||
@@ -89,14 +90,18 @@ public class Climber extends Subsystem{
|
||||
climberFront.set(FRONT_FREQ * speed);
|
||||
}
|
||||
}
|
||||
if (Climb == false) {
|
||||
if (Climb == false || safetySwitch == false) {
|
||||
climberBack.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
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user