Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/action/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions test/test-action-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ describe('rclnodejs action server', function () {
return new Fibonacci.Result();
}

function cancelCallback() {
function cancelCallback(goalHandle) {
return rclnodejs.CancelResponse.ACCEPT;
}

Expand Down Expand Up @@ -334,7 +334,7 @@ describe('rclnodejs action server', function () {
return new Fibonacci.Result();
}

function cancelCallback() {
function cancelCallback(goalHandle) {
return rclnodejs.CancelResponse.REJECT;
}

Expand Down Expand Up @@ -381,7 +381,7 @@ describe('rclnodejs action server', function () {
serverGoalHandle = goalHandle;
}

function cancelCallback() {
function cancelCallback(goalHandle) {
return rclnodejs.CancelResponse.ACCEPT;
}

Expand Down
14 changes: 7 additions & 7 deletions test/types/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
);

Expand All @@ -473,7 +473,7 @@ actionClient.waitForServer();
// $ExpectType void
actionClient.destroy();

// $ExpectType Promise<ClientGoalHandle<"test_msgs/action/Fibonacci">>
// $ExpectType Promise<ClientGoalHandle<"example_interfaces/action/Fibonacci">>
const goalHandlePromise = actionClient.sendGoal(new Fibonacci.Goal());

goalHandlePromise.then((goalHandle) => {
Expand Down Expand Up @@ -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
);
Expand All @@ -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;
Expand Down
10 changes: 6 additions & 4 deletions types/action_server.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@ declare module 'rclnodejs' {
type HandleAcceptedCallback<T extends TypeClass<ActionTypeClassName>> = (
goalHandle: ServerGoalHandle<T>
) => void;
type CancelCallback = () => Promise<CancelResponse> | CancelResponse;
type CancelCallback<T extends TypeClass<ActionTypeClassName>> = (
goalHandle: ServerGoalHandle<T>
) => Promise<CancelResponse> | CancelResponse;

interface ActionServerOptions extends Options<ActionQoS> {
/**
Expand Down Expand Up @@ -116,7 +118,7 @@ declare module 'rclnodejs' {
executeCallback: ExecuteCallback<T>,
goalCallback?: GoalCallback<T>,
handleAcceptedCallback?: HandleAcceptedCallback<T>,
cancelCallback?: CancelCallback,
cancelCallback?: CancelCallback<T>,
options?: ActionServerOptions
);

Expand Down Expand Up @@ -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<T>): void;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional param makes sense, thanks!


/**
* Register a callback for executing action goals.
Expand Down