-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathOutput.py
More file actions
83 lines (66 loc) · 2.21 KB
/
Output.py
File metadata and controls
83 lines (66 loc) · 2.21 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import pandas as pd
import sys
from naoqi import ALProxy
import time
import nep
df = pd.read_csv('file.csv')
columns = list(df.columns.values)
JointAngles = [h for h in columns if 'TimeStamp' not in h]
TimeStamp = df['TimeStamp'].values.tolist()
# Sensor angles
Hip_Pitch = []
Hip_Roll = []
Head_Pitch = []
Head_Yaw = []
LShoulder_Pitch = []
RShoulder_Pitch = []
LShoulder_Roll = []
RShoulder_Roll = []
LElbow_Roll = []
RElbow_Roll = []
LElbow_Yaw = []
RElbow_Yaw = []
sensor = {'RShoulderRoll': RShoulder_Roll, 'LShoulderRoll': LShoulder_Roll,
'RElbowRoll': RElbow_Roll, 'LElbowRoll': LElbow_Roll, 'HeadYaw': Head_Yaw,
'HeadPitch': Head_Pitch, 'LShoulderPitch': LShoulder_Pitch,
'RShoulderPitch': RShoulder_Pitch, 'LElbowYaw': LElbow_Yaw,
'RElbowYaw': RElbow_Yaw, 'HipRoll': Hip_Roll, 'HipPitch': Hip_Pitch}
msg_type = "json"
node = nep.node("subscriber_sample")
sub = node.new_sub("test", msg_type)
def main(robotIP):
PORT = 9559
run = True
record = False
timestamp = TimeStamp[0]/2.0
print(timestamp)
while run:
s, msg = sub.listen()
if s:
if (msg["msg"] == True):
record = True
print("start recording")
if (msg["msg"] == False):
run = False
print("finish recording")
if record:
try:
motionProxy = ALProxy("ALMotion", robotIP, PORT)
except Exception,e:
print "Could not create proxy to ALMotion"
print "Error was: ",e
sys.exit(1)
useSensors = True
for theta in JointAngles:
q = motionProxy.getAngles(theta, useSensors)
sensor[theta].append(q[0])
time.sleep(timestamp)
if __name__ == "__main__":
robotIp = "192.168.11.41"
if len(sys.argv) <= 1:
print "Usage python almotion_getangles.py robotIP (optional default: 127.0.0.1)"
else:
robotIp = sys.argv[1]
main(robotIp)
ThetaSensor = pd.DataFrame.from_dict(sensor)
ThetaSensor.to_csv('body_language_sensor.csv', index=False)