From 7080d2167ae2447ef18f3ba15d2bc39a880b4dc8 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Thu, 19 Mar 2015 13:33:53 -0400 Subject: stuff from Indy --- src/org/usfirst/frc/team4272/robot2015/Robot.java | 12 ++++++++++++ src/org/usfirst/frc/team4272/robot2015/Teleop.java | 16 +++++++++++++--- src/org/usfirst/frc/team4272/robotlib/PushButton.java | 13 +++++++++++++ .../usfirst/frc/team4272/robotlib/ToggleButton.java | 13 +++++++++++++ src/org/usfirst/frc/team4272/robotlib/Toggler.java | 13 ------------- sysProps.xml | Bin 6099 -> 6101 bytes 6 files changed, 51 insertions(+), 16 deletions(-) create mode 100644 src/org/usfirst/frc/team4272/robotlib/PushButton.java create mode 100644 src/org/usfirst/frc/team4272/robotlib/ToggleButton.java delete mode 100644 src/org/usfirst/frc/team4272/robotlib/Toggler.java diff --git a/src/org/usfirst/frc/team4272/robot2015/Robot.java b/src/org/usfirst/frc/team4272/robot2015/Robot.java index 22abd30..454f226 100644 --- a/src/org/usfirst/frc/team4272/robot2015/Robot.java +++ b/src/org/usfirst/frc/team4272/robot2015/Robot.java @@ -2,8 +2,10 @@ package org.usfirst.frc.team4272.robot2015; +import edu.wpi.first.wpilibj.DriverStation; import edu.wpi.first.wpilibj.IterativeRobot; import edu.wpi.first.wpilibj.Relay; +import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; import java.io.FileWriter; import java.io.IOException; @@ -18,6 +20,7 @@ import java.io.PrintWriter; public class Robot extends IterativeRobot { private final HwRobot robot = new HwRobot(); private final HwOI oi = new HwOI(); + private final DriverStation ds = DriverStation.getInstance(); private final Control control = new Control(); private PrintWriter log; @@ -36,6 +39,7 @@ public class Robot extends IterativeRobot { private void inLog() throws IOException { log = new PrintWriter(new FileWriter("/usr/local/frc/share/lukeshu.log", true)); log.println("\ntime" + +",ds:alliance,ds:voltage,ds:FMStime" +",c:lDrive,c:rDrive,c:winch,c:lIntake,c:rIntake,c:grab,c:push" +",i:lDrive.dist,i:lDrive.rate" +",i:rDrive.dist,i:rDrive.rate" @@ -43,7 +47,14 @@ public class Robot extends IterativeRobot { } private void doLog() throws Exception { + SmartDashboard.putNumber("dist", robot.rDriveE.getDistance()); + SmartDashboard.putNumber("raw", robot.rDriveE.getRaw()); + if (!ds.isFMSAttached()) + return; log.println(0 + +","+ds.getAlliance() + +","+ds.getBatteryVoltage() + +","+ds.getMatchTime() +","+control.lDrive +","+control.rDrive +","+control.winch @@ -84,6 +95,7 @@ public class Robot extends IterativeRobot { } public void teleopInit() { + robot.rDriveE.reset(); teleop = new Teleop(); } diff --git a/src/org/usfirst/frc/team4272/robot2015/Teleop.java b/src/org/usfirst/frc/team4272/robot2015/Teleop.java index 541099c..058589a 100644 --- a/src/org/usfirst/frc/team4272/robot2015/Teleop.java +++ b/src/org/usfirst/frc/team4272/robot2015/Teleop.java @@ -1,6 +1,7 @@ package org.usfirst.frc.team4272.robot2015; -import org.usfirst.frc.team4272.robotlib.Toggler; +import org.usfirst.frc.team4272.robotlib.ToggleButton; +import org.usfirst.frc.team4272.robotlib.PushButton; import org.usfirst.frc.team4272.robotlib.Xbox360Controller.Axis; import org.usfirst.frc.team4272.robotlib.Xbox360Controller.Button; @@ -8,8 +9,9 @@ import edu.wpi.first.wpilibj.Joystick; import edu.wpi.first.wpilibj.Relay; public class Teleop { - private Toggler grabButton = new Toggler(); - private Toggler pushButton = new Toggler(); + private ToggleButton grabButton = new ToggleButton(); + private ToggleButton pushButton = new ToggleButton(); + private PushButton camButton = new PushButton(); public Teleop() { } @@ -48,6 +50,14 @@ public class Teleop { control.grab = grabButton.update(oi.xbox.getButton(Button.A)); control.push = pushButton.update(oi.xbox.getButton(Button.B)); + + if (camButton.update(oi.xbox.getButton(Button.RT))) { + try { + ProcessBuilder pb = new ProcessBuilder("/home/lvuser/tweeterbot/bin/snapPhoto"); + pb.redirectErrorStream(true); + pb.start(); + } catch (Exception e) {}; + } return control; } diff --git a/src/org/usfirst/frc/team4272/robotlib/PushButton.java b/src/org/usfirst/frc/team4272/robotlib/PushButton.java new file mode 100644 index 0000000..d14c5d3 --- /dev/null +++ b/src/org/usfirst/frc/team4272/robotlib/PushButton.java @@ -0,0 +1,13 @@ +package org.usfirst.frc.team4272.robotlib; + +public class PushButton { + private boolean prev = false; + public boolean update(boolean next) { + boolean ret = false; + if (next && ! prev) { + ret = true; + } + prev = next; + return ret; + } +} diff --git a/src/org/usfirst/frc/team4272/robotlib/ToggleButton.java b/src/org/usfirst/frc/team4272/robotlib/ToggleButton.java new file mode 100644 index 0000000..1b70ad8 --- /dev/null +++ b/src/org/usfirst/frc/team4272/robotlib/ToggleButton.java @@ -0,0 +1,13 @@ +package org.usfirst.frc.team4272.robotlib; + +public class ToggleButton { + private boolean prev = false; + private boolean state = false; + public boolean update(boolean next) { + if (next && ! prev) { + state = !state; + } + prev = next; + return state; + } +} diff --git a/src/org/usfirst/frc/team4272/robotlib/Toggler.java b/src/org/usfirst/frc/team4272/robotlib/Toggler.java deleted file mode 100644 index 03fffec..0000000 --- a/src/org/usfirst/frc/team4272/robotlib/Toggler.java +++ /dev/null @@ -1,13 +0,0 @@ -package org.usfirst.frc.team4272.robotlib; - -public class Toggler { - private boolean prev = false; - private boolean state = false; - public boolean update(boolean next) { - if (next && ! prev) { - state = !state; - } - prev = next; - return state; - } -} diff --git a/sysProps.xml b/sysProps.xml index 157b03c..88c7046 100644 Binary files a/sysProps.xml and b/sysProps.xml differ -- cgit v1.2.3-54-g00ecf