EasyStack Docs

EasyRevIMU

The EasyRevIMU class is an advanced, highly optimized wrapper for the REV Control Hub or Expansion Hub IMU (Inertial Measurement Unit).

Beyond just reading angles, this class introduces professional-grade features such as aggressive I2C caching (to save precious loop time), collision detection, anti-tip logic, and sensor fusion algorithms, allowing you to build incredibly robust autonomous and teleoperated routines.

#Initialization & Setup

When creating an EasyRevIMU, you must specify the Hub's physical orientation on the robot (where the REV logo and the USB ports are pointing) so the SDK can map the axes correctly.

Java
EasyRevIMU gyro = new EasyRevIMU(
        hardwareMap,
        "imu",
        RevHubOrientationOnRobot.LogoFacingDirection.UP,
        RevHubOrientationOnRobot.UsbFacingDirection.FORWARD
);

EasyRevIMU automatically handles the internal parameter setup and initialization inside the constructor.

#Internal I2C Caching (Performance)

Reading data from the IMU via I2C is one of the most time-consuming operations in the FTC SDK. EasyRevIMU solves this with an internal caching system.

If you call getHeading() or getAngularVelocity() multiple times within a 2-millisecond window, the class will read the physical hardware only once and return the cached value for all subsequent calls. This drastically improves your OpMode's loop times without sacrificing accuracy.

#Reading Orientation (Euler Angles)

The class provides multiple ways to read the robot's orientation in 3D space. You can request the data in either Degrees or Radians.

#Logical Heading (Yaw)

The getHeading() method returns the current Yaw angle, automatically applying any logical offsets you have set (e.g., if you reset the gyro mid-match for field-centric driving).

Java
// Returns the heading in Degrees (Default)
double currentHeading gyro.getHeading();

// Returns the heading in RADIANS
double radHeading gyro.getHeading(AngleUnit.RADIANS);

#Absolute Heading

If you need the raw, unadulterated angle directly from the hardware (ignoring software offsets but applying the inversion multiplier), use getAbsoluteHeading():

Java
 = gyro.getAbsoluteHeading();

#Reading All Axes (Pitch and Roll)

If your robot logic requires Pitch (tilt forward/backward) or Roll (tilt sideways), you can read them individually or extract all Euler angles simultaneously:

Java
// Individual axes
 = gyro.getPitch(AngleUnit.DEGREES);
double rolI gyro.getRoll(AngleUnit.DEGREES);
Java
// Returns a double array containing [Yaw,  Pitch,  Roll] in that exact order
double[] allAngles - gyro.getAngles();

#Reading Angular Velocity

EasyRevIMU can measure how fast the robot is rotating around its axes. This is extremely useful for PID damping (the 'D' term) or calculating Feedforward.

Java
// Returns the rotation speed around the Z axis (Yaw) in DEGREES per Second
 = gyro.getAngularVelocity(AngleUnit.DEGREES);

// Returns speeds for all 3 axes [X, Y, Z]
double[] allSpeeds gyro.getAngularVelocities(AngleUnit.RADIANS);

#Advanced Features: Collision & Motion Detection

The EasyRevIMU includes extraordinary physics-based detection methods that monitor the rate of change in velocity (Jerk) to detect sudden impacts or unsafe states.

#Collision Detection

By calculating rotational jerk, the robot can detect if it has violently hit a wall or another robot.

Java
// Returns true if the rotational jerk exceeds 500 degrees/sec^2
if (gyro.detectCollision(500.0, AngleUnit.DEGREES)) {
    // We hit something! Stop the motors to prevent breaking
    drivetrain.stop();
}

#Anti-Tip System

You can monitor the Pitch and Roll axes to prevent the robot from falling over when extending heavy arms or driving over obstacles.

Java

// Returns true if the robot tilts more than 15 degrees in any direction

if (gyro.isTipping(15.0, AngleUnit.DEGREES)) {

// The robot is about to fall! Automatically lower the elevator

elevator.emergencyRetract();

}

#Stationary Detection

Checks all 3 axes of angular velocity to determine if the robot is perfectly still. This is highly recommended before resetting encoders or firing an autonomous sequence.

Java

// Returns true if the total angular movement is less than 2 degrees/sec

if (gyro.isStationary(2.0, AngleUnit.DEGREES)) {

armEncoder.zero(); // Safe to calibrate!

}

Last updated 2026-11-16

EasyStack - FTC Java library

This site records page views of visitors to understand how the documentation is used. Nothing is sold or shared with third parties.