-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRightForeArmController.cs
More file actions
44 lines (37 loc) · 1.22 KB
/
Copy pathRightForeArmController.cs
File metadata and controls
44 lines (37 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.IO.Ports;
using System;
using System.Text;
using System.Threading;
using System.IO;
//using Kalman;
public class RightForeArmController : MonoBehaviour
{
private SerialPort port = new SerialPort("COM3", 115200);
private String CurrentReading = "ABCD";
private float[] IndividualValues = { 0, 0, 0, 0, 0, 0 };
private String[] SubStrings;
string path = "Assets/test.txt";
void Start()
{
port.ReadTimeout = 2000;
port.Close();
if (!port.IsOpen)
port.Open();
}
void Update()
{
CurrentReading = port.ReadLine();
SubStrings = CurrentReading.Split(',');
print(CurrentReading);
IndividualValues[0] = Convert.ToSingle(SubStrings[0]);
IndividualValues[1] = Convert.ToSingle(SubStrings[1]);
IndividualValues[2] = Convert.ToSingle(SubStrings[2]);
transform.localEulerAngles = new Vector3(IndividualValues[2], IndividualValues[0], -IndividualValues[2]);
StreamWriter writer = new StreamWriter(path, true);
writer.WriteLine(CurrentReading);
writer.Close();
}
}