From ba19eeb21d8e261130cb255d623b794ab1ac1af6 Mon Sep 17 00:00:00 2001 From: spatialfree Date: Sat, 29 Apr 2023 09:58:29 -0400 Subject: [PATCH] flexion iteration --- Micro.bat | 10 --------- src/Mono.cs | 2 +- src/Rig/Rig.cs | 36 ++++++++++++++++++++++-------- src/dofs/wave-cursor/WaveCursor.cs | 14 ------------ 4 files changed, 28 insertions(+), 34 deletions(-) delete mode 100644 Micro.bat diff --git a/Micro.bat b/Micro.bat deleted file mode 100644 index a9bded0..0000000 --- a/Micro.bat +++ /dev/null @@ -1,10 +0,0 @@ -@REM make console window active -@REM powershell -window normal -command "" -dotnet build -pause -cd bin/Debug -@REM echo "zipping into dofdev site" -@REM 7z u oriels.zip %cd%/netcoreapp3.1 -@REM Xcopy "oriels.zip" "C:/dofdev/Web Development/dofdev/res/oriels.zip" /F /Y -cd net6.0 -oriels.exe \ No newline at end of file diff --git a/src/Mono.cs b/src/Mono.cs index b194fcd..c55ff80 100644 --- a/src/Mono.cs +++ b/src/Mono.cs @@ -173,7 +173,7 @@ public class Mono { } int dofIndex = 0; - Pose windowPoseButton = new Pose(-0.5f, 1.3f, 0, Quat.FromAngles(0, -90f, 0)); + Pose windowPoseButton = new Pose(0, 1f, -0.5f, Quat.FromAngles(0, 0, 0)); TextStyle style = Text.MakeStyle(Font.FromFile("add/fonts/DM-Mono.ttf"), 1f * U.cm, Color.White); TextStyle style2 = Text.MakeStyle(Font.FromFile("add/fonts/DM-Mono.ttf"), 1f * U.cm, new Color(0.5f, 0.5f, 0.5f)); Vec2 fieldSize = new Vec2(6f * U.cm, 3f * U.cm); diff --git a/src/Rig/Rig.cs b/src/Rig/Rig.cs index bc749d7..925ed61 100644 --- a/src/Rig/Rig.cs +++ b/src/Rig/Rig.cs @@ -83,21 +83,39 @@ public class Rig { lWrist = new Pose(lCon.pos + lCon.ori * new Vec3(0, 0, 0.052f), lCon.ori); } - public float Flexion(Hand hand, FingerId finger, float deadzone = 0.15f) { - float flexion = (Vec3.Dot( - PullRequest.Direction( - hand.Get(finger, JointId.Tip).position, - hand.Get(finger, JointId.KnuckleMinor).position + public float Flexion(Hand hand, FingerId id) { + float fingerFlex = (Vec3.Dot( + Vec3.Direction( + hand.Get(id, JointId.Tip).position, + hand.Get(id, JointId.KnuckleMinor).position ), - PullRequest.Direction( - hand.Get(finger, JointId.KnuckleMid).position, - hand.Get(finger, JointId.KnuckleMajor).position + Vec3.Direction( + hand.Get(id, JointId.KnuckleMid).position, + hand.Get(id, JointId.KnuckleMajor).position ) ) + 1f) / 2; - flexion = Math.Max(flexion - deadzone, 0f) / (1 - deadzone); + float fingerTrim = 0.15f; + fingerFlex = Math.Max(fingerFlex - fingerTrim, 0f) / (1 - fingerTrim); + + float knuckleFlex = (Vec3.Dot( + Vec3.Direction( + hand.Get(id, JointId.KnuckleMid).position, + hand.Get(id, JointId.KnuckleMajor).position + ), + Vec3.Direction( + hand.Get(id, JointId.KnuckleMajor).position, + hand.Get(id, JointId.Root).position + ) + ) + 1f) / 2; + + float knuckleTrim = 0.666f; + knuckleFlex = Math.Max(knuckleFlex - knuckleTrim, 0f) / (1 - knuckleTrim); + + float flexion = knuckleFlex + fingerFlex; return flexion * flexion; } + public Vec3 Fullstick(bool chirality) { Controller con = Con(chirality).device; diff --git a/src/dofs/wave-cursor/WaveCursor.cs b/src/dofs/wave-cursor/WaveCursor.cs index 4b64746..3352a34 100644 --- a/src/dofs/wave-cursor/WaveCursor.cs +++ b/src/dofs/wave-cursor/WaveCursor.cs @@ -92,18 +92,4 @@ class WaveCursor : dof { /* COMMENTS - !uses a naive flexion method - that needs a refactor to - to both track for - finger & knuckle flexion - - as they are intertwined at the intersection - in way that can't be ignored and must be derived! - in order to have a principled wave-cursor - (let alone a rolls-cursor) - - - sidetest: may be useful for interactions! - where you can use the finger flexion for grabbing - and knuckle flexion for cursor extension */ \ No newline at end of file