3.6 Point to point
Tempo.to(target) (tempo::Tempo::to in C++) builds a route with no start pose. Every time
it starts, it drives from wherever the robot is to the target, around the field’s obstacles.
Bind a drive to a button
import com.tempo.Tempo;
driver.a().whileTrue(Tempo.to(BRANCH_G).command());from tempo import Tempo
driver.a().whileTrue(Tempo.to(BRANCH_G).command())#include <tempo/Tempo.h>
#include <tempo/wpi/Setlist.h>
driver_.A().WhileTrue(tempo::wpi::command(tempo::Tempo::to(BRANCH_G)));The robot drives to BRANCH_G while the button is held. Letting go cancels the command and
the robot stops. BRANCH_G is a Pose2d from your robot code. It’s written for the blue
alliance like any other waypoint and is mirrored on red.
Tempo.to returns a normal Composer, so the options and
hooks of any other route
work on it, and more to(...) calls add more waypoints. A speed(...) or limits(...)
written right after Tempo.to(target) applies to the drive to that target too.
A Tempo.to route has no name, so it isn’t in TempoAutos. If
you want one there, write Composer.named("Approach").to(target) (tempo::Composer::named
in C++).
Targets
to(...) takes the same targets as any route, and it also takes a function that returns the
target. The function is called once, when the route starts.
import com.tempo.Tempo;
driver.rightBumper().whileTrue(
Tempo.to(() -> Reef.nearestBranch(drive.getPose())).command());from tempo import Tempo
driver.rightBumper().whileTrue(
Tempo.to(lambda: reef.nearest_branch(drive.get_pose())).command())#include <tempo/Tempo.h>
#include <tempo/wpi/Setlist.h>
driver_.RightBumper().WhileTrue(tempo::wpi::command(tempo::Tempo::to([this] {
return reef_.NearestBranch(drive_.GetPose());
})));nearestBranch stands in for a function in your own robot code. The target it returns is
never mirrored, so return it for the alliance the robot is on.
If the function returns no target (null, None or an empty optional) or throws, the drive
fails without moving the robot. The leg’s runOnFailure runs and Tempo prints a [Tempo]
line to the console.
Ending the drive
import static edu.wpi.first.units.Units.Degrees;
import static edu.wpi.first.units.Units.Meters;
import static edu.wpi.first.units.Units.Seconds;
Tempo.to(BRANCH_G)
.arriveWithin(Meters.of(0.03), Degrees.of(2))
.giveUpAfter(Seconds.of(3));import math
(Tempo.to(BRANCH_G)
.arrive_within(0.03, math.radians(2))
.give_up_after(3.0))#include <numbers>
tempo::Tempo::to(BRANCH_G)
.arrive_within(0.03, 2.0 * std::numbers::pi / 180.0)
.give_up_after(3.0);The drive ends when the robot is inside the target’s arrival tolerance, or when giveUpAfter
runs out. Without arriveWithin, the tolerance is the one set with
TempoConfig.withTolerance(...), 5 cm and 3 degrees unless changed. A robot that settles just
outside it can still count as arrived
(Missed arrivals).
In Python and C++, arrive_within takes meters and radians.
Inside an auto
import com.tempo.Tempo;
import com.tempo.wpi.Setlist;
Setlist twoPiece = Setlist.named("Two Piece")
.drive(toReef)
.then(superstructure.scoreL4())
.drive(Tempo.to(CORAL_STATION))
.then(superstructure.intake());from tempo import Tempo
from tempo.wpi import Setlist
two_piece = (Setlist.named("Two Piece")
.drive(to_reef)
.then(superstructure.score_l4())
.drive(Tempo.to(CORAL_STATION))
.then(superstructure.intake()))#include <tempo/wpi/Setlist.h>
#include <tempo/Tempo.h>
tempo::Setlist two_piece = tempo::Setlist::named("Two Piece")
.drive(to_reef)
.then(superstructure_.ScoreL4())
.drive(tempo::Tempo::to(CORAL_STATION))
.then(superstructure_.Intake());In a Setlist, a Tempo.to route starts wherever the step before it
left the robot, so it can come right after one of your own drivetrain commands. For one target
with no options, .to(CORAL_STATION) on the Setlist
is the same step.
A route with no start pose can’t reset odometry, and resetOdometry(true) on one throws. Set
the pose with your drivetrain’s own pose reset before the auto starts.
The route is planned when it starts, and the robot holds still until the plan is ready. A
warmed auto can plan a Tempo.to route
that runs first while the robot is disabled, from where the robot is sitting.
In simulation, a route with no start pose needs SimRun.of(route).startingAt(pose)
(starting_at in Python and C++) to say where the robot starts, and the run throws without it
(Simulation).