From 31ea612af56be2b1146d7bb9d8be5b14a7f1ebc9 Mon Sep 17 00:00:00 2001 From: spatialfree Date: Sun, 28 Jan 2024 13:24:23 -0500 Subject: [PATCH] visual braille feedback for demonstration --- sk_demo/src/Mono.cs | 100 +++++++++++++++++++++++++++++++++++++++++--- todo.md | 9 ++-- 2 files changed, 99 insertions(+), 10 deletions(-) diff --git a/sk_demo/src/Mono.cs b/sk_demo/src/Mono.cs index 92765d8..b954b34 100644 --- a/sk_demo/src/Mono.cs +++ b/sk_demo/src/Mono.cs @@ -21,14 +21,68 @@ public class Mono { int last_xi = 0; + public class Character { + public string character; + public int[] dots; + public Character(string character, int[] dots) { + this.character = character; + this.dots = dots; + } + } + + // braille dots + // {{0, 0, + // 0, 0, + // 0, 0 + // }}, // _ + // {{1, 0, + // 0, 0, + // 0, 0 + // }}, // a + // {{1, 0, + // 1, 0, + // 0, 0 + // }}, // b + // alphabet a-z - string[] characters = new string[] { - "_", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", - "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", - "u", "v", "w", "x", "y", "z" + // string[] characters = new string[] { + // "_", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", + // "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", + // "u", "v", "w", "x", "y", "z" + // }; + Character[] characters = new Character[] { + new Character("_", new int[] {0, 0, 0, 0, 0, 0}), + new Character("a", new int[] {1, 0, 0, 0, 0, 0}), + new Character("b", new int[] {1, 0, 1, 0, 0, 0}), + new Character("c", new int[] {1, 1, 0, 0, 0, 0}), + new Character("d", new int[] {1, 1, 0, 1, 0, 0}), + new Character("e", new int[] {1, 0, 0, 1, 0, 0}), + new Character("f", new int[] {1, 1, 1, 0, 0, 0}), + new Character("g", new int[] {1, 1, 1, 1, 0, 0}), + new Character("h", new int[] {1, 0, 1, 1, 0, 0}), + new Character("i", new int[] {0, 1, 1, 0, 0, 0}), + new Character("j", new int[] {0, 1, 1, 1, 0, 0}), + new Character("k", new int[] {1, 0, 0, 0, 1, 0}), + new Character("l", new int[] {1, 0, 1, 0, 1, 0}), + new Character("m", new int[] {1, 1, 0, 0, 1, 0}), + new Character("n", new int[] {1, 1, 0, 1, 1, 0}), + new Character("o", new int[] {1, 0, 0, 1, 1, 0}), + new Character("p", new int[] {1, 1, 1, 0, 1, 0}), + new Character("q", new int[] {1, 1, 1, 1, 1, 0}), + new Character("r", new int[] {1, 0, 1, 1, 1, 0}), + new Character("s", new int[] {0, 1, 1, 0, 1, 0}), + new Character("t", new int[] {0, 1, 1, 1, 1, 0}), + new Character("u", new int[] {1, 0, 0, 0, 1, 1}), + new Character("v", new int[] {1, 0, 1, 0, 1, 1}), + new Character("w", new int[] {0, 1, 1, 1, 0, 1}), + new Character("x", new int[] {1, 1, 0, 0, 1, 1}), + new Character("y", new int[] {1, 1, 0, 1, 1, 1}), + new Character("z", new int[] {1, 0, 0, 1, 1, 1}) }; + + public void Init() { rig.Init(); @@ -61,8 +115,17 @@ public class Mono { int xi = (int)(rig.hand_1.palm.position.x * 20f); xi = Math.Clamp(xi + 10, 0, 26); - Log.Info($"xi: {xi}"); + + Matrix palm_ori = rig.hand_1.palm.ToMatrix(); + Vec3 thumb_tip = palm_ori.Inverse * rig.hand_1.Get(FingerId.Thumb, JointId.Tip).position; + Vec3 index_knuckle = palm_ori.Inverse * rig.hand_1.Get(FingerId.Index, JointId.KnuckleMajor).position; + if (thumb_tip.z > index_knuckle.z - 1.5f * U.cm) { + Log.Info("thumb is up z"); + xi = 0; + } + if (xi != last_xi) { + Log.Info($"xi: {xi}"); last_xi = xi; monoNet.value = xi; monoNet.send = true; @@ -71,7 +134,7 @@ public class Mono { // HUD // void Text.Add(string text, Matrix transform, TextAlign position = TextAlign.Center, TextAlign align = TextAlign.Center, float offX = 0, float offY = 0, float offZ = 0) Text.Add( - characters[last_xi], + characters[last_xi].character, Matrix.TRS( rig.hand_1.palm.position + V.XYZ(0, 0.1f, 0), rig.head_ori * Quat.FromAngles(0, 180, 0), @@ -81,6 +144,31 @@ public class Mono { TextAlign.Center, 0, 0, 0 ); + // show the braille dots(spheres) above the text + for (int i = 0; i < 6; i++) { + float spacing = 0.015f; + float x_offset = i > 2 ? spacing * 0.5f : -spacing * 0.5f; + float y_offset = i > 2 ? (i - 3) * spacing : i * spacing; + // Mesh.Sphere.Draw( + // mat.mono, + // Matrix.TS( + // + // 0.1f + // ), + // Color.White + // ); + if (characters[last_xi].dots[i] == 1) { + Mesh.Sphere.Draw( + mat.mono, + Matrix.TS( + // rig.hand_1.palm.position + V.XYZ(x_offset, 0.1f, 0) + V.XYZ(0, 0.1f, 0) * i, + rig.hand_1.palm.position + V.XYZ(0, 0.2f, 0) + V.XYZ(x_offset, y_offset, 0), + 0.01f + ) * Matrix.R(rig.head_ori), + Color.White + ); + } + } // WORLD mesh_room.Draw( diff --git a/todo.md b/todo.md index a26ef46..84b5a95 100644 --- a/todo.md +++ b/todo.md @@ -1,14 +1,15 @@ ethan : - [ ] bryan fix monado head bob/northstar + [x] bryan fix monado head bob/northstar [x] get the stereokit project into the repo + [ ] try cycling (left-- center(stay) right++) - [ ] thumb lift for char input + [x] thumb lift for char input [x] for the servo frame allow for slide *in out adjustablity niko : - [ ] finger pad bridge - [ ] flatten servo bottoms by adding material + [x] finger pad bridge + [x] flatten servo bottoms by adding material *nice to have: