4.30 Replanner
A Replanner plans one leg and follows it. Each tick it takes a measured pose and a
timestamp, returns robot-relative speeds, and replans when the robot drifts. It doesn’t
schedule commands, require the drivetrain, reset odometry or drive motors. For a teleop
target, use point to point, which requires the drivetrain
and stops on release. Authored routes use Composer.
Building
import com.tempo.Alliance;
import com.tempo.Replanner;
import com.tempo.Tempo;
import edu.wpi.first.math.geometry.Translation2d;
import edu.wpi.first.wpilibj.Timer;
Replanner replanner = Replanner.build(
Tempo.pack(), Tempo.config(),
Alliance.fromDriverStation(),
null, // end heading: null holds the start heading
drive.getPose(),
new Translation2d(3.0, 6.0), // target on the bundled 2026 field
Timer.getTimestamp());import wpilib
from tempo import Alliance, Replanner, Tempo
from wpimath.geometry import Translation2d
replanner = Replanner.build(
Tempo.pack(), Tempo.config(),
Alliance.from_driver_station(),
None, # end heading: None holds the start heading
drive.get_pose(),
Translation2d(3.0, 6.0), # target on the bundled 2026 field
wpilib.Timer.getTimestamp())#include <tempo/Tempo.h>
#include <frc/Timer.h>
auto replanner = tempo::Replanner::build(
tempo::Tempo::pack(), tempo::Tempo::config(),
tempo::Alliance::Blue,
std::nullopt, // end heading (rad): hold the start heading
drive.GetPose(),
frc::Translation2d{3.0_m, 6.0_m}, // target on the bundled 2026 field
frc::Timer::GetTimestamp().value());| Argument | Java | Python | C++ |
|---|---|---|---|
| End heading | Rotation2d, or null to hold | radians, Rotation2d, or None | std::optional<double> radians |
| Start pose | Pose2d | Pose2d or (x, y, heading_rad) | frc::Pose2d |
| Target | Translation2d | Translation2d or (x, y) | frc::Translation2d |
| Start time | s | s | s |
- Pass the alliance the robot runs as. Coordinates are used as given and aren’t
mirrored, and every pack obstacle and avoid zone applies whichever alliance is
passed. C++ has no
from_driver_station(), so pass the alliance your code reads (Alliance). - Java and C++ only have the seven-argument form, which has no rotation targets, aims or turn-rate caps. Those are Composer options.
- The pack’s default avoid zones apply. Python’s
buildtakes more optional arguments after the start time:avoid_zone_mask,custom_avoid_zones,keep_in,follow_modeandcurve_style, and the keyword-onlyvia_points,via_speed_caps,aims,reactive_flip_center,extensionandcross_order. - The first plan is built at once, and
buildthrows when it can’t be. A later failed replan keeps the current follower. - In C++ the
Replannercan keep a pointer intopackand read it on later ticks, so keep the pack alive and unmoved while theReplanneris ticked.Tempo::pack()stays valid until another pack is installed or Tempo is reset.
tick
ChassisSpeeds speeds = replanner.tick(drive.getPose(), Timer.getTimestamp());
drive.runVelocity(speeds);speeds = replanner.tick(drive.get_pose(), wpilib.Timer.getTimestamp())
drive.run_velocity(speeds)#include <tempo/wpi/Geometry.h>
frc::ChassisSpeeds speeds = tempo::wpi::tick(
replanner, drive.GetPose(), frc::Timer::GetTimestamp().value());
drive.RunVelocity(speeds);Call tick every 20 ms loop, with the same monotonic clock in seconds that gave the
start time. It returns robot-relative ChassisSpeeds (ChassisVelocities on 2027).
RobotPy 2027 alpha-7 and beyond spell the clock wpilib.Timer.get_timestamp().
tick doesn’t stop the drivetrain. When isComplete (is_complete) turns true, or
the command using the planner is interrupted, send zero speeds to the drivetrain and
stop calling tick.
Queries and lifetime
| Java | Python / C++ | Behavior |
|---|---|---|
isComplete(now) | is_complete(now) | True once the trajectory’s time has run out and the last ticked pose is at the target: position, plus the stopped-heading check where one applies. A crossing with a target must have been driven too |
isStalled() | is_stalled() | True when commanded to move but not moving. It stays true until rebase or a new planner |
trackingErrorM(pose, now) | tracking_error_m(pose, now) | Cross-track error, m |
viaPointsPassed(now) | via_points_passed(now) | Via-points the plan has crossed, 0 without vias |
followMode() | Python follow_mode (a property), C++ follow_mode() | The control law in use |
plannedPoses(n) | planned_poses(n), C++ tempo::wpi::planned_poses(r, n) | n time-spaced poses, clamped to 2 through 65,536 |
targetPose(now) | target_pose(now), C++ tempo::wpi::target_pose(r, now) | The reference pose, or null, None, empty std::optional |
rebase(now) | rebase(now) | Restarts the trajectory clock at now |
close() | close(), C++ destructor | Frees the native handle |
Call rebase before reusing a planner built earlier, because the plan carries the time
it was built and without a rebase the robot jumps forward along the path on the first
tick. rebase also discards pending replans and clears the stall latch, but the route
and via progress are kept.
Keep one planner across loops, pass a fresh pose and time each tick, and close it when the
command using it ends. Java’s Replanner is AutoCloseable and Python’s is a context
manager. The planner requires no subsystem, so the command using it must require the
drivetrain.