summaryrefslogtreecommitdiff
path: root/src/org/usfirst/frc/team4272/robot2016/Teleop.java
blob: 41919fa6ccb0ab0d4a8e283dd8d63cc5b96fb8e7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
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);
	}

	public Control run(Control control, HwOI oi) {
		/* Drive */
		control.lDrive = jsScale(oi.lStick);
		control.rDrive = jsScale(oi.rStick);
		control.arm = -oi.xbox.getAxis(Axis.LY);
		control.fBall = oi.xbox.getAxis(Axis.RTrigger) - oi.xbox.getAxis(Axis.LTrigger);
		if (control.fBall < -0.1) {
			control.bBall = -1;
		} else {
			control.bBall = oi.xbox.getButton(Button.A) ? 1 : 0;
		}

		SmartDashboard.putNumber("fBall", control.fBall);

		/* 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;
	}
}