Package com.crossbotics.ftchelper.match
Class MatchMemory
java.lang.Object
com.crossbotics.ftchelper.match.MatchMemory
Remembers what autonomous knew, for TeleOp: the alliance and the robot's pose.
With it, ONE TeleOp works for both alliances: it reads the alliance autonomous chose.
(The "pose" is where the robot is on the field and which way it faces.)
// End of autonomous (EasyAuto does this for you):
MatchMemory.remember(Alliance.RED, new FieldPose(0, 0, heading));
// TeleOp INIT:
Alliance alliance = MatchMemory.allianceOr(Alliance.BLUE);
The memory lasts until the robot app restarts. It is old after a few minutes (a new match),
so allianceOr(com.crossbotics.ftchelper.match.Alliance) ignores it after MAX_AGE_SEC.
Java notes: everything here is static, which means there is ONE shared copy for the
whole robot app, not one per object. That is how autonomous and TeleOp (two different OpModes)
see the same memory. synchronized means only one piece of code at a time may use it,
so two parts of the app can never read it half-written.
Docs: docs/modules/match.md (section "MatchMemory")
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final doubleAfter this many seconds the memory belongs to an old match and is ignored. -
Method Summary
Modifier and TypeMethodDescriptionstatic doubleageSec()Seconds sinceremember(com.crossbotics.ftchelper.match.Alliance, com.crossbotics.ftchelper.util.FieldPose)was called (very large if never).static AllianceallianceOr(Alliance fallback) The remembered alliance if it is from this match, elsefallback.static Alliancechosen()The alliance the program running now uses (autonomous's INIT menu, or TeleOp's), or null if none said.static voidclear()Forgets everything (alliance and pose).static FieldPoseA start spot seen from the drivers' wall, as a field position.static booleanTrue if autonomous left an alliance for this match (not older thanMAX_AGE_SEC).Autonomous's report from this match (empty if none, or if it is older thanMAX_AGE_SEC).static FieldPoseWhere the running autonomous wants the robot placed (field frame, seefieldPose(com.crossbotics.ftchelper.match.Alliance, double, double, double)), and its note for the drive team; null if it did not say.static StringThe drive team's note forplacement()("" if none).static voidSaves the alliance and the pose (the pose goes toPoseStore).static voidrememberReport(List<String> lines) Saves autonomous's report (one line per step), for TeleOp's INIT screen.static voidSetschosen()(EasyAuto and EasyTeleOp do it for you).static voidsetPlacement(FieldPose pose, String note) Setsplacement()(null = none) and its note (EasyAuto does it for you).
-
Field Details
-
MAX_AGE_SEC
public static final double MAX_AGE_SECAfter this many seconds the memory belongs to an old match and is ignored.- See Also:
-
-
Method Details
-
remember
Saves the alliance and the pose (the pose goes toPoseStore). Pose may be null. -
allianceOr
The remembered alliance if it is from this match, elsefallback. -
chosen
The alliance the program running now uses (autonomous's INIT menu, or TeleOp's), or null if none said. EasyAuto and EasyTeleOp set it in INIT; the simulator turns its drivers' view to that side. -
setChosen
Setschosen()(EasyAuto and EasyTeleOp do it for you). -
placement
Where the running autonomous wants the robot placed (field frame, seefieldPose(com.crossbotics.ftchelper.match.Alliance, double, double, double)), and its note for the drive team; null if it did not say. EasyAuto sets it in INIT; the simulator puts the robot there. -
placementNote
The drive team's note forplacement()("" if none). -
setPlacement
Setsplacement()(null = none) and its note (EasyAuto does it for you). -
fieldPose
A start spot seen from the drivers' wall, as a field position. The drivers' frame: x inches to the right of the field's centre line, y inches from the centre toward the far wall (negative = your half), heading 0 = facing away from you, counterclockwise +. The field frame (the simulator's): the RED drivers at the bottom (y negative), x to their right, heading 0 = facing away from them.- Parameters:
alliance- whose drivers' wall
-
hasAlliance
public static boolean hasAlliance()True if autonomous left an alliance for this match (not older thanMAX_AGE_SEC). -
rememberReport
Saves autonomous's report (one line per step), for TeleOp's INIT screen. -
lastReport
Autonomous's report from this match (empty if none, or if it is older thanMAX_AGE_SEC). -
ageSec
public static double ageSec()Seconds sinceremember(com.crossbotics.ftchelper.match.Alliance, com.crossbotics.ftchelper.util.FieldPose)was called (very large if never). -
clear
public static void clear()Forgets everything (alliance and pose).
-