Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Positional tracker support #920

Open
wants to merge 68 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
533750b
commit starting code
Stermere Sep 19, 2023
624628c
more bug fixes
Stermere Sep 25, 2023
607fb3b
it works!
Stermere Sep 26, 2023
09dbb0d
simplify forward pass
Stermere Sep 26, 2023
d34b1e5
remove pointless class
Stermere Oct 19, 2023
4bcac94
add Constraint
Stermere Oct 19, 2023
bd41b5a
Make Constraint abstract to allow multiple constraint types to be added
Stermere Dec 23, 2023
a57191d
bug fixes and move classes to own file
Stermere Dec 23, 2023
1ceba55
add constraints to each bone
Stermere Dec 23, 2023
36b69a0
bug fixes + use quat lib projection
Stermere Dec 24, 2023
8606c0e
add apply Constraint Inverse
Stermere Dec 27, 2023
96638dc
bug fixes + make vars private
Stermere Dec 27, 2023
17abee4
fix centroid deadlocking
Stermere Dec 28, 2023
16fb03e
modify applyConstraint + add CompleteConstraint
Stermere Dec 28, 2023
20e4505
spotless
Stermere Dec 28, 2023
a80d7fd
add allowModification to Constraint
Stermere Dec 31, 2023
70f3259
add locking of rotation on bones where a rotation tracker is present
Stermere Dec 31, 2023
cb69dd3
account for bone.rotationOffset + change input to constrainRotation
Stermere Jan 2, 2024
6e3eb0f
fix constrain function
Stermere Jan 5, 2024
fd5363f
formatting + add position offset at time of reset
Stermere Jan 5, 2024
e5d237c
update skeletal constraints
Stermere Jan 5, 2024
0c60b7a
spotless
Stermere Jan 6, 2024
a8ca8f8
add base constraint offset cause its actually needed
Stermere Jan 6, 2024
16771d4
fix bug where a constrained sub-base being unable to solve would affe…
Stermere Jan 13, 2024
7ec4368
fix bug where a chain would jitter if in reach of the target but unab…
Stermere Jan 14, 2024
a879967
small things
Stermere Feb 19, 2024
66b3967
Add IKConstraint
Stermere Feb 20, 2024
57e732b
Reduce IKSolver control in the spine area
Stermere Feb 20, 2024
dfb048a
Allow deviation from rotational constraints if the chains cannot solve
Stermere Mar 18, 2024
1d5a1a5
Update loosening to be more selective and fix chain builder bug
Stermere Mar 26, 2024
025a3ac
Fix bugs, remove unused code
Stermere Mar 29, 2024
ac4fb46
change imports
Stermere Mar 29, 2024
bdedcb0
make spotless happy
Stermere Mar 29, 2024
7af8d66
Fix bug causing NULL Quaternion
Stermere Mar 30, 2024
597bd28
pause ikSolver
Stermere Mar 30, 2024
97e60a3
small formatting things
Stermere Apr 4, 2024
e2480e3
change math
Stermere Apr 4, 2024
e8a41bb
Add toggle for using position information
Stermere Apr 24, 2024
30f0e4b
Fix lint
Stermere May 6, 2024
26e6150
Refactor and simplify constraints
Stermere Jun 18, 2024
d28a209
simplify loosening logic
Stermere Jun 18, 2024
d78e9ca
Fix trackers being assigned a bone when they are unassigned
Stermere Jun 24, 2024
bccaf78
save state before switching it CCDIK
Stermere Jul 7, 2024
0c00385
switch from FABRIK to CCDIK
Stermere Jul 11, 2024
0aaab71
reduce jitter further
Stermere Jul 12, 2024
0a9d3ff
Tuning and better chain control
Stermere Jul 13, 2024
41e242d
fix bugs
Stermere Jul 14, 2024
9bf1b98
Fix hinge constraint bugs and add annealing
Stermere Jul 25, 2024
7e1d1c6
Update server/core/src/main/java/dev/slimevr/tracking/processor/Const…
Stermere Jul 26, 2024
1b87235
Format fixes
Stermere Jul 29, 2024
465e27c
Enforce constraints bidirectionally
Stermere Aug 18, 2024
3b05952
Add upper elbow
Stermere Aug 23, 2024
b377c99
small fixes + optimization
Stermere Aug 31, 2024
b9d206d
Enforce constraints within the skeleton
Stermere Aug 31, 2024
0bf893e
formmating
Stermere Aug 31, 2024
5f47860
Correct for constrain violation
Stermere Sep 9, 2024
e02461d
fix bugs, add loose hinge constraint
Stermere Sep 16, 2024
7e6ec3a
Formatting
Stermere Sep 16, 2024
5529474
Increase hinge constraint loose-ness
Stermere Sep 17, 2024
cbacad9
fix decomposition
Stermere Sep 23, 2024
d4450dc
Add toggles for enabling skeleton constraints
Stermere Sep 23, 2024
69d28ca
lint
Stermere Sep 23, 2024
7d02d7d
fix IK breaking at 180 degree rotations relative to the parent
Stermere Sep 27, 2024
c69d301
Adjust hand constraints and fix constraint corrections interaction wi…
Stermere Oct 15, 2024
60b7b52
Add target and end effector offset to improve solver stability
Stermere Oct 15, 2024
da67cd8
spotless
Stermere Oct 15, 2024
3701865
Always use constraints in iksolver
Stermere Oct 30, 2024
75c3289
Update solarxr-protocol
Stermere Oct 30, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions gui/public/i18n/en/translation.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,14 @@ settings-general-fk_settings-leg_tweak-foot_plant-description = Foot-plant rotat
settings-general-fk_settings-leg_fk = Leg tracking
settings-general-fk_settings-leg_fk-reset_mounting_feet-description = Enable feet Mounting Reset by tiptoeing.
settings-general-fk_settings-leg_fk-reset_mounting_feet = Feet Mounting Reset
settings-general-fk_settings-enforce_joint_constraints = Skeletal Limits
settings-general-fk_settings-enforce_joint_constraints-enforce_constraints = Enforce constraints
settings-general-fk_settings-enforce_joint_constraints-enforce_constraints-description = Prevents joints from rotating past their limit
settings-general-fk_settings-enforce_joint_constraints-correct_constraints = Correct with constraints
settings-general-fk_settings-enforce_joint_constraints-correct_constraints-description = Correct joint rotations when they push last their limit
settings-general-fk_settings-ik = Position data
settings-general-fk_settings-ik-use_position = Use Position data
settings-general-fk_settings-ik-use_position-description = Enables the use of position data from trackers that provide it. When enabling this make sure to full reset and recalibrate in game.
settings-general-fk_settings-arm_fk = Arm tracking
settings-general-fk_settings-arm_fk-description = Force arms to be tracked from the headset (HMD) even if positional hand data is available.
settings-general-fk_settings-arm_fk-force_arms = Force arms from HMD
Expand Down
74 changes: 74 additions & 0 deletions gui/src/components/settings/pages/GeneralSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ interface SettingsForm {
toeSnap: boolean;
footPlant: boolean;
selfLocalization: boolean;
usePosition: boolean;
enforceConstraints: boolean;
correctConstraints: boolean;
};
ratios: {
imputeWaistFromChestHip: number;
Expand Down Expand Up @@ -128,6 +131,9 @@ const defaultValues: SettingsForm = {
toeSnap: false,
footPlant: true,
selfLocalization: false,
usePosition: true,
enforceConstraints: true,
correctConstraints: true,
},
ratios: {
imputeWaistFromChestHip: 0.3,
Expand Down Expand Up @@ -235,6 +241,9 @@ export function GeneralSettings() {
toggles.toeSnap = values.toggles.toeSnap;
toggles.footPlant = values.toggles.footPlant;
toggles.selfLocalization = values.toggles.selfLocalization;
toggles.usePosition = values.toggles.usePosition;
toggles.enforceConstraints = values.toggles.enforceConstraints;
toggles.correctConstraints = values.toggles.correctConstraints;
modelSettings.toggles = toggles;
}

Expand Down Expand Up @@ -981,6 +990,7 @@ export function GeneralSettings() {
)}
/>
</div>

<Typography color="secondary">
{l10n.getString(
'settings-general-fk_settings-arm_fk-reset_mode-description'
Expand Down Expand Up @@ -1033,6 +1043,70 @@ export function GeneralSettings() {
></Radio>
</div>

<div className="flex flex-col pt-2 pb-3">
<Typography bold>
{l10n.getString(
'settings-general-fk_settings-enforce_joint_constraints'
)}
</Typography>
<Typography color="secondary">
{l10n.getString(
'settings-general-fk_settings-enforce_joint_constraints-enforce_constraints-description'
)}
</Typography>
</div>
<div className="grid sm:grid-cols-1 pb-3">
<CheckBox
variant="toggle"
outlined
control={control}
name="toggles.enforceConstraints"
label={l10n.getString(
'settings-general-fk_settings-enforce_joint_constraints-enforce_constraints'
)}
/>
</div>
<div className="flex flex-col pt-2 pb-3">
<Typography color="secondary">
{l10n.getString(
'settings-general-fk_settings-enforce_joint_constraints-correct_constraints-description'
)}
</Typography>
</div>
<div className="grid sm:grid-cols-1 pb-3">
<CheckBox
variant="toggle"
outlined
control={control}
name="toggles.correctConstraints"
label={l10n.getString(
'settings-general-fk_settings-enforce_joint_constraints-correct_constraints'
)}
/>
</div>

<div className="flex flex-col pt-2 pb-3">
<Typography bold>
{l10n.getString('settings-general-fk_settings-ik')}
</Typography>
<Typography color="secondary">
{l10n.getString(
'settings-general-fk_settings-ik-use_position-description'
)}
</Typography>
</div>
<div className="grid sm:grid-cols-1 pb-3">
<CheckBox
variant="toggle"
outlined
control={control}
name="toggles.usePosition"
label={l10n.getString(
'settings-general-fk_settings-ik-use_position'
)}
/>
</div>

{config?.debug && (
<>
<div className="flex flex-col pt-2 pb-3">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,11 @@ class AutoBoneStep(
// Load server configs into the skeleton
skeleton1.loadFromConfig(serverConfig)
skeleton2.loadFromConfig(serverConfig)
// Disable leg tweaks, this will mess with the resulting positions
// Disable leg tweaks and IK solver, these will mess with the resulting positions
skeleton1.setLegTweaksEnabled(false)
skeleton2.setLegTweaksEnabled(false)
skeleton1.setIKSolverEnabled(false)
skeleton2.setIKSolverEnabled(false)
}

fun setCursors(cursor1: Int, cursor2: Int, updatePlayerCursors: Boolean) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class QuaternionMovingAverage(
initialRotation: Quaternion,
) {
var filteredQuaternion = IDENTITY
var filteringImpact = 0f
private var smoothFactor = 0f
private var predictFactor = 0f
private lateinit var rotBuffer: CircularArrayList<Quaternion>
Expand Down Expand Up @@ -91,6 +92,8 @@ class QuaternionMovingAverage(
// Smooth towards the target rotation by the slerp factor
filteredQuaternion = smoothingQuaternion.interpR(latestQuaternion, amt)
}

filteringImpact = latestQuaternion.angleToR(filteredQuaternion)
}

@Synchronized
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,9 @@ public static int createModelSettings(
humanPoseManager.getToggle(SkeletonConfigToggles.TOE_SNAP),
humanPoseManager.getToggle(SkeletonConfigToggles.FOOT_PLANT),
humanPoseManager.getToggle(SkeletonConfigToggles.SELF_LOCALIZATION),
false
humanPoseManager.getToggle(SkeletonConfigToggles.USE_POSITION),
humanPoseManager.getToggle(SkeletonConfigToggles.ENFORCE_CONSTRAINTS),
humanPoseManager.getToggle(SkeletonConfigToggles.CORRECT_CONSTRAINTS)
);
int ratiosOffset = ModelRatios
.createModelRatios(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,9 @@ class RPCSettingsHandler(var rpcHandler: RPCHandler, var api: ProtocolAPI) {
hpm.setToggle(SkeletonConfigToggles.TOE_SNAP, toggles.toeSnap())
hpm.setToggle(SkeletonConfigToggles.FOOT_PLANT, toggles.footPlant())
hpm.setToggle(SkeletonConfigToggles.SELF_LOCALIZATION, toggles.selfLocalization())
hpm.setToggle(SkeletonConfigToggles.USE_POSITION, toggles.usePosition())
hpm.setToggle(SkeletonConfigToggles.ENFORCE_CONSTRAINTS, toggles.enforceConstraints())
hpm.setToggle(SkeletonConfigToggles.CORRECT_CONSTRAINTS, toggles.correctConstraints())
}

if (ratios != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import java.util.concurrent.CopyOnWriteArrayList
/**
* Represents a bone composed of 2 joints: headNode and tailNode.
*/
class Bone(val boneType: BoneType) {
class Bone(val boneType: BoneType, val rotationConstraint: Constraint) {
private val headNode = TransformNode(true)
private val tailNode = TransformNode(false)
var parent: Bone? = null
Expand Down Expand Up @@ -58,6 +58,14 @@ class Bone(val boneType: BoneType) {
headNode.update()
}

/**
* Computes the rotations and positions of this bone.
*/
fun updateThisNode() {
headNode.updateThisNode()
tailNode.updateThisNode()
}

/**
* Returns the world-aligned rotation of the bone
*/
Expand All @@ -75,6 +83,13 @@ class Bone(val boneType: BoneType) {
headNode.localTransform.rotation = rotation * rotationOffset
}

/**
* Sets the global rotation of the bone directly
*/
fun setRotationRaw(rotation: Quaternion) {
headNode.localTransform.rotation = rotation
}

/**
* Returns the global position of the head of the bone
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ public enum BoneType {
RIGHT_UPPER_ARM(BodyPart.RIGHT_UPPER_ARM),
LEFT_SHOULDER(BodyPart.LEFT_SHOULDER),
RIGHT_SHOULDER(BodyPart.RIGHT_SHOULDER),
LEFT_UPPER_SHOULDER,
RIGHT_UPPER_SHOULDER,
LEFT_HAND(BodyPart.LEFT_HAND),
RIGHT_HAND(BodyPart.RIGHT_HAND),
LEFT_HAND_TRACKER,
Expand Down
Loading