Skip to content

Commit

Permalink
Merged dev1 into master at v1.08, confirmed working
Browse files Browse the repository at this point in the history
  • Loading branch information
floogulinc committed Feb 4, 2014
2 parents 26cb054 + 98a005a commit b558e7b
Show file tree
Hide file tree
Showing 4 changed files with 539 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
.Trashes
ehthumbs.db
Thumbs.db
__MACOSX

# NetBeans specific #
nbproject/private/
Expand Down
134 changes: 134 additions & 0 deletions src/com/frc2879/bender/GamepadXbox.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/

package com.frc2879.bender;

/**
*
* @author floogulinc
*/
public class GamepadXbox extends XboxController{

public GamepadXbox(int port) {
super(port);
}

// Defining Joystick Mappings:
public final int Button_X = 3;
public final int Button_Y = 4;
public final int Button_A = 1;
public final int Button_B = 2;
public final int Button_START = 8;
public final int Button_BACK = 7;
public final int Button_RIGHT_BUMPER = 6;
//public final int Button_RIGHT_TRIGGER = 8;
public final int Button_LEFT_BUMPER = 5;
// public final int Button_LEFT_TRIGGER = 7;
public final int Button_LEFT_STICK = 11;
public final int Button_RIGHT_STICK = 12;

// Joystick axis(s)
public final int Stick_LEFT_Y = 2;
public final int Stick_LEFT_X = 1;
public final int Stick_RIGHT_X = 4;
public final int Stick_RIGHT_Y = 5;
public final int Axis_TRIGGER = 3;
public final int Axis_DPAD = 6;


/**
* Returns the X position of the left stick.
*/
public double getLeftX() {
return getRawAxis(Stick_LEFT_X);
}

/**
* Returns the X position of the right stick.
*/
public double getRightX() {
return getRawAxis(Stick_RIGHT_X);
}

/**
* Returns the Y position of the left stick.
*/
public double getLeftY() {
return getRawAxis(Stick_LEFT_Y);
}

/**
* Returns the Y position of the right stick.
*/
public double getRightY() {
return getRawAxis(Stick_RIGHT_Y);
}

/**
* Checks whether Button A is being pressed and returns true if it is.
*/
public boolean getButtonStateA() {
return getRawButton(Button_A);
}

/**
* Checks whether Button B is being pressed and returns true if it is.
*/
public boolean getButtonStateB() {
return getRawButton(Button_B);
}

/**
* Checks whether Button X is being pressed and returns true if it is.
*/
public boolean getButtonStateX() {
return getRawButton(Button_X);
}

/**
* Checks whether Button Y is being pressed and returns true if it is.
*/
public boolean getButtonStateY() {
return getRawButton(Button_Y);
}

public boolean getButtonStateLeftBumper() {
return getRawButton(Button_LEFT_BUMPER);
}

public boolean getButtonStateRightBumper() {
return getRawButton(Button_RIGHT_BUMPER);
}



/**
* Return the DPad axis positions.
*/
public double getDPadX() {
return getRawAxis(Axis_DPAD);
}


//Stuff from old logitech class


/**
* DPad Left and Right only WPILIB cannot access the vertical axis of the
* Logitech Game Controller Dpad
*/
// public boolean getDPadLeft() {
// double x = getDPadX();
// return (x < -0.5);
// }

//public boolean getDPadRight() {
// double x = getDPadX();
// return (x > 0.5);
// }


}
41 changes: 36 additions & 5 deletions src/com/frc2879/bender/Robot.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
/*----------------------------------------------------------------------------*/
package com.frc2879.bender;

import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.RobotDrive;
import edu.wpi.first.wpilibj.SimpleRobot;
import edu.wpi.first.wpilibj.Timer;
import edu.wpi.first.wpilibj.camera.AxisCamera;
import edu.wpi.first.wpilibj.camera.AxisCameraException;

/**
*
Expand All @@ -25,10 +26,11 @@
public class Robot extends SimpleRobot {

RobotDrive drivetrain = new RobotDrive(1, 2);
Gamepad gp = new Gamepad(1);
//Gamepad gp = new Gamepad(1);
GamepadXbox gp = new GamepadXbox(1);

public final String name = "Bender Bot";
public final String version = "v1.06";
public final String version = "v1.08";
public final String fullname = name + " " + version;

// CONFIG VALUES
Expand All @@ -37,11 +39,16 @@ public class Robot extends SimpleRobot {
boolean SquaredInputs = true;

DSOutput dsout;

AxisCamera acam;

//Called exactly 1 time when the competition starts.
protected void robotInit() {
dsout = new DSOutput();
System.out.println("Loading " + fullname);
dsout.say(1, "Loading...");
Timer.delay(0.5);
acam = AxisCamera.getInstance("10.28.79.11");
dsout.say(1, "Welcome to");
dsout.say(2, fullname);

Expand Down Expand Up @@ -82,7 +89,21 @@ public void saysquaredinputs() {
* This function is called once each time the robot enters autonomous mode.
*/
public void autonomous() {

if (isAutonomous()) {
dsout.clearOutput();
dsout.say(1, fullname);
dsout.say(2, "Autonomous Mode");
Timer time = new Timer();
time.start();
while ( time.get() < 1 && isEnabled() && isAutonomous()) {
drivetrain.drive(-0.3, 0); //Negative goes forward for some reason
dsout.say(3, "Time: " + time.get());
Timer.delay(0.01);
}
time.stop();
dsout.say(3, "Time: " + time.get() + " DONE");
time.reset();
}
}

/**
Expand Down Expand Up @@ -147,9 +168,19 @@ public void operatorControl() {
// Drive da robot:
drivetrain.arcadeDrive(moveL, spinL, SquaredInputs);

Timer.delay(0.01);
Timer.delay(0.005);
}

}

protected void disabled(){
if(isDisabled()){
dsout.clearOutput();
dsout.say(1, fullname);
dsout.say(2, "Robot Disabled");
}
}


/**
* This function is called once each time the robot enters test mode.
Expand Down
Loading

0 comments on commit b558e7b

Please sign in to comment.