diff --git a/lib/action/server.js b/lib/action/server.js index d2607ff2..a7de1d51 100644 --- a/lib/action/server.js +++ b/lib/action/server.js @@ -190,7 +190,7 @@ class ActionServer extends Entity { * * The purpose of the cancel callback is to decide if a request to cancel an on-going * (or queued) goal should be accepted or rejected. - * The callback should take one parameter containing the cancel request and must return a + * The callback should take one parameter containing the cancel request (a goal handle) and must return a * {@link CancelResponse} value. * * There can only be one cancel callback per {@link ActionServer}, therefore calling this diff --git a/test/test-action-server.js b/test/test-action-server.js index a14a4cf2..7fc462a9 100644 --- a/test/test-action-server.js +++ b/test/test-action-server.js @@ -289,7 +289,7 @@ describe('rclnodejs action server', function () { return new Fibonacci.Result(); } - function cancelCallback() { + function cancelCallback(goalHandle) { return rclnodejs.CancelResponse.ACCEPT; } @@ -334,7 +334,7 @@ describe('rclnodejs action server', function () { return new Fibonacci.Result(); } - function cancelCallback() { + function cancelCallback(goalHandle) { return rclnodejs.CancelResponse.REJECT; } @@ -381,7 +381,7 @@ describe('rclnodejs action server', function () { serverGoalHandle = goalHandle; } - function cancelCallback() { + function cancelCallback(goalHandle) { return rclnodejs.CancelResponse.ACCEPT; } diff --git a/test/types/main.ts b/test/types/main.ts index c538ff37..038edf28 100644 --- a/test/types/main.ts +++ b/test/types/main.ts @@ -454,13 +454,13 @@ logger.fatal('test msg'); // f64arr.data; // $ExpectType FibonacciConstructor -const Fibonacci = rclnodejs.require('test_msgs/action/Fibonacci'); +const Fibonacci = rclnodejs.require('example_interfaces/action/Fibonacci'); // ---- ActionClient ----- -// $ExpectType ActionClient<"test_msgs/action/Fibonacci"> +// $ExpectType ActionClient<"example_interfaces/action/Fibonacci"> const actionClient = new rclnodejs.ActionClient( node, - 'test_msgs/action/Fibonacci', + 'example_interfaces/action/Fibonacci', 'fibonnaci' ); @@ -473,7 +473,7 @@ actionClient.waitForServer(); // $ExpectType void actionClient.destroy(); -// $ExpectType Promise> +// $ExpectType Promise> const goalHandlePromise = actionClient.sendGoal(new Fibonacci.Goal()); goalHandlePromise.then((goalHandle) => { @@ -515,10 +515,10 @@ goalHandlePromise.then((goalHandle) => { }); // ---- ActionServer ----- -// $ExpectType ActionServer<"test_msgs/action/Fibonacci"> +// $ExpectType ActionServer<"example_interfaces/action/Fibonacci"> const actionServer = new rclnodejs.ActionServer( node, - 'test_msgs/action/Fibonacci', + 'example_interfaces/action/Fibonacci', 'fibonnaci', executeCallback ); @@ -539,7 +539,7 @@ actionServer.registerExecuteCallback(() => new Fibonacci.Result()); actionServer.destroy(); function executeCallback( - goalHandle: rclnodejs.ServerGoalHandle<'test_msgs/action/Fibonacci'> + goalHandle: rclnodejs.ServerGoalHandle<'example_interfaces/action/Fibonacci'> ) { // $ExpectType UUID goalHandle.goalId; diff --git a/types/action_server.d.ts b/types/action_server.d.ts index 314bc2db..194cb4a7 100644 --- a/types/action_server.d.ts +++ b/types/action_server.d.ts @@ -84,7 +84,9 @@ declare module 'rclnodejs' { type HandleAcceptedCallback> = ( goalHandle: ServerGoalHandle ) => void; - type CancelCallback = () => Promise | CancelResponse; + type CancelCallback> = ( + goalHandle?: ServerGoalHandle + ) => Promise | CancelResponse; interface ActionServerOptions extends Options { /** @@ -116,7 +118,7 @@ declare module 'rclnodejs' { executeCallback: ExecuteCallback, goalCallback?: GoalCallback, handleAcceptedCallback?: HandleAcceptedCallback, - cancelCallback?: CancelCallback, + cancelCallback?: CancelCallback, options?: ActionServerOptions ); @@ -153,14 +155,14 @@ declare module 'rclnodejs' { * * The purpose of the cancel callback is to decide if a request to cancel an on-going * (or queued) goal should be accepted or rejected. - * The callback should take one parameter containing the cancel request and must return a + * The callback should take one parameter containing the cancel request ( a GoalHandle) and must return a * {@link CancelResponse} value. * * There can only be one cancel callback per {@link ActionServer}, therefore calling this * function will replace any previously registered callback. * @param cancelCallback - Callback function, if not provided, then unregisters any previously registered callback. */ - registerCancelCallback(cancelCallback?: CancelCallback): void; + registerCancelCallback(cancelCallback?: CancelCallback): void; /** * Register a callback for executing action goals.