Skip to content

Commit a151f03

Browse files
jstnhuangchris-smith
authored andcommitted
Changed ActionClientInterface to expect action type names without extra "Action" appended (#106)
* Changed action interfaces so that the type name does not require an extra "Action" at the end. * Updated action type name in example.
1 parent 290613d commit a151f03

4 files changed

Lines changed: 7 additions & 11 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ const client = nh.serviceClient('/add_two_ints', AddTwoInts);
9292
const nh = rosnodejs.nh;
9393
const as = new rosnodejs.ActionServer({
9494
nh,
95-
type: 'turtle_actionlib/ShapeAction',
95+
type: 'turtle_actionlib/Shape',
9696
actionServer: '/turtle_shape'
9797
});
9898
@@ -102,7 +102,7 @@ as.on('goal', function (goal) {
102102
103103
as.start();
104104
105-
const ac = nh.actionClientInterface('/turtle_shape', 'turtle_actionlib/ShapeAction');
105+
const ac = nh.actionClientInterface('/turtle_shape', 'turtle_actionlib/Shape');
106106
ac.sendGoal({ goal: {edges: 3, radius: 1}});
107107
```
108108
## Run the turtlesim example

src/examples/turtle.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ rosnodejs.initNode('/my_node', {onTheFly: true}).then((rosNode) => {
7777
const shapeActionGoal = rosnodejs.require('turtle_actionlib').msg.ShapeActionGoal;
7878
const ac = rosnodejs.nh.actionClient(
7979
"/turtle_shape",
80-
"turtle_actionlib/ShapeAction"
80+
"turtle_actionlib/Shape"
8181
);
8282
ac.sendGoal(new shapeActionGoal({
8383
goal: {

src/lib/ActionClientInterface.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class ActionClientInterface extends EventEmitter {
4343

4444
const goalOptions = Object.assign({ queueSize: 10, latching: false }, options.goal);
4545
this._goalPub = nh.advertise(this._actionServer + '/goal',
46-
this._actionType + 'Goal',
46+
this._actionType + 'ActionGoal',
4747
goalOptions);
4848

4949
const cancelOptions = Object.assign({ queueSize: 10, latching: false }, options.cancel);
@@ -59,13 +59,13 @@ class ActionClientInterface extends EventEmitter {
5959

6060
const feedbackOptions = Object.assign({ queueSize: 1 }, options.feedback);
6161
this._feedbackSub = nh.subscribe(this._actionServer + '/feedback',
62-
this._actionType + 'Feedback',
62+
this._actionType + 'ActionFeedback',
6363
(msg) => { this._handleFeedback(msg); },
6464
feedbackOptions);
6565

6666
const resultOptions = Object.assign({ queueSize: 1 }, options.result);
6767
this._resultSub = nh.subscribe(this._actionServer + '/result',
68-
this._actionType + 'Result',
68+
this._actionType + 'ActionResult',
6969
(msg) => { this._handleResult(msg); },
7070
resultOptions);
7171

src/lib/NodeHandle.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ class NodeHandle {
207207
* @param {String} actionServer name of the action server
208208
* (e.g., "/turtle_shape")
209209
* @param {String} type action type
210-
* (e.g., "turtle_actionlib/ShapeAction")
210+
* (e.g., "turtle_actionlib/Shape")
211211
* @return {[type]} an instance of ActionClientInterface
212212
*/
213213
actionClientInterface(actionServer, type, options = {}) {
@@ -218,10 +218,6 @@ class NodeHandle {
218218
throw new Error(`Unable to create action client ${actionServer} without type - got ${type}`);
219219
}
220220

221-
if (!type.endsWith('Action')) {
222-
type += 'Action';
223-
}
224-
225221
// don't namespace action client - topics will be resolved by
226222
// advertising through this NodeHandle
227223
return new ActionClientInterface(Object.assign({}, options, {

0 commit comments

Comments
 (0)