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

4.17 Bias

Bias.toward(direction, reach) (Bias::Toward in C++) sets the direction the path passes through a waypoint and how far that direction holds. This route is in REEFSCAPE 2025 coordinates, so it needs the REEFSCAPE 2025 pack loaded.

Java
import static edu.wpi.first.units.Units.Degrees;
import static edu.wpi.first.units.Units.Meters;

import com.tempo.Bias;
import com.tempo.Composer;
import edu.wpi.first.math.geometry.Pose2d;
import edu.wpi.first.math.geometry.Rotation2d;

var route = Composer.startAt(new Pose2d(7.58, 5.85, Rotation2d.fromDegrees(180)),
        Bias.toward(Degrees.of(180), Meters.of(1.0)))
    .to(6.20, 4.00, Bias.toward(Degrees.of(-90), Meters.of(0.8)))
    .to(5.13, 5.14, Rotation2d.fromDegrees(-120));
Python
from tempo import Bias, Composer
from tempo.angles import deg
from wpimath.geometry import Pose2d

route = (Composer.start_at(Pose2d(7.58, 5.85, deg(180)), Bias.toward(deg(180), 1.0))
    .to(6.20, 4.00, Bias.toward(deg(-90), 0.8))
    .to(5.13, 5.14, deg(-120)))
C++
#include <tempo/Angles.h>
#include <tempo/Bias.h>
#include <tempo/Composer.h>

auto route = tempo::Composer::start_at(7.58, 5.85, tempo::angles::deg(180),
        tempo::Bias::Toward(180_deg, 1.0_m))
    .to(6.20, 4.00, tempo::Bias::Toward(-90_deg, 0.8_m))
    .to(5.13, 5.14, tempo::angles::deg(-120));

Factories

LanguageDirectionReach
Java Bias.toward(direction, reach), six overloadsdouble radians, Rotation2d or Angledouble meters or Distance
Python Bias.toward(direction, reach)radians as a number, deg(...) from tempo.angles, or a wpimath Rotation2dmeters as a number
C++ tempo::Bias::Toward(direction, reach)double radians, frc::Rotation2d, or any angle unit (30_deg)double meters or any length unit (0.8_m)

The C++ unit overloads and the _deg and _m literals come from the WPILib units headers (Geometry and units).

AccessorJavaPythonC++
Direction, radians in the authored field framedirectionRad()direction_raddirection_rad()
Reach, metersreachM()reach_mreach_m()

A Bias is immutable and compares by value.

ArgumentMessageThrown as
Reach zero, negative, NaN or infiniteBias reach must be a positive, finite distance.IllegalArgumentException, ValueError, std::invalid_argument
Direction NaN or infiniteBias direction must be a finite angle.the same

A null direction or reach throws NullPointerException in Java.

In Python, None raises ValueError, and a bool direction raises TypeError.

Where it goes

A Bias is always the last argument.

CallJavaPythonC++
Start posestartAt(pose, bias), startAt(x, y, heading, bias)start_at(pose, bias), start_at(x, y, heading_rad, bias)start_at(pose, bias), start_at(x, y, heading_rad, bias)
Waypointto(x, y, bias), to(x, y, heading, bias), to(translation, bias), to(pose, bias)the same, or bias=the same
Point to pointTempo.to(x, y, bias), Tempo.to(x, y, heading, bias), Tempo.to(translation, bias), Tempo.to(pose, bias)Tempo.to(..., bias)Tempo::to(..., bias)

The builder that Composer.named(name) returns (Composer::named in C++) has the same startAt and to forms.

Heading inJavaPythonC++
startAt(x, y, heading, bias)Rotation2d or radiansradiansradians
to(x, y, heading, bias)Rotation2dradians or Rotation2dradians

Behavior

  • The waypoint doesn’t move. The leg arriving ends along the direction and the leg leaving starts along it.
  • A longer reach holds the direction longer and swings wider before the curve bends toward the next point. A reach longer than the distance to the neighboring waypoint is cut to that distance.
  • On the last waypoint, the direction is the one the robot is traveling in as it arrives.
  • A start bias is the direction the first leg leaves the start in when the robot starts the route from rest, and a robot that’s already moving leaves along its velocity.
  • The direction is written for the route’s origin alliance and mirrors with the route for the other alliance.
  • A STRAIGHT leg takes no bias. A bias at a waypoint where a STRAIGHT leg meets a curved one shapes only the curved leg, and only when the robot stops at that waypoint. When the robot drives through, the bias does nothing. Neither case prints a warning.

Collisions

When the biased curve would hit an obstacle, Tempo tries shorter reaches before it drops the bias. If a shorter reach clears, the runtime log prints:

[Tempo] leg 2: the bias at this waypoint was shortened to clear an obstacle.

When no shorter bias clears, the leg is planned around the obstacle without the bias:

[Tempo] leg 2: the bias at this waypoint would collide, so the path routes around it without the bias.

The second message ends without the bias and stops there. when the robot then stops at a waypoint it would have driven through. leg N names the waypoint that leg N ends at, counting from 1. A start bias’s warnings begin with start:. Tempo’s GUI shows the same warnings on the handle, opening Leg N: and Start:.

Differential drives

A differential drive takes a waypoint bias the same way, but it leaves the start along its heading, so a start bias must point along the start heading or straight back from it. The two must agree to about 0.006 degrees, so an angle written in radians to four decimal places passes. A bias straight back backs the robot out. Any other direction throws IllegalStateException, RuntimeError or std::logic_error when the route freezes:

[Tempo] leg 1: a differential drivetrain leaves its start along its heading, so a start bias must point along the start heading or straight back from it; turn the bias or remove it
esc

Loading search...