Added serial link to SSC32
This commit is contained in:
+1
-1
@@ -28,7 +28,7 @@ public class Foot : Component
|
||||
public Vector3 transformation = new Vector3(0, 0, 0);
|
||||
public Vector3 transformation2 = new Vector3(0, 0, 0);
|
||||
|
||||
static float knie_offset = 2;
|
||||
static float knie_offset = 3;
|
||||
|
||||
void RL3()
|
||||
{
|
||||
|
||||
@@ -26,6 +26,8 @@ public class Leg : MonoBehaviour {
|
||||
public GameObject pointShouldBe;
|
||||
public Vector3 pos = new Vector3(0, 0, 0);
|
||||
|
||||
public int startServo = -1;
|
||||
|
||||
private Foot foot = new Foot();
|
||||
|
||||
// Use this for initialization
|
||||
@@ -71,10 +73,34 @@ public class Leg : MonoBehaviour {
|
||||
a3 = foot.O3 - 90;
|
||||
}
|
||||
|
||||
if (!invert && startServo != -1)
|
||||
{
|
||||
Serial.Instance.send(startServo,
|
||||
(int)Remap((float)a1, -90, 90, 2500, 500),
|
||||
(int)Remap((float)a2, -90, 90, 2500, 500), // 0 is middel
|
||||
(int)Remap((float)a3, 90, -90, 2500, 500)); // 0 is middel
|
||||
}
|
||||
else if (invert && startServo != -1)
|
||||
{
|
||||
double a1 = foot.O1 - 90;
|
||||
double a2 = 90 - foot.O2;
|
||||
double a3 = foot.O3 - 90;
|
||||
|
||||
Serial.Instance.send(startServo,
|
||||
(int)Remap((float)a1, -90, 90, 500, 2500),
|
||||
(int)Remap((float)a2, -90, 90, 500, 2500), // 0 is middel
|
||||
(int)Remap((float)a3, 90, -90, 500, 2500)); // 0 is middel
|
||||
}
|
||||
|
||||
Hip1.transform.localRotation = Quaternion.Euler(0, (float)a1, 0);
|
||||
Hip2.transform.localRotation = Quaternion.Euler((float)a2, 0, 0);
|
||||
Knie.transform.localRotation = Quaternion.Euler((float)a3, 0, 0);
|
||||
|
||||
pointShouldBe.transform.localPosition = foot.pos;
|
||||
}
|
||||
|
||||
public static float Remap(float value, float from1, float to1, float from2, float to2)
|
||||
{
|
||||
return (value - from1) / (to1 - from1) * (to2 - from2) + from2;
|
||||
}
|
||||
}
|
||||
|
||||
+36
-44
@@ -14098,7 +14098,7 @@ Transform:
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_GameObject: {fileID: 94996747}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: -20, y: -10, z: 11}
|
||||
m_LocalPosition: {x: -20, y: -15, z: 11}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children:
|
||||
- {fileID: 379804153}
|
||||
@@ -34419,7 +34419,7 @@ MonoBehaviour:
|
||||
a1: 0
|
||||
a2: 0
|
||||
a3: 0
|
||||
point: {x: 4, y: -10, z: -13}
|
||||
point: {x: 4, y: -15, z: -13}
|
||||
rotation: {x: 0, y: 0, z: 0, w: 0}
|
||||
transformation: {x: 0, y: 0, z: 0}
|
||||
transformation2: {x: 0, y: 0, z: 0}
|
||||
@@ -34429,6 +34429,7 @@ MonoBehaviour:
|
||||
translateZ: -5
|
||||
pointShouldBe: {fileID: 32992308}
|
||||
pos: {x: 0, y: 0, z: 0}
|
||||
startServo: 22
|
||||
--- !u!1 &211071650
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -48736,7 +48737,7 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: 30ea8dc0510444c42ae4b4db1f5ee2bd, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
transformation: {x: 0, y: 0, z: 0}
|
||||
transformation: {x: 0, y: 3, z: 0}
|
||||
transformation2: {x: 0, y: 0, z: 0}
|
||||
rotation: {x: 0, y: 0, z: 0, w: 0}
|
||||
rotation2:
|
||||
@@ -48748,20 +48749,6 @@ MonoBehaviour:
|
||||
- {fileID: 210611261}
|
||||
body: {fileID: 2129559090}
|
||||
body2: {fileID: 1971572977}
|
||||
min: -25
|
||||
max: 25
|
||||
speed: 0.1
|
||||
speed2: 0.2
|
||||
speed3: 0.3
|
||||
dir: 0
|
||||
dir2: 0
|
||||
dir3: 0
|
||||
p: 0
|
||||
r: 0
|
||||
y: 0
|
||||
p2: 0
|
||||
r2: 0
|
||||
y2: 0
|
||||
--- !u!1 &311874317
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -54492,7 +54479,7 @@ Transform:
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_GameObject: {fileID: 349087549}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 2}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 3}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children:
|
||||
- {fileID: 526007731}
|
||||
@@ -55121,8 +55108,8 @@ Transform:
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_GameObject: {fileID: 352865049}
|
||||
m_LocalRotation: {x: 0.7071068, y: -0, z: -0, w: 0.70710677}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 1}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 1.5}
|
||||
m_LocalScale: {x: 1, y: 1.5, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 2042398688}
|
||||
m_RootOrder: 0
|
||||
@@ -58982,8 +58969,8 @@ Transform:
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_GameObject: {fileID: 375187693}
|
||||
m_LocalRotation: {x: 0.7071068, y: -0, z: -0, w: 0.70710677}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 1}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 1.5}
|
||||
m_LocalScale: {x: 1, y: 1.5, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 8323914}
|
||||
m_RootOrder: 0
|
||||
@@ -73260,8 +73247,8 @@ Transform:
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_GameObject: {fileID: 471439402}
|
||||
m_LocalRotation: {x: 0.7071068, y: -0, z: -0, w: 0.70710677}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 1}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 1.5}
|
||||
m_LocalScale: {x: 1, y: 1.5, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 842799377}
|
||||
m_RootOrder: 0
|
||||
@@ -92885,16 +92872,17 @@ MonoBehaviour:
|
||||
a1: 0
|
||||
a2: 0
|
||||
a3: 0
|
||||
point: {x: 0, y: -10, z: 15}
|
||||
point: {x: 0, y: -15, z: 15}
|
||||
rotation: {x: 0, y: 0, z: 0, w: 0}
|
||||
transformation: {x: 0, y: 0, z: 0}
|
||||
transformation2: {x: 0, y: 0, z: 0}
|
||||
invert: 0
|
||||
translateX: 0
|
||||
translateY: 0
|
||||
translateZ: 5
|
||||
translateZ: 7
|
||||
pointShouldBe: {fileID: 914986742}
|
||||
pos: {x: 0, y: 0, z: 0}
|
||||
startServo: 3
|
||||
--- !u!1 &596816813
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -99408,7 +99396,7 @@ MonoBehaviour:
|
||||
a1: 0
|
||||
a2: 0
|
||||
a3: 0
|
||||
point: {x: -4, y: -10, z: 13}
|
||||
point: {x: -4, y: -15, z: 13}
|
||||
rotation: {x: 0, y: 0, z: 0, w: 0}
|
||||
transformation: {x: 0, y: 0, z: 0}
|
||||
transformation2: {x: 0, y: 0, z: 0}
|
||||
@@ -99418,6 +99406,7 @@ MonoBehaviour:
|
||||
translateZ: 5
|
||||
pointShouldBe: {fileID: 2018746516}
|
||||
pos: {x: 0, y: 0, z: 0}
|
||||
startServo: 0
|
||||
--- !u!1 &636734778
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -102422,7 +102411,7 @@ Transform:
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_GameObject: {fileID: 596626244}
|
||||
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 5}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 7}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children:
|
||||
- {fileID: 1668338011}
|
||||
@@ -111718,8 +111707,8 @@ Transform:
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_GameObject: {fileID: 704757434}
|
||||
m_LocalRotation: {x: 0.7071068, y: -0, z: -0, w: 0.70710677}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 1}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 1.5}
|
||||
m_LocalScale: {x: 1, y: 1.5, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 958514921}
|
||||
m_RootOrder: 0
|
||||
@@ -134179,8 +134168,8 @@ Transform:
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_GameObject: {fileID: 838292413}
|
||||
m_LocalRotation: {x: 0.7071068, y: -0, z: -0, w: 0.70710677}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 1}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 1.5}
|
||||
m_LocalScale: {x: 1, y: 1.5, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 1440823284}
|
||||
m_RootOrder: 0
|
||||
@@ -138789,7 +138778,7 @@ Transform:
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_GameObject: {fileID: 866778528}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 2}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 3}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children:
|
||||
- {fileID: 246942919}
|
||||
@@ -157426,7 +157415,7 @@ Transform:
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_GameObject: {fileID: 986205296}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 2}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 3}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children:
|
||||
- {fileID: 1248951963}
|
||||
@@ -169384,7 +169373,7 @@ Transform:
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_GameObject: {fileID: 1772413224}
|
||||
m_LocalRotation: {x: -0, y: 1, z: -0, w: 0}
|
||||
m_LocalPosition: {x: 0, y: 0, z: -5}
|
||||
m_LocalPosition: {x: 0, y: 0, z: -7}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children:
|
||||
- {fileID: 1718712321}
|
||||
@@ -234734,7 +234723,7 @@ MonoBehaviour:
|
||||
a1: 0
|
||||
a2: 0
|
||||
a3: 0
|
||||
point: {x: -4, y: -10, z: -13}
|
||||
point: {x: -4, y: -15, z: -13}
|
||||
rotation: {x: 0, y: 0, z: 0, w: 0}
|
||||
transformation: {x: 0, y: 0, z: 0}
|
||||
transformation2: {x: 0, y: 0, z: 0}
|
||||
@@ -234744,6 +234733,7 @@ MonoBehaviour:
|
||||
translateZ: -5
|
||||
pointShouldBe: {fileID: 591879371}
|
||||
pos: {x: 0, y: 0, z: 0}
|
||||
startServo: 16
|
||||
--- !u!1 &1454125721
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -252263,7 +252253,7 @@ Transform:
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_GameObject: {fileID: 1573589440}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 2}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 3}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children:
|
||||
- {fileID: 952427227}
|
||||
@@ -259167,7 +259157,7 @@ MonoBehaviour:
|
||||
a1: 0
|
||||
a2: 0
|
||||
a3: 0
|
||||
point: {x: 4, y: -10, z: 13}
|
||||
point: {x: 4, y: -15, z: 13}
|
||||
rotation: {x: 0, y: 0, z: 0, w: 0}
|
||||
transformation: {x: 0, y: 0, z: 0}
|
||||
transformation2: {x: 0, y: 0, z: 0}
|
||||
@@ -259177,6 +259167,7 @@ MonoBehaviour:
|
||||
translateZ: 5
|
||||
pointShouldBe: {fileID: 1943602706}
|
||||
pos: {x: 0, y: 0, z: 0}
|
||||
startServo: 6
|
||||
--- !u!1 &1619291355
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -283867,16 +283858,17 @@ MonoBehaviour:
|
||||
a1: 0
|
||||
a2: 0
|
||||
a3: 0
|
||||
point: {x: 0, y: -10, z: -15}
|
||||
point: {x: 0, y: -15, z: -15}
|
||||
rotation: {x: 0, y: 0, z: 0, w: 0}
|
||||
transformation: {x: 0, y: 0, z: 0}
|
||||
transformation2: {x: 0, y: 0, z: 0}
|
||||
invert: 1
|
||||
translateX: 0
|
||||
translateY: 0
|
||||
translateZ: -5
|
||||
translateZ: -7
|
||||
pointShouldBe: {fileID: 955360344}
|
||||
pos: {x: 0, y: 0, z: 0}
|
||||
startServo: 19
|
||||
--- !u!1 &1772635191
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -290827,7 +290819,7 @@ Transform:
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_GameObject: {fileID: 1813824933}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 2}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 3}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children:
|
||||
- {fileID: 1534966623}
|
||||
@@ -291218,8 +291210,8 @@ Transform:
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_GameObject: {fileID: 1816451333}
|
||||
m_LocalRotation: {x: 0.7071068, y: -0, z: -0, w: 0.70710677}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 1}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 1.5}
|
||||
m_LocalScale: {x: 1, y: 1.5, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 202055677}
|
||||
m_RootOrder: 0
|
||||
@@ -305967,7 +305959,7 @@ Transform:
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_GameObject: {fileID: 1902568238}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 2}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 3}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children:
|
||||
- {fileID: 1164689000}
|
||||
|
||||
+15
-15
@@ -57,17 +57,17 @@ public class RotationControl : MonoBehaviour
|
||||
public GameObject body;
|
||||
public GameObject body2;
|
||||
|
||||
public rotation r1 = new rotation(0.1f, -15, 15);
|
||||
public rotation r2 = new rotation(0.2f, -15, 15);
|
||||
public rotation r3 = new rotation(0.3f, -15, 15);
|
||||
public rotation r1 = new rotation(0.1f, -10, 10);
|
||||
public rotation r2 = new rotation(0.2f, -10, 10);
|
||||
public rotation r3 = new rotation(0.3f, -10, 10);
|
||||
|
||||
public rotation r4 = new rotation(0.01f, -3, 3);
|
||||
public rotation r5 = new rotation(0.02f, -3, 3);
|
||||
public rotation r6 = new rotation(0.03f, -3, 3);
|
||||
public rotation r4 = new rotation(0.06f, -3, 3);
|
||||
public rotation r5 = new rotation(0.08f, -3, 3);
|
||||
public rotation r6 = new rotation(0.1f, -3, 3);
|
||||
|
||||
public rotation r7 = new rotation(0.001f, -3, 3);
|
||||
public rotation r8 = new rotation(0.002f, -3, 3);
|
||||
public rotation r9 = new rotation(0.003f, -3, 3);
|
||||
public rotation r7 = new rotation(0.1f, -3, 3);
|
||||
public rotation r8 = new rotation(0.2f, -3, 3);
|
||||
public rotation r9 = new rotation(0.3f, -3, 3);
|
||||
|
||||
// Use this for initialization
|
||||
void Start ()
|
||||
@@ -77,17 +77,17 @@ public class RotationControl : MonoBehaviour
|
||||
// Update is called once per frame
|
||||
void FixedUpdate()
|
||||
{
|
||||
rotation.x = r1.update();
|
||||
rotation.y = r2.update();
|
||||
rotation.z = r3.update();
|
||||
//rotation.x = r1.update();
|
||||
//rotation.y = r2.update();
|
||||
//rotation.z = r3.update();
|
||||
|
||||
transformation.x = r4.update();
|
||||
transformation.y = r5.update();
|
||||
//transformation.y = r5.update();
|
||||
transformation.z = r6.update();
|
||||
|
||||
transformation2.x = r7.update();
|
||||
/*transformation2.x = r7.update();
|
||||
transformation2.y = r8.update();
|
||||
transformation2.z = r9.update();
|
||||
transformation2.z = r9.update();*/
|
||||
|
||||
body.transform.eulerAngles = new Vector3(rotation.x*-1, rotation.y*-1, rotation.z*-1);
|
||||
body.transform.position = transformation;
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using System.IO.Ports;
|
||||
|
||||
public class Serial {
|
||||
private static Serial instance;
|
||||
|
||||
private Serial() { }
|
||||
|
||||
~Serial() {
|
||||
serialPort.Close();
|
||||
}
|
||||
|
||||
public static Serial Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
if (instance == null)
|
||||
{
|
||||
instance = new Serial();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
|
||||
SerialPort serialPort;
|
||||
|
||||
public void send(int start, int a, int b, int c)
|
||||
{
|
||||
if (serialPort == null)
|
||||
{
|
||||
serialPort = new SerialPort(@"\\.\" + "COM10", 115200);
|
||||
|
||||
serialPort.Open();
|
||||
serialPort.DiscardOutBuffer();
|
||||
serialPort.DiscardInBuffer();
|
||||
}
|
||||
|
||||
if (serialPort is SerialPort)
|
||||
{
|
||||
|
||||
serialPort.Write(" #");
|
||||
serialPort.Write(start.ToString());
|
||||
serialPort.Write(" P");
|
||||
serialPort.Write(a.ToString());
|
||||
|
||||
start++;
|
||||
|
||||
serialPort.Write(" #");
|
||||
serialPort.Write(start.ToString());
|
||||
serialPort.Write(" P");
|
||||
serialPort.Write(b.ToString());
|
||||
|
||||
start++;
|
||||
|
||||
serialPort.Write(" #");
|
||||
serialPort.Write(start.ToString());
|
||||
serialPort.Write(" P");
|
||||
serialPort.Write(c.ToString());
|
||||
|
||||
serialPort.Write(" \r");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c99b6d9374ff6d3419c7692fdf3c1791
|
||||
timeCreated: 1542057315
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user