Closed Seairth closed 8 years ago
to be sure I understand what you mean, this is what it should look like instead?
@Override
public void setActivity(Activity activity) {
this.currentActivity = activity;
this.currentActivity.initialize();
}
Exactly.
Each time we switch to an activity, we want to call the initialize code to reset the activity. Then, when we start calling update(), we know that we are starting the activity in a known state.
Note: For the autonomy activity, we are going to leave initialize() empty! That way, every time that the currentActivity is set back to that object, calls to update() will continue from the last known state. For instance, imagine the following sequence:
setActivity(getDefaultActivity())
sets currentActivity to the autonomy activityrobot.setActivity(robot.getDetectDefenseActivity())
.robot.setActivity(robot.getBreachLowBarActivity())
.robot.setActivity(robot.getDefaultActivity())
.robot.setActivity(robot.getTurnActivity())
.