1
|
|
|
|
2
|
|
|
package org.usfirst.frc.team3695.robot;
|
3
|
|
|
|
4
|
|
|
import edu.wpi.first.wpilibj.DriverStation;
|
5
|
|
|
import edu.wpi.first.wpilibj.I2C;
|
6
|
|
|
import edu.wpi.first.wpilibj.IterativeRobot;
|
7
|
|
|
import edu.wpi.first.wpilibj.command.Scheduler;
|
8
|
|
|
import edu.wpi.first.wpilibj.livewindow.LiveWindow;
|
9
|
|
|
import edu.wpi.first.wpilibj.smartdashboard.SendableChooser;
|
10
|
|
|
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
|
11
|
|
|
|
12
|
|
|
import org.usfirst.frc.team3695.robot.auto.CommandGroupAuto;
|
13
|
|
|
import org.usfirst.frc.team3695.robot.enumeration.Autonomous;
|
14
|
|
|
import org.usfirst.frc.team3695.robot.enumeration.Position;
|
15
|
|
|
import org.usfirst.frc.team3695.robot.enumeration.Drivetrain;
|
16
|
|
|
import org.usfirst.frc.team3695.robot.enumeration.Goal;
|
17
|
|
|
import org.usfirst.frc.team3695.robot.subsystems.*;
|
18
|
|
|
|
19
|
|
|
/** the magic place where everything happens (where the sequence of events is controlled, top of the hierarchy) */
|
20
|
|
|
public class Robot extends IterativeRobot {
|
21
|
|
|
|
22
|
|
|
/// choosers
|
23
|
|
|
SendableChooser<Goal> goalChooser;
|
24
|
|
|
SendableChooser<Drivetrain> driveChooser;
|
25
|
|
|
SendableChooser<Position> positionChooser;
|
26
|
|
|
// add choosers as needed, these put drop down options in the smart dash
|
27
|
|
|
|
28
|
|
|
|
29
|
|
|
/// subsystems
|
30
|
|
|
// public static SubsystemArduino SUB_ARDUINO;
|
31
|
|
|
public static SubsystemClamp SUB_CLAMP;
|
|
|
|
|
32
|
|
|
public static SubsystemCompressor SUB_COMPRESSOR;
|
|
|
|
|
33
|
|
|
public static SubsystemDrive SUB_DRIVE;
|
|
|
|
|
34
|
|
|
public static SubsystemHook SUB_HOOK;
|
|
|
|
|
35
|
|
|
public static SubsystemManipulator SUB_MANIPULATOR;
|
|
|
|
|
36
|
|
|
public static SubsystemMast SUB_MAST;
|
|
|
|
|
37
|
|
|
|
38
|
|
|
public static OI oi;
|
|
|
|
|
39
|
|
|
public static Vision vision;
|
|
|
|
|
40
|
|
|
|
41
|
|
|
|
42
|
|
|
/// autonomous
|
43
|
|
|
private CommandGroupAuto auto;
|
44
|
|
|
|
45
|
|
|
|
46
|
|
|
|
47
|
|
|
|
48
|
|
|
/** runs when robot is turned on */
|
49
|
|
|
public void robotInit() {
|
50
|
|
|
DriverStation.reportWarning("ROBOT STARTED; GOOD LUCK", false);
|
51
|
|
|
/// instantiate subsystems
|
52
|
|
|
// SUB_ARDUINO = new SubsystemArduino();
|
53
|
|
|
SUB_MANIPULATOR = new SubsystemManipulator();
|
|
|
|
|
54
|
|
|
SUB_CLAMP = new SubsystemClamp();
|
|
|
|
|
55
|
|
|
SUB_COMPRESSOR = new SubsystemCompressor();
|
|
|
|
|
56
|
|
|
SUB_DRIVE = new SubsystemDrive();
|
|
|
|
|
57
|
|
|
SUB_HOOK = new SubsystemHook();
|
|
|
|
|
58
|
|
|
SUB_MAST = new SubsystemMast();
|
|
|
|
|
59
|
|
|
//vision = new Vision();
|
60
|
|
|
|
61
|
|
|
/// instantiate operator interface
|
62
|
|
|
oi = new OI();
|
|
|
|
|
63
|
|
|
|
64
|
|
|
/// instantiate drivetrain chooser
|
65
|
|
|
driveChooser = new SendableChooser<>();
|
66
|
|
|
driveChooser.addDefault(Drivetrain.ROCKET_LEAGUE.toString(), Drivetrain.ROCKET_LEAGUE); // set default to RL drive
|
67
|
|
|
for(int i = 1; i < Drivetrain.values().length; i++) {
|
68
|
|
|
driveChooser.addObject(Drivetrain.values()[i].toString(), Drivetrain.values()[i]); } // add each drivetrain enum value to chooser
|
69
|
|
|
SmartDashboard.putData("Drivetrain", driveChooser); //display the chooser on the dash
|
70
|
|
|
|
71
|
|
|
/// instantiate position chooser
|
72
|
|
|
positionChooser = new SendableChooser<>();
|
73
|
|
|
positionChooser.addDefault(Position.CENTER.toString(), Position.CENTER); // set default to nothing
|
74
|
|
|
for(int i = 1; i < Position.values().length; i++) {
|
75
|
|
|
positionChooser.addObject(Position.values()[i].toString(), Position.values()[i]); } // add each autonomous enum value to chooser
|
76
|
|
|
SmartDashboard.putData("Position", positionChooser); //display the chooser on the dash
|
77
|
|
|
|
78
|
|
|
/// instantiate goal chooser
|
79
|
|
|
goalChooser = new SendableChooser<>();
|
80
|
|
|
goalChooser.addDefault(Goal.NOTHING.toString(), Goal.NOTHING); // set default to nothing
|
81
|
|
|
for(int i = 1; i < Goal.values().length; i++) {
|
82
|
|
|
goalChooser.addObject(Goal.values()[i].toString(), Goal.values()[i]); } // add each autonomous enum value to chooser
|
83
|
|
|
SmartDashboard.putData("Goal", goalChooser); //display the chooser on the dash
|
84
|
|
|
|
85
|
|
|
/// instantiate cameras
|
86
|
|
|
// vision.startCameraThread();
|
87
|
|
|
|
88
|
|
|
DriverStation.reportWarning("SUBSYSTEMS, CHOOSERS INSTANTIATED", false);
|
89
|
|
|
}
|
90
|
|
|
|
91
|
|
|
|
92
|
|
|
/** runs when robot gets disabled */
|
93
|
|
|
public void disabledInit() {
|
94
|
|
|
DriverStation.reportWarning("TELEOP IS DISABLED", false);
|
95
|
|
|
}
|
96
|
|
|
|
97
|
|
|
|
98
|
|
|
/** runs at 50hz when bot is disabled */
|
99
|
|
|
public void disabledPeriodic() {
|
100
|
|
|
Scheduler.getInstance().run();
|
101
|
|
|
}
|
102
|
|
|
|
103
|
|
|
|
104
|
|
|
/** runs when autonomous start */
|
105
|
|
|
public void autonomousInit() {
|
106
|
|
|
DriverStation.reportWarning("AUTONOMOUS IS STARTING...", false);
|
107
|
|
|
if(goalChooser.getSelected() != null) {
|
108
|
|
|
auto = new CommandGroupAuto(positionChooser.getSelected(), goalChooser.getSelected());
|
109
|
|
|
auto.start();
|
110
|
|
|
}
|
111
|
|
|
}
|
112
|
|
|
|
113
|
|
|
/** runs at 50hz when in autonomous */
|
114
|
|
|
public void autonomousPeriodic() {
|
115
|
|
|
Scheduler.getInstance().run();
|
116
|
|
|
}
|
117
|
|
|
|
118
|
|
|
|
119
|
|
|
/** runs when teleop starts*/
|
120
|
|
|
public void teleopInit() {
|
121
|
|
|
DriverStation.reportWarning("TELEOP IS ENABLED", false);
|
122
|
|
|
if (auto != null)
|
123
|
|
|
auto.cancel();
|
124
|
|
|
}
|
125
|
|
|
|
126
|
|
|
|
127
|
|
|
/** runs at ~50hz when in teleop mode */
|
128
|
|
|
public void teleopPeriodic() {
|
129
|
|
|
Scheduler.getInstance().run();
|
130
|
|
|
if (driveChooser.getSelected() != null) {
|
131
|
|
|
SUB_DRIVE.setDrivetrain(driveChooser.getSelected());
|
132
|
|
|
}
|
133
|
|
|
SUB_MANIPULATOR.spinByJoystick(OI.OPERATOR); // THIS IS A PATCH. DO AS I SAY, NOT AS I DO
|
134
|
|
|
}
|
135
|
|
|
|
136
|
|
|
|
137
|
|
|
/** runs at ~50hz when in test mode */
|
138
|
|
|
public void testPeriodic() {
|
139
|
|
|
LiveWindow.run();
|
140
|
|
|
}
|
141
|
|
|
}
|
142
|
|
|
|
143
|
|
|
|
See this CWE advisory on why this is a security issue.