Introduction to Pose Estimation
What is Pose Estimation?
Pose estimation is knowing where the robot is on the field: position (X and Y, usually meters) and heading (which way the front points). Autos, path following, and alignment to game elements all need a pose that updates over time.
Without it, wheel commands do not know if the robot reached the right spot. With a good estimate, you can drive to coordinates, follow splines, and branch logic on field location.
WPILib: Odometry and Pose Estimation
What is a Pose?
Position (X, Y): Distance from the field origin along each axis. Convention depends on the year’s field layout; WPILib documents which corner is (0, 0).
Heading: Rotation in the plane—degrees or radians, positive counterclockwise from the field +X axis in the standard WPILib field frame.
WPILib packs both into Pose2d (Translation2d + Rotation2d).
Basic Pose Representation
package frc.robot.examples;
import edu.wpi.first.math.geometry.Pose2d;
import edu.wpi.first.math.geometry.Rotation2d;
import edu.wpi.first.math.geometry.Transform2d;
import edu.wpi.first.math.geometry.Translation2d;
public class PoseExample {
public static void main(String[] args) {
Pose2d robotPose = new Pose2d(
new Translation2d(2.0, 3.0), // X = 2.0m, Y = 3.0m
Rotation2d.fromDegrees(45.0) // Heading = 45 degrees
);
double x = robotPose.getX(); // 2.0
double y = robotPose.getY(); // 3.0
double headingDegrees = robotPose.getRotation().getDegrees(); // 45.0
double headingRadians = robotPose.getRotation().getRadians();
Pose2d originPose = new Pose2d(0.0, 0.0, Rotation2d.fromDegrees(0.0));
// Transform poses (move and rotate)
Pose2d transformedPose = originPose.transformBy(
new Transform2d(1.0, 0.5, Rotation2d.fromDegrees(90.0))
);
}
}
Coordinate Systems
Field frame: Fixed origin on the carpet. Alliance color can flip which corner is (0, 0); see WPILib Coordinate Systems.
Robot frame: X usually out the front of the robot. Sensor offsets and vision transforms are defined robot-relative, then converted to field coordinates for autos.
Methods of Pose Estimation
Odometry: Integrate wheel travel and gyro heading (dead reckoning). Updates every robot loop; drifts when wheels slip or constants are wrong.
Vision: Cameras see AprilTags (or other landmarks) and solve for robot pose on the field. Absolute when tags are visible; rate and accuracy depend on exposure, distance, and how many tags you see.
Fusion: Run odometry continuously and blend in vision when it is valid. WPILib PoseEstimator classes handle the weighting if you pass sensible standard deviations.
Common Applications in FRC
- Autos and path following to field coordinates
- Scoring alignment and staged pickup positions
- Logic that depends on where you are (defense, cycle routing)
Simple Pose Tracking Example
package frc.robot.examples;
import edu.wpi.first.math.geometry.Pose2d;
import edu.wpi.first.math.geometry.Rotation2d;
public class SimplePoseTracking {
private Pose2d m_currentPose;
public SimplePoseTracking() {
m_currentPose = new Pose2d(0.0, 0.0, Rotation2d.fromDegrees(0.0));
}
/**
* Update robot pose (called every robot loop)
* In real implementation, this would use odometry or vision updates
*/
public void updatePose(Pose2d newPose) {
m_currentPose = newPose;
}
/**
* Get current robot pose
*/
public Pose2d getPose() {
return m_currentPose;
}
/**
* Check if robot is at target position (within tolerance)
*/
public boolean isAtPosition(Pose2d targetPose, double positionTolerance, double angleTolerance) {
double distance = m_currentPose.getTranslation().getDistance(targetPose.getTranslation());
double angleError = Math.abs(
m_currentPose.getRotation().minus(targetPose.getRotation()).getDegrees()
);
return distance < positionTolerance && angleError < angleTolerance;
}
/**
* Calculate distance to target position
*/
public double getDistanceToTarget(Pose2d targetPose) {
return m_currentPose.getTranslation().getDistance(targetPose.getTranslation());
}
}
Key Concepts
Pose: (x, y, θ) on the field—Pose2d in code.
Frames: Field-centric for paths and autos; robot-centric for driver-centric drive and mounting cameras.
Localization: Any method that updates pose; fusion is the usual competition setup.
Field-centric driving: Joystick “forward” moves along the field, not along the robot nose, once pose and gyro are wired correctly.