Package org.team1126.lib.swerve.hardware
Class SwerveIMUs.SwerveIMU
java.lang.Object
org.team1126.lib.swerve.hardware.SwerveIMUs.SwerveIMU
- All Implemented Interfaces:
AutoCloseable
- Enclosing class:
SwerveIMUs
A swerve IMU.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interface(config) -> SwerveIMUstatic interfaceProvides consumer to be saved and invoked periodically with the robot's current chassis speeds to update the simulated IMU. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic SwerveIMUs.SwerveIMUconstruct(SwerveIMUs.SwerveIMU.Ctor ctor, SwerveConfig config, SwerveIMUs.SwerveIMU.IMUSimHook simHook) Constructs a swerve IMU.getAPI()Returns the device's underlying API.abstract edu.wpi.first.math.geometry.Rotation2dgetPitch()Gets the IMU's absolute pitch.abstract edu.wpi.first.math.geometry.Rotation2dgetRoll()Gets the IMU's absolute roll.default List<com.ctre.phoenix6.BaseStatusSignal> Returns all Phoenix status signals in use by the hardware.abstract edu.wpi.first.math.geometry.Rotation2dgetYaw()Gets the IMU's absolute yaw.default booleanIf the device has encountered an error while reading inputs.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.AutoCloseable
close
-
Constructor Details
-
SwerveIMU
public SwerveIMU()
-
-
Method Details
-
construct
public static SwerveIMUs.SwerveIMU construct(SwerveIMUs.SwerveIMU.Ctor ctor, SwerveConfig config, SwerveIMUs.SwerveIMU.IMUSimHook simHook) Constructs a swerve IMU. Wraps to support simulation if applicable.- Parameters:
ctor- The IMU's constructor.config- The general swerve API configuration.simHook- Hook to update the IMU if simulation is active.
-
getYaw
public abstract edu.wpi.first.math.geometry.Rotation2d getYaw()Gets the IMU's absolute yaw. -
getPitch
public abstract edu.wpi.first.math.geometry.Rotation2d getPitch()Gets the IMU's absolute pitch. -
getRoll
public abstract edu.wpi.first.math.geometry.Rotation2d getRoll()Gets the IMU's absolute roll. -
getAPI
Object getAPI()Returns the device's underlying API. -
getSignals
Returns all Phoenix status signals in use by the hardware. Phoenix hardware should not invoke.refresh()on their status signals in their implementations. This method is required for the odometry thread to register signals to be refreshed automatically. Because signals are not thread safe, all returned signals should also be cloned in their initialization as to not interfere with telemetry, which is invoked on the main thread. The exception to this rule is IMU pitch and roll values, as they are only measured synchronously when callingSwerveAPI.refresh(). -
readError
default boolean readError()If the device has encountered an error while reading inputs.
-