File tree Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change 51
51
console . log ( 'Sending result: ' + fibonacciSequence ) ;
52
52
fibonacciServer . setSucceeded ( id , { sequence : fibonacciSequence } ) ;
53
53
} ;
54
+
54
55
var cancelCallback = function ( id ) {
55
56
console . log ( 'Canceled action with goal ID ' + id ) ;
57
+ fibonacciServer . setCanceled ( id , { sequence : [ ] } )
56
58
} ;
57
59
58
60
fibonacciServer . advertise ( actionCallback , cancelCallback ) ;
Original file line number Diff line number Diff line change @@ -216,6 +216,25 @@ export default class Action extends EventEmitter {
216
216
id : id ,
217
217
action : this . name ,
218
218
values : result ,
219
+ status : 4 , // Corresponds to GoalStatus.STATUS_SUCCEEDED
220
+ result : true
221
+ } ;
222
+ this . ros . callOnConnection ( call ) ;
223
+ }
224
+
225
+ /**
226
+ * Helper function to set an action as canceled.
227
+ *
228
+ * @param {string } id - The action goal ID.
229
+ * @param {TResult } result - The result to set.
230
+ */
231
+ setCanceled ( id , result ) {
232
+ var call = {
233
+ op : 'action_result' ,
234
+ id : id ,
235
+ action : this . name ,
236
+ values : result ,
237
+ status : 5 , // Corresponds to GoalStatus.STATUS_CANCELED
219
238
result : true
220
239
} ;
221
240
this . ros . callOnConnection ( call ) ;
@@ -231,6 +250,7 @@ export default class Action extends EventEmitter {
231
250
op : 'action_result' ,
232
251
id : id ,
233
252
action : this . name ,
253
+ status : 6 , // Corresponds to GoalStatus.STATUS_ABORTED
234
254
result : false
235
255
} ;
236
256
this . ros . callOnConnection ( call ) ;
You can’t perform that action at this time.
0 commit comments