package org.usfirst.frc.team4272.robot2016; //import org.usfirst.frc.team4272.robotlib.PushButton; import org.usfirst.frc.team4272.robotlib.Xbox360Controller.Axis; import org.usfirst.frc.team4272.robotlib.Xbox360Controller.Button; import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; import edu.wpi.first.wpilibj.Joystick; public class Teleop { //private PushButton camButton = new PushButton(); public Teleop() { } private static double jsScale(Joystick j) { double y = -j.getY();/* +:forward; -:backward */ double z = -j.getZ();/* +:more-sensitive; -:less-sensitive */ return Math.copySign(Math.pow(Math.abs(y), 2.0-z), y); } private static double bound(double min, double v, double max) { return Math.min(Math.max(v, min), max); } private static double oneIf(boolean b) { return b ? 1 : 0; } public Control run(Control control, HwOI oi) { /* Drive */ control.lDrive1 = jsScale(oi.lStick); control.rDrive1 = jsScale(oi.rStick); control.lDrive2 = oi.lStick.getTrigger() ? control.lDrive1 : 0; control.rDrive2 = oi.rStick.getTrigger() ? control.rDrive1 : 0; control.arm = -oi.xbox.getAxis(Axis.LY); control.fBall = bound(-1, oi.xbox.getAxis(Axis.RTrigger) - oi.xbox.getAxis(Axis.LTrigger), 1); control.bBall = bound(-1, bound(-1, control.fBall, 0) + oneIf(oi.xbox.getButton(Button.A)) - oneIf(oi.xbox.getButton(Button.B)), 1); control.fBall = control.fBall < 0 ? 0.5*control.fBall : control.fBall; control.bBall = control.bBall < 0 ? 0.5*control.bBall : control.bBall; SmartDashboard.putNumber("fBall", control.fBall); SmartDashboard.putNumber("bBall", control.bBall); /* Take pictures */ /* 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; } }