forked from Phred7/FRC2018Pre-SeasonCodeRelease
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRobot.java
More file actions
164 lines (134 loc) · 5.72 KB
/
Copy pathRobot.java
File metadata and controls
164 lines (134 loc) · 5.72 KB
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
package org.usfirst.frc.team2906.robot;
import org.usfirst.frc.team2906.robot.commands.NoAuto;
import org.usfirst.frc.team2906.robot.commands.TestAuto;
import org.usfirst.frc.team2906.robot.subsystems.CameraPivotPOV;
import org.usfirst.frc.team2906.robot.subsystems.DriveTrain;
import org.usfirst.frc.team2906.robot.subsystems.NavX;
import org.usfirst.frc.team2906.robot.subsystems.Pneumatics;
import org.usfirst.frc.team2906.robot.subsystems.VisionLEDs;
import org.usfirst.frc.team2906.robot.commands.*;
import edu.wpi.first.wpilibj.IterativeRobot;
import edu.wpi.first.wpilibj.command.Command;
import edu.wpi.first.wpilibj.command.Scheduler;
import edu.wpi.first.wpilibj.livewindow.LiveWindow;
import edu.wpi.first.wpilibj.networktables.NetworkTable;
import edu.wpi.first.wpilibj.smartdashboard.SendableChooser;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
public class Robot extends IterativeRobot {
public static DriveTrain driveWC;
public static CameraPivotPOV camPiv;
public static NavX navX;
public static Pneumatics pneumatics;
//public static gAngleSPI gyro;
public static VisionLEDs leds;
public static OI oi;
Command autonomousCommand;
Command NoAuto;
Command TestAuto;
Command AutoDriveStraight;
Command AutoTurn90;
Command AutoTurn180;
Command AutoDriveTurnDrive;
Command Auto20InchTest;
Command Auto20InchTestReturn;
SendableChooser<Command> autoChooser = new SendableChooser<>();
final String noAuto = "No Auto";
final String testAuto = "Test Auto";
final String autoDriveStraight = "Drive Straight PID Auto";
final String autoDriveSquare = "Drive Square Auto";
final String autoTurn90 = "Turn 90 Degrees";
final String autoTurn180 = "Turn 180 Degrees";
final String autoDriveTurnDrive = "Drive Turn Drive";
final String auto20InchTest = "Drive 20 Inches For Testable Data";
final String auto20InchTestReturn = "Return To Start For Re-Test";
//String[] autoChooserList = { noAuto, testAuto, autoDriveStraight, autoDriveSquare, autoTurn90, autoTurn180, autoDriveTurnDrive, auto20InchTest, auto20InchTestReturn };
@Override
public void robotInit() {
RobotMap.init();
driveWC = new DriveTrain();
camPiv = new CameraPivotPOV();
navX = new NavX();
pneumatics = new Pneumatics();
//gyro = new gAngleSPI();
leds = new VisionLEDs();
oi = new OI();
NetworkTable table = NetworkTable.getTable("SmartDashboard");
table.putStringArray("Auto List", autoChooserList);
//autoChooser = new SendableChooser();
autoChooser.addDefault("Default, No Auto", new NoAuto());
autoChooser.addObject("Test Auto", new TestAuto());
autoChooser.addObject("Drive Straight PID Auto", new AutoDriveStraight());
autoChooser.addObject("Drive Square", new AutoDriveSquare());
autoChooser.addObject("Turn 90", new AutoTurn90());
autoChooser.addObject("Turn 180", new AutoTurn180());
autoChooser.addObject("Drive Turn Drive", new AutoDriveTurnDrive());
autoChooser.addObject("Drive 20 Inches For Testable Data", new Auto20InchTest());
autoChooser.addObject("Return To Start For Re-Test", new Auto20InchTestReturn());
SmartDashboard.putData("Auto mode", autoChooser);
SmartDashboard.putData("TurnTeleTest", new AutoTurn90());
NetworkTable table = NetworkTable.getTable("limelight");
double targetOffsetAngle_Horizontal = table.getNumber("tx", 0);
double targetOffsetAngle_Vertical = table.getNumber("ty", 0);
double targetArea = table.getNumber("ta", 0);
double targetSkew = table.getNumber("ts", 0);
}
@Override
public void disabledInit() {
Robot.driveWC.resetEncs();
Robot.navX.resetNavX();
}
@Override
public void disabledPeriodic() {
Scheduler.getInstance().run();
Robot.driveWC.resetEncs();
}
@Override
public void autonomousInit() {
//Robot.driveWC.resetEncs();
autonomousCommand = (Command) autoChooser.getSelected();
System.out.println("Auto selected: " + autoChooser.getSelected());
SmartDashboard.putNumber("navx angle", RobotMap.navX.getAngle());
if (autonomousCommand != null) {
autonomousCommand.start();
}
}
@Override
public void autonomousPeriodic() {
Scheduler.getInstance().run();
SmartDashboard.putNumber("Left Encoder", driveWC.getLHardEnc());
SmartDashboard.putNumber("Right Encoder", driveWC.getRHardEnc());
SmartDashboard.putNumber("Left Voltage", driveWC.getVoltageL());
SmartDashboard.putNumber("Right Voltage", driveWC.getVoltageR());
SmartDashboard.putNumber("navx angle", RobotMap.navX.getAngle());
SmartDashboard.putNumber("navx pitch", RobotMap.navX.getPitch());
SmartDashboard.putNumber("navx roll", RobotMap.navX.getRoll());
SmartDashboard.putNumber("navx yaw", RobotMap.navX.getYaw());
}
@Override
public void teleopInit() {
//Robot.driveWC.resetEncs();
if (autonomousCommand != null)
autonomousCommand.cancel();
}
@Override
public void teleopPeriodic() {
Scheduler.getInstance().run();
SmartDashboard.putNumber("Left Encoder", driveWC.getLHardEnc());
SmartDashboard.putNumber("Right Encoder", driveWC.getRHardEnc());
SmartDashboard.putNumber("Left Voltage", driveWC.getVoltageL());
SmartDashboard.putNumber("Right Voltage", driveWC.getVoltageR());
SmartDashboard.putNumber("navx angle", RobotMap.navX.getAngle());
SmartDashboard.putNumber("navx pitch", RobotMap.navX.getPitch());
SmartDashboard.putNumber("navx roll", RobotMap.navX.getRoll());
SmartDashboard.putNumber("navx yaw", RobotMap.navX.getYaw());
SmartDashboard.putBoolean("Collission", Robot.navX.collisionDetection());
SmartDashboard.putNumber("x velocity", Robot.navX.getXVelocity());
SmartDashboard.putNumber("y velocity", Robot.navX.getYVelocity());
SmartDashboard.putNumber("z velocity", Robot.navX.getZVelocity());
//SmartDashboard.putNumber("Gyro angle", RobotMap.gAngle);
}
@Override
public void testPeriodic() {
LiveWindow.run();
}
}