-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathReq_node.py
executable file
·42 lines (33 loc) · 1.13 KB
/
Req_node.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
#!/usr/bin/env python3
import time
import rospy
from Rotation_Conversion_srv.srv import quat2rodrigues
from Rotation_Conversion_srv.srv import quat2rodriguesRequest
from Rotation_Conversion_srv.srv import quat2zyx
from Rotation_Conversion_srv.srv import quat2zyxRequest
def rot_convert_client():
S = 1
if (S == 1):
rospy.wait_for_service('quat2rodrigues')
else:
rospy.wait_for_service('quat2zyx')
while not rospy.is_shutdown():
if (S == 1):
client = rospy.ServiceProxy('quat2rodrigues', quat2rodrigues) #Initialise client for the service "rot_convert"
req = quat2rodriguesRequest()
else:
client = rospy.ServiceProxy('quat2zyx', quat2zyx) #Initialise client for the service "rot_convert"
req = quat2zyxRequest()
req.q.w = 1
req.q.x = 2
req.q.y = 3
req.q.z = 4
res = client(req) # Get the response from the service.
print(req)
print(res)
time.sleep(3)
if __name__ == "__main__":
try:
rot_convert_client()
except rospy.ROSInterruptException:
pass