Compare commits

..
Author SHA1 Message Date
Ryan Butler df9148332f Update Cargo.toml for release profile settings 2026-02-15 10:11:14 -05:00
12 changed files with 58 additions and 90 deletions

No files matched your search

-6
View File
@@ -116,9 +116,3 @@ licensed under `GPL-v3`.
## Discord ## Discord
We use discord *a lot* to coordinate and discuss development. Come join us at We use discord *a lot* to coordinate and discuss development. Come join us at
https://discord.gg/SlimeVR! https://discord.gg/SlimeVR!
## Use of AI
We DO NOT accept contributions that are generated with AI (for example, "vibe-coding").
If you do use AI, and you believe your usage of AI is reasonable, you must clearly disclose
how you used AI in your submission.
+2 -1
View File
@@ -13,4 +13,5 @@ rust-version = "1.82" # Tauri's MSRV
repository = "https://github.com/SlimeVR/SlimeVR-Server" repository = "https://github.com/SlimeVR/SlimeVR-Server"
[profile.release] [profile.release]
lto = "thin" lto = true
strip = true
-2
View File
@@ -662,8 +662,6 @@ settings-general-fk_settings-skeleton_settings-impute_hip_from_waist_legs = Impu
settings-general-fk_settings-skeleton_settings-interp_hip_legs = Average the hip's yaw and roll with the legs' settings-general-fk_settings-skeleton_settings-interp_hip_legs = Average the hip's yaw and roll with the legs'
settings-general-fk_settings-skeleton_settings-interp_knee_tracker_ankle = Average the knee trackers' yaw and roll with the ankles' settings-general-fk_settings-skeleton_settings-interp_knee_tracker_ankle = Average the knee trackers' yaw and roll with the ankles'
settings-general-fk_settings-skeleton_settings-interp_knee_ankle = Average the knees' yaw and roll with the ankles' settings-general-fk_settings-skeleton_settings-interp_knee_ankle = Average the knees' yaw and roll with the ankles'
settings-general-fk_settings-skeleton_settings-fingers_mitten = Fingers Mitten Mode
settings-general-fk_settings-self_localization-title = Mocap mode settings-general-fk_settings-self_localization-title = Mocap mode
settings-general-fk_settings-self_localization-description = Mocap Mode allows the skeleton to roughly track its own position without a headset or other trackers. Note that this requires feet and head trackers to work and is still experimental. settings-general-fk_settings-self_localization-description = Mocap Mode allows the skeleton to roughly track its own position without a headset or other trackers. Note that this requires feet and head trackers to work and is still experimental.
@@ -75,7 +75,6 @@ export type SettingsForm = {
usePosition: boolean; usePosition: boolean;
enforceConstraints: boolean; enforceConstraints: boolean;
correctConstraints: boolean; correctConstraints: boolean;
fingersMitten: boolean;
}; };
ratios: { ratios: {
imputeWaistFromChestHip: number; imputeWaistFromChestHip: number;
@@ -135,7 +134,6 @@ const defaultValues: SettingsForm = {
usePosition: true, usePosition: true,
enforceConstraints: true, enforceConstraints: true,
correctConstraints: true, correctConstraints: true,
fingersMitten: false,
}, },
ratios: { ratios: {
imputeWaistFromChestHip: 0.3, imputeWaistFromChestHip: 0.3,
@@ -233,7 +231,6 @@ export function GeneralSettings() {
toggles.usePosition = values.toggles.usePosition; toggles.usePosition = values.toggles.usePosition;
toggles.enforceConstraints = values.toggles.enforceConstraints; toggles.enforceConstraints = values.toggles.enforceConstraints;
toggles.correctConstraints = values.toggles.correctConstraints; toggles.correctConstraints = values.toggles.correctConstraints;
toggles.fingersMitten = values.toggles.fingersMitten;
modelSettings.toggles = toggles; modelSettings.toggles = toggles;
} }
@@ -1039,15 +1036,6 @@ export function GeneralSettings() {
'settings-general-fk_settings-skeleton_settings-extended_knees_model' 'settings-general-fk_settings-skeleton_settings-extended_knees_model'
)} )}
/> />
<CheckBox
variant="toggle"
outlined
control={control}
name="toggles.fingersMitten"
label={l10n.getString(
'settings-general-fk_settings-skeleton_settings-fingers_mitten'
)}
/>
</div> </div>
<div className="flex flex-col"> <div className="flex flex-col">
<div className="flex flex-col pt-2 pb-3 gap-2"> <div className="flex flex-col pt-2 pb-3 gap-2">
+3 -8
View File
@@ -129,6 +129,9 @@ export function checkForUpdate(
if ( if (
!device.hardwareInfo?.officialBoardType || !device.hardwareInfo?.officialBoardType ||
![BoardType.SLIMEVR, BoardType.SLIMEVR_V1_2].includes(
device.hardwareInfo.officialBoardType
) ||
!semver.valid(currentFirmwareRelease.version) || !semver.valid(currentFirmwareRelease.version) ||
!semver.valid(device.hardwareInfo.firmwareVersion?.toString() ?? 'none') !semver.valid(device.hardwareInfo.firmwareVersion?.toString() ?? 'none')
) { ) {
@@ -140,14 +143,6 @@ export function checkForUpdate(
currentFirmwareRelease.version currentFirmwareRelease.version
); );
if (
![BoardType.SLIMEVR, BoardType.SLIMEVR_V1_2].includes(
device.hardwareInfo.officialBoardType
)
) {
return canUpdate ? 'unavailable' : 'updated';
}
if ( if (
canUpdate && canUpdate &&
device.hardwareStatus?.batteryPctEstimate != null && device.hardwareStatus?.batteryPctEstimate != null &&
@@ -209,7 +209,6 @@ fun createModelSettings(
humanPoseManager.getToggle(SkeletonConfigToggles.USE_POSITION), humanPoseManager.getToggle(SkeletonConfigToggles.USE_POSITION),
humanPoseManager.getToggle(SkeletonConfigToggles.ENFORCE_CONSTRAINTS), humanPoseManager.getToggle(SkeletonConfigToggles.ENFORCE_CONSTRAINTS),
humanPoseManager.getToggle(SkeletonConfigToggles.CORRECT_CONSTRAINTS), humanPoseManager.getToggle(SkeletonConfigToggles.CORRECT_CONSTRAINTS),
humanPoseManager.getToggle(SkeletonConfigToggles.FINGERS_MITTEN),
) )
val ratiosOffset = ModelRatios val ratiosOffset = ModelRatios
.createModelRatios( .createModelRatios(
@@ -241,7 +241,6 @@ class RPCSettingsHandler(var rpcHandler: RPCHandler, var api: ProtocolAPI) {
hpm.setToggle(SkeletonConfigToggles.USE_POSITION, toggles.usePosition()) hpm.setToggle(SkeletonConfigToggles.USE_POSITION, toggles.usePosition())
hpm.setToggle(SkeletonConfigToggles.ENFORCE_CONSTRAINTS, toggles.enforceConstraints()) hpm.setToggle(SkeletonConfigToggles.ENFORCE_CONSTRAINTS, toggles.enforceConstraints())
hpm.setToggle(SkeletonConfigToggles.CORRECT_CONSTRAINTS, toggles.correctConstraints()) hpm.setToggle(SkeletonConfigToggles.CORRECT_CONSTRAINTS, toggles.correctConstraints())
hpm.setToggle(SkeletonConfigToggles.FINGERS_MITTEN, toggles.fingersMitten())
} }
if (ratios != null) { if (ratios != null) {
@@ -17,8 +17,7 @@ public enum SkeletonConfigToggles {
SELF_LOCALIZATION(10, "Self Localization", "selfLocalization", false), SELF_LOCALIZATION(10, "Self Localization", "selfLocalization", false),
USE_POSITION(11, "Use Position", "usePosition", true), USE_POSITION(11, "Use Position", "usePosition", true),
ENFORCE_CONSTRAINTS(12, "Enforce Constraints", "enforceConstraints", true), ENFORCE_CONSTRAINTS(12, "Enforce Constraints", "enforceConstraints", true),
CORRECT_CONSTRAINTS(13, "Correct Constraints", "correctConstraints", true), CORRECT_CONSTRAINTS(13, "Correct Constraints", "correctConstraints", true),;
FINGERS_MITTEN(14, "Fingers Mitten", "fingersMitten", true),;
public static final SkeletonConfigToggles[] values = values(); public static final SkeletonConfigToggles[] values = values();
private static final Map<String, SkeletonConfigToggles> byStringVal = new HashMap<>(); private static final Map<String, SkeletonConfigToggles> byStringVal = new HashMap<>();
@@ -197,7 +197,6 @@ class HumanSkeleton(
private var forceArmsFromHMD = true private var forceArmsFromHMD = true
private var enforceConstraints = true private var enforceConstraints = true
private var correctConstraints = true private var correctConstraints = true
private var fingersMitten = true
// Ratios // Ratios
private var waistFromChestHipAveraging = 0f private var waistFromChestHipAveraging = 0f
@@ -1205,8 +1204,6 @@ class HumanSkeleton(
SkeletonConfigToggles.ENFORCE_CONSTRAINTS -> enforceConstraints = newValue SkeletonConfigToggles.ENFORCE_CONSTRAINTS -> enforceConstraints = newValue
SkeletonConfigToggles.CORRECT_CONSTRAINTS -> correctConstraints = newValue SkeletonConfigToggles.CORRECT_CONSTRAINTS -> correctConstraints = newValue
SkeletonConfigToggles.FINGERS_MITTEN -> fingersMitten = newValue
} }
} }
@@ -24,6 +24,8 @@ class TrackerResetsHandler(val tracker: Tracker) {
Math.PI.toFloat(), Math.PI.toFloat(),
0f, 0f,
).toQuaternion() ).toQuaternion()
private val QuarterPitch = Quaternion.rotationAroundXAxis(FastMath.HALF_PI)
private var driftAmount = 0f private var driftAmount = 0f
private var averagedDriftQuat = Quaternion.IDENTITY private var averagedDriftQuat = Quaternion.IDENTITY
private var rotationSinceReset = Quaternion.IDENTITY private var rotationSinceReset = Quaternion.IDENTITY
@@ -52,16 +54,6 @@ class TrackerResetsHandler(val tracker: Tracker) {
// Reference adjustment quats // Reference adjustment quats
/**
* Gyro fix is set by full reset. This sets the current y rotation to 0, correcting
* for initial yaw rotation and the rotation incurred by mounting orientation. This
* is a local offset in rotation and does not affect the axes of rotation.
*
* This rotation is only used to compute [attachmentFix], otherwise [yawFix] would
* correct for the same rotation.
*/
private var gyroFix = Quaternion.IDENTITY
/** /**
* Attachment fix is set by full reset. This sets the current x and z rotations to * Attachment fix is set by full reset. This sets the current x and z rotations to
* 0, correcting for initial pitch and roll rotation. This is a global offset in * 0, correcting for initial pitch and roll rotation. This is a global offset in
@@ -188,12 +180,9 @@ class TrackerResetsHandler(val tracker: Tracker) {
/** /**
* Get the reference adjusted accel. * Get the reference adjusted accel.
*/ */
// TODO: Make this actually adjusted to the corrected IMU heading. The current // All IMU axis corrections are inverse to undo `adjustToReference` after local yaw offsets are added
// implementation for heading correction doesn't appear to be correct and may simply // Order is VERY important here! Please be extremely careful! >~>
// make acceleration worse, so I'm just leaving this until we work that out. The fun getReferenceAdjustedAccel(rawRot: Quaternion, accel: Vector3): Vector3 = (adjustToReference(rawRot) * (attachmentFix * mountingOrientation * mountRotFix * tposeDownFix).inv()).sandwich(accel)
// output of this will be world space, but with an unknown offset to heading (yaw).
// - Butterscotch
fun getReferenceAdjustedAccel(rawRot: Quaternion, accel: Vector3): Vector3 = rawRot.sandwich(accel)
/** /**
* Converts raw or filtered rotation into reference- and * Converts raw or filtered rotation into reference- and
@@ -202,22 +191,17 @@ class TrackerResetsHandler(val tracker: Tracker) {
*/ */
private fun adjustToReference(rotation: Quaternion): Quaternion { private fun adjustToReference(rotation: Quaternion): Quaternion {
var rot = rotation var rot = rotation
// Align heading axis with bone space // Correct for global pitch/roll offset
if (!tracker.isHmd || tracker.trackerPosition != TrackerPosition.HEAD) {
rot *= mountingOrientation
}
// Heading correction assuming manual orientation is correct
rot = gyroFix * rot
// Align attitude axes with bone space
rot *= attachmentFix rot *= attachmentFix
// Secondary heading axis alignment with bone space for automatic mounting // Correct for global yaw offset without affecting local yaw so we can change this
// Note: Applying an inverse amount of heading correction corresponding to the // later without invalidating local yaw offset corrections
// axis alignment quaternion will leave the correction to another variable if (!tracker.isHmd || tracker.trackerPosition != TrackerPosition.HEAD) {
rot = mountRotFix.inv() * (rot * mountRotFix) rot = mountingOrientation.inv() * rot * mountingOrientation
// More attitude axes alignment specifically for the t-pose configuration, this }
// probably shouldn't be a separate variable from attachmentFix? rot = mountRotFix.inv() * rot * mountRotFix
// T-pose global correction
rot *= tposeDownFix rot *= tposeDownFix
// More heading correction // Align local yaw with reference
rot = yawFix * rot rot = yawFix * rot
rot = constraintFix * rot rot = constraintFix * rot
return rot return rot
@@ -227,8 +211,6 @@ class TrackerResetsHandler(val tracker: Tracker) {
* Converts raw or filtered rotation into zero-reference-adjusted by * Converts raw or filtered rotation into zero-reference-adjusted by
* applying quaternions produced after full reset and yaw reset only * applying quaternions produced after full reset and yaw reset only
*/ */
// This is essentially just adjustToReference but aligning to quaternion identity
// rather than to the bone.
private fun adjustToIdentity(rotation: Quaternion): Quaternion { private fun adjustToIdentity(rotation: Quaternion): Quaternion {
var rot = rotation var rot = rotation
rot = gyroFixNoMounting * rot rot = gyroFixNoMounting * rot
@@ -283,15 +265,23 @@ class TrackerResetsHandler(val tracker: Tracker) {
lastResetQuaternion = oldRot lastResetQuaternion = oldRot
// Adjust raw rotation to mountingOrientation // Adjust raw rotation to mountingOrientation
val mountingAdjustedRotation = tracker.getRawRotation() * mountingOrientation val rotation = tracker.getRawRotation()
// Gyrofix // Gyrofix
if (tracker.allowMounting || (tracker.trackerPosition == TrackerPosition.HEAD && !tracker.isHmd)) { val gyroFix = if (tracker.allowMounting || (tracker.trackerPosition == TrackerPosition.HEAD && !tracker.isHmd)) {
gyroFix = if (tracker.isComputed) { if (tracker.isComputed) {
fixGyroscope(tracker.getRawRotation()) fixGyroscope(rotation)
} else { } else {
fixGyroscope(mountingAdjustedRotation * tposeDownFix) if (tracker.trackerPosition.isFoot()) {
// Feet are rotated by 90 deg pitch, this means we're relying on IMU rotation
// to be set correctly here.
fixGyroscope(rotation * tposeDownFix * QuarterPitch)
} else {
fixGyroscope(rotation * tposeDownFix)
}
} }
} else {
Quaternion.IDENTITY
} }
// Mounting for computed trackers // Mounting for computed trackers
@@ -306,7 +296,7 @@ class TrackerResetsHandler(val tracker: Tracker) {
if (resetHmdPitch) { if (resetHmdPitch) {
// Reset the HMD's pitch if it's assigned to head and resetHmdPitch is true // Reset the HMD's pitch if it's assigned to head and resetHmdPitch is true
// Get rotation without yaw (make sure to use the raw rotation directly!) // Get rotation without yaw (make sure to use the raw rotation directly!)
val rotBuf = getYawQuaternion(tracker.getRawRotation()).inv() * tracker.getRawRotation() val rotBuf = getYawQuaternion(rotation).inv() * rotation
// Isolate pitch // Isolate pitch
Quaternion(rotBuf.w, -rotBuf.x, 0f, 0f).unit() Quaternion(rotBuf.w, -rotBuf.x, 0f, 0f).unit()
} else { } else {
@@ -314,7 +304,7 @@ class TrackerResetsHandler(val tracker: Tracker) {
Quaternion.IDENTITY Quaternion.IDENTITY
} }
} else { } else {
fixAttachment(mountingAdjustedRotation) (gyroFix * rotation).inv()
} }
// Rotate attachmentFix by 180 degrees as a workaround for t-pose (down) // Rotate attachmentFix by 180 degrees as a workaround for t-pose (down)
@@ -326,7 +316,7 @@ class TrackerResetsHandler(val tracker: Tracker) {
// Don't adjust yaw if head and computed // Don't adjust yaw if head and computed
if (tracker.trackerPosition != TrackerPosition.HEAD || !tracker.isComputed) { if (tracker.trackerPosition != TrackerPosition.HEAD || !tracker.isComputed) {
yawFix = fixYaw(mountingAdjustedRotation, reference) yawFix = gyroFix * reference.project(Vector3.POS_Y).unit()
tracker.yawResetSmoothing.reset() tracker.yawResetSmoothing.reset()
} }
@@ -370,7 +360,7 @@ class TrackerResetsHandler(val tracker: Tracker) {
lastResetQuaternion = oldRot lastResetQuaternion = oldRot
val yawFixOld = yawFix val yawFixOld = yawFix
yawFix = fixYaw(tracker.getRawRotation() * mountingOrientation, reference) yawFix = fixYaw(tracker.getRawRotation(), reference)
tracker.yawResetSmoothing.reset() tracker.yawResetSmoothing.reset()
makeIdentityAdjustmentQuatsYaw() makeIdentityAdjustmentQuatsYaw()
@@ -409,9 +399,9 @@ class TrackerResetsHandler(val tracker: Tracker) {
constraintFix = Quaternion.IDENTITY constraintFix = Quaternion.IDENTITY
// Get the current calibrated rotation // Get the current calibrated rotation
var rotBuf = adjustToDrift(tracker.getRawRotation() * mountingOrientation) var rotBuf = adjustToDrift(tracker.getRawRotation())
rotBuf = gyroFix * rotBuf
rotBuf *= attachmentFix rotBuf *= attachmentFix
rotBuf = mountingOrientation.inv() * rotBuf * mountingOrientation
rotBuf = yawFix * rotBuf rotBuf = yawFix * rotBuf
// Adjust buffer to reference // Adjust buffer to reference
@@ -467,14 +457,22 @@ class TrackerResetsHandler(val tracker: Tracker) {
mountRotFix = Quaternion.IDENTITY mountRotFix = Quaternion.IDENTITY
} }
private fun fixGyroscope(sensorRotation: Quaternion): Quaternion = getYawQuaternion(sensorRotation).inv() // EulerOrder.YXZ is actually better for gyroscope fix, as it can get yaw at any roll.
// Consequentially, instead of the roll being limited, the pitch is limited to
private fun fixAttachment(sensorRotation: Quaternion): Quaternion = (gyroFix * sensorRotation).inv() // 90 degrees from the yaw plane. This means trackers may be mounted upside down
// or with incorrectly configured IMU rotation, but we will need to compensate for
// the pitch.
private fun fixGyroscope(sensorRotation: Quaternion): Quaternion = getYawQuaternion(sensorRotation, EulerOrder.YXZ).inv()
private fun fixYaw(sensorRotation: Quaternion, reference: Quaternion): Quaternion { private fun fixYaw(sensorRotation: Quaternion, reference: Quaternion): Quaternion {
var rot = gyroFix * sensorRotation var rot = sensorRotation * attachmentFix
rot *= attachmentFix // We need to fix the global yaw offset for the euler yaw calculation
rot = mountRotFix.inv() * (rot * mountRotFix) if (!tracker.isHmd || tracker.trackerPosition != TrackerPosition.HEAD) {
rot = mountingOrientation.inv() * rot * mountingOrientation
}
rot = mountRotFix.inv() * rot * mountRotFix
// TODO: Get diff from ref to rot, use euler angle (YZX) yaw as output.
// This prevents pitch and roll from affecting the alignment.
rot = getYawQuaternion(rot) rot = getYawQuaternion(rot)
return rot.inv() * reference.project(Vector3.POS_Y).unit() return rot.inv() * reference.project(Vector3.POS_Y).unit()
} }
@@ -485,7 +483,7 @@ class TrackerResetsHandler(val tracker: Tracker) {
// In both cases, the isolated yaw value changes // In both cases, the isolated yaw value changes
// with the tracker's roll when pointing forward. // with the tracker's roll when pointing forward.
// calling twinNearest() makes sure this rotation has the wanted polarity (+-). // calling twinNearest() makes sure this rotation has the wanted polarity (+-).
private fun getYawQuaternion(rot: Quaternion): Quaternion = EulerAngles(EulerOrder.YZX, 0f, rot.toEulerAngles(EulerOrder.YZX).y, 0f).toQuaternion().twinNearest(rot) private fun getYawQuaternion(rot: Quaternion, order: EulerOrder = EulerOrder.YZX): Quaternion = EulerAngles(order, 0f, rot.toEulerAngles(order).y, 0f).toQuaternion().twinNearest(rot)
private fun makeIdentityAdjustmentQuatsFull() { private fun makeIdentityAdjustmentQuatsFull() {
val sensorRotation = tracker.getRawRotation() val sensorRotation = tracker.getRawRotation()
@@ -93,13 +93,13 @@ class SkeletonResetTests {
TrackerPosition.HIP, TrackerPosition.HIP,
TrackerPosition.LEFT_LOWER_LEG, TrackerPosition.LEFT_LOWER_LEG,
TrackerPosition.RIGHT_LOWER_LEG, TrackerPosition.RIGHT_LOWER_LEG,
-> mountRot * Quaternion.SLIMEVR.FRONT -> mountRot
TrackerPosition.LEFT_UPPER_LEG, TrackerPosition.LEFT_UPPER_LEG,
TrackerPosition.RIGHT_UPPER_LEG, TrackerPosition.RIGHT_UPPER_LEG,
-> mountRot -> mountRot * Quaternion.SLIMEVR.FRONT
else -> mountRot else -> mountRot * Quaternion.SLIMEVR.FRONT
} }
val actualMounting = tracker.resetsHandler.mountRotFix val actualMounting = tracker.resetsHandler.mountRotFix