Compare commits

...
10 changed files with 55 additions and 18 deletions

No files matched your search

+5 -4
View File
@@ -7,8 +7,9 @@ This document describes essential knowledge required to contribute to the SlimeV
### Prerequisites
- [Git](https://git-scm.com/downloads)
- [Java v17+](https://adoptium.net/temurin/releases/)
- [Node.js v16.9+](https://nodejs.org) (We recommend the use of `nvm` instead of installing Node.js directly)
- [Java v25](https://adoptium.net/temurin/releases/)
- [Node.js v24+](https://nodejs.org) (We recommend the use of `nvm` instead of installing Node.js directly)
- [pnpm](https://pnpm.io/installation)
## Cloning the code
First, clone the codebase using git in a terminal in the folder you want.
@@ -36,13 +37,13 @@ be at `server/desktop/build/libs/slimevr.jar` (you can ignore `server.jar`).
### Electron (gui)
- Activate corepack (included with Node.js) via `corepack enable`
- Activate corepack (included with Node.js) via `corepack enable`
(might require launching Git Bash as administrator on Windows)
- Make sure you're at the root of the repository.
- Run `pnpm i` in your IDE's terminal to download and install dependencies.
- To launch the GUI in dev mode, run `pnpm gui`.
- If you get an "Electron uninstall" error, run `node .\gui\electron\node_modules\electron\install.js`.
- Finally, to compile for production, run `pnpm package:build` under `gui/electron`.
- Finally, to compile for production, run `pnpm package:build` under `gui/electron`.
The result will be in `gui/dist/artifacts/`. Content will change depending on the platform.
## Code style
+2
View File
@@ -586,6 +586,8 @@ settings-driver-bones-description = Which bones this output sends is configured
settings-driver-bones-link = Open Bone Routing
settings-driver-velocity = Send velocity
settings-driver-velocity-description = Send linear and angular velocity data to the driver. Allows SteamVR/Monado tracker pose prediction and compatibility with applications that expect this data.
settings-driver-controller_tracking_fallback = Controller tracking fallback
settings-driver-controller_tracking_fallback-description = Override your controllers' tracking, with trackers mounted on your arms and hands, when your controllers lose tracking
## Tracker mechanics
settings-general-mounting_method = Mounting calibration method
@@ -33,12 +33,14 @@ import { defineSettingsPage } from '@/components/settings/settings-definitions';
type DriverForm = {
enabled: boolean;
sendVelocity: boolean;
controllerTrackingFallback: boolean;
};
function toForm(settings: DriverSettingsResponseT): DriverForm {
return {
enabled: settings.enabled,
sendVelocity: settings.sendVelocity,
controllerTrackingFallback: settings.controllerTrackingFallback,
};
}
@@ -108,6 +110,11 @@ export const driverSettingsPage = defineSettingsPage({
title: 'settings-driver-velocity',
description: 'settings-driver-velocity-description',
},
controllerTrackingFallback: {
title: 'settings-driver-controller_tracking_fallback',
description:
'settings-driver-controller_tracking_fallback-description',
},
},
},
},
@@ -137,6 +144,7 @@ export function DriverSettings() {
const settingsReq = new ChangeDriverSettingsRequestT();
settingsReq.enabled = values.enabled;
settingsReq.sendVelocity = values.sendVelocity;
settingsReq.controllerTrackingFallback = values.controllerTrackingFallback;
sendRPCPacket(RpcMessage.ChangeDriverSettingsRequest, settingsReq);
};
@@ -243,6 +251,19 @@ export function DriverSettings() {
/>
}
/>
<SettingRow
setting={groups.data.rows.controllerTrackingFallback}
controlId="driver-controller-tracking-fallback"
{...resetTo('controllerTrackingFallback')}
control={
<CheckBox
variant="toggle"
control={control}
name="controllerTrackingFallback"
id="driver-controller-tracking-fallback"
/>
}
/>
</SettingsGroup>
</SettingsAdvanced>
</div>
@@ -46,6 +46,7 @@ data class BoneRoutingConfig(
data class DriverConfig(
val enabled: Boolean = true,
val sendVelocity: Boolean = false,
val controllerTrackingFallback: Boolean = false,
)
// Used in TrackerActionConfig
@@ -47,7 +47,7 @@ import kotlin.time.Duration.Companion.seconds
import kotlin.time.TimeMark
// Feet go slightly inwards on pose mounting
private const val FEET_POSE_DEG_INWARDS = 15
private const val FEET_POSE_DEG_INWARDS = 15 * FastMath.DEG_TO_RAD
data class ResetsState(
val canDoYawReset: Boolean,
@@ -237,9 +237,13 @@ class ResetsManager(
private fun getYawOffset(bodyPart: BodyPart?, armsResetMode: ArmsMountingResetMode) = when (bodyPart) {
// Feet go back but a little inwards
BodyPart.LEFT_FOOT -> FastMath.PI - FEET_POSE_DEG_INWARDS * FastMath.DEG_TO_RAD
BodyPart.LEFT_FOOT -> FastMath.PI - FEET_POSE_DEG_INWARDS
BodyPart.RIGHT_FOOT -> FastMath.PI + FEET_POSE_DEG_INWARDS * FastMath.DEG_TO_RAD
in ResetBodyParts.LEFT_TOES -> FastMath.PI - FEET_POSE_DEG_INWARDS
BodyPart.RIGHT_FOOT -> FastMath.PI + FEET_POSE_DEG_INWARDS
in ResetBodyParts.RIGHT_TOES -> FastMath.PI + FEET_POSE_DEG_INWARDS
// Going forward
in ResetBodyParts.UPPER_LEGS -> 0f
@@ -36,7 +36,8 @@ private const val SMOOTHING_MS_MAX = 50.0
// Prediction
private const val PREDICTION_MS_MAX = 30.0
private const val PREVIOUS_PREDICTION_CARRYOVER = 0.2f
private val PREDICTION_CARRYOVER_TIME = 20.milliseconds // TODO might need to be tuned
private const val MAX_PREDICTION_CARRYOVER_RATIO = 0.5
// Used to minimize latency even more for arm tracking where it is more noticeable
private val PART_MULTIPLIER = BodyPartMap(
@@ -100,7 +101,8 @@ private fun computePredictedRotation(
if (previousRotation == null) return targetRotation
// Use some of the previous prediction
val previousPredictionDelta = previousPredictedRotation?.localAbout(previousRotation)?.pow(PREVIOUS_PREDICTION_CARRYOVER)
val carryoverRatio = (PREDICTION_CARRYOVER_TIME / poseTimeDelta).coerceAtMost(MAX_PREDICTION_CARRYOVER_RATIO).toFloat()
val previousPredictionDelta = previousPredictedRotation?.localAbout(previousRotation)?.pow(carryoverRatio)
?: Quaternion.IDENTITY
val currentDelta = if (poseTimeDelta > Duration.ZERO) {
@@ -26,8 +26,13 @@ val POSITIONAL_IK_TARGETS = arrayOf(
BodyPart.RIGHT_FOOT to BodyPart.RIGHT_LOWER_LEG,
)
val requiredInactive = BodyPartMap(
// TODO Use active rotations as IK constraints instead and fill in the blanks
private val requiredInactive = BodyPartMap(
mapOf(
BodyPart.LEFT_LOWER_LEG to arrayOf(BodyPart.LEFT_UPPER_LEG),
BodyPart.RIGHT_LOWER_LEG to arrayOf(BodyPart.RIGHT_UPPER_LEG),
BodyPart.LEFT_FOOT to arrayOf(BodyPart.LEFT_LOWER_LEG, BodyPart.LEFT_UPPER_LEG),
BodyPart.RIGHT_FOOT to arrayOf(BodyPart.RIGHT_LOWER_LEG, BodyPart.RIGHT_UPPER_LEG),
BodyPart.LEFT_HAND to arrayOf(BodyPart.LEFT_SHOULDER, BodyPart.LEFT_UPPER_ARM, BodyPart.LEFT_LOWER_ARM),
BodyPart.RIGHT_HAND to arrayOf(BodyPart.RIGHT_SHOULDER, BodyPart.RIGHT_UPPER_ARM, BodyPart.RIGHT_LOWER_ARM),
),
@@ -41,8 +46,6 @@ class PositionalTargetProcessor(
override fun process(mutableIkTargets: IKTargets, inputSkeleton: InputSkeleton, fk: ComputedSkeleton, floorLevel: Float) {
if (!settings.context.state.value.data.skeletonConfig.toggles.useTrackerPositions) return
for ((bodyPart, target) in bodyParts) {
// TODO Use active rotations as IK constraints instead and fill in the blanks
// Disable if you have arm trackers
if (requiredInactive[bodyPart]?.any { inputSkeleton[it]?.isRotationActive == true } == true) continue
mutableIkTargets[target] = inputSkeleton[bodyPart]?.position ?: continue
@@ -24,6 +24,7 @@ import solarxr_protocol.rpc.RoutingOutputState
internal fun buildDriverSettingsResponse(config: DriverConfig) = DriverSettingsResponse(
enabled = config.enabled,
sendVelocity = config.sendVelocity,
controllerTrackingFallback = config.controllerTrackingFallback,
)
class DriverSettingsBehaviour(
@@ -50,6 +51,7 @@ class DriverSettingsBehaviour(
driverConfig = driverConfig.copy(
enabled = req.enabled,
sendVelocity = req.sendVelocity,
controllerTrackingFallback = req.controllerTrackingFallback,
),
)
},
@@ -22,6 +22,10 @@ import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.onEach
import solarxr_protocol.datatypes.MagnetometerStatus
import kotlin.time.Duration.Companion.seconds
// When a tracker comes back from sleep, prevents a disproportionate correction
private val MAX_DELTA_TIME = 0.5.seconds
class TrackerStayAlignedBehaviour(
private val settings: Settings,
@@ -72,20 +76,17 @@ class TrackerStayAlignedBehaviour(
.flatMapLatest { (enabled, imuType, magStatus) ->
if (magStatus == MagnetometerStatus.ENABLED || imuType == null || !enabled) return@flatMapLatest emptyFlow()
// Ignore every other emission for performance (50FPS instead of 100FPS when at 100TPS)
var index = 0
var lastRotationTime = timeSource.markNow()
receiver.context.state
.distinctUntilChangedBy { it.rawRotation }
.filter { index++ % 2 == 0 }
.onEach { state ->
val yawCorrectionPerSec = IMU_TO_YAW_CORRECTION.getOrDefault(imuType, YAW_CORRECTION_DEFAULT)
if (yawCorrectionPerSec == Angle.ZERO) return@onEach
val lastFrameTimeSeconds = lastRotationTime.elapsedNow().inFloatingSeconds
val deltaTime = lastRotationTime.elapsedNow().coerceAtMost(MAX_DELTA_TIME).inFloatingSeconds
lastRotationTime = timeSource.markNow()
val applyYawCorrection = yawCorrectionPerSec * lastFrameTimeSeconds
val applyYawCorrection = yawCorrectionPerSec * deltaTime
val yawCorrectionResult = TrackerYawCorrection.computeYawCorrection(
state,