Skip to content

Commit cdd0808

Browse files
authored
Manager (#8)
merged manager with main
1 parent c556cc9 commit cdd0808

File tree

12 files changed

+321
-4
lines changed

12 files changed

+321
-4
lines changed

.github/scripts/constants.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import sys
44

55
# List of files to excuse (constants and things we didnt make and stuff we wont use)
6-
excused_files = ["GlobalConstants.java", "IndexerConstants.java"]
6+
excused_files = ["GlobalConstants.java", "IndexerConstants.java", "ManagerConstants.java", "AdjustableHoodConstants.java", "HoodedShooterSupersystemConstants.java", "ShooterConstants.java", "IntakeConstants.java"]
77

88
# Not really dirs becasue the full ones didnt work
99
excused_dirs = [

simgui-ds.json

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
{
2+
"keyboardJoysticks": [
3+
{
4+
"axisConfig": [
5+
{
6+
"decKey": 65,
7+
"incKey": 68
8+
},
9+
{
10+
"decKey": 87,
11+
"incKey": 83
12+
},
13+
{
14+
"decKey": 69,
15+
"decayRate": 0.0,
16+
"incKey": 82,
17+
"keyRate": 0.009999999776482582
18+
}
19+
],
20+
"axisCount": 3,
21+
"buttonCount": 4,
22+
"buttonKeys": [
23+
90,
24+
88,
25+
67,
26+
86
27+
],
28+
"povConfig": [
29+
{
30+
"key0": 328,
31+
"key135": 323,
32+
"key180": 322,
33+
"key225": 321,
34+
"key270": 324,
35+
"key315": 327,
36+
"key45": 329,
37+
"key90": 326
38+
}
39+
],
40+
"povCount": 1
41+
},
42+
{
43+
"axisConfig": [
44+
{
45+
"decKey": 74,
46+
"incKey": 76
47+
},
48+
{
49+
"decKey": 73,
50+
"incKey": 75
51+
}
52+
],
53+
"axisCount": 2,
54+
"buttonCount": 4,
55+
"buttonKeys": [
56+
77,
57+
44,
58+
46,
59+
47
60+
],
61+
"povCount": 0
62+
},
63+
{
64+
"axisConfig": [
65+
{
66+
"decKey": 263,
67+
"incKey": 262
68+
},
69+
{
70+
"decKey": 265,
71+
"incKey": 264
72+
}
73+
],
74+
"axisCount": 2,
75+
"buttonCount": 6,
76+
"buttonKeys": [
77+
260,
78+
268,
79+
266,
80+
261,
81+
269,
82+
267
83+
],
84+
"povCount": 0
85+
},
86+
{
87+
"axisCount": 0,
88+
"buttonCount": 0,
89+
"povCount": 0
90+
}
91+
]
92+
}

src/main/deploy/swerve/modules/phyicalproperties.json renamed to src/main/deploy/swerve/modules/physicalproperties.json

File renamed without changes.

src/main/java/frc/robot/GlobalConstants.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,6 @@ public enum RobotMode {
1818
public static class Controllers {
1919

2020
public static final XboxController DRIVER_CONTROLLER = new XboxController(0);
21+
public static final XboxController OPERATOR_CONTROLLER = new XboxController(1);
2122
}
2223
}
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
package frc.robot.Manager;
2+
3+
import static frc.robot.GlobalConstants.Controllers.*;
4+
import static frc.robot.Manager.ManagerConstants.*;
5+
import static frc.robot.Manager.ManagerStates.*;
6+
7+
import frc.robot.Subsystems.Drive.Drive;
8+
import frc.robot.Subsystems.HoodedShooterSupersystem.HoodedShooterSupersystem;
9+
import frc.robot.Subsystems.Indexer.Indexer;
10+
import frc.robot.Subsystems.Intake.Intake;
11+
import frc.robot.Subsystems.Vision.Vision;
12+
import org.littletonrobotics.junction.Logger;
13+
import org.team7525.subsystem.Subsystem;
14+
15+
public class Manager extends Subsystem<ManagerStates> {
16+
17+
private static Manager instance;
18+
private Intake intake;
19+
public Drive drive;
20+
private Indexer indexer;
21+
private HoodedShooterSupersystem hoodedShooterSupersystem;
22+
private Vision vision;
23+
24+
public static Manager getInstance() {
25+
if (instance == null) {
26+
instance = new Manager();
27+
}
28+
return instance;
29+
}
30+
31+
public Manager() {
32+
super(SUBSYSTEM_NAME, ManagerStates.IDLE);
33+
intake = Intake.getInstance();
34+
hoodedShooterSupersystem = HoodedShooterSupersystem.getInstance();
35+
drive = Drive.getInstance();
36+
indexer = Indexer.getInstance();
37+
vision = Vision.getInstance();
38+
39+
//add triggers
40+
addTrigger(IDLE, OUTTAKING, DRIVER_CONTROLLER::getXButtonPressed);
41+
addTrigger(INTAKE_PASSING, OUTTAKING, DRIVER_CONTROLLER::getXButtonPressed);
42+
addTrigger(INTAKING, OUTTAKING, DRIVER_CONTROLLER::getXButtonPressed);
43+
44+
addTrigger(IDLE, INTAKING, DRIVER_CONTROLLER::getAButtonPressed);
45+
addTrigger(INTAKING, INTAKE_PASSING, DRIVER_CONTROLLER::getAButtonPressed);
46+
addTrigger(INTAKE_PASSING, FIXED_ALIGN, DRIVER_CONTROLLER::getAButtonPressed);
47+
addTrigger(FIXED_ALIGN, FIXED_SHOOT, DRIVER_CONTROLLER::getAButtonPressed);
48+
addTrigger(FIXED_ALIGN, FIXED_SHOOT, () -> hoodedShooterSupersystem.readyToShoot());
49+
50+
addTrigger(INTAKE_PASSING, DYNAMIC_ALIGN, DRIVER_CONTROLLER::getYButtonPressed);
51+
addTrigger(DYNAMIC_ALIGN, DYNAMIC_SHOOT, DRIVER_CONTROLLER::getYButtonPressed);
52+
addTrigger(DYNAMIC_ALIGN, DYNAMIC_SHOOT, () -> hoodedShooterSupersystem.readyToShoot());
53+
}
54+
55+
@Override
56+
public void runState() {
57+
if (DRIVER_CONTROLLER.getBButtonPressed()) {
58+
setState(IDLE);
59+
}
60+
61+
logData();
62+
63+
intake.setState(getState().getIntakeStates());
64+
hoodedShooterSupersystem.setState(getState().getHoodedShooterSupersystemStates());
65+
indexer.setState(getState().getIndexerStates());
66+
67+
hoodedShooterSupersystem.periodic();
68+
indexer.periodic();
69+
intake.periodic();
70+
drive.periodic();
71+
vision.periodic();
72+
}
73+
74+
public boolean hasGamepiece() {
75+
return intake.hasGamepiece();
76+
}
77+
78+
public void logData() {
79+
Logger.recordOutput(SUBSYSTEM_NAME + "/State Time", getStateTime());
80+
Logger.recordOutput(SUBSYSTEM_NAME + "/State String", getState().getStateString());
81+
}
82+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package frc.robot.Manager;
2+
3+
public final class ManagerConstants {
4+
5+
public static final String SUBSYSTEM_NAME = "Manager";
6+
}
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
package frc.robot.Manager;
2+
3+
import frc.robot.Subsystems.HoodedShooterSupersystem.HoodedShooterSupersystemStates;
4+
import frc.robot.Subsystems.Indexer.IndexerState;
5+
import frc.robot.Subsystems.Intake.IntakeStates;
6+
import org.team7525.subsystem.SubsystemStates;
7+
8+
public enum ManagerStates implements SubsystemStates {
9+
IDLE("Idle", IntakeStates.IDLE, IndexerState.IDLE, HoodedShooterSupersystemStates.IDLE),
10+
OUTTAKING(
11+
"Outtaking",
12+
IntakeStates.OUTTAKING,
13+
IndexerState.IDLE,
14+
HoodedShooterSupersystemStates.IDLE
15+
),
16+
INTAKING(
17+
"Intaking",
18+
IntakeStates.INTAKING,
19+
IndexerState.IDLE,
20+
HoodedShooterSupersystemStates.IDLE
21+
),
22+
INTAKE_PASSING(
23+
"Passing",
24+
IntakeStates.PASSING,
25+
IndexerState.INTAKING,
26+
HoodedShooterSupersystemStates.IDLE
27+
),
28+
FIXED_ALIGN(
29+
"Fixed Align",
30+
IntakeStates.IDLE,
31+
IndexerState.IDLE,
32+
HoodedShooterSupersystemStates.FIXED
33+
),
34+
DYNAMIC_ALIGN(
35+
"Dynamic Align",
36+
IntakeStates.IDLE,
37+
IndexerState.IDLE,
38+
HoodedShooterSupersystemStates.DYNAMIC
39+
),
40+
DYNAMIC_SHOOT(
41+
"Dynamic Shoot",
42+
IntakeStates.IDLE,
43+
IndexerState.SHOOTING,
44+
HoodedShooterSupersystemStates.DYNAMIC
45+
),
46+
FIXED_SHOOT(
47+
"Fixed Shoot",
48+
IntakeStates.IDLE,
49+
IndexerState.SHOOTING,
50+
HoodedShooterSupersystemStates.FIXED
51+
);
52+
53+
private String stateString;
54+
private IntakeStates intake;
55+
private IndexerState indexer;
56+
private HoodedShooterSupersystemStates hoodedShooterSupersystem;
57+
58+
ManagerStates(
59+
String stateString,
60+
IntakeStates intake,
61+
IndexerState indexer,
62+
HoodedShooterSupersystemStates hoodedShooterSupersystem
63+
) {
64+
this.stateString = stateString;
65+
this.intake = intake;
66+
this.indexer = indexer;
67+
this.hoodedShooterSupersystem = hoodedShooterSupersystem;
68+
}
69+
70+
@Override
71+
public String getStateString() {
72+
return stateString;
73+
}
74+
75+
public IntakeStates getIntakeStates() {
76+
return intake;
77+
}
78+
79+
public IndexerState getIndexerStates() {
80+
return indexer;
81+
}
82+
83+
public HoodedShooterSupersystemStates getHoodedShooterSupersystemStates() {
84+
return hoodedShooterSupersystem;
85+
}
86+
}

src/main/java/frc/robot/Robot.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
package frc.robot;
66

77
import edu.wpi.first.wpilibj.DriverStation;
8+
import edu.wpi.first.wpilibj2.command.CommandScheduler;
9+
import frc.robot.Manager.Manager;
10+
import frc.robot.Utilitys.Utilitys;
811
import org.littletonrobotics.junction.LoggedRobot;
912
import org.littletonrobotics.junction.Logger;
1013
import org.littletonrobotics.junction.networktables.NT4Publisher;
@@ -17,21 +20,29 @@
1720
*/
1821
public class Robot extends LoggedRobot {
1922

23+
public Manager manager;
24+
2025
/**
2126
* This function is run when the robot is first started up and should be used for any
2227
* initialization code.
2328
*/
2429
public Robot() {}
2530

2631
public void robotInit() {
32+
manager = Manager.getInstance();
33+
2734
Logger.addDataReceiver(new NT4Publisher());
2835
Logger.start();
2936
CommandsUtil.logCommands();
3037
DriverStation.silenceJoystickConnectionWarning(true);
3138
}
3239

3340
@Override
34-
public void robotPeriodic() {}
41+
public void robotPeriodic() {
42+
CommandScheduler.getInstance().run();
43+
manager.periodic();
44+
Utilitys.controllers.clearCache();
45+
}
3546

3647
@Override
3748
public void autonomousInit() {}

src/main/java/frc/robot/Subsystems/HoodedShooterSupersystem/HoodedShooterSupersystemStates.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
public enum HoodedShooterSupersystemStates implements SubsystemStates {
88
IDLE("IDLE", AdjustableHoodStates.IDLE, ShooterStates.IDLE),
9-
FIXED("FIXED", AdjustableHoodStates.FIXED, ShooterStates.IDLE),
9+
FIXED("FIXED", AdjustableHoodStates.FIXED, ShooterStates.FIXED),
1010
DYNAMIC("DYNAMIC", AdjustableHoodStates.DYNAMIC, ShooterStates.DYNAMIC);
1111

1212
private final String stateString;

src/main/java/frc/robot/Subsystems/Indexer/IndexerConstants.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,7 @@ public static class SIM {
3232
1,
3333
1
3434
);
35+
36+
public static final double STDDEV = 1.0;
3537
}
3638
}

0 commit comments

Comments
 (0)