1.3 Connect the drivetrain
1. Give Tempo the drivetrain
Tempo drives the robot through four methods of your drivetrain:
- One that returns the robot’s pose on the field.
- One that resets the pose to a given pose.
- One that returns the measured robot-relative chassis speeds.
- One that drives at robot-relative chassis speeds.
Pass them to Tempo.configure(...) (tempo::wpi::configure(...) in C++) in
that order, then the config and the subsystem. The call can go anywhere in
your robot code that runs once at startup, before any routes are built. This example is in your drivetrain subsystem, below
the CONFIG (kConfig in C++) from
Configure the robot.
import com.tempo.Tempo;
// Once at startup, before any route is built.
Tempo.configure(
this::getPose,
this::resetPose,
this::getRobotRelativeSpeeds,
this::runVelocity,
CONFIG,
this);from tempo import Tempo
# Once at startup, before any route is built.
Tempo.configure(
self.get_pose,
self.reset_pose,
self.get_robot_relative_speeds,
self.run_velocity,
CONFIG,
self)#include <tempo/Tempo.h>
#include <tempo/wpi/Setlist.h>
// Once at startup, before any route is built.
tempo::wpi::configure(
[this] { return GetPose(); },
[this](const frc::Pose2d& pose) { ResetPose(pose); },
[this] { return GetRobotRelativeSpeeds(); },
[this](const frc::ChassisSpeeds& speeds) { RunVelocity(speeds); },
kConfig,
{this});From another class, write the four methods through your drivetrain object and pass that object last:
Tempo.configure(
drive::getPose,
drive::resetPose,
drive::getRobotRelativeSpeeds,
drive::runVelocity,
CONFIG,
drive);Tempo.configure(
drive.get_pose,
drive.reset_pose,
drive.get_robot_relative_speeds,
drive.run_velocity,
CONFIG,
drive)In C++ the lambdas call the drivetrain object, as in
[this] { return m_drive.GetPose(); }, and the last argument is {&m_drive}.
<tempo/wpi/Setlist.h> is the header that declares tempo::wpi::configure
(the WPILib-side Setlist).
The arguments are in the same order as PathPlanner’s
AutoBuilder.configure(...): the pose supplier, the pose reset, the
robot-relative speeds supplier and the robot-relative output, the config, and the drive subsystem
last. The output takes only the speeds, with no feedforwards argument.
There’s no path-following controller argument, because the gains are
part of the config. The alliance check is optional
and goes between the config and the subsystem, like AllianceFlipUtil::shouldFlip.
Without it, Tempo reads the alliance from the Driver Station.
If Tempo’s GUI generates your config, the fifth argument is its CONFIG
(kConfig in C++), named through the file you gave the robot config, like
Constants.CONFIG. The GUI’s setup guide has the call to copy. See
Export robot code.
If your robot doesn’t use the command scheduler, leave out the subsystem. See Without the command scheduler.
On WPILib 2027 the speeds type is ChassisVelocities. See
2026 vs 2027.
2. Check the connection
- Drive forward while facing 0 degrees and the pose’s x should go up.
- Turn counterclockwise and the heading should go up.
- Calling your velocity method with a positive x speed should drive the
robot forward, whichever way it’s facing. A positive y speed (
vy) should move it to its left.
Pass the speeds straight to swerve kinematics or the differential-drive wheel-speed conversion. If you treat them as field-relative and convert them, they get rotated by the robot’s heading and the robot drives off in the wrong direction.
The Tempo reference has every form of
Tempo.configure(...) and the rules for each method.
3. Raise the loop priority
If you’re on a roboRIO, raise the robot thread’s priority as the last line of robot init. If you don’t, Tempo prints a warning on the first loop it runs in. These are the WPILib 2026 calls. Run the robot loop at real-time priority has the call for WPILib 2027 and SystemCore.
import edu.wpi.first.wpilibj.Threads;
// Robot.java: last line of the constructor or robotInit().
Threads.setCurrentThreadPriority(true, 99);import wpilib
# robot.py: last line of robotInit().
wpilib.setCurrentThreadPriority(True, 99)#include <frc/Threads.h>
// Robot.cpp: last line of the constructor or RobotInit().
frc::SetCurrentThreadPriority(true, 99);This isn’t absolutely required… but it helps keep your robot loop on time.
If it fails…
The velocity method treats the speeds as field-relative and converts them. Pass them straight to kinematics.
The pose getter didn’t show the reset within 0.5 s, so the route drove from the pose it returned and Tempo printed [Tempo] the pose getter still reported ....
Raise the robot thread priority as the last line of robot init.
Planning is running inside the robot loop, or a blocking call starves it.