Skip to content

Commit f80d172

Browse files
authored
Add options for action client (#58)
Callers can now pass in options for individual publishers/subscribers in rosnodejs action clients.
1 parent 163bf4a commit f80d172

2 files changed

Lines changed: 14 additions & 10 deletions

File tree

src/lib/ActionClient.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,29 +41,33 @@ class ActionClient extends EventEmitter {
4141

4242
const nh = options.nh;
4343

44-
// FIXME: support user options for these parameters
44+
const goalOptions = Object.assign({ queueSize: 10, latching: true }, options.goal);
4545
this._goalPub = nh.advertise(this._actionServer + '/goal',
4646
this._actionType + 'Goal',
47-
{ queueSize: 1, latching: true });
47+
goalOptions);
4848

49+
const cancelOptions = Object.assign({ queueSize: 10, latching: true }, options.cancel);
4950
this._cancelPub = nh.advertise(this._actionServer + '/cancel',
5051
'actionlib_msgs/GoalID',
51-
{ queueSize: 1, latching: true });
52+
cancelOptions);
5253

54+
const statusOptions = Object.assign({ queueSize: 1 }, options.status);
5355
this._statusSub = nh.subscribe(this._actionServer + '/status',
5456
'actionlib_msgs/GoalStatusArray',
5557
(msg) => { this._handleStatus(msg); },
56-
{ queueSize: 1 } );
58+
statusOptions);
5759

60+
const feedbackOptions = Object.assign({ queueSize: 1 }, options.feedback);
5861
this._feedbackSub = nh.subscribe(this._actionServer + '/feedback',
5962
this._actionType + 'Feedback',
6063
(msg) => { this._handleFeedback(msg); },
61-
{ queueSize: 1 } );
64+
feedbackOptions);
6265

66+
const resultOptions = Object.assign({ queueSize: 1 }, options.result);
6367
this._resultSub = nh.subscribe(this._actionServer + '/result',
6468
this._actionType + 'Result',
6569
(msg) => { this._handleResult(msg); },
66-
{ queueSize: 1 } );
70+
resultOptions);
6771

6872
this._goals = {};
6973
this._goalCallbacks = {};
@@ -134,6 +138,6 @@ class ActionClient extends EventEmitter {
134138
});
135139
return id;
136140
}
137-
};
141+
}
138142

139143
module.exports = ActionClient;

src/lib/NodeHandle.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ class NodeHandle {
185185
}
186186
}
187187

188-
actionClient(actionServer, type) {
188+
actionClient(actionServer, type, options={}) {
189189
if (!actionServer) {
190190
throw new Error(`Unable to create action client to unspecified server - [${actionServer}]`);
191191
}
@@ -195,11 +195,11 @@ class NodeHandle {
195195

196196
// don't namespace action client - topics will be resolved by
197197
// advertising through this NodeHandle
198-
return new ActionClient({
198+
return new ActionClient(Object.assign({}, options, {
199199
actionServer,
200200
type,
201201
nh: this
202-
});
202+
}));
203203
}
204204

205205
/**

0 commit comments

Comments
 (0)