@@ -53,6 +53,7 @@ def _is_earlier(t1, t2):
53
53
54
54
class GoalStatus :
55
55
"""Valid goal statuses."""
56
+
56
57
PENDING = 0
57
58
ACTIVE = 1
58
59
PREEMPTED = 2
@@ -93,16 +94,9 @@ def __init__(self, action_client, goal_message):
93
94
self .status = None
94
95
self .feedback = None
95
96
96
- self .goal_message = Message ({
97
- 'goal_id' : {
98
- 'stamp' : {
99
- 'secs' : 0 ,
100
- 'nsecs' : 0
101
- },
102
- 'id' : self .goal_id
103
- },
104
- 'goal' : dict (self .goal_message )
105
- })
97
+ self .goal_message = Message (
98
+ {'goal_id' : {'stamp' : {'secs' : 0 , 'nsecs' : 0 }, 'id' : self .goal_id }, 'goal' : dict (self .goal_message )}
99
+ )
106
100
107
101
self .action_client .add_goal (self )
108
102
@@ -167,8 +161,7 @@ def _set_feedback(self, feedback):
167
161
def is_active (self ):
168
162
if self .status is None :
169
163
return False
170
- return (self .status ['status' ] == GoalStatus .ACTIVE or
171
- self .status ['status' ] == GoalStatus .PENDING )
164
+ return self .status ['status' ] == GoalStatus .ACTIVE or self .status ['status' ] == GoalStatus .PENDING
172
165
173
166
@property
174
167
def is_finished (self ):
@@ -190,8 +183,9 @@ class ActionClient(EventEmitterMixin):
190
183
timeout (:obj:`int`): **Deprecated.** Connection timeout, expressed in seconds.
191
184
"""
192
185
193
- def __init__ (self , ros , server_name , action_name , timeout = None ,
194
- omit_feedback = False , omit_status = False , omit_result = False ):
186
+ def __init__ (
187
+ self , ros , server_name , action_name , timeout = None , omit_feedback = False , omit_status = False , omit_result = False
188
+ ):
195
189
super (ActionClient , self ).__init__ ()
196
190
self .ros = ros
197
191
self .server_name = server_name
@@ -226,7 +220,8 @@ def __init__(self, ros, server_name, action_name, timeout=None,
226
220
227
221
if timeout :
228
222
LOGGER .warn (
229
- 'Deprecation warning: timeout parameter is ignored, and replaced by the DEFAULT_CONNECTION_TIMEOUT constant.' )
223
+ 'Deprecation warning: timeout parameter is ignored, and replaced by the DEFAULT_CONNECTION_TIMEOUT constant.'
224
+ )
230
225
231
226
self .wait_status = threading .Event ()
232
227
@@ -295,7 +290,8 @@ class SimpleActionServer(EventEmitterMixin):
295
290
server_name (:obj:`str`): Action server name, e.g. ``/fibonacci``.
296
291
action_name (:obj:`str`): Action message name, e.g. ``actionlib_tutorials/FibonacciAction``.
297
292
"""
298
- STATUS_PUBLISH_INTERVAL = 0.5 # In seconds
293
+
294
+ STATUS_PUBLISH_INTERVAL = 0.5 # In seconds
299
295
300
296
def __init__ (self , ros , server_name , action_name ):
301
297
super (SimpleActionServer , self ).__init__ ()
@@ -318,17 +314,11 @@ def __init__(self, ros, server_name, action_name):
318
314
self .result_publisher .advertise ()
319
315
320
316
# Track the goals and their status in order to publish status
321
- self .status_message = Message (dict (
322
- header = dict (
323
- stamp = dict (secs = 0 , nsecs = 100 ),
324
- frame_id = ''
325
- ),
326
- status_list = []
327
- ))
317
+ self .status_message = Message (dict (header = dict (stamp = dict (secs = 0 , nsecs = 100 ), frame_id = '' ), status_list = []))
328
318
329
319
# Needed for handling preemption prompted by a new goal being received
330
- self .current_goal = None # currently tracked goal
331
- self .next_goal = None # the one that'll be preempting
320
+ self .current_goal = None # currently tracked goal
321
+ self .next_goal = None # the one that'll be preempting
332
322
self .preempt_request = False
333
323
334
324
self .goal_listener .subscribe (self ._on_goal_message )
@@ -381,8 +371,7 @@ def _on_goal_message(self, message):
381
371
# needs to happen AFTER rest is set up
382
372
will_cancel = True
383
373
else :
384
- self .status_message ['status_list' ] = [
385
- dict (goal_id = message ['goal_id' ], status = GoalStatus .ACTIVE )]
374
+ self .status_message ['status_list' ] = [dict (goal_id = message ['goal_id' ], status = GoalStatus .ACTIVE )]
386
375
self .current_goal = message
387
376
will_emit_goal = message ['goal' ]
388
377
@@ -435,17 +424,12 @@ def set_succeeded(self, result):
435
424
Args:
436
425
result (:obj:`dict`): Dictionary of key/values to set as the result of the action.
437
426
"""
438
- LOGGER .info (
439
- 'Action server {} setting current goal to SUCCEEDED' .format (self .server_name ))
427
+ LOGGER .info ('Action server {} setting current goal to SUCCEEDED' .format (self .server_name ))
440
428
441
429
with self ._lock :
442
- result_message = Message ({
443
- 'status' : {
444
- 'goal_id' : self .current_goal ['goal_id' ],
445
- 'status' : GoalStatus .SUCCEEDED
446
- },
447
- 'result' : result
448
- })
430
+ result_message = Message (
431
+ {'status' : {'goal_id' : self .current_goal ['goal_id' ], 'status' : GoalStatus .SUCCEEDED }, 'result' : result }
432
+ )
449
433
450
434
self .result_publisher .publish (result_message )
451
435
@@ -469,13 +453,9 @@ def send_feedback(self, feedback):
469
453
Args:
470
454
feedback (:obj:`dict`): Dictionary of key/values of the feedback message.
471
455
"""
472
- feedback_message = Message ({
473
- 'status' : {
474
- 'goal_id' : self .current_goal ['goal_id' ],
475
- 'status' : GoalStatus .ACTIVE
476
- },
477
- 'feedback' : feedback
478
- })
456
+ feedback_message = Message (
457
+ {'status' : {'goal_id' : self .current_goal ['goal_id' ], 'status' : GoalStatus .ACTIVE }, 'feedback' : feedback }
458
+ )
479
459
480
460
self .feedback_publisher .publish (feedback_message )
481
461
@@ -485,12 +465,9 @@ def set_preempted(self):
485
465
486
466
with self ._lock :
487
467
self .status_message ['status_list' ] = []
488
- result_message = Message ({
489
- 'status' : {
490
- 'goal_id' : self .current_goal ['goal_id' ],
491
- 'status' : GoalStatus .PREEMPTED
492
- }
493
- })
468
+ result_message = Message (
469
+ {'status' : {'goal_id' : self .current_goal ['goal_id' ], 'status' : GoalStatus .PREEMPTED }}
470
+ )
494
471
495
472
self .result_publisher .publish (result_message )
496
473
0 commit comments