@@ -58,23 +58,21 @@ public static Superstructure getInstance() {
58
58
59
59
@ Override
60
60
public void periodic () {
61
- updateMeasurement ();
61
+ measurement = new SuperstructureState (arm .getState (), intake .getState (), shooter .getState ());
62
+
63
+ SuperstructureMechanism .getInstance ().updateSuperstructure (measurement );
62
64
}
63
65
64
66
@ Override
65
67
public void addToShuffleboard (ShuffleboardTab tab ) {
66
68
addStateToShuffleboard (tab , "Measurement" , () -> measurement );
67
69
addStateToShuffleboard (tab , "Goal" , () -> goal );
68
70
69
- ShuffleboardLayout state = Telemetry .addColumn (tab , "State" );
70
-
71
- state .addString (
71
+ Telemetry .addColumn (tab , "State" ).addString (
72
72
"State" ,
73
73
() -> this .getCurrentCommand () != null ? this .getCurrentCommand ().getName () : "NONE" );
74
74
75
- ShuffleboardLayout at = Telemetry .addColumn (tab , "At Goal?" );
76
-
77
- at .addBoolean ("At Goal?" , () -> at (goal ));
75
+ Telemetry .addColumn (tab , "At Goal?" ).addBoolean ("At Goal?" , this ::atGoal );
78
76
}
79
77
80
78
private void addStateToShuffleboard (
@@ -105,16 +103,6 @@ private void addStateToShuffleboard(
105
103
() -> state .get ().shooterState ().serializerVelocityRotationsPerSecond ());
106
104
}
107
105
108
- private void updateMeasurement () {
109
- measurement = new SuperstructureState (arm .getState (), intake .getState (), shooter .getState ());
110
-
111
- SuperstructureMechanism .getInstance ().updateSuperstructure (measurement );
112
- }
113
-
114
- public SuperstructureState getState () {
115
- return measurement ;
116
- }
117
-
118
106
public void setPosition (SuperstructureState state ) {
119
107
arm .setPosition (state .armState ());
120
108
}
@@ -127,18 +115,18 @@ public void setGoal(SuperstructureState goal) {
127
115
shooter .setGoal (goal .shooterState ());
128
116
}
129
117
130
- public boolean at ( SuperstructureState goal ) {
131
- updateMeasurement ();
132
-
133
- return measurement .atGoal (goal );
118
+ public boolean atGoal ( ) {
119
+ return arm . atGoal ()
120
+ && intake . atGoal ()
121
+ && shooter .atGoal ();
134
122
}
135
123
136
124
private Command hold (SuperstructureState goal ) {
137
125
return run (() -> setGoal (goal ));
138
126
}
139
127
140
128
private Command to (SuperstructureState goal ) {
141
- return run (() -> setGoal (goal )).until (() -> at ( goal ) );
129
+ return run (() -> setGoal (goal )).until (this :: atGoal );
142
130
}
143
131
144
132
public Command stow () {
0 commit comments