mirror of
https://github.com/SlimeVR/SlimeVR-Server.git
synced 2026-12-06 08:42:32 -08:00
No more HMD; flexible reliable reference instead.
This commit is contained in:
1 parent
6b253da7cf
commit
2fc6810043
26 files changed
+223
-215
No files matched your search
@@ -98,8 +98,8 @@ data class ResetsConfig(
|
||||
val yawResetSmoothTime: Float = 0.0f,
|
||||
/** Save automatic mounting reset calibration */
|
||||
val saveMountingReset: Boolean = false,
|
||||
/** Reset a VR headset's attitude on full reset */
|
||||
val resetHmdAttitude: Boolean = false,
|
||||
/** Reset a reliable reference's (HMD) attitude on full reset */
|
||||
val resetReliableReferenceAttitude: Boolean = false,
|
||||
/** Used as preferred mounting method and tracking checklist */
|
||||
val lastMountingMethod: MountingMethod = MountingMethod.POSE,
|
||||
)
|
||||
|
||||
@@ -25,16 +25,16 @@ import kotlin.math.sqrt
|
||||
internal const val SAMPLE_INTERVAL_MS = 16L
|
||||
|
||||
private const val FLOOR_ALPHA = 0.1f
|
||||
private const val HMD_ALPHA = 0.1f
|
||||
private const val HEAD_ALPHA = 0.1f
|
||||
|
||||
private const val CONTROLLER_STABILITY_THRESHOLD = 0.005f
|
||||
internal const val CONTROLLER_STABILITY_DURATION = 300_000_000L
|
||||
|
||||
private const val HMD_STABILITY_THRESHOLD = 0.003f
|
||||
private const val HEAD_STABILITY_THRESHOLD = 0.003f
|
||||
internal const val HEAD_STABILITY_DURATION = 600_000_000L
|
||||
|
||||
internal const val MAX_FLOOR_Y = 0.10f
|
||||
internal const val HMD_RISE_THRESHOLD = 1.2f
|
||||
internal const val HEAD_RISE_THRESHOLD = 1.2f
|
||||
internal const val HEIGHT_MIN = 1.4f
|
||||
internal const val HEIGHT_MAX = 1.936f
|
||||
|
||||
@@ -57,18 +57,18 @@ private fun isControllerPointingDown(snapshot: TrackerSnapshot): Boolean {
|
||||
return (forward dot Vector3.NEG_Y) >= CONTROLLER_ANGLE_THRESHOLD
|
||||
}
|
||||
|
||||
private fun isHmdLeveled(snapshot: TrackerSnapshot): Boolean {
|
||||
private fun isHeadLeveled(snapshot: TrackerSnapshot): Boolean {
|
||||
val up = snapshot.rotation.sandwich(Vector3.POS_Y)
|
||||
return (up dot Vector3.POS_Y) >= HEAD_ANGLE_THRESHOLD
|
||||
}
|
||||
|
||||
class BaseCalibrationBehaviour : HeightCalibrationBehaviourType {
|
||||
fun canCalibrate(trackers: List<TrackerState>): Boolean {
|
||||
val hasHmd = trackers.any { it.bodyPart == BodyPart.HEAD && it.position != null }
|
||||
val hasHand = trackers.any {
|
||||
val hasPositionalHead = trackers.any { it.bodyPart == BodyPart.HEAD && it.position != null }
|
||||
val hasPositionalHand = trackers.any {
|
||||
(it.bodyPart == BodyPart.LEFT_HAND || it.bodyPart == BodyPart.RIGHT_HAND) && it.position != null
|
||||
}
|
||||
return hasHmd && hasHand
|
||||
return hasPositionalHead && hasPositionalHand
|
||||
}
|
||||
|
||||
override fun observe(receiver: HeightCalibrationManager) {
|
||||
@@ -96,7 +96,7 @@ class BaseCalibrationBehaviour : HeightCalibrationBehaviourType {
|
||||
internal suspend fun runCalibrationSession(
|
||||
context: HeightCalibrationContext,
|
||||
userConfig: UserConfig,
|
||||
hmdUpdates: kotlinx.coroutines.flow.Flow<TrackerSnapshot>,
|
||||
headUpdates: kotlinx.coroutines.flow.Flow<TrackerSnapshot>,
|
||||
controllerUpdates: kotlinx.coroutines.flow.Flow<TrackerSnapshot>,
|
||||
clock: () -> Long = System::nanoTime,
|
||||
) {
|
||||
@@ -107,8 +107,8 @@ internal suspend fun runCalibrationSession(
|
||||
|
||||
var floorFiltered: Vector3? = null
|
||||
var floorEnergyEma = 0f
|
||||
var hmdFiltered: Vector3? = null
|
||||
var hmdEnergyEma = 0f
|
||||
var headFiltered: Vector3? = null
|
||||
var headEnergyEma = 0f
|
||||
|
||||
fun dispatch(status: UserHeightCalibrationStatus, height: Float = currentHeight) {
|
||||
currentHeight = height
|
||||
@@ -163,43 +163,43 @@ internal suspend fun runCalibrationSession(
|
||||
}
|
||||
|
||||
// Height phase: collect HMD updates until a terminal status is reached
|
||||
hmdUpdates
|
||||
headUpdates
|
||||
.sample(SAMPLE_INTERVAL_MS)
|
||||
.takeWhile { !context.state.value.status.isTerminal() }
|
||||
.collect { snapshot ->
|
||||
val now = clock()
|
||||
val relativeY = snapshot.position.y - currentFloorLevel
|
||||
|
||||
if (relativeY <= HMD_RISE_THRESHOLD) {
|
||||
if (relativeY <= HEAD_RISE_THRESHOLD) {
|
||||
dispatch(UserHeightCalibrationStatus.WAITING_FOR_RISE, relativeY)
|
||||
heightStableStart = null
|
||||
hmdFiltered = null
|
||||
hmdEnergyEma = 0f
|
||||
headFiltered = null
|
||||
headEnergyEma = 0f
|
||||
return@collect
|
||||
}
|
||||
|
||||
if (!isHmdLeveled(snapshot)) {
|
||||
if (!isHeadLeveled(snapshot)) {
|
||||
dispatch(UserHeightCalibrationStatus.WAITING_FOR_FW_LOOK, relativeY)
|
||||
heightStableStart = null
|
||||
hmdFiltered = null
|
||||
hmdEnergyEma = 0f
|
||||
headFiltered = null
|
||||
headEnergyEma = 0f
|
||||
return@collect
|
||||
}
|
||||
|
||||
dispatch(UserHeightCalibrationStatus.RECORDING_HEIGHT, relativeY)
|
||||
|
||||
val pos = snapshot.position
|
||||
val prev = hmdFiltered ?: pos
|
||||
val newFiltered = prev * (1f - HMD_ALPHA) + pos * HMD_ALPHA
|
||||
hmdFiltered = newFiltered
|
||||
val prev = headFiltered ?: pos
|
||||
val newFiltered = prev * (1f - HEAD_ALPHA) + pos * HEAD_ALPHA
|
||||
headFiltered = newFiltered
|
||||
|
||||
val dev = pos - newFiltered
|
||||
hmdEnergyEma = hmdEnergyEma * (1f - HMD_ALPHA) + (dev dot dev) * HMD_ALPHA
|
||||
headEnergyEma = headEnergyEma * (1f - HEAD_ALPHA) + (dev dot dev) * HEAD_ALPHA
|
||||
|
||||
if (sqrt(hmdEnergyEma) > HMD_STABILITY_THRESHOLD) {
|
||||
if (sqrt(headEnergyEma) > HEAD_STABILITY_THRESHOLD) {
|
||||
heightStableStart = null
|
||||
hmdFiltered = null
|
||||
hmdEnergyEma = 0f
|
||||
headFiltered = null
|
||||
headEnergyEma = 0f
|
||||
return@collect
|
||||
}
|
||||
|
||||
|
||||
@@ -53,17 +53,17 @@ class HeightCalibrationManager(
|
||||
private var sessionJob: Job? = null
|
||||
|
||||
// These Flows do nothing until the calibration use collect on it
|
||||
val hmdUpdates: Flow<TrackerSnapshot> = serverContext.context.state
|
||||
val headUpdates: Flow<TrackerSnapshot> = serverContext.context.state
|
||||
.flatMapLatest { state ->
|
||||
val hmd = state.trackers.values
|
||||
val positionalHead = state.trackers.values
|
||||
.find {
|
||||
val state = it.context.state.value
|
||||
state.bodyPart == BodyPart.HEAD && state.status == TrackerStatus.OK && state.position != null
|
||||
}
|
||||
?: return@flatMapLatest emptyFlow()
|
||||
hmd.context.state.map { s ->
|
||||
positionalHead.context.state.map { s ->
|
||||
TrackerSnapshot(
|
||||
position = s.position ?: error("head (or HMD) will always have a position in this case"),
|
||||
position = s.position ?: error("Head will always have a position here."),
|
||||
rotation = s.rawRotation,
|
||||
)
|
||||
}
|
||||
@@ -89,7 +89,7 @@ class HeightCalibrationManager(
|
||||
|
||||
fun start() {
|
||||
sessionJob?.cancel()
|
||||
sessionJob = context.scope.launch { runCalibrationSession(context, userConfig, hmdUpdates, controllerUpdates) }
|
||||
sessionJob = context.scope.launch { runCalibrationSession(context, userConfig, headUpdates, controllerUpdates) }
|
||||
}
|
||||
|
||||
fun cancel() {
|
||||
|
||||
@@ -152,21 +152,19 @@ class ResetsManager(val context: ResetsContext, val server: VRServer, val settin
|
||||
|
||||
private fun getResetAction(referenceRotation: Quaternion?, resetType: ResetType, bodyPart: BodyPart?, resetsConfig: ResetsConfig) = when (resetType) {
|
||||
ResetType.YAW -> TrackerActions.YawReset(referenceRotation, resetsConfig.yawResetSmoothTime.toDouble().seconds)
|
||||
ResetType.FULL -> TrackerActions.FullReset(referenceRotation, resetsConfig.resetHmdAttitude)
|
||||
ResetType.FULL -> TrackerActions.FullReset(referenceRotation, resetsConfig.resetReliableReferenceAttitude)
|
||||
ResetType.POSE_MOUNTING -> TrackerActions.PoseMountingReset(referenceRotation, getYawOffset(bodyPart, resetsConfig.armsResetMode))
|
||||
}
|
||||
|
||||
// TODO: currently HMD is a special case for calibration, but we should have something
|
||||
// more generic like "isReliable" in state or in the reset actions parameters.
|
||||
// Also need to make it more generic in the tracker reducer.
|
||||
private fun getReliableReferenceTracker(allTrackers: Collection<Tracker>) = allTrackers.firstOrNull {
|
||||
val state = it.context.state.value
|
||||
state.isHmd && state.bodyPart == BodyPart.HEAD && state.status.isActive()
|
||||
state.isAssignedReliableReference && state.status.isActive()
|
||||
}
|
||||
|
||||
// By priority, higher value = higher priority. 0 for others.
|
||||
private val referenceBodyParts = mapOf(
|
||||
BodyPart.HEAD to 6,
|
||||
BodyPart.HEAD to 7,
|
||||
BodyPart.NECK to 6,
|
||||
BodyPart.UPPER_CHEST to 5,
|
||||
BodyPart.LOWER_CHEST to 4,
|
||||
BodyPart.HIP to 3,
|
||||
|
||||
@@ -26,7 +26,7 @@ class HeightCalibrationBehaviour(
|
||||
receiver.sendRpc(
|
||||
UserHeightRecordingStatusResponse(
|
||||
status = state.status,
|
||||
hmdHeight = state.currentHeight,
|
||||
headHeight = state.currentHeight,
|
||||
),
|
||||
)
|
||||
}.launchIn(receiver.context.scope)
|
||||
|
||||
@@ -22,7 +22,7 @@ class ResetsBehaviour(
|
||||
armsResetMode = config.armsResetMode,
|
||||
yawResetSmoothTime = config.yawResetSmoothTime,
|
||||
saveMountingReset = config.saveMountingReset,
|
||||
resetHmdAttitude = config.resetHmdAttitude,
|
||||
resetReliableReferenceAttitude = config.resetReliableReferenceAttitude,
|
||||
),
|
||||
)
|
||||
}.launchIn(receiver.context.scope)
|
||||
@@ -37,7 +37,7 @@ class ResetsBehaviour(
|
||||
armsResetMode = req.armsResetMode,
|
||||
yawResetSmoothTime = req.yawResetSmoothTime,
|
||||
saveMountingReset = req.saveMountingReset,
|
||||
resetHmdAttitude = req.resetHmdAttitude,
|
||||
resetReliableReferenceAttitude = req.resetReliableReferenceAttitude,
|
||||
),
|
||||
)
|
||||
},
|
||||
|
||||
@@ -62,9 +62,9 @@ class SkeletonProportionsBehaviour(
|
||||
}.launchIn(receiver.context.scope)
|
||||
|
||||
receiver.rpcDispatcher.on<ChangeUserHeightRequest> { req ->
|
||||
val hmdHeight = req.hmdHeight ?: return@on
|
||||
val headHeight = req.headHeight ?: return@on
|
||||
val floorHeight = req.floorHeight ?: 0f
|
||||
val height = hmdHeight - floorHeight
|
||||
val height = headHeight - floorHeight
|
||||
if (height >= MIN_HEIGHT) {
|
||||
userConfig.context.dispatch(
|
||||
UserConfigActions.Update {
|
||||
|
||||
@@ -24,7 +24,7 @@ private val CHECKLIST_STEP_ORDER: List<TrackingChecklistStepId> = listOf(
|
||||
TrackingChecklistStepId.FULL_RESET,
|
||||
TrackingChecklistStepId.MOUNTING_CALIBRATION,
|
||||
TrackingChecklistStepId.FEET_MOUNTING_CALIBRATION,
|
||||
TrackingChecklistStepId.UNASSIGNED_HMD,
|
||||
TrackingChecklistStepId.UNASSIGNED_RELIABLE_REFERENCE,
|
||||
TrackingChecklistStepId.STAY_ALIGNED_CONFIGURED,
|
||||
TrackingChecklistStepId.VRCHAT_OSC_TRACKING_DISABLED,
|
||||
TrackingChecklistStepId.VRCHAT_SETTINGS,
|
||||
|
||||
@@ -90,8 +90,11 @@ data class TrackerState(
|
||||
val stayAlignedData: StayAlignedData,
|
||||
val pendingSkeletonResets: List<ResetType> = emptyList(),
|
||||
) {
|
||||
/** Considered an HMD if it comes from driver and driver told us it's the head. */
|
||||
val isHmd = origin == DeviceOrigin.DRIVER && intendedBodyPart == BodyPart.HEAD
|
||||
private val isHmd = origin == DeviceOrigin.DRIVER && intendedBodyPart == BodyPart.HEAD
|
||||
|
||||
/** Indicates if the tracker is a reliable reference for aligning other trackers. */
|
||||
val isReliableReference = isHmd
|
||||
val isAssignedReliableReference = isReliableReference && bodyPart == intendedBodyPart
|
||||
}
|
||||
|
||||
fun List<TrackerState>.getFirstActiveFor(bodyPart: BodyPart): TrackerState? = this.firstOrNull { it.bodyPart == bodyPart && it.status.isActive() }
|
||||
@@ -106,7 +109,7 @@ sealed interface TrackerActions {
|
||||
data class SetRotation(val rotation: Quaternion? = null, val acceleration: Vector3? = null, val magnetometer: Vector3? = null, val position: Vector3? = null, val increaseTps: Boolean = true) : TrackerActions
|
||||
data class SetMountingOrientation(val mountingOrientation: HeadingAlignment) : TrackerActions
|
||||
data class SetRestOrientation(val restOrientation: Quaternion) : TrackerActions
|
||||
data class FullReset(val referenceRotation: Quaternion?, val resetHmdAttitude: Boolean = false) : TrackerActions
|
||||
data class FullReset(val referenceRotation: Quaternion?, val resetReliableReferenceAttitude: Boolean = false) : TrackerActions
|
||||
data class YawReset(val referenceRotation: Quaternion?, val smoothTime: Duration = Duration.ZERO) : TrackerActions
|
||||
data class TickYawResetSmoothing(val heading: HeadingCorrection, val done: Boolean) : TrackerActions
|
||||
data class PoseMountingReset(val referenceRotation: Quaternion?, val yawOffset: Float) : TrackerActions
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package dev.slimevr.tracker
|
||||
|
||||
import io.github.axisangles.ktmath.Quaternion
|
||||
import solarxr_protocol.datatypes.BodyPart
|
||||
import solarxr_protocol.datatypes.MountingMethod
|
||||
import solarxr_protocol.rpc.ResetType
|
||||
import kotlin.time.Duration
|
||||
@@ -71,8 +70,6 @@ fun reduce(
|
||||
}
|
||||
|
||||
is TrackerActions.SetMountingOrientation -> {
|
||||
if (state.isHmd) return state
|
||||
|
||||
state.copy(
|
||||
mountingOrientation = action.mountingOrientation,
|
||||
sessionCalibration = state.sessionCalibration.copy(
|
||||
@@ -89,11 +86,10 @@ fun reduce(
|
||||
rotationDirty = true,
|
||||
)
|
||||
|
||||
// TODO centaur when using both a positional and an IMU tracker on spine.
|
||||
is TrackerActions.FullReset -> {
|
||||
val alignAttitude = !state.isHmd || action.resetHmdAttitude
|
||||
val correctHeading = !state.isHmd && action.referenceRotation != null
|
||||
val alignHeading = !state.isHmd && state.position != null && action.referenceRotation != null
|
||||
val alignAttitude = !state.isAssignedReliableReference || action.resetReliableReferenceAttitude
|
||||
val correctHeading = action.referenceRotation != null
|
||||
val alignHeading = state.position != null && action.referenceRotation != null
|
||||
|
||||
val referenceRotation = action.referenceRotation ?: state.rawRotation
|
||||
|
||||
@@ -110,7 +106,7 @@ fun reduce(
|
||||
referenceRotation,
|
||||
)
|
||||
} else {
|
||||
state.sessionCalibration.attitudeAlignment
|
||||
Quaternion.IDENTITY
|
||||
}
|
||||
val headingAlignment =
|
||||
if (alignHeading) {
|
||||
@@ -175,9 +171,9 @@ fun reduce(
|
||||
val referenceRotation = action.referenceRotation ?: state.rotation
|
||||
|
||||
// Positional trackers' heading is aligned on full reset, not on mounting reset, except for a reference.
|
||||
val alignHeading = (state.position == null || action.referenceRotation == null) && !state.isHmd
|
||||
val alignHeading = state.position == null || action.referenceRotation == null
|
||||
// A positional reference tracker needs to correct its heading on mounting reset.
|
||||
val correctHeading = state.position != null && action.referenceRotation == null && !state.isHmd
|
||||
val correctHeading = state.position != null && action.referenceRotation == null
|
||||
|
||||
val headingAlignment = if (alignHeading) {
|
||||
estimateHeadingAlign(
|
||||
|
||||
@@ -36,12 +36,12 @@ fun applyFullCalibration(
|
||||
rawRotation: CalibratedRotation,
|
||||
trackerState: TrackerState,
|
||||
): CalibratedRotation {
|
||||
// Don't use heading alignment for an assigned HMD
|
||||
val isAssignedHmd = trackerState.isHmd && trackerState.bodyPart == BodyPart.HEAD
|
||||
val headingAlignment = if (isAssignedHmd) Quaternion.IDENTITY else trackerState.sessionCalibration.headingAlignment
|
||||
// Never use heading correction/alignment for an assigned reliable reference
|
||||
val headingCorrection = if (trackerState.isAssignedReliableReference) Quaternion.IDENTITY else trackerState.sessionCalibration.headingCorrection
|
||||
val headingAlignment = if (trackerState.isAssignedReliableReference) Quaternion.IDENTITY else trackerState.sessionCalibration.headingAlignment
|
||||
return applyCalibration(
|
||||
rawRotation,
|
||||
trackerState.sessionCalibration.headingCorrection,
|
||||
headingCorrection,
|
||||
trackerState.sessionCalibration.attitudeAlignment,
|
||||
headingAlignment,
|
||||
trackerState.restOrientation,
|
||||
@@ -80,13 +80,13 @@ fun applyFullCalibration(
|
||||
rawRotation: RawRotation,
|
||||
trackerState: TrackerState,
|
||||
): CalibratedAcceleration {
|
||||
// Don't use heading alignment for an assigned HMD
|
||||
val isAssignedHmd = trackerState.isHmd && trackerState.bodyPart == BodyPart.HEAD
|
||||
val headingAlignment = if (isAssignedHmd) Quaternion.IDENTITY else trackerState.sessionCalibration.headingAlignment
|
||||
// Never use heading correction/alignment for an assigned reliable reference
|
||||
val headingCorrection = if (trackerState.isAssignedReliableReference) Quaternion.IDENTITY else trackerState.sessionCalibration.headingCorrection
|
||||
val headingAlignment = if (trackerState.isAssignedReliableReference) Quaternion.IDENTITY else trackerState.sessionCalibration.headingAlignment
|
||||
return applyCalibration(
|
||||
rawAcceleration,
|
||||
rawRotation,
|
||||
trackerState.sessionCalibration.headingCorrection,
|
||||
headingCorrection,
|
||||
headingAlignment,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ package dev.slimevr.trackingchecklist
|
||||
import dev.slimevr.VRServer
|
||||
import dev.slimevr.VRServerState
|
||||
import dev.slimevr.config.Settings
|
||||
import dev.slimevr.device.DeviceState
|
||||
import dev.slimevr.networkprofile.NetworkProfileManager
|
||||
import dev.slimevr.resets.ResetBodyParts
|
||||
import dev.slimevr.resets.ResetsManager
|
||||
@@ -45,7 +44,7 @@ import solarxr_protocol.rpc.TrackingChecklistStepId
|
||||
import solarxr_protocol.rpc.TrackingChecklistStepVisibility
|
||||
import solarxr_protocol.rpc.TrackingChecklistTrackerError
|
||||
import solarxr_protocol.rpc.TrackingChecklistTrackerReset
|
||||
import solarxr_protocol.rpc.TrackingChecklistUnassignedHMD
|
||||
import solarxr_protocol.rpc.TrackingChecklistUnassignedReliableReference
|
||||
import solarxr_protocol.rpc.VRCOSCTrackingDataState
|
||||
|
||||
// Flat-maps a server state flow into a combined flow of all context states for a given collection.
|
||||
@@ -77,7 +76,8 @@ data class ChecklistTracker(
|
||||
val origin: DeviceOrigin,
|
||||
val status: TrackerStatus,
|
||||
val bodyPart: BodyPart?,
|
||||
val isHmd: Boolean,
|
||||
val intendedBodyPart: BodyPart?,
|
||||
val isReliableReference: Boolean,
|
||||
val imuType: ImuType?,
|
||||
val completedRestCalibration: Boolean?,
|
||||
// Deliberately not the position itself: the checks only ask whether there is one, and carrying the
|
||||
@@ -90,7 +90,8 @@ fun checklistTracker(tracker: TrackerState) = ChecklistTracker(
|
||||
origin = tracker.origin,
|
||||
status = tracker.status,
|
||||
bodyPart = tracker.bodyPart,
|
||||
isHmd = tracker.isHmd,
|
||||
intendedBodyPart = tracker.intendedBodyPart,
|
||||
isReliableReference = tracker.isReliableReference,
|
||||
imuType = tracker.imuType,
|
||||
completedRestCalibration = tracker.completedRestCalibration,
|
||||
hasPosition = tracker.position != null,
|
||||
@@ -100,18 +101,19 @@ internal fun trackerStatesFlow(server: VRServer): Flow<List<ChecklistTracker>> =
|
||||
tracker.context.state.map { state -> checklistTracker(state) }.distinctUntilChanged()
|
||||
}
|
||||
|
||||
class HMDCheckBehaviour(private val trackerStates: StateFlow<List<ChecklistTracker>>) : TrackingChecklistBehaviourType {
|
||||
class ReliableReferenceCheckBehaviour(private val trackerStates: StateFlow<List<ChecklistTracker>>) : TrackingChecklistBehaviourType {
|
||||
private fun computeStep(trackers: List<ChecklistTracker>): TrackingChecklistStep {
|
||||
val hmdTracker = trackers.firstOrNull { tracker -> tracker.isHmd }
|
||||
val isAssigned = hmdTracker?.bodyPart == BodyPart.HEAD
|
||||
val reliableReference = trackers.firstOrNull { tracker -> tracker.isReliableReference }
|
||||
val isAssigned = reliableReference?.bodyPart == reliableReference?.intendedBodyPart
|
||||
return TrackingChecklistStep(
|
||||
valid = isAssigned,
|
||||
enabled = hmdTracker != null,
|
||||
enabled = reliableReference != null,
|
||||
ignorable = true,
|
||||
visibility = TrackingChecklistStepVisibility.WHEN_INVALID,
|
||||
extraData = if (hmdTracker != null && !isAssigned) {
|
||||
TrackingChecklistUnassignedHMD(
|
||||
trackerId = hmdTracker.id.toUShort(),
|
||||
extraData = if (reliableReference != null && !isAssigned) {
|
||||
TrackingChecklistUnassignedReliableReference(
|
||||
trackerId = reliableReference.id.toUShort(),
|
||||
intendedBodyPart = reliableReference.intendedBodyPart ?: BodyPart.NONE,
|
||||
)
|
||||
} else {
|
||||
null
|
||||
@@ -123,7 +125,7 @@ class HMDCheckBehaviour(private val trackerStates: StateFlow<List<ChecklistTrack
|
||||
trackerStates
|
||||
.map { trackers -> computeStep(trackers) }
|
||||
.distinctUntilChanged()
|
||||
.onEach { step -> receiver.context.dispatch(TrackingChecklistActions.UpdateStep(TrackingChecklistStepId.UNASSIGNED_HMD, step)) }
|
||||
.onEach { step -> receiver.context.dispatch(TrackingChecklistActions.UpdateStep(TrackingChecklistStepId.UNASSIGNED_RELIABLE_REFERENCE, step)) }
|
||||
.launchIn(receiver.context.scope)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ class TrackingChecklist(
|
||||
.stateIn(context.scope, SharingStarted.Eagerly, initialValue = emptyList())
|
||||
|
||||
val stepBehaviours: List<TrackingChecklistBehaviourType> = buildList {
|
||||
add(HMDCheckBehaviour(trackerStates))
|
||||
add(ReliableReferenceCheckBehaviour(trackerStates))
|
||||
add(TrackerRestCheckBehaviour(trackerStates))
|
||||
add(FullResetCheckBehaviour(trackerStates, appContext.resetsManager))
|
||||
add(MountingCalibrationCheckBehaviour(trackerStates, appContext.resetsManager, appContext.config.settings))
|
||||
|
||||
@@ -16,7 +16,7 @@ import solarxr_protocol.rpc.VRCSpineMode
|
||||
import solarxr_protocol.rpc.VRCTrackerModel
|
||||
import kotlin.math.abs
|
||||
|
||||
// The HMD height is taken from the HMD pose, which is between the eyes.
|
||||
// The head height is usually taken from the HMD pose, which is between the eyes.
|
||||
// This compensates for the offset to the full height (top of the head).
|
||||
// From Drillis and Contini (1966)
|
||||
const val EYE_HEIGHT_TO_HEIGHT_RATIO = 0.936f
|
||||
|
||||
Reference in new issue
Block a user