Examples

Use-Case

This example program demonstrates how to use the AndyMark IMU in an FTC OpMode. It initializes the sensor from the robot’s hardware map and continuously reads orientation and motion data while the OpMode is active. The IMU provides information such as angular orientation (heading, pitch, and roll), angular velocity, and linear acceleration. These values are updated in real time and displayed on the Driver Station screen, allowing users to see exactly how their robot is rotating and moving.

This example is especially useful for testing the IMU, understanding its output format, and verifying sensor mounting orientation. Teams can use it to develop field-centric drive systems, balance mechanisms, or autonomous routines that require precise robot orientation. Because the program is designed for direct sensor feedback, it can also be used as a diagnostic or learning tool without requiring advanced programming knowledge.

Mounting Examples

Configuration

Code Example

public class AndyMarkIMU extends LinearOpMode 
{
    private AndyMarkIMU sensor_IMU;

    @Override
    public void runOpMode() 
    {
        // Initialize the sensor from hardware map
        sensor_IMU = hardwareMap.get(AndyMarkIMU.class, "sensor_imu");

        // Initialize sensor
        sensor.initialize();

        waitForStart();

        while (opModeIsActive()) 
        {
            // Get orientation in degrees
            YawPitchRollAngles orientation = sensor_IMU.getRobotYawPitchRollAngles();

            double heading = orientation.getYaw(AngleUnit.DEGREES);  // Same as yaw
            double pitch   = orientation.getPitch(AngleUnit.DEGREES);
            double roll    = orientation.getRoll(AngleUnit.DEGREES);

            // Display orientation data
            telemetry.addData("Heading", "%.1f", heading);
            telemetry.addData("Pitch", "%.1f", pitch);
            telemetry.addData("Roll", "%.1f", roll);
            telemetry.update();
        }
    }
}

Last updated

Was this helpful?