mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
[hal, wpilib] Add support for onboard IMU mount orientations with Euler angles (#8061)
This commit is contained in:
@@ -159,7 +159,14 @@ public class OnboardIMU {
|
||||
|
||||
private double[] getRawEulerAngles() {
|
||||
double[] anglesRaw = new double[3];
|
||||
IMUJNI.getIMUEulerAngles(anglesRaw);
|
||||
switch (m_mountOrientation) {
|
||||
case kFlat -> IMUJNI.getIMUEulerAnglesFlat(anglesRaw);
|
||||
case kLandscape -> IMUJNI.getIMUEulerAnglesLandscape(anglesRaw);
|
||||
case kPortrait -> IMUJNI.getIMUEulerAnglesPortrait(anglesRaw);
|
||||
default -> {
|
||||
// NOP
|
||||
}
|
||||
}
|
||||
return anglesRaw;
|
||||
}
|
||||
|
||||
@@ -176,16 +183,12 @@ public class OnboardIMU {
|
||||
}
|
||||
|
||||
private double getYawNoOffset() {
|
||||
switch (m_mountOrientation) {
|
||||
case kFlat:
|
||||
return IMUJNI.getIMUYawFlat();
|
||||
case kLandscape:
|
||||
return IMUJNI.getIMUYawLandscape();
|
||||
case kPortrait:
|
||||
return IMUJNI.getIMUYawPortrait();
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return switch (m_mountOrientation) {
|
||||
case kFlat -> IMUJNI.getIMUYawFlat();
|
||||
case kLandscape -> IMUJNI.getIMUYawLandscape();
|
||||
case kPortrait -> IMUJNI.getIMUYawPortrait();
|
||||
default -> 0;
|
||||
};
|
||||
}
|
||||
|
||||
private final MountOrientation m_mountOrientation;
|
||||
|
||||
Reference in New Issue
Block a user