4.16 Rotation targeting
A leg’s heading comes from a waypoint heading in to(...), from
rotationTarget(...) (rotation_target), or from aimTarget(...)
(aim_target). The guide is Rotation.
This example uses the reef id from the
REEFSCAPE 2025 pack, so it
needs that pack loaded:
import com.tempo.Angles;
import com.tempo.Composer;
import com.tempo.Condition;
import edu.wpi.first.math.geometry.Pose2d;
import edu.wpi.first.math.geometry.Translation2d;
Translation2d reefCenter = new Translation2d(4.489, 4.026);
var route = Composer.startAt(new Pose2d(7.58, 5.85, Angles.deg(180)))
.to(5.13, 5.14, Angles.deg(-120)) // waypoint heading
.rotationTarget(0.5, Angles.deg(-135))
.to(2.70, 4.03)
.aimTarget(0.3, 0.8, reefCenter)
.to(3.30, 2.60)
.aimTarget(Condition.passed("reef"), reefCenter); // from passing the reef to the leg's endfrom tempo import Composer, Condition
from tempo.angles import deg
from wpimath.geometry import Pose2d, Translation2d
reef_center = Translation2d(4.489, 4.026)
route = (Composer.start_at(Pose2d(7.58, 5.85, deg(180)))
.to(5.13, 5.14, deg(-120)) # waypoint heading
.rotation_target(0.5, deg(-135))
.to(2.70, 4.03)
.aim_target(0.3, 0.8, reef_center)
.to(3.30, 2.60)
.aim_target(Condition.passed("reef"), reef_center)) # from passing the reef to the leg's end#include <tempo/Angles.h>
#include <tempo/Composer.h>
#include <tempo/Condition.h>
const frc::Translation2d reefCenter{4.489_m, 4.026_m};
auto route = tempo::Composer::start_at(7.58, 5.85, tempo::angles::deg(180))
.to(5.13, 5.14, tempo::angles::deg(-120)) // waypoint heading
.rotation_target(0.5, tempo::angles::deg(-135))
.to(2.70, 4.03)
.aim_target(0.3, 0.8, reefCenter)
.to(3.30, 2.60)
.aim_target(tempo::Condition::passed("reef"), reefCenter); // from passing the reef to the leg's endWaypoint heading
to(x, y, heading) or to(pose) arrives facing the heading. to(x, y) or
to(point) requires none. On swerve the robot keeps its heading there unless a
later waypoint heading or rotation target needs a turn, which is then spread
over the waypoints with no heading before it. A mecanum drive turns to face the
straight line from the leg’s start to its end.
Rotation has the full rule.
rotationTarget(fraction, heading)
The robot faces heading by fraction of the leg’s planned path distance. 0 is
leaving the previous waypoint and 1 is arriving. Several targets on one leg
sort by fraction and interpolate. A waypoint heading is the target at 1.
| Argument | Java | Python | C++ |
|---|---|---|---|
fraction | double, 0 to 1 | float | double |
heading | radians, Rotation2d or Angle | radians or Rotation2d | radians |
turnRate, optional | rad/s or AngularVelocity | rad/s | rad/s |
The turn rate caps how fast the planned heading changes, so with a low cap the robot
can reach heading later than fraction.
Python takes it as the third argument or as turn_rate=.
aimTarget(…)
aimTarget points the robot’s front at a target while the leg drives. The
target comes after any window or condition arguments, and an optional turn-rate
cap follows the target (in Python, a trailing number or turn_rate=).
| Form | Active |
|---|---|
aimTarget(target) | The whole drive, and the leg’s waypoint heading is dropped |
aimTarget(fraction, target) | From fraction to the end of the leg |
aimTarget(from, to, target) | From from to to, with 0 <= from < to <= 1 |
aimTarget(condition, target) | While a state Condition holds (inside, near, when, always, combinations), arming again each time, or from a moment (passed, entered, exited) to the end of the leg |
| Target | Java | Python | C++ |
|---|---|---|---|
| Fixed point | Translation2d | Translation2d or (x, y) | frc::Translation2d |
| Fixed pose (aims at its position) | Pose2d | Pose2d | frc::Pose2d |
| Live point | Supplier<Translation2d> | callable returning a Translation2d or Pose2d | lambda returning a Translation2d, Pose2d or an optional of one |
| Live heading | HeadingSupplier | callable returning radians or Rotation2d | std::function<std::optional<double>()>, radians |
Java’s HeadingSupplier extends Supplier<Rotation2d> so the two supplier
overloads stay distinct.
Python has one callable form. A number or Rotation2d is a heading and a
Translation2d or Pose2d is a point. Any other value raises TypeError
during the run.
A live value of null, None or std::nullopt means no target that loop.
The heading turns back to the planned profile, and it turns to the target again
when a value returns. Tempo’s GUI can show fixed targets. Supplier targets exist
only in code.
Which aim decides
While an aim is active it overrides the planned heading. The most recently armed aim that’s still active decides. When it ends the next most recent one decides, or the planned profile if there is none. A window that ended doesn’t arm again.
| Change | Turns at |
|---|---|
| An aim starts, arms again, or gets a live value back | Its cap, else the angular-velocity limit |
| Handover between aims | The incoming aim’s cap, else the outgoing aim’s, else the limit |
| The last aim stops steering | The outgoing aim’s cap, else the limit |
The limit is the robot’s maxAngularVelocity, lowered by the leg’s
limits(...). With no cap and no limit, the change is immediate.
- A leg with an aim plans clearance with the circle its footprint sweeps.
- A leg steered only by aims arrives on position alone, so the heading tolerance doesn’t apply. A replan keeps the robot’s heading.
- Later legs start from the heading the aim left, until one turns the robot on
its own (a waypoint heading, rotation target,
facingTravel()or a differential-drive leg). - On mecanum, a fixed aim with no condition is part of the planned profile, so wheel limits include its turn. Live and conditional aims steer reactively.
- Inside a Rotation Lock no aim turns the robot.
Differential drives
A differential drive faces along its path. A rotationTarget, an aimTarget
or a waypoint heading on a leg the robot drives through fails the
freeze (Errors).
A waypoint heading where the robot stops is allowed (on the last leg, on a leg
that ends in Arrival.STOP or a pause, or with arriveWith), but the robot
doesn’t turn to it and arrives facing along its path.
Unit helpers
| Helper | Java returns | Python and C++ return |
|---|---|---|
Angles.deg, rad, turnFraction (deg, rad, turn_fraction in tempo.angles and tempo::angles) | Rotation2d | radians |
Rates.degPerSec, radPerSec, rotPerSec (deg_per_sec, rad_per_sec, rot_per_sec in tempo.rates and tempo::rates) | AngularVelocity | rad/s |
import com.tempo.Angles;
import com.tempo.Rates;
route.rotationTarget(0.5, Angles.deg(90), Rates.degPerSec(180));from tempo.angles import deg
from tempo.rates import deg_per_sec
route.rotation_target(0.5, deg(90), turn_rate=deg_per_sec(180))#include <tempo/Angles.h>
#include <tempo/Rates.h>
route.rotation_target(0.5, tempo::angles::deg(90), tempo::rates::deg_per_sec(180));Tempo wraps a heading target into [-pi, pi] when it plans, so turnFraction(2.25)
is the same target as turnFraction(0.25). The value the helper returns isn’t wrapped
on 2026 (2026 vs 2027).
Rates don’t wrap, so rotPerSec(2) is two turns per second.
Errors
| Cause | Message |
|---|---|
rotationTarget fraction outside 0 to 1 | [Tempo] a rotation target's position is a fraction of the way along the leg, in [0, 1]; got {value} |
| Heading not finite | [Tempo] a rotation target's heading must be a finite angle; got {value} |
| Turn rate not positive and finite | [Tempo] a turn rate cap must be positive and finite; got {value} |
aimTarget fraction outside 0 to 1 | [Tempo] an aim target's position is a fraction of the way along the leg, in [0, 1]; got {value} |
| Window start not before its end | [Tempo] an aim target's window must start before it ends; got {from} to {to} |
progress, remaining or matchTime condition | [Tempo] a {kind} condition cannot start an aim; use passed, entered, exited, inside, near, when or always, or a fraction of the way along the leg |
| Differential-drive leg with a rotation target (freeze) | [Tempo] leg {leg}: a differential drivetrain faces along its path and cannot turn to a rotation target; remove the rotation target from that leg |
| Differential-drive leg with an aim (freeze) | [Tempo] leg {leg}: a differential drivetrain faces along its path and cannot aim at a target; remove the aim target from that leg |
| Differential-drive waypoint heading where the leg does not stop (freeze) | [Tempo] leg {leg}: a differential drivetrain accepts a waypoint heading only where it stops, since it faces along its path while it moves; stop at that waypoint or remove the heading |
Argument errors throw IllegalArgumentException, ValueError or
std::invalid_argument at the call. Freeze errors throw
IllegalStateException, RuntimeError or std::logic_error.
Alliance mirroring
Waypoint headings, rotation targets and fixed aim points mirror when the route’s
originAlliance is BLUE or RED and the robot is on the other alliance. Live
suppliers pass through unchanged.