Skip to content

Commit 18bbb05

Browse files
Latest Update
1 parent b51ec9d commit 18bbb05

14 files changed

+2285
-4423
lines changed

Box_wall_test.unity

Lines changed: 1711 additions & 4264 deletions
Large diffs are not rendered by default.

Manus Interfacing/Manus_interpreter.cs

Lines changed: 50 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public class Manus_interpreter : MonoBehaviour
4343
[SerializeField]
4444
public bool Is_right;
4545

46-
public int my_finger_opt = 2;
46+
public int my_finger_opt = 2;
4747
public Quaternion my_quart;
4848
public Vector3 my_vec;
4949
public int select_option = 2;
@@ -98,11 +98,11 @@ public class Manus_interpreter : MonoBehaviour
9898

9999
void print_quat(Quaternion quart)
100100
{
101-
Debug.Log( "Printing Quarternion: " +
101+
Debug.Log("Printing Quarternion: " +
102102
"X: " + quart.x +
103103
"Y: " + quart.y +
104104
"Z: " + quart.z +
105-
"W: " + quart.w
105+
"W: " + quart.w
106106
);
107107
}
108108

@@ -111,7 +111,7 @@ void print_vector(Vector3 vec)
111111
Debug.Log("Printing Vector: " +
112112
"X: " + vec.x +
113113
"Y: " + vec.y +
114-
"Z: " + vec.z
114+
"Z: " + vec.z
115115
);
116116
}
117117

@@ -138,7 +138,7 @@ void Start()
138138

139139

140140
//Data cleaner for data recieved for double values from the Manus.
141-
void merge_value<T>(T output_value,T input_value)
141+
void merge_value<T>(T output_value, T input_value)
142142
{
143143
output_value = input_value;
144144
}
@@ -193,10 +193,10 @@ void Update()
193193
}
194194
//Quaternion q = hands[0].get_wrist();
195195

196-
// Debug.Log("Wrist data= X: " + q.x + "Y: " + q.y + "Z: " + q.z + "W: " + q.w);
196+
// Debug.Log("Wrist data= X: " + q.x + "Y: " + q.y + "Z: " + q.z + "W: " + q.w);
197197

198198
//Debug.Log(carpal_inx);
199-
}
199+
}
200200

201201
//Function that phrases in a single finger
202202
private void add_manus_hand(ref manus_hand_t hand, ref manus_hand_raw_t raw_hand, device_type_t which_hand_side, ik_body_t body_side, ik_profile_t my_profile)
@@ -210,7 +210,7 @@ private void add_manus_hand(ref manus_hand_t hand, ref manus_hand_raw_t raw_hand
210210
Manus.ManusGetHand(session, which_hand_side, out hand);
211211

212212
//Manus.ManusGetHand_id(session, 2602524395, which_hand_side, out hand);
213-
213+
214214
Manus.ManusGetBatteryLevel(session, which_hand_side, out bat_value);
215215

216216
//Set Battery level
@@ -224,7 +224,7 @@ private void add_manus_hand(ref manus_hand_t hand, ref manus_hand_raw_t raw_hand
224224

225225
//Set manus_profile finger data
226226
add_manus_profile_hands(ref my_profile, ref hand_in_use);
227-
227+
228228
//Set regular Manus hand data
229229
add_hand_fingers(ref hand, ref which_hand_side, ref hand_in_use);
230230

@@ -254,18 +254,26 @@ public Manus_hand_obj get_hand(device_type_t side)
254254
}
255255
}
256256

257+
//Using an int
257258
public Manus_hand_obj get_hand(int side)
258259
{
259-
if (side == 0)
260-
{
261-
return hands[0];
260+
return hands[side];
261+
}
262+
263+
//Using a bool
264+
public Manus_hand_obj get_hand(bool side)
265+
{
266+
if (side)
267+
{//Right Hand
268+
return hands[1];
262269
}
263270
else
264-
{
265-
return hands[1];
271+
{ //Left Hand
272+
return hands[0];
266273
}
267274
}
268275

276+
269277
//Add the calcuations for the arm calculations on the manus API
270278
private void add_arm_calc(ref manus_hand_t hand, ref ik_body_t body_side, ref ik_profile_t my_profile, ref Manus_hand_obj my_hand)
271279
{
@@ -304,8 +312,8 @@ private void add_hand_fingers(ref manus_hand_t device, ref device_type_t side, r
304312
Quaternion[] quarts_to_write = new Quaternion[2];
305313
quarts_to_write[0] = process_quat(quarts[0]);
306314
quarts_to_write[1] = process_quat(quarts[1]);
307-
manus_hand.set_imus(quarts_to_write);
308-
315+
manus_hand.set_imus(quarts_to_write);
316+
309317

310318
manus_hand.add_vector_fingers(single_hand_array); //Add in vector data from manus for each individual bone.
311319
manus_hand.set_wrist(process_quat(device.wrist)); //**NEW** Add in wrist data into the manus_hand_obj
@@ -409,25 +417,43 @@ private void add_hand_fingers_raw(ref manus_hand_raw_t hand, ref device_type_t s
409417
{
410418
List<double> single_hand_array_raw = new List<double>();
411419
bool set_grab = false;
420+
bool set_thumbs_up = false;
412421
for (int h = 0; h < 10; h++)
413422
{
414423
single_hand_array_raw.Add(hand.finger_sensor[h]);
415424
}
416425

417-
int count = 0;
418-
foreach(double i in single_hand_array_raw)
426+
int count_grab = 0;
427+
int count_thumbs_up = 0;
428+
429+
430+
//If the finger is compressed beyond .75, add as a compressed finger
431+
foreach (double i in single_hand_array_raw)
419432
{
420-
if (i > .5)
421-
{
422-
count += 1;
423-
}
433+
if (i > .75)
434+
count_grab++;
435+
//if (i > .95)
436+
// count_thumbs_up++;
424437
}
425-
if (count > 5)
438+
//if ( single_hand_array_raw[8] < .3 && single_hand_array_raw[9] < .3 && count_thumbs_up >= 7)
439+
//{
440+
// set_thumbs_up = true;
441+
//}
442+
443+
//If more than 8 fingers compressed, set grab.
444+
if (count_grab > 8)
426445
set_grab = true;
446+
447+
448+
449+
427450
manus_hand.set_grabbing(set_grab);
428451
manus_hand.set_hand_raw(single_hand_array_raw);
429452
}
453+
454+
455+
430456
}
431457
}
432458
//######################################################################################################################################
433-
459+

Utillity Scripts/Manus_To_TCP.cs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,15 @@
1010
// ===========
1111
// Data phraser from Manus to TPC server.
1212
//
13+
// NOT IN USE
14+
//
15+
//
1316
///////////////////////////////////////////////////////////////////////////////
1417

18+
19+
20+
21+
1522
using System.Collections;
1623
using System.Collections.Generic;
1724
using UnityEngine;
@@ -22,6 +29,7 @@
2229
public class Manus_To_TCP : MonoBehaviour {
2330
TCP_Server server;
2431
Manus_interpreter interpreter;
32+
ur5_kinematics angle_controller;
2533

2634
// Use this for initialization
2735
void Start () {
@@ -33,11 +41,19 @@ void Start () {
3341

3442
// Update is called once per frame
3543
void Update () {
36-
string converted_string_manus = consodiliate_strings();
37-
server.IPC_comms_message = converted_string_manus;
44+
//convert_array
45+
//string converted_string_manus = consodiliate_strings();
46+
////server.IPC_comms_message = converted_string_manus;
47+
//server.SendMessage();
48+
3849
}
3950

4051

52+
//string convert_array()
53+
//{
54+
55+
//}
56+
4157
string consodiliate_strings()
4258
{
4359
Manus_hand_obj device0 = interpreter.get_hand(0);

Utillity Scripts/TCP_Server.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ void Update()
4949
//}
5050
}
5151

52+
public void set_msg(string msg_out)
53+
{
54+
IPC_comms_message = msg_out;
55+
}
56+
5257
/// <summary>
5358
/// Runs in background TcpServerThread; Handles incomming TcpClient requests
5459
/// </summary>

Utillity Scripts/UR5_to_TPC.cs

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
///////////////////////////////////////////////////////////////////////////////
2+
//
3+
// Original System: UR5_to_TPC.cs
4+
// Subsystem: Human-Robot Interaction
5+
// Workfile: Unity workspace?
6+
// Revision: 1.0 - 6/29/2018
7+
// Author: Esteban Segarra
8+
//
9+
// Description
10+
// ===========
11+
// Data phraser from UR5 to TPC server.
12+
//
13+
///////////////////////////////////////////////////////////////////////////////
14+
15+
16+
using UnityEngine;
17+
using UnityEngine.UI;
18+
using TPC_Server;
19+
20+
public class UR5_to_TPC : MonoBehaviour
21+
{
22+
public string output_string;
23+
TCP_Server server;
24+
ur5_kinematics angle_controller;
25+
gripper_kinematic grip_obj;
26+
public GameObject robot;
27+
public Button send_msg;
28+
29+
// Use this for initialization
30+
void Start()
31+
{
32+
server = GetComponent<TCP_Server>();
33+
GameObject gripper = GameObject.Find("Base_Gripper");
34+
grip_obj = gripper.GetComponent<gripper_kinematic>();
35+
36+
//GameObject robot = GameObject.Find("UR5");
37+
angle_controller = robot.GetComponent<ur5_kinematics>();
38+
send_msg.onClick.AddListener(add_active_state);
39+
}
40+
41+
42+
43+
////Update is called once per frame
44+
////void Update()
45+
////{
46+
//// output_string = convert_array(angle_controller.get_vector_UR5());
47+
//// output_string += add_gripper();
48+
//// output_string += "\n";
49+
50+
//// / server.SendMessage(output_string);
51+
////}
52+
53+
string add_gripper()
54+
{
55+
string out_stg = null;
56+
57+
out_stg += "Gripper:";
58+
out_stg += grip_obj.get_ratio().ToString();
59+
out_stg += ";";
60+
return out_stg;
61+
}
62+
63+
void add_active_state()
64+
{
65+
output_string = convert_array(angle_controller.get_vector_UR5());
66+
output_string += add_gripper();
67+
output_string += "\n";
68+
//server.SendMessage(output_string);
69+
server.set_msg(output_string);
70+
71+
}
72+
string convert_array(float[] array_in)
73+
{
74+
string output_str = null;
75+
output_str += "UR5_pos:";
76+
for (int i = 0; i < 6; i++)
77+
{
78+
output_str += array_in[i].ToString();
79+
if (i < 5)
80+
output_str += ",";
81+
}
82+
output_str += ";";
83+
return output_str;
84+
}
85+
}

Utillity Scripts/UR5_to_TPC.cs.meta

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

Utillity Scripts/VIVE_controller.cs

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,22 @@ public class VIVE_controller : MonoBehaviour {
2626
private bool release_gripper = false;
2727
public GameObject gripper;
2828
private gripper_kinematic kine;
29-
29+
//private SteamVR_TrackedController controller;
3030

3131

3232
// Use this for initialization
3333
void Start () {
3434
track_obj = GetComponent<SteamVR_TrackedObject>();
3535
interact = this.GetComponent<interaction>();
36-
kine = gripper.GetComponent<gripper_kinematic>();
37-
}
38-
39-
// Update is called once per frame
40-
void Update () {
36+
kine = gripper.GetComponent<gripper_kinematic>();
37+
38+
}
39+
40+
41+
42+
43+
// Update is called once per frame
44+
void Update () {
4145
device_obj = SteamVR_Controller.Input((int)track_obj.index);
4246

4347
//Conditionals for when the controller's trigger is pressed.
@@ -59,7 +63,8 @@ void Update () {
5963
if (gripper_ratio < 1.0f)
6064
gripper_ratio += gripper_speed;
6165
if (gripper_ratio >= 1.0f)
62-
device_obj.TriggerHapticPulse(10000);
66+
gripper_ratio = 1.0f;
67+
// device_obj.TriggerHapticPulse(10000);
6368
device_obj.TriggerHapticPulse(100);
6469
}
6570

@@ -75,13 +80,27 @@ void Update () {
7580
gripper_ratio -= gripper_speed;
7681
if (gripper_ratio <= 0)
7782
{
83+
gripper_ratio = 0;
7884
device_obj.TriggerHapticPulse(10000);
7985
release_gripper = false;
8086
}
8187
}
8288

8389

84-
kine.set_grip(gripper_ratio);
90+
//Test
91+
if (device_obj.GetPress(SteamVR_Controller.ButtonMask.Touchpad))
92+
{
93+
float tiltAroundX = device_obj.GetAxis(Valve.VR.EVRButtonId.k_EButton_Axis0).x;
94+
float tiltAroundY = device_obj.GetAxis(Valve.VR.EVRButtonId.k_EButton_Axis0).y;
95+
interact.Rotate(tiltAroundX, tiltAroundY);
96+
97+
device_obj.TriggerHapticPulse(100);
98+
}
99+
100+
101+
102+
//Gripper data
103+
kine.set_grip(gripper_ratio);
85104
Vector2 trig_Val = device_obj.GetAxis(Valve.VR.EVRButtonId.k_EButton_SteamVR_Trigger);
86105
}
87106

0 commit comments

Comments
 (0)