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

3.9 Hand off the arrival

arriveWith hands the end of a leg to a drivetrain command from your robot code, like a vision align. Tempo stops driving at the handover, and the leg ends when the command ends. The examples use REEF_G from Write the first auto.

Hand off at a fraction

Tempo drives 85% of the way to REEF_G and the vision align drives the rest. The coral is released after the align ends.

Java
route.to(REEF_G)
    .arriveWith(0.85, drive.visionAlign(REEF_G))   // the align drives the last 15%
    .runAfter(coral.release());
Python
(route.to(REEF_G)
    .arrive_with(0.85, drive.vision_align(REEF_G))   # the align drives the last 15%
    .run_after(coral.release()))
C++
// align_ and release_ are stored frc2::CommandPtr members.
route.to(REEF_G)
    .arrive_with(0.85, align_.get())   // the align drives the last 15%
    .run_after(release_.get());

The fraction runs from 0 at the previous waypoint to 1 at this one, the same as Condition.progress. The arriveWith command may require the drivetrain. Other hooks can’t.

Tempo mirrors the route’s waypoint on red, but it can’t mirror a pose inside your command. The command has to use the right pose for its alliance, and Field.mirror flips a blue pose to the red side.

Hand off at the waypoint

If you leave out the fraction, the handover happens where Tempo’s own drive would have ended the leg. Normally that’s when the robot gets inside the leg’s arrival tolerance.

Java
route.to(REEF_G)
    .arriveWith(drive.visionAlign(REEF_G))
    .runAfter(coral.release());
Python
(route.to(REEF_G)
    .arrive_with(drive.vision_align(REEF_G))
    .run_after(coral.release()))
C++
route.to(REEF_G)
    .arrive_with(align_.get())
    .run_after(release_.get());

Java also accepts a factory that makes the command at the handover. After the factory, list the subsystems its command needs besides the drivetrain:

Java
route.to(REEF_G)
    .arriveWith(drive::alignCommand, vision)
    .runAfter(coral.release());

Python also accepts a factory, and any callable that isn’t a command is treated as one. If its command needs subsystems besides the drivetrain, list them as requirements=[...]:

Python
(route.to(REEF_G)
    .arrive_with(drive.align_command, requirements=[vision])
    .run_after(coral.release()))

C++ takes only a command.

After the command ends

When the command ends, any position triggers on the leg that haven’t fired yet fire in the order they were declared. Then the waypoint’s runAfter commands run. If the leg still has a crossing with a target the command didn’t drive, the leg has failed. Those triggers don’t fire, runAfter is skipped and runOnFailure runs.

The next leg starts from where the command left the robot. If that’s too far from the waypoint for the plan Tempo already made, Tempo plans again and the robot holds still while it does.

The preview and simulated runs in Tempo’s GUI assume the command reaches the waypoint. A SimRun places the robot at the waypoint at the handover, at rest and at the waypoint’s heading if it has one. The next leg starts there.

Time limits and failures

giveUpAfter still applies to the leg. When it runs out the command is interrupted, the leg counts as failed and runOnFailure runs. endWhen also ends the leg and interrupts the command. In both cases the unfired position triggers don’t fire.

The stall check is off while the command drives. A command that never ends keeps the auto from starting the next leg until giveUpAfter runs out, or for the rest of the auto if the leg has none.

A second arriveWith on a waypoint, a fraction outside 0 to 1 or a missing command throws at the call.

If a running hook uses WPILib’s kCancelIncoming (CANCEL_INCOMING on 2027 alpha-7 and beyond) and shares a subsystem with the arriveWith command, the command doesn’t start. Tempo prints one line naming both and drives the arrival itself.

If your drivetrain command isn’t part of reaching a waypoint, like a drive between two routes, put it in a Setlist .then(...) step.

esc

Loading search...