-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathjoint_test.py
76 lines (57 loc) · 1.9 KB
/
joint_test.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/usr/bin/python
# RShoulderPitch:-2.0857 to 2.0857 # -1(highest) to 2.0(lowest)
# RShoulderRoll:-1.3265 to 0.3142 # -1.3 to 0
# RElbowYaw:-2.0857 to 2.0857 # -2 to 2
# RElbowRoll:0.0349 to 1.5446 # 0 to 1.3
# RWristYaw:-1.8238 to 1.8238
# RHand:Open and close
import rospy
from std_msgs.msg import String
import naoqi
import time
import numpy as np
from naoqi import ALProxy,motion
PORT =9559
robotIP="10.42.0.1"
fractionMaxSpeed=0.5
try:
postureProxy=ALProxy("ALRobotPosture",robotIP,PORT)
except(Exception, e):
print ("Could not create proxy to ALRobotPosture")
print ("Error was: ", e)
postureProxy.goToPosture("Stand", 0.7)
try:
motionProxy = ALProxy("ALMotion", robotIP, PORT)
except (Exception,e):
print ("Could not create proxy to ALMotion")
print ("Error was: ",e)
names=["RShoulderPitch","RShoulderRoll","RElbowYaw","RElbowRoll"]
angles=[0,-0.5,2,0]
angles1=[1,-0.5,1,1]
from rospy_tutorials.msg import Floats
def callback(data):
print ("start")
#rospy.loginfo(rospy.get_caller_id() + 'I heard %s', data.data)
print rospy.get_name(), "I heard %s "%str(data.data)
print (type(data.data))
dat=list(data.data)
print (type(dat))
#rospy.loginfo(rospy.get_caller_id() + "I heard %s", data.data)
motionProxy.setAngles(names,dat,fractionMaxSpeed)
time.sleep(1.0)
print("hello")
motionProxy.setAngles(names,dat,fractionMaxSpeed)
#time.sleep(2.0)
print("bye")
def listener():
# In ROS, nodes are uniquely named. If two nodes with the same
# name are launched, the previous one is kicked off. The
# anonymous=True flag means that rospy will choose a unique
# name for our 'listener' node so that multiple listeners can
# run simultaneously.
rospy.init_node('listener', anonymous=True) # to avoid problem with names
rospy.Subscriber('floats', Floats , callback)
# spin() simply keeps python from exiting until this node is stopped
rospy.spin()
if __name__ == '__main__':
listener()