Class LightningIMU

  • All Implemented Interfaces:
    edu.wpi.first.util.sendable.Sendable, edu.wpi.first.wpilibj2.command.Subsystem

    public class LightningIMU
    extends edu.wpi.first.wpilibj2.command.SubsystemBase
    Base gyroscope type. Supports the NavX and the Pigeon.
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static interface  LightningIMU.IMUFunction
      A generic function on the IMU to support lambda structure
      static class  LightningIMU.IMUType
      Supported IMU types
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      edu.wpi.first.math.geometry.Rotation2d getHeading()
      Get the IMU heading as a Rotation2d.
      LightningIMU.IMUType getType()  
      java.util.function.Supplier<edu.wpi.first.math.geometry.Rotation2d> heading()
      A function that can be used to get the heading of the IMU
      static LightningIMU navX()
      Creates a new NavX.
      static LightningIMU none()
      Creates a static IMU
      void periodic()  
      static LightningIMU pigeon​(int id)
      Creates a new Pigeon with the given ID.
      void reset()
      Reset IMU heading to 0
      LightningIMU.IMUFunction zero()
      Function to reset IMU heading
      • Methods inherited from class edu.wpi.first.wpilibj2.command.SubsystemBase

        addChild, getName, getSubsystem, initSendable, setName, setSubsystem
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface edu.wpi.first.wpilibj2.command.Subsystem

        getCurrentCommand, getDefaultCommand, register, setDefaultCommand, simulationPeriodic
    • Method Detail

      • pigeon

        public static LightningIMU pigeon​(int id)
        Creates a new Pigeon with the given ID.
        Parameters:
        id - CAN ID of the Pigeon
        Returns:
        IMU object configured for a Pigeon
      • navX

        public static LightningIMU navX()
        Creates a new NavX.
        Returns:
        IMU object configured for the NavX (SPI)
      • none

        public static LightningIMU none()
        Creates a static IMU
        Returns:
        IMU object that effectively does nothing
      • getHeading

        public edu.wpi.first.math.geometry.Rotation2d getHeading()
        Get the IMU heading as a Rotation2d.
        Returns:
        The heading
      • heading

        public java.util.function.Supplier<edu.wpi.first.math.geometry.Rotation2d> heading()
        A function that can be used to get the heading of the IMU
        Returns:
        A supplier of Rotation2d objects.
      • reset

        public void reset()
        Reset IMU heading to 0
      • periodic

        public void periodic()