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

4.24 Mirroring

Field.mirror flips a point or pose to the other alliance’s side of the field.

Java
import com.tempo.Field;
import edu.wpi.first.math.geometry.Pose2d;
import edu.wpi.first.math.geometry.Rotation2d;
import edu.wpi.first.math.geometry.Translation2d;

// (13.059, 4.026) on the REEFSCAPE 2025 pack
Translation2d redReef = Field.mirror(new Translation2d(4.489, 4.026));
Pose2d redPose = Field.mirror(new Pose2d(3.21, 4.03, new Rotation2d()));
Translation2d center = Field.center();
Python
from tempo import Field
from wpimath.geometry import Pose2d, Translation2d

# (13.059, 4.026) on the REEFSCAPE 2025 pack
red_reef = Field.mirror(Translation2d(4.489, 4.026))
red_pose = Field.mirror(Pose2d(3.21, 4.03, 0.0))
center = Field.center()
C++
#include <tempo/Field.h>
#include <tempo/wpi/Geometry.h>

// (13.059, 4.026) on the REEFSCAPE 2025 pack
frc::Translation2d red_reef = tempo::Field::mirror(frc::Translation2d{4.489_m, 4.026_m});
frc::Pose2d red_pose = tempo::Field::mirror(frc::Pose2d{3.21_m, 4.03_m, 0_deg});
frc::Translation2d center = tempo::wpi::field_center();

Field.mirror takes a WPILib Translation2d or Pose2d and returns the same type.

Python also accepts an (x, y) or (x, y, heading_rad) tuple and returns a Translation2d or Pose2d.

Configure Tempo first, because the symmetry and pivot come from the loaded pack. The samples use the REEFSCAPE 2025 pack.

Field.center() (C++ tempo::wpi::field_center()) returns the pivot. That’s the pack’s fieldCenterM if it’s set and the geometric center if it isn’t, and it’s always (0, 0) for a fieldCenter origin.

C++ also has tempo::Mirroring for an explicit pivot.

Routes mirror according to originAlliance, so don’t also mirror a pose by hand before passing it to a route. A direct Replanner mirrors nothing.

Field size and zones

Java and PythonC++Returns
Field.length()Field::length()The field length in meters
Field.width()Field::width()The field width in meters
Field.contains(zoneId, point)Field::contains(zone_id, point)Whether a Translation2d is inside the named region, as pointInZone answers it

Formula

For a pose (x, y, theta) and pivot (cx, cy), with wrap_pi keeping the heading in [-pi, pi]:

Pack symmetryx'y'theta'
rotational or none2 * cx - x2 * cy - ywrap_pi(theta + pi)
mirror2 * cx - xywrap_pi(pi - theta)
esc

Loading search...