mirror of
https://github.com/BroncBotz3481/YAGSL
synced 2026-06-19 06:21:40 +00:00
Updated to 2024.4.6.1
This commit is contained in:
@@ -23,7 +23,11 @@ public class Pigeon2Swerve extends SwerveIMU
|
||||
/**
|
||||
* Offset for the Pigeon 2.
|
||||
*/
|
||||
private Rotation3d offset = new Rotation3d();
|
||||
private Rotation3d offset = new Rotation3d();
|
||||
/**
|
||||
* Inversion for the gyro
|
||||
*/
|
||||
private boolean invertedIMU = false;
|
||||
|
||||
/**
|
||||
* Generate the SwerveIMU for pigeon.
|
||||
@@ -79,6 +83,16 @@ public class Pigeon2Swerve extends SwerveIMU
|
||||
this.offset = offset;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the gyro to invert its default direction
|
||||
*
|
||||
* @param invertIMU invert gyro direction
|
||||
*/
|
||||
public void setInverted(boolean invertIMU)
|
||||
{
|
||||
invertedIMU = invertIMU;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the {@link Rotation3d} from the IMU without any zeroing. Robot relative.
|
||||
*
|
||||
@@ -88,14 +102,15 @@ public class Pigeon2Swerve extends SwerveIMU
|
||||
public Rotation3d getRawRotation3d()
|
||||
{
|
||||
// TODO: Switch to suppliers.
|
||||
StatusSignal<Double> w = imu.getQuatW();
|
||||
StatusSignal<Double> x = imu.getQuatX();
|
||||
StatusSignal<Double> y = imu.getQuatY();
|
||||
StatusSignal<Double> z = imu.getQuatZ();
|
||||
return new Rotation3d(new Quaternion(w.refresh().getValue(),
|
||||
x.refresh().getValue(),
|
||||
y.refresh().getValue(),
|
||||
z.refresh().getValue()));
|
||||
StatusSignal<Double> w = imu.getQuatW();
|
||||
StatusSignal<Double> x = imu.getQuatX();
|
||||
StatusSignal<Double> y = imu.getQuatY();
|
||||
StatusSignal<Double> z = imu.getQuatZ();
|
||||
Rotation3d reading = new Rotation3d(new Quaternion(w.refresh().getValue(),
|
||||
x.refresh().getValue(),
|
||||
y.refresh().getValue(),
|
||||
z.refresh().getValue()));
|
||||
return invertedIMU ? reading.unaryMinus() : reading;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user