2.3 Replanning
When the robot drifts too far off its planned path, Tempo plans a way back onto it and the robot follows the path from there. The new plan uses the same field, footprint and route constraints as the first one. Replanning can’t fix a bad pose estimate. It also can’t avoid other robots, because a plan only routes around the game pack’s field elements and the route’s avoid zones.
Small tracking errors don’t need a replan, because the follower corrects them every loop. Replanning’s settings are in ReplanningConfigs, and a leg can have its own or turn replanning off (Composer).
When a replan starts
A replan starts when the robot is farther from its path than the drift threshold, which is about 0.25 m for the robot from Configure the robot. Tempo’s standard followers also replan when the robot falls behind schedule, more than twice the threshold behind where the path has it at that time.
Replans are at least 0.10 s apart by default and only one runs at a time. The new plan starts at the robot’s pose and keeps the leg’s remaining waypoints, terrain crossings and constraints. The old plan keeps driving until the new one is ready, and then the robot blends into it over 0.25 s by default.
If the pose jumps more than 0.75 m in one loop, Tempo replans right away. The robot holds still until that plan is ready and then follows it with no blend.
Getting back on the path
A replan gets back on the path the leg was driving, so a shaped path like a sweep over game pieces keeps its shape after the robot gets pushed. The robot drives a short connector to a point on the path ahead, then follows the original path and headings from there. That point is at most 1.5 m past the robot’s nearest point on the path, plus half a second at its current speed. It’s never past a waypoint the robot hasn’t reached or past the start of a crossing it hasn’t entered.
A robot within 5 cm of the path with nothing in the way picks the path up where it is. Commands and rotation targets on the part of the path the connector skips still run.
If no connector works, the replan drives a new path to the leg’s target and the console prints:
[Tempo] no clear way back onto the planned path ahead; driving a new path to the targetIt prints again only after a later replan gets back on the path.
A replan also drives a new path, with nothing printed, when:
- less than 0.5 m of path is left
- the robot is pressed into an obstacle’s or the field edge’s clearance
- the robot is inside a crossing it hasn’t finished
- a crossing ahead has a target with a heading and the path hasn’t finished turning toward it (this one prints the message too)
- the leg is on a mecanum drive and has an aim target or a rotation target
- the leg is still driving its opening plan from
openingFirst
With mode(ReplanMode.NEW_PATH) every replan drives a new path to the leg’s
target, and the message never prints.
When the pose is lost
If the pose has a NaN coordinate or heading, Tempo sends zero speeds until it’s valid again. While it’s lost, these pause:
- the leg’s planned motion, custom controllers and stall timers
- arrival, position and progress conditions, a
leg’s
endWhenandCondition.when - live aim targets
The auto clock, Condition.matchTime,
giveUpAfter deadlines and a
Setlist’s own endWhen and Condition.when keep running.
A leg whose deadline runs out while the pose is lost fails. Its
runOnFailure commands start and the route goes on to the next leg.
Otherwise the leg picks up where it paused when the pose comes back, and it
speeds up within its acceleration limit.
When replanning fails
If a replan fails, Tempo tries again after 0.10 s. While the robot is within three drift thresholds of its path (0.75 m at the default), it keeps driving the current plan.
Farther off than that, or after a pose jump, the robot slows to a stop and replans from there. That plan can turn the robot in place first. If there’s still no path 0.75 s after it stopped, the leg fails as a stall.
A replan made while the robot is on terrain the leg doesn’t cross() leaves
that terrain by its nearest edge, or fails.
In Java, route.handle().replanFailed() tells you a replan failed during the
run. Every language logs a replans event with installed set to false
(TempoLogging).
If a leg’s first plan fails, the leg is skipped (The auto finished but the robot did nothing).
Pre-planning
While a route drives, Tempo plans the next two legs from where they’re
expected to start (preplanAhead
changes how many). Legs that share one trajectory count as one.
A route’s first pre-planned leg is used when the robot starts within the route’s arrival tolerance of the planned start. That’s never more than 0.30 m or 3 degrees. A later leg is used when the robot is within 0.30 m of where it was expected. Otherwise the leg is planned again from the robot’s pose.
If it fails…
No connector back onto the path works, so the replan drives a new path to the leg’s target.
Close to its path the robot keeps the current plan. Farther off or after a pose jump, it stops and replans from there. If there’s still no path, the leg fails as a stall. Pair the leg with failure handling.
Raise the drift threshold (drift) or lower the rate (rate).