-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathRobotContainerBase.java
90 lines (66 loc) · 3.06 KB
/
RobotContainerBase.java
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
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018-2019 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
package frc.team670.mustanglib;
import java.util.ArrayList;
import java.util.List;
import frc.team670.mustanglib.commands.MustangCommand;
import frc.team670.mustanglib.commands.MustangScheduler;
import frc.team670.mustanglib.subsystems.MustangSubsystemBase;
import frc.team670.mustanglib.subsystems.MustangSubsystemBase.HealthState;
import frc.team670.mustanglib.utils.MustangController;
/**
* This class is where the bulk of the robot should be declared. Since
* Command-based is a "declarative" paradigm, very little robot logic should
* actually be handled in the Robot periodic methods (other than the
* scheduler calls). Instead, the structure of the robot (including subsystems,
* commands, and button mappings) should be declared here.
*/
public abstract class RobotContainerBase {
// The robot's subsystems and commands are defined here...
public static List<MustangSubsystemBase> allSubsystems = new ArrayList<MustangSubsystemBase>();
public static void addSubsystem(MustangSubsystemBase... subsystems) {
for (MustangSubsystemBase m_subsystemBase : subsystems) {
allSubsystems.add(m_subsystemBase);
}
}
/**
* Recalculates the health of all subsystems on the robot.
*/
public static void checkSubsystemsHealth() {
for (MustangSubsystemBase s : allSubsystems) {
s.getHealth(true);
if (s.getHealth(false).equals(HealthState.GREEN)) {
// MustangScheduler.getInstance().registerSubsystem(s); //TODO: Test this today
// if(s.getDefaultMustangCommand() != null){
// MustangScheduler.getInstance().setDefaultCommand(s,
// s.getDefaultMustangCommand());
// }
} else if (s.getHealth(false).equals(HealthState.RED)) {
MustangScheduler.getInstance().cancel(s.getDefaultMustangCommand());
MustangScheduler.getInstance().unregisterSubsystem(s);
}
s.pushHealthToDashboard();
}
}
public abstract void robotInit();
public abstract MustangCommand getAutonomousCommand();
public abstract void autonomousInit();
public abstract void autonomousExit();
public abstract void teleopInit();
public abstract void testInit();
public abstract void disabled();
public abstract void disabledPeriodic();
public abstract void periodic();
public abstract void autonomousPeriodic();
public abstract void teleopPeriodic();
public abstract MustangController getOperatorController();
public abstract MustangController getDriverController();
public abstract MustangController getBackupController();
public static List<MustangSubsystemBase> getSubsystems() {
return allSubsystems;
}
}