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

3.4 Zones & regions

Use a Region for a shape you write in code, like a rectangle or a circle, and Zone.named(id) for a game pack element. The examples use the REEFSCAPE 2025 pack.

Stay inside an area

stayWithin keeps one leg’s path inside an area, called a keep-in.

Java
import com.tempo.Region;
import com.tempo.Zone;
import static edu.wpi.first.units.Units.Meters;

// Inside a rectangle beside the barge post.
parkRoute.to(parkTarget)
    .stayWithin(Region.rectangle(7.8, 4.4, 9.8, 6.0));

// Inside the reef's bounding box grown by 1.0 m.
reefRoute.to(reefOrbit)
    .stayWithin(Region.near(Zone.named("reef"), Meters.of(1.0)));

// Inside both a rectangle and a circle.
localRoute.to(target)
    .stayWithin(Region.rectangle(6.0, 2.0, 8.0, 6.0))
    .stayWithin(Region.circle(7.0, 4.0, 1.2));
Python
from tempo import Region, Zone

# Inside a rectangle beside the barge post.
park_route.to(park_target).stay_within(Region.rectangle(7.8, 4.4, 9.8, 6.0))

# Inside the reef's bounding box grown by 1.0 m.
reef_route.to(reef_orbit).stay_within(Region.near(Zone.named("reef"), 1.0))

# Inside both a rectangle and a circle.
(local_route.to(target)
    .stay_within(Region.rectangle(6.0, 2.0, 8.0, 6.0))
    .stay_within(Region.circle(7.0, 4.0, 1.2)))
C++
#include <tempo/Region.h>

// Inside a rectangle beside the barge post.
park_route.to(park_target)
    .stay_within(tempo::Region::rectangle(7.8, 4.4, 9.8, 6.0));

// Inside the reef's bounding box grown by 1.0 m.
reef_route.to(reef_orbit)
    .stay_within(tempo::Region::zone(tempo::Zone::named("reef")).grown_by(1.0));

// Inside both a rectangle and a circle.
local_route.to(target)
    .stay_within(tempo::Region::rectangle(6.0, 2.0, 8.0, 6.0))
    .stay_within(tempo::Region::circle(7.0, 4.0, 1.2));

stayWithin (stay_within) applies only to the to(...) before it, and with several calls the leg has to stay inside all of them. stayWithin(Zone.named(id)) uses the element’s bounding box, and an unknown id throws when the call runs.

C++ has no Region::near. Use Region::zone(zone).grown_by(d) and you get the same region.

Coordinates are in meters, and keep-ins are mirrored with the route. The whole robot has to fit inside a keep-in along the leg. A keep-in wider than twice the robot radius (center to the farthest bumper corner) fits at any heading.

The start and target centers can sit on the boundary with the footprint hanging over it. A center outside the boundary means the leg can’t be planned.

The other shapes are in Regions, zones and terrain.

Avoid an area

avoid(region) keeps the robot’s footprint out of a region for every leg of the route.

Java
Composer.startAt(start)
    .avoid(Region.circle(6.0, 4.0, 0.8))   // clear of a partner's path
    .to(8.0, 2.0)
    .to(8.0, 6.0);
Python
(Composer.start_at(start)
    .avoid(Region.circle(6.0, 4.0, 0.8))   # clear of a partner's path
    .to(8.0, 2.0)
    .to(8.0, 6.0))
C++
tempo::Composer::start_at(start)
    .avoid(tempo::Region::circle(6.0, 4.0, 0.8))   // clear of a partner's path
    .to(8.0, 2.0)
    .to(8.0, 6.0);

A leg whose waypoint is inside the region can’t be planned. A route that starts inside the region drives out, and the region applies from then on.

Pack zones: ignore and allow

A pack region with effect = "avoid" applies to every route unless the route turns it off. The REEFSCAPE 2025 pack doesn’t have one, so this example adds this region to it:

TOML
[[regions]]
id = "protectedZone"
shape = "rectangle"
minM = [6.0, 0.0]
maxM = [7.5, 2.0]
effect = "avoid"
Java
Composer.startAt(start)
    .ignore(Zone.named("protectedZone"))   // this route may cross it
    .to(7.0, 1.0);
Python
(Composer.start_at(start)
    .ignore(Zone.named("protectedZone"))   # this route may cross it
    .to(7.0, 1.0))
C++
tempo::Composer::start_at(start)
    .ignore(tempo::Zone::named("protectedZone"))   // this route may cross it
    .to(7.0, 1.0);

ignore turns the zone off for the whole route. allow(zone) turns it back on, and a zone the pack declares with enabled = false is off until a route calls allow.

If the id isn’t an avoid zone in the pack, nothing throws and the route still runs. Tempo prints a [Tempo] ignore(Zone.named(...)) does nothing line (allow(...) for an allow call) that lists the avoid zones the pack has.

Zones can also be drawn on the Paths screen in Tempo’s GUI.

Legs that can’t be planned

If a keep-in leaves no route, or the start or target center is outside it, Tempo skips the leg and goes on to the next one. It prints a [Tempo] console line naming the leg and logs a giveUps event with cause noRoute. The leg’s runOnFailure command runs without waiting for the leg’s giveUpAfter time (Failure handling).

If it fails…

A leg is skipped Above →

The keep-in leaves no route, or the start or target center is outside it. Make the keep-in wider than the robot (twice the robot radius fits at any heading) and keep both centers inside it.

ignore or allow does nothing Above → [Tempo] ignore(Zone.named("{id}")) does nothing: the loaded game pack ... declares no avoid zone "{id}".

The id isn’t an avoid zone in the loaded pack. Use one of the ids the message lists.

esc

Loading search...