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); } }