mirror of
https://github.com/BroncBotz3481/YAGSL
synced 2026-06-26 07:01:39 +00:00
Updated to 2024.4.6.1
This commit is contained in:
@@ -20,7 +20,11 @@ public class PigeonSwerve extends SwerveIMU
|
||||
/**
|
||||
* Offset for the Pigeon.
|
||||
*/
|
||||
private Rotation3d offset = new Rotation3d();
|
||||
private Rotation3d offset = new Rotation3d();
|
||||
/**
|
||||
* Inversion for the gyro
|
||||
*/
|
||||
private boolean invertedIMU = false;
|
||||
|
||||
/**
|
||||
* Generate the SwerveIMU for pigeon.
|
||||
@@ -62,6 +66,16 @@ public class PigeonSwerve 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.
|
||||
*
|
||||
@@ -72,7 +86,8 @@ public class PigeonSwerve extends SwerveIMU
|
||||
{
|
||||
double[] wxyz = new double[4];
|
||||
imu.get6dQuaternion(wxyz);
|
||||
return new Rotation3d(new Quaternion(wxyz[0], wxyz[1], wxyz[2], wxyz[3]));
|
||||
Rotation3d reading = new Rotation3d(new Quaternion(wxyz[0], wxyz[1], wxyz[2], wxyz[3]));
|
||||
return invertedIMU ? reading.unaryMinus() : reading;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user