Examples
Was this helpful?
Was this helpful?
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();
}
}
}