Skip to content
Tempo on GitHub (opens in a new tab)

4.21 GamePack

Tempo.pack() returns the active GamePack after configuration. It holds the field’s dimensions, obstacles, terrain, regions and symmetry, loaded from a game pack TOML file.

Loading

Java
public static final TempoConfig CONFIG = new TempoConfig()
    // ... the rest of the config
    .withGamePack(GamePacks.REBUILT_2026);

GamePack pack = GamePack.bundled(GamePacks.REBUILT_2026);
Python
CONFIG = (TempoConfig()
    # ... the rest of the config
    .with_game_pack(GamePacks.REBUILT_2026))

pack = GamePack.bundled(GamePacks.REBUILT_2026)
C++
inline const tempo::TempoConfig kConfig = tempo::TempoConfig{}
    // ... the rest of the config
    .with_game_pack(tempo::GamePacks::kRebuilt2026);

auto pack = tempo::GamePack::bundled(tempo::GamePacks::kRebuilt2026);

Tempo.configure(...) loads a pack from code first, then tempo/game.toml in the deploy folder, then the pack bundled for the WPILib year. The deploy file is src/main/deploy/tempo/game.toml in Java and C++ and deploy/tempo/game.toml in RobotPy. The bundled packs are listed in Game packs.

GamePack.bundled("rebuilt-2026") selects a bundled pack by id (reefscape-2025 and crescendo-2024 are the other two), and an unknown id throws. Tempo.bundledGamePack() returns the default bundled pack and ignores deploy files. Each load returns a new pack, and your code closes it when it’s done (Lifetime).

game.toml loads whenever it is in the folder. Other TOML files beside it are ignored, and a single TOML file with another name loads. Both cases print one warning, and startup continues:

WarningCause
[Tempo] ignoring extra game packs in deploy/tempo: old.toml. Only game.toml is loaded. ...game.toml and other TOML files
[Tempo] loaded the game pack deploy/tempo/field.toml; name it game.toml. ...One TOML file with another name

Deploy errors fail startup (Java and Python TempoException, C++ std::runtime_error):

MessageCause
[Tempo] deploy/tempo holds several game packs and none is named game.toml (a.toml, b.toml); ...Several TOML files, none named game.toml
[Tempo] deploy/tempo must be a directorytempo is a file
[Tempo] deploy/tempo/game.toml must be a regular fileThe pack to load is not a regular file. The message names the file

A pack that fails to parse fails the load, and Tempo doesn’t fall back to another pack.

Advanced loading

JavaPythonC++Reads
GamePack.load(path)GamePack.load(path)GamePack::load(path)A TOML file
GamePack.fromToml(text)GamePack.from_toml(text)GamePack::from_toml(text)TOML text
Tempo.configureForTesting(config, path)Java tests: that file, no discovery

A loaded pack goes in withGamePack(...) the same way, as in withGamePack(GamePack.load(path)). Every loader rejects input over 4 MiB (4,194,304 bytes).

Queries

Element ids in the samples belong to the bundled REBUILT 2026 pack, and Game packs lists them all.

Java
double length = pack.fieldLengthM();                       // +X, meters
boolean hasHub = Tempo.pack().hasElement("hub");
boolean blocked = pack.pointInObstacle(new Translation2d(4.63, 4.03), Alliance.BLUE);
boolean inZone = pack.pointInZone(new Translation2d(8.27, 6.0), "neutralZone");
Python
length = pack.field_length_m()
has_hub = Tempo.pack().has_element("hub")
blocked = pack.point_in_obstacle(Translation2d(4.63, 4.03), Alliance.BLUE)
in_zone = pack.point_in_zone(Translation2d(8.27, 6.0), "neutralZone")
C++
double length = pack.field_length_m();
bool has_hub = tempo::Tempo::pack().has_element("hub");
bool blocked = pack.point_in_obstacle(frc::Translation2d{4.63_m, 4.03_m}, tempo::Alliance::Blue);
bool in_zone = pack.point_in_zone(frc::Translation2d{8.27_m, 6.0_m}, "neutralZone");
JavaPython / C++Returns
fieldLengthM(), fieldWidthM()field_length_m(), field_width_m()Field size in meters
isRotationallySymmetric()is_rotationally_symmetric()Despite its name, this reports the origin. True for a fieldCenter origin and false for alwaysBlue, whatever symmetry says
Field.center(), which reads the active packPython pack.field_center(), C++ tempo::wpi::field_center(pack)The mirror pivot
hasElement(id)has_element(id)Whether any obstacle, region, avoid zone or terrain has the id
elementKind(id)element_kind(id)The element group, or null (None, std::nullopt) for an unknown id
pointInObstacle(point, alliance)point_in_obstacle(...)Inside any physical obstacle. The alliance argument has no effect and every obstacle is tested. Terrain and avoid zones don’t count
pointInZone(point, id)point_in_zone(...)Inside a named region, and false for other kinds and unknown ids. Where two regions share an id, as the blue and red allianceZone copies do, a point inside either is inside
avoidZoneCount()avoid_zone_count()Avoid zones, 0 to 64
avoidZoneId(index)avoid_zone_id(index)The id at a mask bit, or null, None or an empty string when out of range
avoidZoneIndex(id), elementBounds(id), terrainIndex(id)Java only: mask bit, [minX, minY, maxX, maxY], terrain index. -1 or null when unknown
sourcePath()Python source_pathThe file path, or null for TOML text

Point queries don’t test whether the footprint fits or a route exists.

Lifetime

GamePack is AutoCloseable in Java, a context manager in Python, and move-only RAII in C++.

  • A pack your code loads is yours to close, unless you passed it to Tempo. Tempo closes a pack it was given.
  • Never close the pack Tempo.pack() returns.
  • A replaced pack stays open until every route build still reading it has finished.
  • In Java a Replanner keeps its pack open after your code closes the GamePack. In C++ the pack must outlive the Replanner (Replanner).
esc

Loading search...