diff --git a/2018-unity-sim/.vs/Hexapod/v15/Server/sqlite3/storage.ide b/2018-unity-sim/.vs/Hexapod/v15/Server/sqlite3/storage.ide index e04b087..b9471d5 100644 --- a/2018-unity-sim/.vs/Hexapod/v15/Server/sqlite3/storage.ide +++ b/2018-unity-sim/.vs/Hexapod/v15/Server/sqlite3/storage.ide @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:9eee43514d1020ba2627eb6f457f0988d344f1e03ae4f6b56f3b9f74b0f11c9a +oid sha256:d61c4d70456f0abfd29aecca2ed8d20f6777e4f66d293946712d789e4d52661d size 704512 diff --git a/2018-unity-sim/.vs/Hexapod/v15/Server/sqlite3/storage.ide-shm b/2018-unity-sim/.vs/Hexapod/v15/Server/sqlite3/storage.ide-shm index 932885a..e98703c 100644 --- a/2018-unity-sim/.vs/Hexapod/v15/Server/sqlite3/storage.ide-shm +++ b/2018-unity-sim/.vs/Hexapod/v15/Server/sqlite3/storage.ide-shm @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:85af3a56d42078a28e2a5b9648318d5d4366c3b8f2619964af930a619d4d9c61 +oid sha256:1789ed53dec422b13077d32aaf6316b27ffaeb93028b2a0e350bca958d62772d size 32768 diff --git a/2018-unity-sim/.vs/Hexapod/v15/Server/sqlite3/storage.ide-wal b/2018-unity-sim/.vs/Hexapod/v15/Server/sqlite3/storage.ide-wal index f35783d..401006c 100644 --- a/2018-unity-sim/.vs/Hexapod/v15/Server/sqlite3/storage.ide-wal +++ b/2018-unity-sim/.vs/Hexapod/v15/Server/sqlite3/storage.ide-wal @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:5740adf887e1bd00e25894ebdddd61c5db4544f5da22d6cd989a2bb35d6e7f6a +oid sha256:4863417bbcb00c136855aab9c10306c8a494aa756b537506fcaa6f3089a243fc size 4140632 diff --git a/2018-unity-sim/Assets/Foot.cs b/2018-unity-sim/Assets/Foot.cs index 4f1375f..ca37191 100644 --- a/2018-unity-sim/Assets/Foot.cs +++ b/2018-unity-sim/Assets/Foot.cs @@ -127,36 +127,41 @@ public class Foot : Component Y += translateY; Z += translateZ; - Y = Y * (invert ? -1 : 1); - X = X * (invert ? -1 : -1); - Z = Z * (invert ? -1 : -1); - /*RotateX(); RotateY(); RotateZ();*/ - - rotationY = rotationY * (invert ? 1 : 1); - + // Z and X is working. Y has problems when combined with others. - Vector3 v = new Vector3((float)Z, (float)Y, (float)X); - v = Quaternion.Euler((float)rotationX, (float)rotationY, (float)rotationZ) * v; - Z = v.x; + Vector3 v = new Vector3((float)X, (float)Y, (float)Z); + v = Quaternion.Euler((float)0, (float)rotationY, (float)0) * v; + v = Quaternion.Euler((float)rotationX, (float)0, (float)0) * v; + v = Quaternion.Euler((float)0, (float)0, (float)rotationZ) * v; + X = v.x; Y = v.y; - X = v.z; - - Y = Y * (invert ? -1 : 1); - X = X * (invert ? -1 : -1); - Z = Z * (invert ? -1 : -1); - + Z = v.z; + X -= translateX; Y -= translateY; Z -= translateZ; + // translate to my stupid formula coordinates. + double tx = X; + double ty = Y; + double tz = Z; + X = tz * (invert ? -1 : 1); + Y = ty * -1; + Z = tx * -1; + + // run IK O1 = (90 - FO1()); O2 = T1(); O3 = 180 - T3(); - Y = Y * -1; - pos = new Vector3((float)Z, (float)Y, (float)X); + // translate to my stupid formula coordinates. + X = tx; + Y = ty; + Z = tz; + + pos = new Vector3((float)X * (invert ? -1 : 1), (float)Y, (float)Z * (invert ? -1 : 1)); } } diff --git a/2018-unity-sim/Assets/Leg.cs b/2018-unity-sim/Assets/Leg.cs index 031c82f..58393b3 100644 --- a/2018-unity-sim/Assets/Leg.cs +++ b/2018-unity-sim/Assets/Leg.cs @@ -34,13 +34,12 @@ public class Leg : MonoBehaviour { void Update() { foot.X = point.x; - foot.Y = point.y * -1; - //foot.Z = point.z * (invert ? -1 : 1); - foot.Z = point.z * (invert ? 1 : -1); + foot.Y = point.y; + foot.Z = point.z; foot.rotationX = rotation.x; - foot.rotationY = rotation.y * (invert ? -1 : 1); - foot.rotationZ = rotation.z * (invert ? -1 : 1); + foot.rotationY = rotation.y; + foot.rotationZ = rotation.z; foot.translateX = translateX; foot.translateY = translateY; @@ -67,8 +66,6 @@ public class Leg : MonoBehaviour { Hip2.transform.localRotation = Quaternion.Euler((float)a2, 0, 0); Knie.transform.localRotation = Quaternion.Euler((float)a3, 0, 0); - pos = foot.pos; - pos.x = pos.x * (invert ? 1 : -1); - pointShouldBe.transform.localPosition = pos; + pointShouldBe.transform.localPosition = foot.pos; } } diff --git a/2018-unity-sim/Assets/Main.unity b/2018-unity-sim/Assets/Main.unity index bfc5163..98cf40c 100644 --- a/2018-unity-sim/Assets/Main.unity +++ b/2018-unity-sim/Assets/Main.unity @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:4e1d1aabe8ab67ceea93b385482c976ce33c87bf3b13ada9201ea7deebd226bd -size 33557 +oid sha256:8a2be3952982ba00b2a7e7dbe0048ab7b2ee517dc1d3ec8c10a0011141abb118 +size 36028 diff --git a/2018-unity-sim/Assets/RotationControl.cs b/2018-unity-sim/Assets/RotationControl.cs index 1e7a1b3..928f774 100644 --- a/2018-unity-sim/Assets/RotationControl.cs +++ b/2018-unity-sim/Assets/RotationControl.cs @@ -25,34 +25,34 @@ public class RotationControl : MonoBehaviour // Update is called once per frame void Update() { - /*if (!dir2 && rotation.x < max) + if (!dir2 && rotation.x < max) rotation.x += speed2; else if (!dir2) dir2 = !dir2; else if (dir2 && rotation.x > min) rotation.x -= speed2; else if (dir2) - dir2 = !dir2;*/ + dir2 = !dir2; - /*if (!dir3 && rotation.y < max) + if (!dir3 && rotation.y < max) rotation.y += speed3; else if (!dir3) dir3 = !dir3; else if (dir3 && rotation.y > min) rotation.y -= speed3; else if (dir3) - dir3 = !dir3;*/ + dir3 = !dir3; - /*if (!dir && rotation.z < max) + if (!dir && rotation.z < max) rotation.z += speed; else if (!dir) dir = !dir; else if (dir && rotation.z > min) rotation.z -= speed; else if (dir) - dir = !dir;*/ + dir = !dir; - body.transform.eulerAngles = new Vector3(rotation.x*-1, rotation.y, rotation.z); + body.transform.eulerAngles = new Vector3(rotation.x*-1, rotation.y*-1, rotation.z*-1); for (int index = 0; index < rotation2.Count; ++index) {