Skip to content

Commit 189b17d

Browse files
committed
Add status field to action result messages
1 parent 5ac00b0 commit 189b17d

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

examples/ros2_action_server.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,10 @@
5151
console.log('Sending result: ' + fibonacciSequence);
5252
fibonacciServer.setSucceeded(id, { sequence: fibonacciSequence });
5353
};
54+
5455
var cancelCallback = function(id) {
5556
console.log('Canceled action with goal ID ' + id);
57+
fibonacciServer.setCanceled(id, { sequence: []})
5658
};
5759

5860
fibonacciServer.advertise(actionCallback, cancelCallback);

src/core/Action.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,25 @@ export default class Action extends EventEmitter {
216216
id: id,
217217
action: this.name,
218218
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
219238
result: true
220239
};
221240
this.ros.callOnConnection(call);
@@ -231,6 +250,7 @@ export default class Action extends EventEmitter {
231250
op: 'action_result',
232251
id: id,
233252
action: this.name,
253+
status: 6, // Corresponds to GoalStatus.STATUS_ABORTED
234254
result: false
235255
};
236256
this.ros.callOnConnection(call);

0 commit comments

Comments
 (0)