Class LightningIMU
- java.lang.Object
-
- edu.wpi.first.wpilibj2.command.SubsystemBase
-
- com.lightningrobotics.common.subsystem.core.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 theNavX
and thePigeon
.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
LightningIMU.IMUFunction
A generic function on the IMU to support lambda structurestatic 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 aRotation2d
.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 IMUstatic LightningIMU
navX()
Creates a newNavX
.static LightningIMU
none()
Creates a static IMUvoid
periodic()
static LightningIMU
pigeon(int id)
Creates a newPigeon
with the given ID.void
reset()
Reset IMU heading to 0LightningIMU.IMUFunction
zero()
Function to reset IMU heading-
Methods inherited from class edu.wpi.first.wpilibj2.command.SubsystemBase
addChild, getName, getSubsystem, initSendable, setName, setSubsystem
-
-
-
-
Method Detail
-
pigeon
public static LightningIMU pigeon(int id)
Creates a newPigeon
with the given ID.- Parameters:
id
- CAN ID of thePigeon
- Returns:
- IMU object configured for a
Pigeon
-
navX
public static LightningIMU navX()
Creates a newNavX
.- Returns:
- IMU object configured for the NavX (SPI)
-
none
public static LightningIMU none()
Creates a static IMU- Returns:
- IMU object that effectively does nothing
-
getType
public LightningIMU.IMUType getType()
-
getHeading
public edu.wpi.first.math.geometry.Rotation2d getHeading()
Get the IMU heading as aRotation2d
.- 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
-
zero
public LightningIMU.IMUFunction zero()
Function to reset IMU heading- Returns:
- An
LightningIMU.IMUFunction
that zeros the IMU heading when called
-
periodic
public void periodic()
-
-