Package swervelib.imu
Class Pigeon2Swerve
java.lang.Object
swervelib.imu.SwerveIMU
swervelib.imu.Pigeon2Swerve
SwerveIMU interface for the Pigeon2
-
Field Summary
Modifier and TypeFieldDescription(package private) com.ctre.phoenix6.hardware.Pigeon2
Pigeon2 IMU device.private boolean
Inversion for the gyroprivate edu.wpi.first.math.geometry.Rotation3d
Offset for the Pigeon 2.static double
Wait time for status frames to show up. -
Constructor Summary
ConstructorDescriptionPigeon2Swerve
(int canid) Generate the SwerveIMU for pigeon.Pigeon2Swerve
(int canid, String canbus) Generate the SwerveIMU for pigeon. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Clear sticky faults on IMU.void
Reset IMU to factory default.Optional<edu.wpi.first.math.geometry.Translation3d>
getAccel()
Fetch the acceleration [x, y, z] from the IMU in meters per second squared.getIMU()
Get the instantiated IMU object.edu.wpi.first.math.geometry.Rotation3d
Fetch theRotation3d
from the IMU without any zeroing.edu.wpi.first.math.geometry.Rotation3d
Fetch theRotation3d
from the IMU.void
setInverted
(boolean invertIMU) Set the gyro to invert its default directionvoid
setOffset
(edu.wpi.first.math.geometry.Rotation3d offset) Set the gyro offset.
-
Field Details
-
STATUS_TIMEOUT_SECONDS
public static double STATUS_TIMEOUT_SECONDSWait time for status frames to show up. -
imu
com.ctre.phoenix6.hardware.Pigeon2 imuPigeon2 IMU device. -
offset
private edu.wpi.first.math.geometry.Rotation3d offsetOffset for the Pigeon 2. -
invertedIMU
private boolean invertedIMUInversion for the gyro
-
-
Constructor Details
-
Pigeon2Swerve
Generate the SwerveIMU for pigeon.- Parameters:
canid
- CAN ID for the pigeoncanbus
- CAN Bus name the pigeon resides on.
-
Pigeon2Swerve
public Pigeon2Swerve(int canid) Generate the SwerveIMU for pigeon.- Parameters:
canid
- CAN ID for the pigeon
-
-
Method Details
-
factoryDefault
public void factoryDefault()Reset IMU to factory default.- Specified by:
factoryDefault
in classSwerveIMU
-
clearStickyFaults
public void clearStickyFaults()Clear sticky faults on IMU.- Specified by:
clearStickyFaults
in classSwerveIMU
-
setOffset
public void setOffset(edu.wpi.first.math.geometry.Rotation3d offset) Set the gyro offset. -
setInverted
public void setInverted(boolean invertIMU) Set the gyro to invert its default direction- Specified by:
setInverted
in classSwerveIMU
- Parameters:
invertIMU
- invert gyro direction
-
getRawRotation3d
public edu.wpi.first.math.geometry.Rotation3d getRawRotation3d()Fetch theRotation3d
from the IMU without any zeroing. Robot relative.- Specified by:
getRawRotation3d
in classSwerveIMU
- Returns:
Rotation3d
from the IMU.
-
getRotation3d
public edu.wpi.first.math.geometry.Rotation3d getRotation3d()Fetch theRotation3d
from the IMU. Robot relative.- Specified by:
getRotation3d
in classSwerveIMU
- Returns:
Rotation3d
from the IMU.
-
getAccel
Fetch the acceleration [x, y, z] from the IMU in meters per second squared. If acceleration isn't supported returns empty. -
getIMU
Get the instantiated IMU object.
-