Three-Branch Autonomous Structure
Organize reusable autonomous branches without tying the pattern to one season.
Organize reusable autonomous branches without tying the pattern to one season.
In this lesson, you will:
A three-branch autonomous combines vision selection, several path options, and mechanism actions. The organization matters as much as the path math.
The robot should have a small menu of tested routines rather than a giant method full of copied path code. Common actions should be reused.
Create branch builders, common score/park actions, and one selector. Keep each path named for field intent.
CenterstageAuto.javaJava
Action selected;
boolean visionAccepted = true;
switch (propPosition) {
case LEFT:
selected = leftBranchPath();
break;
case RIGHT:
selected = rightBranchPath();
break;
case CENTER:
selected = centerBranchPath();
break;
case UNKNOWN:
default:
visionAccepted = false;
selected = new InstantAction(() -> robot.safeState());
break;
}
Action routine = visionAccepted
? new SequentialAction(selected, score(), park())
: selected;
try {
Actions.runBlocking(routine);
} finally {
robot.safeState();
}Copied paths drift apart. If one branch is fixed and others are not, the code becomes unreliable. Extract shared pieces.
Refactor a three-branch auto so common scoring and parking actions are reused.
Check your understanding before moving on.
0 of 2 answered