summaryrefslogtreecommitdiff
path: root/src/org/usfirst/frc/team4272/robot2016/HwRobot.java
blob: 54265a17e119f287f44014bc1295d9ed6ab2d079 (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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
package org.usfirst.frc.team4272.robot2016;

import edu.wpi.first.wpilibj.networktables.NetworkTable;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;

import edu.wpi.first.wpilibj.DigitalInput;
import edu.wpi.first.wpilibj.Encoder;
import edu.wpi.first.wpilibj.PIDOutput;
import edu.wpi.first.wpilibj.PIDSourceType;
import edu.wpi.first.wpilibj.PowerDistributionPanel;
import edu.wpi.first.wpilibj.Talon;
import edu.wpi.first.wpilibj.Jaguar;
import edu.wpi.first.wpilibj.Solenoid;

import org.usfirst.frc.team4272.robotlib.PIDOutputSplitter;
import org.usfirst.frc.team4272.robotlib.PIDServo;

public class HwRobot {
	/* Relay == a Spike */
	/* PCM = Pneumatics Control Module */

	/* All of the numbered inputs are in the classes:
	 * - DIO: 0-9
	 * - Relay: 0-3
	 * - Analog In: 0-3
	 * - PWM: 0-9
	 * - PCM: 0-7 (the PCM is connected via CAN).
	 * - CAN
	 *
	 * For completeness, the roboRIO also has: i2c, RS-232, SPI,
	 * RSL, 2xUSB-A, an accelerometer, and an expansion port.
	 *
	 * And, for communication: USB-B and Ethernet.
	 */

	// naming convention: {side_letter}{Thing}{E|M (encoder/motor)}

	private final PIDOutput
	    rDriveM = new Talon(/*PWM*/0), /* PDP 2, 3 */
	    lDriveM = new Talon(/*PWM*/1), /* PDP 12, 13 */
	    climber = new Talon(/*PWM*/3), /* PDP 4 */
	    camRotate = new PIDServo(8),
	    camTilt = new PIDServo(9);
	public final Encoder   lDriveE = new Encoder(/*DIO*/0,/*DIO*/2, /*DIO*/1, /*reverse*/false);
	public final Encoder   rDriveE = new Encoder(/*DIO*/3,/*DIO*/5, /*DIO*/4, /*reverse*/true);
	public final PowerDistributionPanel PDP = new PowerDistributionPanel(); /* via CAN */

	public Solenoid PCM1 = new Solenoid(/*PCM*/ 4);
	public Solenoid PCM2 = new Solenoid(5);
	public Solenoid PCM3 = new Solenoid(6);
	public Solenoid PCM4 = new Solenoid(7);
	
	public HwRobot() {
		lDriveE.setDistancePerPulse(10.0/*feet*/ / 1865.75/*pulses*/);
		rDriveE.setDistancePerPulse(10.0/*feet*/ / 1865.75/*pulses*/);

		lDriveE.setPIDSourceType(PIDSourceType.kRate);
		rDriveE.setPIDSourceType(PIDSourceType.kRate);
		//PDP.initTable(NetworkTable.getTable("PDP"));
	}

	public void run(Control c) {
		lDriveM.pidWrite(c.lDrive);
		rDriveM.pidWrite(c.rDrive);
		climber.pidWrite(c.climber);
		camRotate.pidWrite(c.camRotate);
		camTilt.pidWrite(c.camTilt);

		PCM1.set(c.highGear);
		PCM2.set(!c.highGear);

		PCM3.set(c.PCM3);
		PCM4.set(c.PCM4);

		SmartDashboard.putNumber("lDriveE distance", lDriveE.getDistance());
		SmartDashboard.putNumber("lDriveE rate", lDriveE.getRate());
		SmartDashboard.putNumber("rDriveE distance", rDriveE.getDistance());
		SmartDashboard.putNumber("rDriveE rate", rDriveE.getRate());

		//PDP.updateTable();
		//SmartDashboard.putData("PDP", PDP);
	}
}