-
Notifications
You must be signed in to change notification settings - Fork 35
/
SuperstructureGoal.java
40 lines (33 loc) · 1.28 KB
/
SuperstructureGoal.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
package com.team254.frc2019.states;
/**
* Represents a goal for the superstructure
*/
public class SuperstructureGoal {
public final SuperstructureState state;
public SuperstructureGoal(double turret, double elevator, double shoulder, double wrist) {
this(new SuperstructureState(turret, elevator, shoulder, wrist));
}
public SuperstructureGoal(SuperstructureState state) {
this.state = new SuperstructureState(state);
}
public boolean equals(SuperstructureGoal other) {
return this.state.turret == other.state.turret &&
this.state.elevator == other.state.elevator &&
this.state.shoulder == other.state.shoulder &&
this.state.wrist == other.state.wrist;
}
public boolean isAtDesiredState(SuperstructureState currentState) {
double[] distances = {
currentState.turret - state.turret,
currentState.elevator - state.elevator,
currentState.shoulder - state.shoulder,
currentState.wrist - state.wrist
};
for (int i = 0; i < distances.length; i++) {
if (Math.abs(distances[i]) > SuperstructureConstants.kPadding[i]) {
return false;
}
}
return true;
}
}