Skip to content

Commit

Permalink
Finished Climbing Mechanism
Browse files Browse the repository at this point in the history
  • Loading branch information
brookeblanton committed Mar 24, 2019
1 parent d63f20d commit 57aabae
Show file tree
Hide file tree
Showing 11 changed files with 130 additions and 122 deletions.
25 changes: 14 additions & 11 deletions src/main/java/frc/robot/OI.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@ public OI() {
}

private void initDriverControls(Joystick joystick) {
Button ClimberGo = new JoystickButton(joystick, ControllerMap.X);
Button ClimberStop = new JoystickButton(joystick, ControllerMap.B);
ClimberGo.whileHeld(new ClimberGo());
ClimberStop.whileHeld(new ClimberStop());

Button CameraSwitch = new JoystickButton(joystick, ControllerMap.BUMPER_LEFT);
CameraSwitch.whenPressed(new SwitchCamera());

Expand All @@ -45,17 +40,25 @@ private void initOperatorControls(Joystick joystick) {
HatchRetrieve.whenReleased(new RumbleDriver(0.5));
HatchScore.whileHeld(new HatchScore());

Button CargoUp = new JoystickButton(joystick, ControllerMap.BUMPER_LEFT);
Button CargoDown = new JoystickButton(joystick, ControllerMap.BUMPER_RIGHT);
Button CargoLevel1 = new JoystickButton(joystick, ControllerMap.Y);
CargoUp.whileHeld(new CargoUp());
CargoDown.whileHeld(new CargoDown());
CargoLevel1.whenPressed(new CargoArmLevel1AndRumble());
//Gerard and Iago are taking a long nap :(
// Button CargoUp = new JoystickButton(joystick, ControllerMap.BUMPER_LEFT);
// Button CargoDown = new JoystickButton(joystick, ControllerMap.BUMPER_RIGHT);
// Button CargoLevel1 = new JoystickButton(joystick, ControllerMap.Y);
// CargoUp.whileHeld(new CargoUp());
// CargoDown.whileHeld(new CargoDown());
// CargoLevel1.whenPressed(new CargoArmLevel1AndRumble());

Button CargoIntake = new JoystickButton(joystick, ControllerMap.LOGO_LEFT);
Button CargoDeliver = new JoystickButton(joystick, ControllerMap.LOGO_RIGHT);
CargoIntake.whenPressed(new CargoIntakeAndRumble());
CargoDeliver.whileHeld(new CargoDeliver());

Button FrontUp = new JoystickButton(joystick, ControllerMap.BUMPER_LEFT);
Button BackUp = new JoystickButton(joystick, ControllerMap.BUMPER_RIGHT);
FrontUp.whileHeld(new ClimberFrontUp());
FrontUp.whenReleased(new ClimberFrontDown());
BackUp.whileHeld(new ClimberBackUp());
BackUp.whenReleased(new ClimberBackDown());
}

//// CREATING BUTTONS
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/frc/robot/Robot.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ public class Robot extends TimedRobot {
public static Tank_Drive kopchassis = new Tank_Drive();
public static Hatch hatch;
public static Cargo cargo;
public static Climber climber;
public static ClimberFront climberF;
public static ClimberBack climberB;
public static Camera camera;
public static Limelight limelight;

Expand All @@ -42,7 +43,8 @@ public class Robot extends TimedRobot {
public void robotInit(){
preferences = Preferences.getInstance();
hatch = new Hatch();
climber = new Climber();
climberF = new ClimberFront();
climberB = new ClimberBack();
cargo = new Cargo();
camera = new Camera();
limelight = new Limelight();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
import edu.wpi.first.wpilibj.command.Command;
import frc.robot.Robot;

public class ClimberFrontGo extends Command {
public ClimberFrontGo() {
requires(Robot.climber);
public class ClimberBackDown extends Command {
public ClimberBackDown() {
requires(Robot.climberB);
}

// Called just before this Command runs the first time
Expand All @@ -23,6 +23,7 @@ protected void initialize() {
// Called repeatedly when this Command is scheduled to run
@Override
protected void execute() {
Robot.climberB.backDown();
}

// Make this return true when this Command no longer needs to run execute()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
import edu.wpi.first.wpilibj.command.Command;
import frc.robot.Robot;

public class ClimberBackGo extends Command {
public ClimberBackGo() {
requires(Robot.climber);
public class ClimberBackUp extends Command {
public ClimberBackUp() {
requires(Robot.climberB);
}

// Called just before this Command runs the first time
Expand All @@ -23,6 +23,7 @@ protected void initialize() {
// Called repeatedly when this Command is scheduled to run
@Override
protected void execute() {
Robot.climberB.backUp();
}

// Make this return true when this Command no longer needs to run execute()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
import edu.wpi.first.wpilibj.command.Command;
import frc.robot.Robot;

public class ClimberFrontStop extends Command {
public ClimberFrontStop() {
requires(Robot.climber);
public class ClimberFrontDown extends Command {
public ClimberFrontDown() {
requires(Robot.climberF);
}

// Called just before this Command runs the first time
Expand All @@ -23,6 +23,7 @@ protected void initialize() {
// Called repeatedly when this Command is scheduled to run
@Override
protected void execute() {
Robot.climberF.frontDown();
}

// Make this return true when this Command no longer needs to run execute()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
import edu.wpi.first.wpilibj.command.Command;
import frc.robot.Robot;

public class ClimberBackStop extends Command {
public ClimberBackStop() {
requires(Robot.climber);
public class ClimberFrontUp extends Command {
public ClimberFrontUp() {
requires(Robot.climberF);
}

// Called just before this Command runs the first time
Expand All @@ -23,6 +23,7 @@ protected void initialize() {
// Called repeatedly when this Command is scheduled to run
@Override
protected void execute() {
Robot.climberF.frontUp();
}

// Make this return true when this Command no longer needs to run execute()
Expand Down
45 changes: 0 additions & 45 deletions src/main/java/frc/robot/commands/ClimberGo.java

This file was deleted.

49 changes: 49 additions & 0 deletions src/main/java/frc/robot/commands/ClimberReset.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*----------------------------------------------------------------------------*/
/* 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.Command;
import frc.robot.Robot;

public class ClimberReset extends Command {
public ClimberReset() {
// Use requires() here to declare subsystem dependencies
// eg. requires(chassis);
requires(Robot.climberF);
requires(Robot.climberB);
}

// 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() {
Robot.climberF.frontDown();
Robot.climberB.backDown();
}

// 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() {
}
}
45 changes: 0 additions & 45 deletions src/main/java/frc/robot/commands/ClimberStop.java

This file was deleted.

38 changes: 38 additions & 0 deletions src/main/java/frc/robot/subsystems/ClimberBack.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*----------------------------------------------------------------------------*/
/* 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.subsystems;

import edu.wpi.first.wpilibj.Solenoid;
import edu.wpi.first.wpilibj.command.Subsystem;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
import frc.robot.RobotMap;

/**
* Add your docs here.
*/
public class ClimberBack extends Subsystem {
// Put methods for controlling this subsystem
// here. Call these from Commands.
Solenoid back = new Solenoid(RobotMap.climberbackSolenoid);

public void backUp() {
back.set(true);
SmartDashboard.putBoolean("Climber Back", true);
}

public void backDown() {
back.set(false);
SmartDashboard.putBoolean("Climber Back", false);
}

@Override
public void initDefaultCommand() {
// Set the default command for a subsystem here.
// setDefaultCommand(new MySpecialCommand());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,29 @@

import edu.wpi.first.wpilibj.Solenoid;
import edu.wpi.first.wpilibj.command.Subsystem;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
import frc.robot.RobotMap;
import frc.robot.commands.ClimberStop;
import frc.robot.commands.ClimberReset;

/**
* Add your docs here.
*/
public class Climber extends Subsystem {
public class ClimberFront extends Subsystem {

Solenoid front = new Solenoid(RobotMap.climberfrontSolenoid);
Solenoid back = new Solenoid(RobotMap.climberbackSolenoid);

public void pushup() {
public void frontUp() {
front.set(true);
SmartDashboard.putBoolean("Climber Front", true);
}

public void pushstop() {
public void frontDown() {
front.set(false);
SmartDashboard.putBoolean("Climber Front", false);
}

@Override
public void initDefaultCommand() {
setDefaultCommand(new ClimberStop());
setDefaultCommand(new ClimberReset());
}
}

0 comments on commit 57aabae

Please sign in to comment.