// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.

package org.wpilib.snippets.onboardimu;

import org.wpilib.framework.TimedRobot;
import org.wpilib.hardware.imu.OnboardIMU;
import org.wpilib.hardware.imu.OnboardIMU.MountOrientation;

/**
 * on board IMU snippets for wpilib-docs.
 * https://docs.wpilib.org/en/stable/docs/software/hardware-apis/sensors/accelerometers-software.html
 */
public class Robot extends TimedRobot {
  // Creates an object for the on board IMU
  OnboardIMU iMU = new OnboardIMU(MountOrientation.FLAT);

  /** Called once at the beginning of the robot program. */
  public Robot() {}

  @Override
  public void teleopPeriodic() {
    // Gets the current acceleration in the X axis
    iMU.getAccelX();
    // Gets the current acceleration in the Y axis
    iMU.getAccelY();
    // Gets the current acceleration in the Z axis
    iMU.getAccelZ();

    // Gets the current angle in the X axis
    iMU.getAngleX();
    // Gets the current angle in the Y axis
    iMU.getAngleY();
    // Gets the current angle in the Z axis
    iMU.getAngleZ();

    // Gets the current angle as a Rotation2D
    iMU.getRotation2d();
  }
}
