Repository navigation
Expand file tree
/
Copy pathserver.py
More file actions
executable file
·114 lines (88 loc) · 2.67 KB
/
Copy pathserver.py
File metadata and controls
executable file
·114 lines (88 loc) · 2.67 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#!/usr/bin/env python3
import rospy
import time
from service_node.srv import *
NAMESPACE = "/arm"
# SERVICE TOPIC
SERVICE_CMD = NAMESPACE + "/arm_cmd"
SERVICE_STOP = NAMESPACE + "/x_stop"
def clientVision(a):
rate = rospy.Rate(1)
try:
global visionResp
rospy.wait_for_service('Vision')
service = rospy.ServiceProxy(
'Vision', Vision)
visionResp = service(a)
rate.sleep()
except rospy.ServiceException as e:
print("Service call failed: %s" % e)
def clientArm(a, b, c, d, e, f):
rate = rospy.Rate(1)
global armResp
try:
rospy.wait_for_service(SERVICE_CMD)
service = rospy.ServiceProxy(
SERVICE_CMD, Arm)
armResp = service(a, b, c, d, e, f)
rate.sleep()
except rospy.ServiceException as e:
print("Service call failed: %s" % e)
def clientNav(a, b, c):
rate = rospy.Rate(1)
global navResp
try:
rospy.wait_for_service('Nav')
service = rospy.ServiceProxy(
'Nav', Nav)
navResp = service(a, b, c)
rate.sleep()
except rospy.ServiceException as e:
print("Service call failed: %s" % e)
def clientHMI(a, b, c):
rate = rospy.Rate(1)
global hmiResp
try:
rospy.wait_for_service('HMI')
service = rospy.ServiceProxy(
'HMI', HMI)
hmiResp = service(a, b, c)
rate.sleep()
except rospy.ServiceException as e:
print("Service call failed: %s" % e)
def clientStop():
rate = rospy.Rate(1)
global stopResp
try:
rospy.wait_for_service(SERVICE_STOP)
service = rospy.ServiceProxy(
SERVICE_STOP, Stop)
stopResp = service()
rate.sleep()
except rospy.ServiceException as e:
print("Service call failed: %s" % e)
def clientButton():
rate = rospy.Rate(1)
global buttonResp
try:
rospy.wait_for_service('buttonStatus')
service = rospy.ServiceProxy(
'buttonStatus', buttonStatus)
buttonResp = service(True)
rate.sleep()
except rospy.ServiceException as e:
print("Service call failed: %s" % e)
if __name__ == "__main__":
rospy.init_node("Server")
global visionResp, buttonResp, stopResp, hmiResp, navResp, armResp
clientVision(True)
if visionResp.z == True:
clientArm(0, visionResp.x, visionResp.y , 300, 120, False)
time.sleep(26)
clientArm(0, 0, 0 , 300, 120, True)
clientButton()
print(buttonResp)
if buttonResp.isActive == True:
clientStop()
time.sleep(1)
clientArm(0, -visionResp.x, -visionResp.y , 300, 120, False)