Skip to content

Commit

Permalink
Merge pull request #2 from NicoletFEAR/Game-Mech
Browse files Browse the repository at this point in the history
Game mech
  • Loading branch information
Noah-Kennedy committed Feb 10, 2016
2 parents acc0ef3 + 7497bf8 commit 83a568b
Show file tree
Hide file tree
Showing 12 changed files with 374 additions and 37 deletions.
51 changes: 46 additions & 5 deletions Stronghold2016/src/com/nicoletfear/Stronghold2016/OI.java
Original file line number Diff line number Diff line change
@@ -1,39 +1,80 @@
package com.nicoletfear.Stronghold2016;

import edu.wpi.first.wpilibj.DigitalInput;
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.buttons.Button;
import edu.wpi.first.wpilibj.buttons.JoystickButton;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;


import com.nicoletfear.Stronghold2016.commands.ExampleCommand;
import com.nicoletfear.Stronghold2016.commands.ArmDown;
import com.nicoletfear.Stronghold2016.commands.ArmUp;
import com.nicoletfear.Stronghold2016.commands.IntakeCommand;
import com.nicoletfear.Stronghold2016.commands.PassCommand;
import com.nicoletfear.Stronghold2016.commands.ShootCommand;

/**
* This class is the glue that binds the controls on the physical operator
* interface to the commands and command groups that allow control of the robot.
*/
public class OI {

//instantiate buttons, sensors and joysticks here
public Joystick left0;
public Joystick right1;

public static Joystick gameMech;
public static Button aButton;
public static Button bButton;
public static Button yButton;
public static Button rightBumper;
public static Button leftBumper;
public static DigitalInput limitSwitchTop;
public static DigitalInput limitSwitchBottom;


public OI() {
// BEGIN AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=CONSTRUCTORS
//construct buttons and joysticks here here
gameMech = new Joystick(2);
aButton = new JoystickButton(gameMech , com.nicoletfear.Stronghold2016.xbox.Buttons.A);
bButton = new JoystickButton(gameMech , com.nicoletfear.Stronghold2016.xbox.Buttons.B);
yButton = new JoystickButton(gameMech , com.nicoletfear.Stronghold2016.xbox.Buttons.Y);
rightBumper = new JoystickButton(gameMech , com.nicoletfear.Stronghold2016.xbox.Buttons.RightBump);
leftBumper = new JoystickButton(gameMech , com.nicoletfear.Stronghold2016.xbox.Buttons.LeftBump);

//construct sensors here
limitSwitchTop = new DigitalInput(RobotMap.limitSwitchTopPort);
limitSwitchBottom = new DigitalInput(RobotMap.limitSwitchBottomPort);


//tie buttons to commands here
aButton.whileHeld(new IntakeCommand());
bButton.whileHeld(new PassCommand());
yButton.whileHeld(new ShootCommand());
rightBumper.whileHeld(new ArmUp());
leftBumper.whileHeld(new ArmDown());
//runs commands when buttons pressed

right1 = new Joystick(1);

left0 = new Joystick(0);


//Button A = new JoystickButton(gameMech, 1);
//1 is button A on xbox



// END AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=CONSTRUCTORS
}
public static void init(){

}
public Joystick getLeft() {
return left0;
}

public Joystick getRight() {
return right1;
}

//// CREATING BUTTONS
// One type of button is a joystick button which is any button on a joystick.
// You create one by telling it which joystick it's on and which button
Expand Down
19 changes: 13 additions & 6 deletions Stronghold2016/src/com/nicoletfear/Stronghold2016/Robot.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@

package com.nicoletfear.Stronghold2016;

import edu.wpi.first.wpilibj.DigitalInput;
import edu.wpi.first.wpilibj.IterativeRobot;
import edu.wpi.first.wpilibj.command.Command;
import edu.wpi.first.wpilibj.command.Scheduler;
import edu.wpi.first.wpilibj.livewindow.LiveWindow;
import com.nicoletfear.Stronghold2016.commands.ExampleCommand;
import com.nicoletfear.Stronghold2016.subsystems.Arm;
import com.nicoletfear.Stronghold2016.subsystems.DriveTrain;
import com.nicoletfear.Stronghold2016.subsystems.ExampleSubsystem;
import com.nicoletfear.Stronghold2016.subsystems.Intake;

import edu.wpi.first.wpilibj.smartdashboard.SendableChooser;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;

Expand All @@ -20,9 +22,15 @@
*/
public class Robot extends IterativeRobot {

public static final ExampleSubsystem exampleSubsystem = new ExampleSubsystem();
public static final DriveTrain driveTrain = new DriveTrain();
public static final Intake intake = new Intake();
public static final Arm arm = new Arm();
public static OI oi;

//always do this
//dont ask why
public String Skynet = "Sentient";
public Boolean SkynetEnabled = true;

Command autonomousCommand;
SendableChooser chooser;
Expand All @@ -31,14 +39,14 @@ public class Robot extends IterativeRobot {
* This function is run when the robot is first started up and should be
* used for any initialization code.
*/

public void robotInit() {
oi = new OI();
chooser = new SendableChooser();
chooser.addDefault("Default Auto", new ExampleCommand());
// chooser.addObject("My Auto", new MyAutoCommand());
SmartDashboard.putData("Auto mode", chooser);

}

/**
* This function is called once each time the robot enters Disabled mode.
* You can use it to reset any subsystem information you want to clear when
Expand All @@ -63,7 +71,6 @@ public void disabledPeriodic() {
*/
public void autonomousInit() {
autonomousCommand = (Command) chooser.getSelected();

/* String autoSelected = SmartDashboard.getString("Auto Selector", "Default");
switch(autoSelected) {
case "My Auto":
Expand Down
25 changes: 22 additions & 3 deletions Stronghold2016/src/com/nicoletfear/Stronghold2016/RobotMap.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
package com.nicoletfear.Stronghold2016;

import edu.wpi.first.wpilibj.DigitalInput;

/**
* The RobotMap is a mapping from the ports sensors and actuators are wired into
* to a variable name. This provides flexibility changing wiring, makes checking
Expand All @@ -10,11 +13,27 @@ public class RobotMap {
//CANTalon ports
// use instead of magic numbers
//will be updated once we have a finished bot

public static final int backLeftPort = 0;
public static final int backRightPort = 1;
public static final int frontLeftPort = 3;
public static final int frontRightPort = 2;
public static final int backRightPort = 7;
public static final int frontLeftPort = 42;
public static final int frontRightPort = 12;
public static final int intakeMotorPort = 15;
public static final int positionMotorPort = 1;
public static final int limitSwitchTopPort = 8;
public static final int limitSwitchBottomPort = 7;

public static final double armSpeed = .2;
public static final double intakeSpeed = -1;
public static final double passSpeed = .5;
public static final double shootSpeed = 1;




//I think that our error may be in here



// For example to map the left and right motors, you could define the
// following variables to use with your drivetrain subsystem.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@

package com.nicoletfear.Stronghold2016.commands;

import edu.wpi.first.wpilibj.command.Command;

import com.nicoletfear.Stronghold2016.Robot;

/**
*Command that lowers arm. It stops when the user releases the
*lower limit switch or releases the button
*/
public class ArmDown extends Command {

public ArmDown() {
// Use requires() here to declare subsystem dependencies
requires(Robot.arm);
}

// Called just before this Command runs the first time
protected void initialize() {
Robot.arm.armDown();
}

// Called repeatedly when this Command is scheduled to run
protected void execute() {

}

// Make this return true when this Command no longer needs to run execute()
protected boolean isFinished() {
return Robot.arm.downLimitSwitchPressed();
}

// Called once after isFinished returns true
protected void end() {
Robot.arm.armStop();
}

// Called when another command which requires one or more of the same
// subsystems is scheduled to run
protected void interrupted() {
end();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@

package com.nicoletfear.Stronghold2016.commands;

import edu.wpi.first.wpilibj.command.Command;

import com.nicoletfear.Stronghold2016.Robot;

/**
*Command that raises arm. It stops when the user releases the
*upper limit switch or releases the button
*/
public class ArmUp extends Command {

public ArmUp() {
// Use requires() here to declare subsystem dependencies
requires(Robot.arm);
}

// Called just before this Command runs the first time
protected void initialize() {
Robot.arm.armUp();
}

// Called repeatedly when this Command is scheduled to run
protected void execute() {
}

// Make this return true when this Command no longer needs to run execute()
protected boolean isFinished() {
return Robot.arm.upLimitSwitchPressed();
}

// Called once after isFinished returns true
protected void end() {
Robot.arm.armStop();
}

// Called when another command which requires one or more of the same
// subsystems is scheduled to run
protected void interrupted() {
end();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,18 @@
import com.nicoletfear.Stronghold2016.Robot;

/**
*
*this command intakes the ball at maximum speed
*/
public class ExampleCommand extends Command {
public class IntakeCommand extends Command {

public ExampleCommand() {
public IntakeCommand() {
// Use requires() here to declare subsystem dependencies
requires(Robot.exampleSubsystem);
requires(Robot.intake);
}

// Called just before this Command runs the first time
protected void initialize() {
Robot.intake.intake();
}

// Called repeatedly when this Command is scheduled to run
Expand All @@ -30,10 +31,12 @@ protected boolean isFinished() {

// Called once after isFinished returns true
protected void end() {
Robot.intake.stopIntake();
}

// Called when another command which requires one or more of the same
// subsystems is scheduled to run
protected void interrupted() {
end();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@

package com.nicoletfear.Stronghold2016.commands;

import edu.wpi.first.wpilibj.command.Command;

import com.nicoletfear.Stronghold2016.Robot;
import com.nicoletfear.Stronghold2016.xbox.Buttons;

/**
*this command passes the ball
*/
public class PassCommand extends Command {

public PassCommand() {
// Use requires() here to declare subsystem dependencies
requires(Robot.intake);
}

// Called just before this Command runs the first time
protected void initialize() {
Robot.intake.pass();
}

// Called repeatedly when this Command is scheduled to run
protected void execute() {

//when A is pressed, starts passing
//when A is released, stops intake from spinning
}

// Make this return true when this Command no longer needs to run execute()
protected boolean isFinished() {
return false;
}

// Called once after isFinished returns true
protected void end() {
Robot.intake.stopIntake();
}

// Called when another command which requires one or more of the same
// subsystems is scheduled to run
protected void interrupted() {
end();
}
}
Loading

0 comments on commit 83a568b

Please sign in to comment.