Skip to content

Commit bc5022f

Browse files
Merge pull request #1 from OvercodedStack/Temp_work_hand
Temp work hand
2 parents fd0b6a1 + e549948 commit bc5022f

File tree

10 files changed

+3169
-370
lines changed

10 files changed

+3169
-370
lines changed

Box_wall_test.unity

Lines changed: 912 additions & 312 deletions
Large diffs are not rendered by default.

LeftHand_Manus.prefab

Lines changed: 1021 additions & 0 deletions
Large diffs are not rendered by default.

LeftHand_Manus.prefab.meta

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Manus Interfacing/Finger.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,13 @@ public Finger(List<pose> array_in)
4343
}
4444
public Finger(List<double> array_in)
4545
{
46-
bones_doubles = new List<double>();
47-
double[] doe = array_in.ToArray();
48-
foreach (double d in doe)
49-
{
50-
bones_doubles.Add(d);
51-
}
52-
46+
//bones_doubles = new List<double>();
47+
//double[] doe = array_in.ToArray();
48+
//foreach (double d in doe)
49+
//{
50+
// bones_doubles.Add(d);
51+
//}
52+
bones_doubles = array_in;
5353
//bones_doubles.Clear();
5454
//bones_doubles = new List<double>(array_in);
5555
}

Manus Interfacing/Manus_hand_obj.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,14 @@ public void add_vector_fingers_manus_profile(List<Finger> fingr) {
8080
///hand_fingers_manus_profile = fingr;
8181
}
8282
public void add_vector_fingers(List<Finger> fingr) {
83-
hand_fingers = new List<Finger>();
84-
Finger[] doe = fingr.ToArray();
85-
foreach (Finger d in doe)
86-
{
87-
hand_fingers.Add(d);
88-
}
89-
90-
///hand_fingers = fingr;
83+
//hand_fingers = new List<Finger>();
84+
//Finger[] doe = fingr.ToArray();
85+
//foreach (Finger d in doe)
86+
//{
87+
// hand_fingers.Add(d);
88+
//}
89+
90+
hand_fingers = fingr;
9191
}
9292

9393
//Set the raw hand data array to the private array in this object.

Manus Interfacing/Manus_interpreter.cs

Lines changed: 71 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,13 @@ public class Manus_interpreter : MonoBehaviour
4040
private double ring;
4141
[SerializeField]
4242
private double thumb;
43+
[SerializeField]
44+
public bool Is_right;
45+
46+
public int my_finger_opt = 2;
47+
public Quaternion my_quart;
48+
public Vector3 my_vec;
49+
public int select_option = 2;
4350

4451
//Connected
4552
bool isL, isR;
@@ -111,7 +118,7 @@ void print_vector(Vector3 vec)
111118
//I start the program.
112119
void Start()
113120
{
114-
Debug.Log("I tried.");
121+
Debug.Log("Starting Manus_API");
115122
session = new IntPtr();
116123
lefth = new manus_hand_t();
117124
righth = new manus_hand_t();
@@ -125,7 +132,7 @@ void Start()
125132
isL = false;
126133

127134
Manus.ManusInit(out session);
128-
Debug.Log("I is done.");
135+
Debug.Log("Done.");
129136

130137
}
131138

@@ -146,16 +153,47 @@ void Update()
146153
add_manus_hand(ref righth, ref rightraw, device_type_t.GLOVE_RIGHT, right_arm, myProfileR);
147154

148155
//Finger[] f = this.hands[0].get_hand_profile_manus().ToArray();
149-
double[] ls = this.hands[1].get_raw_hand().ToArray();
150-
bat_value = this.hands[1].get_bat();
151-
index = ls[0];
152-
middle = ls[1];
153-
ring = ls[2];
154-
thumb = ls[3];
155156

156-
Quaternion q = hands[0].get_wrist();
157+
if (Is_right)
158+
{
159+
double[] ls = this.hands[1].get_raw_hand().ToArray();
160+
bat_value = this.hands[1].get_bat();
161+
index = ls[0];
162+
middle = ls[1];
163+
ring = ls[2];
164+
thumb = ls[3];
165+
//List<Finger> tempF = this.hands[1].get_hand();
166+
//List<pose> ps = tempF[my_finger_opt].get_finger_data();
167+
//my_quart = ps[select_option].rotation;
168+
my_quart = this.hands[1].get_wrist();
169+
my_quart.x = (my_quart.x * 180F) / 3.14165F;
170+
my_quart.y = (my_quart.y * 180F) / 3.14165F;
171+
my_quart.z = (my_quart.z * 180F) / 3.14165F;
172+
my_quart.w = (my_quart.w * 180F) / 3.14165F;
173+
my_vec = my_quart.eulerAngles;
157174

158-
Debug.Log("Wrist data= X: " + q.x + "Y: " + q.y + "Z: " + q.z + "W: " + q.w);
175+
}
176+
else
177+
{
178+
double[] ls = this.hands[0].get_raw_hand().ToArray();
179+
bat_value = this.hands[0].get_bat();
180+
index = ls[0];
181+
middle = ls[1];
182+
ring = ls[2];
183+
thumb = ls[3];
184+
//List<Finger> tempF = this.hands[0].get_hand();
185+
//List<pose> ps = tempF[my_finger_opt].get_finger_data();
186+
//my_quart = ps[select_option].rotation;
187+
my_quart = this.hands[0].get_wrist();
188+
my_quart.x = (my_quart.x * 180F) / 3.14165F;
189+
my_quart.y = (my_quart.y * 180F) / 3.14165F;
190+
my_quart.z = (my_quart.z * 180F) / 3.14165F;
191+
my_quart.w = (my_quart.w * 180F) / 3.14165F;
192+
my_vec = my_quart.eulerAngles;
193+
}
194+
//Quaternion q = hands[0].get_wrist();
195+
196+
// Debug.Log("Wrist data= X: " + q.x + "Y: " + q.y + "Z: " + q.z + "W: " + q.w);
159197

160198
//Debug.Log(carpal_inx);
161199
}
@@ -170,6 +208,8 @@ private void add_manus_hand(ref manus_hand_t hand, ref manus_hand_raw_t raw_hand
170208
Manus.ManusGetHandRaw(session, which_hand_side, out raw_hand);
171209
Manus.ManusGetProfile(session, out my_profile); ///Wrong assumption, it does not provide real-time data.
172210
Manus.ManusGetHand(session, which_hand_side, out hand);
211+
212+
//Manus.ManusGetHand_id(session, 2602524395, which_hand_side, out hand);
173213

174214
Manus.ManusGetBatteryLevel(session, which_hand_side, out bat_value);
175215

@@ -231,25 +271,30 @@ private void add_arm_calc(ref manus_hand_t hand, ref ik_body_t body_side, ref ik
231271
private void add_hand_fingers(ref manus_hand_t device, ref device_type_t side, ref Manus_hand_obj manus_hand)
232272
{
233273
List<Finger> single_hand_array = new List<Finger>(); //Finger array
234-
pose temp_pose; //Temporary pose format.
235-
List<pose> temp_finger = new List<pose>(); //Temporary array for bones.
274+
List<pose> temp_finger; //Temporary array for bones.
236275
for (int i = 0; i < 5; i++)//Illiterate through the fingers
237276
{
277+
temp_finger = new List<pose>();
238278
for (int j = 0; j < 5; j++)//Illiterate through the poses.
239279
{
280+
pose temp_pose = new pose(); //Temporary pose format.
240281
temp_pose.rotation = process_quat(device.fingers[i].joints[j].rotation);
241282
temp_pose.translation = process_vector(device.fingers[i].joints[j].translation);
242283
temp_finger.Add(temp_pose);//Add poses to a temporay finger array
243284
}
244285
Finger real_finger = new Finger(temp_finger); //Instantiate a finger class
245286
single_hand_array.Add(real_finger); //Add the finger to the hand
246287
}
288+
289+
247290
//**NEW** Pass imu Data to device.
248291
quat_t[] quarts = device.raw.imu;
249292
Quaternion[] quarts_to_write = new Quaternion[2];
250293
quarts_to_write[0] = process_quat(quarts[0]);
251294
quarts_to_write[1] = process_quat(quarts[1]);
252-
manus_hand.set_imus(quarts_to_write);
295+
manus_hand.set_imus(quarts_to_write);
296+
297+
253298
manus_hand.add_vector_fingers(single_hand_array); //Add in vector data from manus for each individual bone.
254299
manus_hand.set_wrist(process_quat(device.wrist)); //**NEW** Add in wrist data into the manus_hand_obj
255300

@@ -340,20 +385,21 @@ private void add_manus_profile_hands(ref ik_profile_t my_profile, ref Manus_hand
340385
private void add_hand_fingers_raw(ref manus_hand_raw_t hand, ref device_type_t side, ref Manus_hand_obj manus_hand)
341386
{
342387
List<double> single_hand_array_raw = new List<double>();
343-
if (side == device_type_t.GLOVE_LEFT)
344-
{
345-
for (int h = 0; h < 5; h++)
346-
{
347-
single_hand_array_raw.Add(hand.finger_sensor[h]);
348-
}
349-
}
350-
else
388+
for (int h = 0; h < 10; h++)
351389
{
352-
for (int h = 5; h < 10; h++)
353-
{
354-
single_hand_array_raw.Add(hand.finger_sensor[h]);
355-
}
390+
single_hand_array_raw.Add(hand.finger_sensor[h]);
356391
}
392+
//if (side == device_type_t.GLOVE_LEFT)
393+
//{
394+
395+
//}
396+
//else
397+
//{
398+
// for (int h = 0; h < 10; h++)
399+
// {
400+
// single_hand_array_raw.Add(hand.finger_sensor[h]);
401+
// }
402+
//}
357403
manus_hand.set_hand_raw(single_hand_array_raw);
358404
}
359405
}

0 commit comments

Comments
 (0)