Repository navigation
Expand file tree
/
Copy pathSaved_Code.txt
More file actions
355 lines (291 loc) · 11.5 KB
/
Copy pathSaved_Code.txt
File metadata and controls
355 lines (291 loc) · 11.5 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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
'''
# line 69 to 91 copied to Drive.py
class Driving(smach.State):
def __init__(self):
smach.State.__init__(self, outcomes = ['outcome_mine', 'outcome_dump', 'outcome_manual'],
input_keys = ['x_in'],
output_keys = ['x_out'])
# Drive chooses to mine, dump, or go to manual (and execute its function)
def execute(self, userdata):
#DRIVE STUFF
userdata.x_out = random.randint(0, 2)
rospy.loginfo(userdata.x_in)
if(userdata.x_in == 0):
return 'outcome_manual'
elif(userdata.x_in == 1):
return 'outcome_mine'
else:
return 'outcome_dump'
'''
'''
# line 94 to 115 copied to Mining.py file
class Mining(smach.State):
def __init__(self):
smach.State.__init__(self, outcomes = ['outcome_drive', 'outcome_manual', 'outcome_dig'],
input_keys = ['x_in'],
output_keys = ['x_out'])
def execute(self, userdata):
#MINE STUFF
userdata.x_out = random.randint(0, 2)
rospy.loginfo(userdata.x_in)
return 'outcome_dig'
############################ tripple quote here
if(userdata.x_in == 0):
return 'outcome_manual'
else:
return 'outcome_drive'
############################## tripple quote end here
'''
'''
# line 119 to 137 copied in Dump.py
class Dump(smach.State):
def __init__(self):
smach.State.__init__(self, outcomes = ['outcome_drive', 'outcome_manual', 'outcome_dump'],
input_keys = ['x_in'],
output_keys = ['x_out'])
def execute(self, userdata):
#DUMP STUFF
userdata.x_out = random.randint(0, 2)
rospy.loginfo(userdata.x_in)
return 'outcome_dump'
############################## tripple qyote here
if(userdata.x_in == 0):
return 'outcome_manual'
else:
return 'outcome_drive'
############################# tripple quote end here
'''
'''
# line 142 to 159 copied to Manual_Control.py file
class Manual_Control(smach.State):
def __init__(self):
smach.State.__init__(self, outcomes = ['outcome_mine', 'outcome_dump', 'outcome_drive'],
input_keys = ['x_in'],
output_keys = ['x_out'])
def execute(self, userdata):
#MANUAL STUFF
userdata.x_out = random.randint(0, 2)
rospy.loginfo(userdata.x_in)
if(userdata.x_in == 0):
return 'outcome_mine'
elif(userdata.x_in == 1):
return 'outcome_dump'
else:
return 'outcome_drive'
'''
# S S S S S S S S S S S S
# START OF SM_SUB_DIGGING
# S S S S S S S S S S S S
'''
# line 166 to 182 copied to Bl_ON.py file
class BL_ON(smach.State):
def __init__(self):
smach.State.__init__(self, outcomes = ['outcome_next'],
input_keys = ['x_in'],
output_keys = ['x_out'])
def execute(self, userdata):
rospy.loginfo("Running --> Sub Digging: BL_ON")
client = actionlib.SimpleActionClient("/name0/position",odrive_ros.msg.SetpointAction)
client.wait_for_server()
goal = odrive_ros.msg.SetpointGoal(setpoint=10)
client.send_goal(goal,feedback_cb=fdbk_cb)
client.wait_for_result()
print(client.get_result())
return 'outcome_next'
'''
'''
# line 186 to 202 copied to BL_Lower.py file
class BL_Lower(smach.State):
def __init__(self):
smach.State.__init__(self, outcomes = ['outcome_next'],
input_keys = ['x_in'],
output_keys = ['x_out'])
def execute(self, userdata):
rospy.loginfo("Running --> Sub Digging: BL_Lower")
client = actionlib.SimpleActionClient("/name0/position",odrive_ros.msg.SetpointAction)
client.wait_for_server()
goal = odrive_ros.msg.SetpointGoal(setpoint=10)
client.send_goal(goal,feedback_cb=fdbk_cb)
client.wait_for_result()
print(client.get_result())
return 'outcome_next'
'''
'''
# line 209 to 225 copied to Dump_Move.py file
class Dump_Move(smach.State):
def __init__(self):
smach.State.__init__(self, outcomes = ['outcome_next'],
input_keys = ['x_in'],
output_keys = ['x_out'])
def execute(self, userdata):
rospy.loginfo("Running --> Sub Digging: Dump_Move")
client = actionlib.SimpleActionClient("/name0/position",odrive_ros.msg.SetpointAction)
client.wait_for_server()
goal = odrive_ros.msg.SetpointGoal(setpoint=10)
client.send_goal(goal,feedback_cb=fdbk_cb)
client.wait_for_result()
print(client.get_result())
return 'outcome_next'
'''
'''
# line 230 to 246 copied to Robot_Lower.py file
class Robot_Lower(smach.State):
def __init__(self):
smach.State.__init__(self, outcomes = ['outcome_next'],
input_keys = ['x_in'],
output_keys = ['x_out'])
def execute(self, userdata):
rospy.loginfo("Running --> Sub Digging: Robot_Lower")
client = actionlib.SimpleActionClient("/name0/position",odrive_ros.msg.SetpointAction)
client.wait_for_server()
goal = odrive_ros.msg.SetpointGoal(setpoint=10)
client.send_goal(goal,feedback_cb=fdbk_cb)
client.wait_for_result()
print(client.get_result())
return 'outcome_next'
'''
'''
# line 253 to 262 copied to Timeout.py file
class Timeout(smach.State):
def __init__(self):
smach.State.__init__(self, outcomes = ['outcome_next'],
input_keys = ['x_in'],
output_keys = ['x_out'])
'
def execute(self, userdata):
rospy.loginfo("Running --> Sub Digging: Timeout")
return 'outcome_next'
'''
'''
# line 268 to 284 copied to Dump_Move.py file
class Dump_Stop(smach.State):
def __init__(self):
smach.State.__init__(self, outcomes = ['outcome_next'],
input_keys = ['x_in'],
output_keys = ['x_out'])
def execute(self, userdata):
rospy.loginfo("Running --> Sub Digging: Dump_Stop")
client = actionlib.SimpleActionClient("/name0/position",odrive_ros.msg.SetpointAction)
client.wait_for_server()
goal = odrive_ros.msg.SetpointGoal(setpoint=10)
client.send_goal(goal,feedback_cb=fdbk_cb)
client.wait_for_result()
print(client.get_result())
return 'outcome_next'
'''
'''
# line 290 to 306 copied to BL_Raise.py file
class BL_Raise(smach.State):
def __init__(self):
smach.State.__init__(self, outcomes = ['outcome_next'],
input_keys = ['x_in'],
output_keys = ['x_out'])
def execute(self, userdata):
rospy.loginfo("Running --> Sub Digging: BL_Raise")
client = actionlib.SimpleActionClient("/name0/position",odrive_ros.msg.SetpointAction)
client.wait_for_server()
goal = odrive_ros.msg.SetpointGoal(setpoint=10)
client.send_goal(goal,feedback_cb=fdbk_cb)
client.wait_for_result()
print(client.get_result())
return 'outcome_next'
'''
'''
# line 312 to 328 copied to Return.py file
class Return(smach.State):
def __init__(self):
smach.State.__init__(self, outcomes = ['outcome_return'],
input_keys = ['x_in'],
output_keys = ['x_out'])
def execute(self, userdata):
rospy.loginfo("Running --> Sub Digging: Return")
return 'outcome_return'
# E E E E E E E E E E E E
# END OF SM_SUB_DIGGING
# E E E E E E E E E E E E
# S S S S S S S S S S S S
# START OF SM_SUB_DUMPING
# S S S S S S S S S S S S
'''
'''
# line 334 to 342 copied to Rangefinder_Check.py file
class Rangefinder_Check(smach.State):
def __init__(self):
smach.State.__init__(self, outcomes = ['outcome_next'],
input_keys = ['x_in'],
output_keys = ['x_out'])
def execute(self, userdata):
rospy.loginfo("Running --> Sub Digging: Rangefinder_Check")
return 'outcome_next'
'''
'''
# line to 348 to 364 copied to BL_Move.py file
class BL_Move(smach.State):
def __init__(self):
smach.State.__init__(self, outcomes = ['outcome_next'],
input_keys = ['x_in'],
output_keys = ['x_out'])
def execute(self, userdata):
rospy.loginfo("Running --> Sub Digging: BL_Move")
client = actionlib.SimpleActionClient("/name0/position",odrive_ros.msg.SetpointAction)
client.wait_for_server()
goal = odrive_ros.msg.SetpointGoal(setpoint=10)
client.send_goal(goal,feedback_cb=fdbk_cb)
client.wait_for_result()
print(client.get_result())
return 'outcome_next'
'''
'''
# line 371 to 387 copied to Dump_Rotate.py file
class Dump_Rotate(smach.State):
def __init__(self):
smach.State.__init__(self, outcomes = ['outcome_next'],
input_keys = ['x_in'],
output_keys = ['x_out'])
def execute(self, userdata):
rospy.loginfo("Running --> Sub Digging: Dump_Rotate")
client = actionlib.SimpleActionClient("/name0/position",odrive_ros.msg.SetpointAction)
client.wait_for_server()
goal = odrive_ros.msg.SetpointGoal(setpoint=10)
client.send_goal(goal,feedback_cb=fdbk_cb)
client.wait_for_result()
print(client.get_result())
return 'outcome_next'
'''
'''
# line 393 to 409 copied to Dump_Lower.py file
class Dump_Lower(smach.State):
def __init__(self):
smach.State.__init__(self, outcomes = ['outcome_next'],
input_keys = ['x_in'],
output_keys = ['x_out'])
def execute(self, userdata):
rospy.loginfo("Running --> Sub Digging: Dump_Lower")
client = actionlib.SimpleActionClient("/name0/position",odrive_ros.msg.SetpointAction)
client.wait_for_server()
goal = odrive_ros.msg.SetpointGoal(setpoint=10)
client.send_goal(goal,feedback_cb=fdbk_cb)
client.wait_for_result()
print(client.get_result())
return 'outcome_next'
'''
'''
# line 415 to 435 copied to BL_Reset.py file
class BL_Reset(smach.State):
def __init__(self):
smach.State.__init__(self, outcomes = ['outcome_next'],
input_keys = ['x_in'],
output_keys = ['x_out'])
def execute(self, userdata):
rospy.loginfo("Running --> Sub Digging: BL_reset")
client = actionlib.SimpleActionClient("/name0/position",odrive_ros.msg.SetpointAction)
client.wait_for_server()
goal = odrive_ros.msg.SetpointGoal(setpoint=10)
client.send_goal(goal,feedback_cb=fdbk_cb)
client.wait_for_result()
print(client.get_result())
return 'outcome_next'
# E E E E E E E E E E E E
# END OF SM_SUB_DIGGING
# E E E E E E E E E E E E
'''