Class MatchMemory

java.lang.Object
com.crossbotics.ftchelper.match.MatchMemory

public final class MatchMemory extends Object
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 Details

    • MAX_AGE_SEC

      public static final double MAX_AGE_SEC
      After this many seconds the memory belongs to an old match and is ignored.
      See Also:
  • Method Details

    • remember

      public static void remember(Alliance chosen, FieldPose pose)
      Saves the alliance and the pose (the pose goes to PoseStore). Pose may be null.
    • allianceOr

      public static Alliance allianceOr(Alliance fallback)
      The remembered alliance if it is from this match, else fallback.
    • chosen

      public static Alliance 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

      public static void setChosen(Alliance a)
      Sets chosen() (EasyAuto and EasyTeleOp do it for you).
    • placement

      public static FieldPose placement()
      Where the running autonomous wants the robot placed (field frame, see fieldPose(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

      public static String placementNote()
      The drive team's note for placement() ("" if none).
    • setPlacement

      public static void setPlacement(FieldPose pose, String note)
      Sets placement() (null = none) and its note (EasyAuto does it for you).
    • fieldPose

      public static FieldPose fieldPose(Alliance alliance, double x, double y, double headingDeg)
      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 than MAX_AGE_SEC).
    • rememberReport

      public static void rememberReport(List<String> lines)
      Saves autonomous's report (one line per step), for TeleOp's INIT screen.
    • lastReport

      public static List<String> lastReport()
      Autonomous's report from this match (empty if none, or if it is older than MAX_AGE_SEC).
    • ageSec

      public static double ageSec()
    • clear

      public static void clear()
      Forgets everything (alliance and pose).