Skip to content

2.3 Trajectory and heading

trajectory turns a planned path into a timed trajectory under the robot’s limits. rotation profiles the heading along it. Both are part of Core modules.

trajectory: Two-pass velocity profile

Entry point: Trajectory::build(spline, constraints, samples_per_segment, heading)

samples_per_segment is a count, or a Sampling (Path planning): the planner passes Sampling::Spaced, which takes fewer samples of the short straight pieces of a subdivided fit.

The heading parameter is a HeadingSpec from the rotation module. The builder bakes a target heading into every sample. There are two variants. build_with_speed_zones caps velocity inside named shapes, which is how terrain crossings slow the robot down. build_differential produces a profile for tank drivetrains.

A differential plan bakes the path tangent as its heading. The replanner (plan_differential_route) turns every heading half a turn when the plan’s departure tangent lies more than a quarter turn from the leg’s start heading (drives_backward), so the robot backs along the path. A footprint that a half turn changes is planned again turned around. The RAMSETE DifferentialFollower reads a sample whose heading faces against its velocity as a reversed reference (heading tangent plus pi and a negative reference speed). The runtime starts each differential group from the robot’s heading and hands the next group the heading its plan ends with (AutoRuntime::faces_its_path).

  1. Sample the spline into the spatial grid and compute velocity ceilings from the constraints, curvature, speed zones and any point caps.
  2. Forward pass: limit each ceiling to sqrt(v_prev^2 + 2 * a_long * ds).
  3. Backward pass: limit each forward speed to sqrt(v_next^2 + 2 * a_long * ds).
  4. Bound acceleration over the interpolated velocity intervals, including their interior extrema, and apply an enabled path-turn-rate ceiling on the same intervals. Each interval’s bound is a 24-step bisection on its demand. With the turn-rate ceiling off the demand does not fall as the free end’s speed rises. Newton’s method finds a bracket and two evaluations certify it (DemandBracket). The bracket decides every midpoint outside it by comparison, and only a midpoint inside it is evaluated. The bounds keep the plain bisection’s bits.
  5. Build time and acceleration samples, then bake the requested heading profile.

a_long is the longitudinal budget remaining after lateral acceleration. Normal trajectory construction consumes scalar peak limits. Hardware wrappers derive those peaks from current-limited motor torque, calibrated drivetrain losses, mass, and grip. A route resolved from a motor model also carries the drive’s acceleration at each speed (TrajectoryConstraints::drive, DriveAcceleration). That lowers a_long on every forward step. Each step takes the curve at the speed it would reach under the curve at its start. That speed is an upper bound on every speed the step passes through, so a plan never asks the motors for more than they give. A curve measured by calibration (MeasuredAcceleration, in DriveAcceleration::measured) takes the terms’ place. It is linear between its points and held flat outside them. It never rises with speed, because the step bound needs that. Backward steps keep the scalar limit, since back-EMF and the loss both help braking. The profile does not model battery voltage, allocate forces to individual swerve modules, or model chassis rotational inertia, so hardware-derived peaks do not establish full dynamic feasibility. The private velocity_profile helper reuses the ceiling vector through both passes while preserving operand order. Held headings skip unused face-travel preparation. Stationary turns and stopped-pose heading tails still receive their required duration.

Hardware and path constraints

The hardware calculation uses SI values throughout. Wheel size is a radius and gearing is motor rotations per wheel rotation. The motor model is R = Vnom / Istall, Kt = Tstall / Istall, Kv = omegaFree / (Vnom - R * Ifree), and I(omega, V) = (V - omega / Kv) / R. Reduction multiplies torque and divides speed. These definitions follow WPILib’s DCMotor model.

Measured drive speed at 12 V sets the estimated loss current L, the current the motor draws at that speed, clamped to the configured current ceiling, as in PathPlanner’s module model. PathPlanner charges L at every speed. Tempo charges 0.15 L at standstill and lets the rest grow in proportion to wheel speed, so the loss still reaches L at the measured speed and the motor tops out there. The 0.15 is STATIC_LOSS_SHARE. SysId kS on FRC swerve drives is 0.1 to 0.25 V, 8 to 20% of the roughly 1.2 V of loss a drive measured 10% under free speed shows at top speed. A loss that takes the whole current a level drives with (the ceiling, 85% of it for CAREFUL) refuses that level, because the drive cannot hold its measured speed on that current.

With I_stall the 12 V stall current and v_m the measured speed, a wheel at speed v has min(I_limit - 0.15 L - 0.85 L v / v_m, (I_stall - 0.15 L) (1 - v / v_m)) of current over the loss. The current limit binds below the speed where back-EMF meets it, and the back-EMF line reaches zero at v_m. Summed over every modeled gearbox as force over mass, that is DriveAcceleration. The drive query returns its torque terms (netTorque, torqueFade, voltageTorqueSlope). Starting force is the sum of each modeled gearbox’s net torque from rest divided by its wheel radius. Starting acceleration is min(force / mass, mu * 9.81) and centripetal acceleration is mu * 9.81. Equal limits indicate grip-limited starting acceleration. A selected velocity ceiling does not redefine the measured 12 V speed or its losses.

A drive group’s optional supplyCurrent (each motor’s supply current limit S) adds trajectory::SupplyLimit. A controller draws about its motor’s electrical power from the bus, S * 12 V = I (I R + e v) with winding resistance R = 12 V / I_stall and back EMF e v at wheel speed v. The motor current the supply limit allows is the positive root I_S(v) = 2P / (e v + sqrt((e v)^2 + 4 R P)), P = 12 S. Where I_S(v) is below the current-limited line’s current, the line loses that difference’s torque, so the curve is unchanged near rest and falls faster at speed. The bus is the nominal 12 V the rest of the model uses. The term is the same in the model’s curve and in SimplePhysics::curve. It joins the curve’s identity for plan reuse and travels in config.driveAcceleration.supply. Speed levels are limits from rest and do not read it. Without the field the curve has no term and every value is unchanged. A measured curve replaces the whole model, the term included, because the robot was measured under its supply limit.

A stated limit may rise above an estimate up to drive_model::Ceilings (simple physics with no loss, or a measured value). It plans along SimplePhysics::curve when it does. A cap within 1e-9 of an estimate resolves as the estimate.

At curvature kappa, the lateral speed ceiling is sqrt(C / abs(kappa)). Tempo shares the available acceleration through (aLong / A)^2 + (aLat / C)^2 <= 1, with aLat = v^2 * kappa. This elliptical budget is a scalar approximation. The optional steering-rate constraint bounds travel-direction rotation. It does not certify individual module azimuth rates while the chassis rotates. Full module velocities also contain omega * moduleOffset, as shown by WPILib’s swerve kinematics.

Mecanum wheel limits

TrajectoryConstraints.mecanum (MecanumLimits) is set only for a mecanum robot. Routes carry it as config.mecanum (strafeEfficiency, optional turnRadiusM, mecanumMargin). The routed preview takes mecanum (strafe_efficiency, turn_radius_m, mecanum_margin). The standalone replanner takes it through tempo_replanner_new_mecanum_v2. Following WPILib’s mecanum kinematics, the fastest wheel runs at |vx| + |vy| / e + k * |omega| for a robot-relative chassis speed, a strafe efficiency e and a turn radius k. The turn radius is the largest |x| + |y| wheel offset. Without turnRadiusM the core takes the largest |x| + |y| over the footprint’s vertices, or sqrt(2) times the robot radius (MecanumLimits::outline_turn_radius). The forward speed and acceleration limits are the wheels’ limits. The planning margin defaults to 0 and multiplies both limits by 1 - mecanumMargin to cover battery sag and roller slip.

Planned aims use a distance-domain heading on the original spline grid. Point bearings use atan2(target - position) and its closed-form first and second derivatives. Each interval bounds the relative translation direction, dtheta/ds, and d²theta/ds². Its speed ceiling includes wheel speed, the aim’s turn-rate cap, and the leg’s angular limit. Wheel and angular acceleration are linear in path acceleration after substituting v_next² = v² + 2*a*ds, and one forward/backward pass applies those bounds. A stationary head or tail supplies a slew that begins or ends at rest. Moving aim activation and retirement match the preceding heading and rate with a distance-domain transition. No heading knots are added to the grid.

Other mecanum heading profiles first estimate the direction and turn rate, then profile under their wheel bounds. Local refinement tightens intervals whose wheel load exceeds the budget. Swerve and differential profiles do not enter either mecanum pass.

Headings and timing change after the profile (crossing headings, stationary alignments, merged corners, narrow-turn braking), so every finished plan is certified. Trajectory::certify_mecanum (trajectory/mecanum.rs) runs at the end of the build and again on every plan Replanner returns, waypoint times following the new clock. It bounds the interpolated reference over every interval between samples. Distance-domain aims use closed-form interval bounds, and time-domain angular spans use pieces of at most 5 ms. The bound on each wheel’s speed is its speed at the piece’s ends turned by its first heading, plus the piece’s turn times the speed and the turn radius times the largest turn rate. The bound on each wheel’s acceleration comes from the translation acceleration, the turn of the travel direction relative to the robot and the turn radius times the largest turn-rate change. A turn rate that steps at a sample, or a velocity that steps over no time, is read over one 20 ms loop. The check streams with no storage that grows with the trajectory. Running c times slower divides speeds and steps by c and smooth accelerations by c^2. An overloaded trajectory with an angular profile slows uniformly. The profile slows with it, every heading staying at its place on the path. One without an angular profile slows stretch by stretch first. The distance-domain profile permits at most one uniform slowdown followed by a strict check. Other profiles allow up to 16 slowdowns. A non-finite clock, a trajectory over 600 s or two million pieces, or a bound that still exceeds the physical limit fails certification. The replanner then reports no route.

On a leg without Rotation Locks, a fixed point or fixed heading aim without a condition is part of the planned heading profile, including progress windows. The entry and exit headings slew from the preceding planned heading using the aim’s cap or the leg’s angular limit. Point bearings come from the position on the path. Within the larger of the robot circumradius and translation tolerance, the bearing holds its last value outside that radius. The original grid bounds each entry and exit. A resumed bearing slews from the held heading. A point aim never contributes a zero speed ceiling. Retiming keeps each heading at its distance along that path, so omega = dtheta/ds * v enters the wheel constraint. The aim’s own turn-rate cap, each keyframe’s cap and the leg’s angular velocity and acceleration limits also bound the finished profile. A stopped leg keeps a stationary head for an entry slew and a stationary tail when the turn needs time after translation has arrived. Footprint heading bounds bisect the clock to visit only overlapping intervals. A failed wheel certificate returns no route.

Live and condition-gated aims remain reactive. Travel-facing legs keep fixed aims reactive while retaining the moving-plan rejoin checks. A leg with Rotation Locks also keeps its aims reactive. Each Lock holds the heading reached at its live distance boundary and its Key resumes the aim from that heading. AimState::command_limited starts from the planned heading and carries the turn rate from loop to loop. After an interruption it rejoins the plan within the rotation tolerance when the rate difference is at most alpha * dt. The standalone evaluators read that rate through tempo_replanner_target_angular_velocity_v1. The native tempo_aim_limited_step_v1 supplies the same step arithmetic to Java, Python and C++. tests/fixtures/api/mecanumAimLimit.json holds their shared cases. A command’s translation is rotated into the current robot frame, and the next five control loops bound wheel speed and acceleration by direction. When translation and rotation together exceed wheel capacity, a common factor scales all three chassis components, preserving travel direction and rotation per meter. The follower corrects the resulting delay. The replanner applies the final limiter once, at the physical wheel limits, retaining the planning margin for feedback. Command history resets at route start. After a loop gap the limiter retains the last command and bounds the wheel step by the physical acceleration limit times the actual elapsed time. Discontinuous requests whose entire ray lies outside the wheel-acceleration bounds slew the whole chassis vector toward the desaturated request. free_heading retains the swept-footprint requirement for collision checks. tests/fixtures/api/mecanumSaturation.json pins the shared chassis results in Rust, Java, Python and C++. A routed preview aim marked reactive: true uses the same replanner and limiter on a 20 ms ideal plant. Its supplied point represents the live target or active condition during that preview. Swerve and differential profiles skip mecanum retiming and command desaturation.

Trajectory::sample(t_s: f64) returns a TrajectoryState at seconds from the trajectory’s start. duration_s() returns its duration as an f64 in seconds.

rotation: Heading profiles

rotation computes the HeadingSpec for a segment. The spec says when the robot starts rotating, what it points at, and how the profile ramps. The trajectory builder bakes the result into per-sample target headings.

Positions along a drive

Every position along a drive is a fraction of distance along the planned path. Fraction 0 leaves the previous waypoint and 1 arrives. Rotation keyframes (RotationKeyframe::at_fraction), aim activation (aimTarget(fraction, ...)), progress triggers (Condition.progress, the SPATIAL_PROGRESS trigger mode) and the editor’s rotation and command markers all read it. A marker drawn halfway along the path, the heading due there and the command fired there land on the same point. tests/fixtures/api/fractionBasis.json holds sampled paths with a slow and a fast stretch, and a straight leg that accelerates and brakes, each with fractions mapped to points. The core, the three bindings and the editor read it.

The angular profiles schedule turns on the trajectory’s clock. The builder places each interior keyframe on that clock after the translation profile exists (trajectory::keyframes_in_time). Its time fraction is the share of the duration at which the samples’ arc length reaches the keyframe’s fraction of the path’s length. A fast stretch spends less time than its share of the distance. When a keyframe’s turn does not fit between it and the keyframe before, the builder caps the speed of that stretch alone at its length over the turn’s time. The rest of the leg keeps its profile. Fraction 0 is due before translation and 1 at the end on either basis. A turn in place covers no distance and reads fractions on its clock. The narrow-turn scheduler reads deadlines through Trajectory::time_at_distance_fraction, so retiming that brakes or waits keeps each deadline at its point on the path. A stationary start alignment covers no distance, so it leaves every keyframe’s fraction as authored. A mid-leg replan keeps each keyframe still ahead at its place on the path. The leg’s path is the distance covered plus the active plan ahead. A keyframe at fraction f lies f * total - covered ahead. The replacement reads that as a share of the active plan’s stretch ahead, which stands in for the replacement’s own length until it is planned. Keyframes already passed are dropped. Plan reuse keys carry a word naming the distance basis, so a plan keyed on the duration basis never matches.

At run time Replanner::path_progress finds the robot’s foot point on the active plan (searched near the previous read, so a plan that crosses itself keeps the arm the robot drives) and returns the distance covered and left. The distance left is never less than the straight line to the drive’s end. Replanner::leg_distance_fraction is covered over covered plus left. A replan replaces the path ahead and keeps the distance already covered, so the fraction is read against the current path and does not jump at the switch. The search window widens ahead by the robot’s travel since the last read. The distance covered never grows faster than that travel. The offset kept for later reads carries the capped value, so a read that comes up short of the robot reads late, never early. A pose that jumps backward reads the smaller distance. An arrival within the leg’s tolerance reads 1. Triggers and aims latch, so once one has fired a moved fraction neither un-fires nor refires it. The auto runtime starts each leg’s reading afresh. Before a leg has a plan the straight line from its start stands in. Hosts that evaluate aims beside a standalone replanner (Java, Python and C++ AimEvaluator) read the same value through tempo_replanner_leg_distance_fraction_v1. The wasm preview reads the planned pose’s own arc length over the leg’s span of the plan.

Rejoining the line

ReplanSettings::mode picks how those replans head back. ReplanMode::RejoinPath, the default, is what this section describes. ReplanMode::NewPath keeps no line and makes no plan copy (Replanner::rejoin_ask asks no join, Replanner::copy_wanted asks no copy). Every replan is then remaining_route_config planned by plan_route_latched and no rejoin warning is said. The route JSON spells the mode as the replan object’s mode key (NEW_PATH), left out for the default. The standalone replanner’s CReplanSettings carries it as the mode byte at offset 33 (tests/fixtures/api/replanMode.json).

A replan for drift, schedule lag or a relocalization returns to the leg’s line. The line is the active plan when the first such replan is asked for, kept as RejoinLine. A full-route upgrade, a crossing replan or an endpoint hold replaces it. A head is never one. A leg inside an unfinished crossing and a leg with planned aims (headings placed by distance, which the splice does not re-offset) replan fresh. A robot that still owes its plan’s turn toward a targeted crossing’s heading, where the active plan’s heading at its place stands more than the crossing’s 0.05 rad tolerance off both the crossing’s heading and the robot’s, is asked no join and drives a fresh path with the rejoin warning (Replanner::turn_owed_before_crossing). A connector arrives on the line’s heading and the line turns on its own schedule. A robot trailing that turn would reach the crossing still turning, stop there to turn and start its approach off the line. A fresh path spreads the turn left over the whole way. A line that holds the crossing’s heading, a sweep before a bump, is joined however a shove turned the robot. Without the rule, runs of the regions page’s bump route (replan_heading_intent.rs) at drivetrain lags from 30 to 70 ms missed the crossing’s target. The line is a copy made where its plan was made (plan_copy, where the constructor runs on a planning worker and a fresh replan’s product carries one), so taking it copies nothing on the loop. Its vias’ arcs and the stretches of it inside each crossing’s terrain (LineMarks) are measured with it, so the capture scans nothing. Where the capture cannot read the robot’s progress (the active plan is a fresh path, or a relocalization disowned it) the worker finds it. Replanner::rejoin_ask captures, on the tick that asks, the robot’s progress along the line (the larger of the last read and the farthest read so far, line_progress_m, or after a relocalization the corrected pose’s own foot, since progress read on the disowned pose was never driven) and the farthest join. That join is short of the next unreached via, of the entry, less the body’s reach, of the first stretch of an unentered anchored crossing the robot’s progress has not passed the end of (a robot beside the terrain still owes it), and of 0.5 m before the line’s end. Replanner::plan_rejoin runs on the worker lane beside the fresh plan’s inputs. Within 5 cm of the line, when a box of the robot’s radius swept straight onto the join presses into no obstacle deeper than at its ends and crosses none, the robot joins where it stands. Farther off a connector takes it back, since a box swept across a real outline’s gap can pass where the outline does not. Otherwise a connector is planned to points ahead. The first is at least v sqrt(6 d / a_c) along, the run a cubic sideways step d needs at the robot’s own speed v under the centripetal limit. None is past 1.5 m plus 0.5 s of that speed beyond the robot’s nearest point. The connector leaves along the robot’s motion where that points within 60 degrees of the join (its pull scaled by the cosine) and arrives along the line at the line’s speed and heading, under the leg’s full obstacle check, crossing only terrain already entered. Every join is tried that way before any is tried through the line’s point 0.3 m short of it (plan_connector). A fit held to a boundary tangent is checked against the round body, which fails where the line runs closer to a wall than that body while its own certificate of the real outline allows it. An approach connector is kept when it arrives within 0.05 rad of the line’s direction.

Trajectory::rejoin_line copies the line from the join, its arc moved after the connector’s and its clock after the connector’s end. A slower arrival regains the line’s speed forward only, on the friction ellipse, which keeps every braking distance. From the sample where speeds agree the clock moves by one constant. Under an angular acceleration limit the two heading profiles join where heading and rate agree (AngularProfile::rejoined). Otherwise one cubic leaves the connector’s end and meets the line where speeds agree or at the line’s next span boundary, where a turn ends or a keyframe falls, within the limits. A join whose speed comes back only past that boundary is refused so no keyframe is skipped. Without the acceleration limit the heading turns onto the line’s within the turn-rate cap. A join whose heading does not get there before the line ends is refused. Either way the body is certified against the field over the stretch whose headings neither plan made. A leg a live override steers (reactive aims, or an override within the last 0.5 s) holds the robot’s heading on the connector. Mecanum plans are certified as any plan.

While the line is kept and the active plan is the line or a plan back onto it (SpliceMap), progress reads in line terms. A connector foot a of L_c maps to s_b + (s_k - s_b) a / L_c and the tail to s_k + a - L_c. Covered plus left stays the line’s total. The travel cap reaches as far as the robot’s travel along the plan maps to on the line (across the connector’s end too). A read on the line taken before it was kept counts in line terms. Triggers and keyframes in the skipped stretch fire during the connector. An endpoint hold turns the last read back into the active plan’s terms. leg_covered_at and progress_mark read the line, so a fresh fallback remaps keyframes, aims and Locks in line terms. When no join within reach holds, the replan plans the fresh path and says the rejoin warning once, again only after a later replan rejoins. A short line, an unfinished crossing, or a start inside an obstacle’s or the field edge’s round-body clearance that is itself the block (a connector from the start moved just clear of it reaches a join) plans the fresh path quietly. The speed-deficit report also counts lagging re-routes in a row whatever the command did, since each rejoin restarts the reference at the line’s speed where the robot stands. Tracking the command between them starts the count over. An endpoint hold keeps reading progress along the line on the held plan and retires the line when the next plan installs.

An enabled angular acceleration limit also stores an analytic heading profile. Trajectory construction shares its timing with translation and evaluates heading and angular velocity continuously. See angular constraints for the profile equations, runtime bounds, and physical-model limitations.

Reactive point aims use aim::AimState. Activation goes in authoring order and the most recently armed aim steers. Its optional turn-rate cap slews the heading after the first active tick. An aim with a window end (untilFraction, from aimTarget(from, to, point)) retires once the leg’s distance fraction reaches it and never arms again on that plan. An aim on a state condition (inside(zone) or a host predicate) steers only while the condition holds and arms again, as the most recent, when it holds again. An aim on an edge condition (entered, exited, passed) stays armed to the end of the leg once it fires. A change of steering never steps the heading. An aim that starts while the plan steers slews from the planned heading at its cap, else the angular-velocity limit. A handoff between aims slews at the incoming aim’s cap, else the outgoing aim’s, else that limit. When the last aim stops steering, or a live aim has no value, the heading slews back to the planned profile at the outgoing cap or that limit before the profile takes over. The limit is the robot-wide one lowered by the leg’s own, the same limit the planned profile obeys. The SUPPLIED kind reads one host value per tick that is a heading (second slot NaN) or a point, for bindings that cannot tell the two apart before the supplier runs. A differential base faces along its path and cannot turn in place mid-route, so route_from_json refuses aims and keyframes before a leg’s end on a differential leg. It also refuses a waypoint heading (a keyframe at the end) unless the leg ends at rest. A leg that ends at rest is the route’s last leg, an arriveWith leg, or one the next leg leaves from a stop or a wait. A heading accepted there is not driven yet, because the base does not turn in place to it. Activation fractions are fractions of the path’s distance (see above). The runtime resolves the bearing from the live pose. The wasm preview uses the planned pose on a 20 ms clock and samples between ticks without changing that clock’s state. Uncapped aims active from leg start resolve directly at each requested sample. Routed jobs retain stateful aim progress between steps and cap fresh facing evaluations at min(work, 1024) per step. Waypoint receipts carry the exact incoming heading so a junction wait holds it before the next leg’s aim activates. Fixed-angle keyframes are placed on the plan’s clock at their fraction of its distance. A following held leg carries the exit heading of a reactive-only leg. Reactive legs use the footprint’s full rotation envelope and remain separate planning groups. Differential preview headings come from the core’s travel-facing trajectory profile.

Free headings

A waypoint that names no heading (.to(x, y)) reaches the core as a leg with HeadingSpec.free_heading (route JSON rotation.freeHeading, routed preview target free_heading). Its start heading is chained from the leg before and it has no keyframe of its own. free_heading::resolve_free_headings runs in AutoRuntime::new after the Locks resolve and before the legs group into plans, and in the routed preview at the same point. It plans nothing and is linear in the legs.

  • A run of free legs with nothing after it requiring a heading keeps the heading it starts at. Its legs lose the flag, so they plan, reuse plans and replan as holding legs, bit for bit (free_headings.rs compares the command streams, and the recorded sequencing routes carry the flag with unchanged traces).
  • A run before a leg with keyframes turns toward that leg’s first winning keyframe. The turn is shared by straight-line distance over the free legs and the next leg up to the keyframe’s fraction, an estimate made before any path exists. Each plan of free legs turns at most what its turn rate (the leg’s angular limit, lowered by the keyframe’s cap) allows over its straight-line length at its top speed. A path is never shorter, so the plan never slows for its share. The required leg turns the rest from where the last plan ends. Free legs that share one plan take one spec, so they keep sharing it.
  • A run on a mecanum drive instead turns each plan to face the direction from its start to its end, forward or backward, whichever is nearer. It turns at the fraction its turn needs at the top speed and the turn rate the wheels allow (v / turn_radius, capped by the angular limit). It does not turn early for a later required heading.
  • Legs with aims, face travel, Rotation Lock spans or the narrow-spot switch, and differential legs, end a run. The runs before them keep their heading, even when a Lock starts after the locked leg’s rotation target.
  • A free leg never picks a heading to pass a narrow span. A swerve leg turns toward the next required heading or holds. A gap that fits only one way needs a waypoint heading or a Lock.

A leg that keeps the flag after the pass turns by the route’s choice. When its turn would sweep the outline against something at an end (Replanner::turn_reaches_an_end), or the turning candidate fails its certificate or finds no route, plan_route_latched_with_waypoints plans the leg again with its keyframes cleared, holding its start heading, and skips the turning retries. Where the held start heading has no route either, the turn is planned once more with the retries a required turn takes. Plan identity sets TURN_BY_CHOICE_FLAG in the heading-mode word for such legs, and rotation_eq compares the flag. Such a plan may end on its start heading instead of the one chosen. The group after it (AutoRuntime::follows_chosen_turn) is warmed and planned ahead from the chosen heading as usual, but its plan is taken only within the heading tolerance of the robot’s heading at the handoff. Otherwise it plans from where the robot is, starting from its heading. Whenever the plan holds, on the first plan or on a replan from the live heading partway through the turn, it ends short of the chosen keyframe. The leg’s stopped arrival (Replanner::is_motion_complete_with_rotation_tolerance) then reads the installed plan’s end heading instead of the chosen keyframe, as it does for planned aims. Reading the keyframe would leave the robot at rest on the plan’s end short of it, and the settle watchdog only opens once that arrival passes.

A robot held short of a heading it can never reach, by a field element or by an end heading no plan turns to, is ended by the heading-stall watchdog (AutoRuntime::heading_stall_exhausted). It opens on a leg that is not hook paced the first time Replanner::heading_short_of_arrival reports that only the heading keeps the stopped arrival from passing, when the reference clock is done and the robot is inside the arrival radius, the replan threshold. A leg turning to a live aim never reports it, since it does not wait for a heading. From then until the leg ends the watchdog keeps a best heading error and the time it was set. An error 1 deg below the best, or 5 deg above it (a push that turns the robot away), sets a new best and restarts the clock. Translation never counts, so a vision correction or a shove off the target and back keeps the clock running. Once 2 s (HEADING_STALL_S) pass with no progress, the next tick that again owes only the heading ends the leg. The leg is missed and failed and its fail case fires. The giveUps event carries cause stalled, the arrival logs as not reached, and the next leg plans from the live pose. A LegGaveUp warning reads [Tempo] leg N (target X, Y) stopped D deg short of its heading and C cm from its target, with no heading progress for 2.0 s; the leg is missed. N counts from 1, as the narrow-turn and Rotation Lock warnings do. The target is in the runtime frame. The core does not know whether its route is a Setlist connecting drive, which reads as leg 1 with the next route’s start as its target. The leg’s timeout_s and until run alongside the watchdog and win a tie. The bindings need nothing new, because they read the miss, the failure and the fail case as they do for a give-up on time. A Setlist join after such a leg compares against that leg’s arrival tolerance as after any other. A heading left outside it starts a connecting drive when the next route’s first waypoint names a heading, and a turn in place into the same obstruction stalls in turn. The 2 s window sits well clear of the longest legitimate span without heading progress in the tempo-core suite on a leg that went on to arrive, 0.12 s (measured 2026-10-25), apart from two tests that slow the robot on purpose (0.66 s and 1.90 s).

A leg a host controller paces has no reference clock, so neither the settle watchdog nor the heading-stall watchdog opens on it. The replanner’s stall watchdog judges only a robot commanded faster than 0.15 m/s. Its own progress watchdog (AutoRuntime::host_progress_exhausted) runs while the robot is outside the leg’s arrival tolerance. It keeps the best distance to the target and the best heading error, each with the time it was set. A distance 1 cm (SETTLE_IMPROVEMENT_M) below the best or a heading error 1 deg below it is progress. A reading 5 cm or 5 deg above it, a push, restarts that clock too. Once the distance has made none for 1 s and the heading none for 2 s, whatever the robot is commanded, the leg ends as a heading stall does, with the warning reading with no progress toward either for 2.0 s. A host follower whose heading correction could not beat static friction left the robot 3.1 deg short of a 3 deg tolerance sending 0.05 rad/s. The leg waited for the end of the auto period.

A route whose first leg requires no heading starts from the robot’s heading. As the first leg begins, AutoRuntime::carry_live_start_heading rewrites the start heading of the legs chained from the authored start, up to and including the first that turns on its own, and drops their prepared plans. A route that resets odometry to its start finds the two equal.

Narrow-span heading holds

HeadingSpec.no_narrow_turns enables the per-leg scheduler in trajectory/narrow_turns.rs. No binding sets it. A locked leg’s held plan does, and the hold-scheduler fixtures set it through the sequencer’s optional JSON field noNarrowTurns and the routed-preview target field no_narrow_turns. Missing fields are false. Enabled legs form separate planning groups, and plan-reuse identity includes the switch.

The scheduler reuses the planning obstacle sets and the swept-outline geometry primitives. For effective footprint vertices v, the rotational clearance is R = max(norm(v)) + obstacle_margin_m. A profiling chord is narrow when its center segment is less than R from a blocking shape, or leaves a keep-in region eroded by R. Equivalently, spare clearance beyond the body’s half-width must cover the farthest-corner radius plus the margin minus that half-width. Terrain crossing masks, endpoint terrain exemptions, avoid zones, custom obstacles and footprint extensions follow the same planning configuration. Connected narrow chords merge into holds, and required crossing headings also constrain those holds.

Candidate holds include the surrounding authored headings, intermediate angles that use the free angular time on either side, and the narrow span orientation. They are restricted to the authored turn and certified with the translated physical footprint’s convex hull on obstructed chords. A clear physical rotational disk certifies every held angle on the chord. Obstacle proximity and keep-in bounds are checked once per chord and reused across candidate angles. An angle is read against an obstacle without that hull where the outline’s points at both ends of the chord stand a micrometre apart from the obstacle along x, y, a side of the outline or the chord’s normal, and against a keep-in rectangle where they stand a micrometre inside it (Clearance::fits): the hull then stands as far off, a thousand times the nanometre its measured clearance is held to, and a chord with nothing nearer builds no hull. A chord, outline or shape with a coordinate outside the exact domain of segments_intersect, or small enough for it to read two segments as meeting, is measured. fits_tests compares 30,000 seeded chords with the measured answer. Up to 64 schedules survive each bounded search stage, ranked by the angular time missing from the available translation time. The shortest certified candidate wins. This is a bounded schedule search and does not prove a global continuous-time optimum.

Rest-to-rest analytic angular spans obey the chassis and keyframe turn-rate limits and the angular acceleration limit. AUTO turns finish as late as possible before the next hold or target. Insufficient free intervals lower local speed ceilings at a braking point and rerun the acceleration-constrained speed passes. Stopped boundaries absorb any remaining time while the turn proceeds. Translation accelerates to the highest reachable speed at narrow-span entry. Keyframe deadlines stay at their fractions of the path’s distance, placed on the retimed clock including waits, and bound the beginning and end of every angular hold.

The graph uses the held footprint’s heading, including orientations across the travel direction. Required headings take priority over a narrow hold. A leg starting inside a targeted terrain crossing receives a certified stationary alignment before translation. The runtime follows that prefix before latching the crossing heading and keeps translation stopped until the measured heading settles. If the margin leaves no feasible turn interval, field-edge repair first tries to create enough clearance. A physical-clearance schedule can then preserve holds through tight spans while reporting rotation inside the preferred margin. If no constant-heading schedule fits, the ordinary swept geometry can supply a certified partial turn inside a narrow span. Required authored turns begin as early as clearance and angular limits allow in that case. The fallback ranks turn windows by the amount of rotation inside narrow chords, retaining at most 64 schedules, and certifies each accepted schedule. A field-edge envelope that overhangs during rotation gets two inward anchors per affected authored span, clamped one micrometre inside the full rotational-clearance bounds. Authored endpoints and waypoint times retain their identities. The repair targets only field-boundary clearance. Trajectory::narrow_turn_warning carries either a relaxed hold or a boundary repair through cached and warmed plans. The auto runtime logs it once when the leg drives. WASM’s preview receipt carries the same leg-specific text to the editor’s planning status and the affected leg’s inspector. Differential trajectories ignore the option. Physically obstructed orientations still fail planning. Every accepted enabled plan, including one read from the cache or using ordinary swept geometry, must reach each winning heading where the final plan reaches its fraction of the path’s distance. At a tied fraction, only the last authored keyframe supplies a heading and turn-rate cap, matching the ordinary angular profile. Matching consecutive headings share one hold, including any crossing interval and fractional deadlines that overlap after retiming. Conflicting heading requirements return the ordinary no-route result. The hold search keeps no timing preference. It ranks held angles by drive time alone. Where a turn happens is set by the Rotation Keys that release it.

The final footprint certificate checks the resulting trajectory. Disabled legs call the ordinary planner directly, bypassing the scheduling and deadline-repair function and its stack state. Detection and scheduling do no work. Their cache keys retain the ordinary layout, and the switch takes a bit of the heading-mode word. The existing trajectory arithmetic is preserved.

Unconditional fixed point aims on enabled legs become destination-bearing constraints in the runtime and preview. Live or gated aims retain the circular rotation envelope because their future bearings are unknown. The authored rotation remains coupled to translation on differential drives.

Rotation Locks and Keys

A segment’s rotationLocks (route JSON) or a target’s rotation_locks (routed preview) lists Lock and Key markers at fractions of the leg’s path distance. rotation_locks::resolve_spans resolves them in drive order. A Lock stays in force until a Key, possibly several legs later. Each leg it touches gets a LockSpan on HeadingSpec::rotation_locks. A span carried in from an earlier leg starts at 0 and holds there. A span a Lock opens on the leg holds only after it, so a keyframe at the Lock itself is still reached. At one fraction every Lock applies before every Key, so a Lock and a Key at the same place release the robot there (ties in tests/fixtures/api/rotationLocks.json). AutoRuntime::new and the routed preview drop every keyframe inside a span, then restart the heading chain. A later leg whose authored start heading was the dropped end heading starts from the end heading the spans left. The runtime prints one line per dropped rotation target, dropped waypoint heading, aim that meets a span and Lock never released, once per route and never for a warm-up route. The preview returns the same text through take_warnings.

HeadingSpec::holds_enabled is true for a leg with the switch or any span. Every such leg plans through Replanner::plan_locked_leg when it has a span. Without the narrow-spot switch the leg first plans as the unlocked leg does, with the same sweep and path. Trajectory::constrain_narrow_headings adds one hold window per span with a free but constant heading, detecting no narrow spans. The resulting profile must pass the actual swept-footprint check. The leg also plans with the held footprint and narrow-span detection, and takes that plan when it is faster and Trajectory::narrow_outside_locks finds no chord outside the spans too narrow to turn in. The held footprint then matters only inside a span, which is how a Lock passes a narrow spot. With the switch on, the leg plans as a switched leg does with the span windows added. A span covering the leg’s start makes the leg start from rest in rotation. When no plan fits at the leg’s carried exit speed, the leg plans again ending at rest, with NarrowTurnWarning::LockSlowed. The runtime reconciles the lower exit speed into the next junction and the preview reads it from the plan. A span is never released, so a leg no plan holds every span of has no route. Each hold window starts and ends at the exact times the plan reaches the Lock and the Key (LockBound) instead of at the nearest samples. A turn the time after the Key cannot fit finishes at rest after the leg’s last sample. A replan rescales the spans ahead of the robot as it rescales keyframes. One that starts inside a span keeps the heading the active plan holds there instead of the measured one. An aim leg whose end a Lock holds ends on the heading the aim left. The runtime carries that heading into the legs after (AutoRuntime::ends_on_reactive_aim), the preview carries it as the next group’s start, and the bindings’ static exit heading reads as unknown. Locked legs never merge. Plan identity carries the spans behind a heading-mode bit, and a head plan is never made for one. HeadingSpec::holds_heading_at(fraction) answers whether a leg holds its heading at a point. It does inside a span, which every accepted plan holds exactly, and anywhere on a switched leg, whose holds sit where the path is too narrow to turn.

Inside a span the runtime and the preview stop resolving aims. The heading an aim last commanded is held (AimState::hold), or the planned hold when no aim had turned the robot. A capped aim slews again from the held heading at the Key.

Legs without any hold sweep the hull of the outline over every heading they turn through. turning_legs_without_holds_keep_the_whole_footprint_clear (rust/core/tests/rotation_locks.rs) drives 1,500 seeded shipped-pack routes and checks the placed footprint at 4,001 samples each. All 521 that plan with both ends farther than the circumradius from every obstacle stay clear. An end parked within the circumradius bounds its contact run by the turning hull’s depth at that end instead of the held outline’s. Of 664 such turning routes, 7 overlapped an obstacle mid-turn, by up to 5.6 cm (2026-10-15). With holds on, the swept-footprint certificate cleared all 692 of the same routes that planned.

esc

Loading search...