diff --git a/src/core/Action.js b/src/core/Action.js index 019459916..294a92778 100644 --- a/src/core/Action.js +++ b/src/core/Action.js @@ -151,12 +151,10 @@ class Action extends EventEmitter2 { * * @param {Object} rosbridgeRequest - The ROSLIB.ActionGoal to send. * @param {string} rosbridgeRequest.id - The ID of the action goal. + * @param {TGoal} rosbridgeRequest.args - The arguments of the action goal. */ _executeAction(rosbridgeRequest) { - var id; - if (rosbridgeRequest.id) { - id = rosbridgeRequest.id; - } + var id = rosbridgeRequest.id; // If a cancellation callback exists, call it when a cancellation event is emitted. if (typeof id === 'string') { @@ -167,9 +165,11 @@ class Action extends EventEmitter2 { }); } - // Call the goal execution function provided. - // @ts-expect-error -- possibly null - this._actionCallback(rosbridgeRequest.args, id); + // Call the action goal execution function provided. + if (typeof this._actionCallback === 'function') + { + this._actionCallback(rosbridgeRequest.args, id); + } } /**