-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_ati_client.py
54 lines (40 loc) · 1.39 KB
/
test_ati_client.py
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
45
46
47
48
49
50
51
52
53
54
from RobotRaconteur.Client import *
import time
import numpy
import sys, subprocess
def main():
# url='rr+local:///?nodeid=8570e7c7-b75e-4234-ae69-185caf0c59df&service=ati_sensor'
url='rr+tcp://localhost:59823?service=ati_sensor'
if (len(sys.argv)>=2):
url=sys.argv[1]
#Connect to the service
cli = RRN.ConnectService(url)
#Connect a wire connection
wrench_wire = cli.wrench_sensor_value.Connect()
#Add callback for when the wire value change
wrench_wire.WireValueChanged += wrench_wire_cb
if (sys.version_info > (3, 0)):
input("Server started, press enter to quit...")
else:
raw_input("Server started, press enter to quit...")
def wrench_wire_cb(w,value,time):
# print("==============")
# print("torque.x",value['torque']['x'])
# print("torque.y",value['torque']['y'])
# print("torque.z",value['torque']['z'])
# print("force.x",value['force']['x'])
# print("force.y",value['force']['y'])
# print("force.z",value['force']['z'])
# print("==============")
statement = """
Torque X {}
Torque Y {}
Torque Z {}
Force X {}
Force Y {}
Force Z {}
""".format(value['torque']['x'], value['torque']['y'], value['torque']['z'], value['force']['x'],value['force']['y'],value['force']['z'])
subprocess.call('clear')
print(statement)
if __name__=='__main__':
main()