11package org .usfirst .frc .team69 .robot ;
2- import edu .wpi .first .networktables .NetworkTableInstance ;
2+
3+ import com .pathplanner .lib .auto .NamedCommands ;
4+ import edu .wpi .first .wpilibj .DriverStation ;
5+ import edu .wpi .first .wpilibj .Joystick ;
6+ import edu .wpi .first .wpilibj .PowerDistribution ;
7+ import edu .wpi .first .wpilibj .livewindow .LiveWindow ;
8+ import edu .wpi .first .wpilibj .shuffleboard .Shuffleboard ;
9+ import edu .wpi .first .wpilibj .shuffleboard .ShuffleboardTab ;
310import edu .wpi .first .wpilibj .smartdashboard .SendableChooser ;
4- import edu .wpi .first .wpilibj .smartdashboard .SmartDashboard ;
511import edu .wpi .first .wpilibj2 .command .Command ;
612import org .hyperonline .hyperlib .HYPERRobot ;
13+ import org .hyperonline .hyperlib .oi .BadOIMapException ;
714import org .hyperonline .hyperlib .oi .OI ;
15+ import org .hyperonline .hyperlib .pref .PreferencesListener ;
16+ import org .hyperonline .hyperlib .pref .PreferencesUpdater ;
817import org .usfirst .frc .team69 .robot .commands .AutonomousCommands ;
9- import org .usfirst .frc .team69 .robot .subsystems .DriveTrain ;
10-
11- public class Robot extends HYPERRobot implements PreferencesListener {
18+ import org .usfirst .frc .team69 .robot .subsystems .swerve .SwerveSubsystem ;
1219
13- public static OI oi ;
14- public static DriveTrain driveTrain ;
1520
16- private NetworkTableInstance m_tableInstance = NetworkTableInstance .getDefault ();
21+ /**
22+ * The VM is configured to automatically run this class, and to call the functions corresponding to
23+ * each mode, as described in the IterativeRobot documentation. If you change the name of this class
24+ * or the package after creating this project, you must also update the manifest file in the
25+ * resource directory.
26+ */
27+ public class Robot extends HYPERRobot implements PreferencesListener {
28+ public static OI <Joystick , Joystick , Joystick , Joystick > oi ;
29+ public static SwerveSubsystem driveTrain ;
30+ public static PowerDistribution powerDistribution ;
31+ private final String driverTabName = "Drive Team" ;
1732 private Command autonomousCommand ;
1833 private SendableChooser <Command > chooser ;
34+ private ShuffleboardTab driverTab ;
1935
20-
21- public Robot (){}
36+ public Robot () {
37+ m_burnFlashOnInit = false ;
38+ }
2239
2340 @ Override
2441 protected void initOI () {
25- oi = new OI (OIMap .class , true );
42+ try {
43+ oi = new OI <>(OIMap .class , true );
44+ } catch (BadOIMapException e ) {
45+ DriverStation .reportError (e .getMessage (), e .getStackTrace ());
46+ }
2647 }
2748
2849 @ Override
2950 protected void initSubsystems () {
30- driveTrain = new DriveTrain ();
51+ // disable automatically checking of Preference updates
52+ // preferences will not be updating while the robot is running during matches,
53+ // so we do not need to clog the HYPERRobot.robotPeriodic()
54+ PreferencesUpdater .setAutoCheckForUpdate (true );
55+
56+ powerDistribution = new PowerDistribution (RobotMap .Electrical .POWER_DISTRIBUTION_PORT , RobotMap .Electrical .POWER_DISTRIBUTION_TYPE );
3157
58+ driveTrain = new SwerveSubsystem ();
3259 }
3360
3461 @ Override
3562 protected void initHelpers () {
36-
63+ DriverStation .silenceJoystickConnectionWarning (true );
64+ driverTab = Shuffleboard .getTab (driverTabName );
65+ if (DriverStation .getMatchType () != DriverStation .MatchType .None ) {
66+ Shuffleboard .selectTab (driverTabName );
67+ }
3768 }
3869
3970 @ Override
4071 protected void initCommands () {
4172 oi .initCommands ();
73+
4274 chooser = new AutonomousCommands ().createAutoChooser ();
43- SmartDashboard .putData ("Auto Chooser" , chooser );
75+ driverTab .add ("Auto Chooser" , chooser ).withPosition (0 , 0 ).withSize (2 , 1 );
76+ }
77+
78+ /**
79+ * This autonomous (along with the chooser code above) shows how to select between different
80+ * autonomous modes using the dashboard. The sendable chooser code works with the Java
81+ * SmartDashboard. If you prefer the LabVIEW Dashboard, remove all of the chooser code and
82+ * uncomment the getString code to get the auto name from the text box below the Gyro
83+ *
84+ * <p>You can add additional auto modes by adding additional commands to the chooser code above
85+ * (like the commented example) or additional comparisons to the switch structure below with
86+ * additional strings & commands.
87+ */
88+ @ Override
89+ public void autonomousInit () {
90+ super .autonomousInit ();
91+ autonomousCommand = chooser .getSelected ();
92+ if (autonomousCommand != null ) {
93+ autonomousCommand .schedule ();
94+ }
95+ }
96+
97+ /**
98+ * This function is called periodically during autonomous
99+ */
100+ @ Override
101+ public void autonomousPeriodic () {
102+ super .autonomousPeriodic ();
44103 }
45- }
104+
105+ @ Override
106+ public void teleopInit () {
107+ super .teleopInit ();
108+ // This makes sure that the autonomous stops running when
109+ // teleop starts running. If you want the autonomous to
110+ // continue until interrupted by another command, remove
111+ // this line or comment it out.
112+ if (autonomousCommand != null ) {
113+ autonomousCommand .cancel ();
114+ }
115+ }
116+
117+ /**
118+ * This function is called periodically during operator control
119+ */
120+ @ Override
121+ public void teleopPeriodic () {
122+ super .teleopPeriodic ();
123+ }
124+
125+ /**
126+ * This function is called once each time the robot enters test mode.
127+ */
128+ @ Override
129+ public void testInit () {
130+ super .testInit ();
131+ LiveWindow .setEnabled (true );
132+ }
133+
134+ /**
135+ * This function is called periodically during test mode
136+ */
137+ @ Override
138+ public void testPeriodic () {
139+ super .testPeriodic ();
140+ // LiveWindow.run();
141+ }
142+
143+ /**
144+ * This function is called once each time the robot enters Disabled mode. You can use it to reset
145+ * any subsystem information you want to clear when the robot is disabled.
146+ */
147+ @ Override
148+ public void disabledInit () {
149+ super .disabledInit ();
150+ }
151+
152+ @ Override
153+ public void disabledPeriodic () {
154+ super .disabledPeriodic ();
155+ }
156+
157+ @ Override
158+ public void onPreferencesUpdated () {
159+
160+ }
161+
162+
163+ }
0 commit comments