forked from Team254/FRC-2019-Public
-
Notifications
You must be signed in to change notification settings - Fork 0
/
AvoidDriveBasePlanner.java
41 lines (35 loc) · 1.74 KB
/
AvoidDriveBasePlanner.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
package com.team254.frc2019.planners;
import com.team254.frc2019.statemachines.SuperstructureCommands;
import com.team254.frc2019.states.SuperstructureConstants;
import com.team254.frc2019.states.SuperstructureGoal;
import com.team254.lib.util.Util;
/**
* Superstructure motion planner meant to avoid colliding with the drivebase
*/
public class AvoidDriveBasePlanner implements ISuperstructureMotionPlanner {
public boolean isValidGoal(SuperstructureGoal goal) {
return goal.state.isOverBumper() || goal.state.isTurretSafeForWristBelowBumper();
}
@Override
public SuperstructureGoal plan(SuperstructureGoal prevSetpoint, SuperstructureGoal goal) {
boolean turretWantsMove = !Util.epsilonEquals(prevSetpoint.state.turret, goal.state.turret,
SuperstructureConstants.kTurretPaddingDegrees);
if (turretWantsMove) {
if (!prevSetpoint.state.isOverBumper()) {
// Move towards a stowed position until I'm safe to turn.
SuperstructureGoal result = new SuperstructureGoal(SuperstructureCommands.tuckedPosition);
result.state.turret = prevSetpoint.state.turret;
return result;
}
// Used at the Silicon Valley Regional; not applicable for champs robot
// else if (!goal.state.isOverBumper()) {
// // Do not move down towards the setpoint until the turret is done
// SuperstructureGoal result = new SuperstructureGoal(SuperstructureCommands.tuckedPosition);
// result.state.turret = goal.state.turret;
// return result;
// }
}
// No restrictions needed.
return new SuperstructureGoal(goal.state);
}
}