Skip to content

Commit

Permalink
Merged dev1 into master at v1.11, confirmed working
Browse files Browse the repository at this point in the history
  • Loading branch information
floogulinc committed Feb 16, 2014
2 parents b558e7b + 49cf64b commit e9bd54b
Show file tree
Hide file tree
Showing 6 changed files with 171 additions and 89 deletions.
26 changes: 26 additions & 0 deletions src/com/frc2879/bender/ButtonState.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.frc2879.bender;

/**
*
* @author floogulinc
*/
public class ButtonState{

public boolean State;

public ButtonState(boolean state) {
State = state;
}

public boolean getstate(){
return State;
}

public void setstate(boolean state){
State = state;
}




}
5 changes: 0 additions & 5 deletions src/com/frc2879/bender/DSOutput.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
/*
* 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;

import edu.wpi.first.wpilibj.DriverStationLCD;
Expand Down
5 changes: 0 additions & 5 deletions src/com/frc2879/bender/Gamepad.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
/*
* 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;

import edu.wpi.first.wpilibj.Joystick;
Expand Down
14 changes: 8 additions & 6 deletions src/com/frc2879/bender/GamepadXbox.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
/*
* 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;

/**
Expand Down Expand Up @@ -94,6 +88,14 @@ public boolean getButtonStateX() {
public boolean getButtonStateY() {
return getRawButton(Button_Y);
}


public boolean getButtonStateSTART() {
return getRawButton(Button_START);
}
public boolean getButtonStateBACK() {
return getRawButton(Button_BACK);
}

public boolean getButtonStateLeftBumper() {
return getRawButton(Button_LEFT_BUMPER);
Expand Down
206 changes: 137 additions & 69 deletions src/com/frc2879/bender/Robot.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@
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;

/**
*
*
* @author floogulinc
*
* Robot Code for FRC Team 2879 Orange Thunder
* TEST BOT - Bender
*/
/**
* The VM is configured to automatically run this class, and to call the
Expand All @@ -29,60 +31,105 @@ public class Robot extends SimpleRobot {
//Gamepad gp = new Gamepad(1);
GamepadXbox gp = new GamepadXbox(1);

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

// CONFIG VALUES
int DriveSensitivity = 100;
int TurnSensitivity = 100;
boolean SquaredInputs = true;

//boolean sawyerdrive = false;
int DriveMode = 0; // 0 is arcade, 1 is tank, 2 is sawyer

DSOutput dsout;

AxisCamera acam;

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

}

boolean pbuttonRB = false;
boolean pbuttonLB = false;
boolean pbuttonY = false;
boolean pbuttonX = false;
boolean pbuttonDPADL = false;
boolean pbuttonDPADR = false;
ButtonState pbuttonRB = new ButtonState(false);
ButtonState pbuttonLB = new ButtonState(false);
ButtonState pbuttonY = new ButtonState(false);
ButtonState pbuttonX = new ButtonState(false);
ButtonState pbuttonDPADL = new ButtonState(false);
ButtonState pbuttonDPADR = new ButtonState(false);
ButtonState pbuttonBACK = new ButtonState(false);

boolean bumpertoggle = false; //true is turn sensitivity, false for drive

public void saydrivesensitivity() {
public void saydrivesensitivity(int line) {
if (bumpertoggle) {
dsout.say(2, "DSensitivity: " + Integer.toString(DriveSensitivity));
dsout.say(line, "DSensitivity: " + Integer.toString(DriveSensitivity));
} else {
dsout.say(2, "*DSensitivity: " + Integer.toString(DriveSensitivity));
dsout.say(line, "*DSensitivity: " + Integer.toString(DriveSensitivity));
}

}

public void sayturnsensitivity() {
public void sayturnsensitivity(int line) {
if (bumpertoggle) {
dsout.say(3, "*TSensitivity: " + Integer.toString(TurnSensitivity));
dsout.say(line, "*TSensitivity: " + Integer.toString(TurnSensitivity));
} else {
dsout.say(3, "TSensitivity: " + Integer.toString(TurnSensitivity));
dsout.say(line, "TSensitivity: " + Integer.toString(TurnSensitivity));
}

}

public void saysquaredinputs() {
dsout.say(4, "Squared Inputs: " + SquaredInputs);
public void saysquaredinputs(int line) {
dsout.say(line, "Squared Inputs: " + SquaredInputs);
}

String[] drivemodename = {
"Arcade",
"Tank",
"Sawyer"};

public void saydrivemode(int line) {
dsout.say(line, "Mode: " + drivemodename[DriveMode]);
}

public void sayscreentele() {

dsout.say(1, fullname);
saydrivemode(2);
saysquaredinputs(3);
if (DriveMode == 1) {
dsout.clearLine(4);
dsout.clearLine(5);
} else {
saydrivesensitivity(4);
sayturnsensitivity(5);
}
}

public void switchdrivemode() {
switch (DriveMode) {
case 0:
DriveMode = 1;
break;
case 1:
DriveMode = 2;
break;
case 2:
DriveMode = 0;
break;
default:
DriveMode = 0;
break;
}
}

/**
Expand All @@ -95,7 +142,7 @@ public void autonomous() {
dsout.say(2, "Autonomous Mode");
Timer time = new Timer();
time.start();
while ( time.get() < 1 && isEnabled() && isAutonomous()) {
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);
Expand All @@ -106,81 +153,102 @@ public void autonomous() {
}
}

public boolean buttoncheck(boolean button, ButtonState pbutton) {
if (button) {
pbutton.setstate(true);
return false;
} else if (pbutton.getstate() && !button) {
pbutton.setstate(false);
return true;
} else {
pbutton.setstate(false);
return false;
}
}

/**
* This function is called once each time the robot enters operator control.
*/
public void operatorControl() {
drivetrain.setSafetyEnabled(true);
dsout.clearOutput();
dsout.say(1, fullname);
saydrivesensitivity();
sayturnsensitivity();
saysquaredinputs();
sayscreentele();
while (isOperatorControl() && isEnabled()) {

// Update joystick values:
double moveL = (gp.getLeftY() * ((double) (DriveSensitivity) / 100));
double spinL = (gp.getLeftX() * ((double) (TurnSensitivity) / 100));

if (gp.getButtonStateRightBumper()) {
pbuttonRB = true;
} else if (pbuttonRB && !gp.getButtonStateRightBumper()) {
if (bumpertoggle) {
TurnSensitivity = (TurnSensitivity) + (10);
sayturnsensitivity();
} else {
DriveSensitivity = (DriveSensitivity) + (10);
saydrivesensitivity();
}
pbuttonRB = false;
double move = 0;
double spin = 0;

double tankleft = 0;
double tankright = 0;

if (DriveMode == 0) {
move = (gp.getLeftY() * ((double) (DriveSensitivity) / 100));
spin = (gp.getLeftX() * ((double) (TurnSensitivity) / 100));
} else if (DriveMode == 2) {
move = (gp.getLeftY() * ((double) (DriveSensitivity) / 100));
spin = (gp.getRightX() * ((double) (TurnSensitivity) / 100));
} else if (DriveMode == 1) {
tankleft = gp.getLeftY();
tankright = gp.getRightY();
}

if (gp.getButtonStateLeftBumper()) {
pbuttonLB = true;
} else if (pbuttonLB && !gp.getButtonStateLeftBumper()) {
if (bumpertoggle) {
TurnSensitivity = (TurnSensitivity) - (10);
sayturnsensitivity();
} else {
DriveSensitivity = (DriveSensitivity) - (10);
saydrivesensitivity();
if (DriveMode != 1) {
if (buttoncheck(gp.getButtonStateRightBumper(), pbuttonRB)) {
if (bumpertoggle) {
TurnSensitivity = (TurnSensitivity) + (10);
sayscreentele();
} else {
DriveSensitivity = (DriveSensitivity) + (10);
sayscreentele();
}
}
pbuttonLB = false;
}

if (gp.getButtonStateY()) {
pbuttonY = true;
} else if (pbuttonY && !gp.getButtonStateY()) {
bumpertoggle = !bumpertoggle;
saydrivesensitivity();
sayturnsensitivity();
pbuttonY = false;
if (buttoncheck(gp.getButtonStateLeftBumper(), pbuttonLB)) {
if (bumpertoggle) {
TurnSensitivity = (TurnSensitivity) - (10);
sayscreentele();
} else {
DriveSensitivity = (DriveSensitivity) - (10);
sayscreentele();
}
}

if (buttoncheck(gp.getButtonStateY(), pbuttonY)) {
bumpertoggle = !bumpertoggle;
sayscreentele();
}
}

if (gp.getButtonStateX()) {
pbuttonX = true;
} else if (pbuttonX && !gp.getButtonStateX()) {
if (buttoncheck(gp.getButtonStateX(), pbuttonX)) {
SquaredInputs = !SquaredInputs;
saysquaredinputs();
pbuttonX = false;
sayscreentele();
}

if (buttoncheck(gp.getButtonStateBACK(), pbuttonBACK)) {
switchdrivemode();
sayscreentele();
}

// Drive da robot:
drivetrain.arcadeDrive(moveL, spinL, SquaredInputs);
if (DriveMode == 1) {
drivetrain.tankDrive(tankleft, tankright, SquaredInputs);
} else {
drivetrain.arcadeDrive(move, spin, SquaredInputs);
}

Timer.delay(0.005);
}

dsout.clearOutput();
}
protected void disabled(){
if(isDisabled()){

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
4 changes: 0 additions & 4 deletions src/com/frc2879/bender/XboxController.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.frc2879.bender;

import edu.wpi.first.wpilibj.DriverStation;
Expand Down

0 comments on commit e9bd54b

Please sign in to comment.