Skip to content

Commit cad6920

Browse files
committed
Consistent message String type naming
* Use RclString nameing for all std_msgs/msg/String type * Add node destruction before rclnodejs shutdown
1 parent 239acea commit cad6920

6 files changed

Lines changed: 39 additions & 35 deletions

File tree

test/client_setup.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
const rclnodejs = require('../index.js');
1818

1919
rclnodejs.init().then(function() {
20-
var node = rclnodejs.createNode('service');
20+
var node = rclnodejs.createNode('client');
2121
const AddTwoInts = 'example_interfaces/srv/AddTwoInts';
2222
var client = node.createClient(AddTwoInts, 'add_two_ints');
2323
const request = {

test/test-cross-lang.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ describe('Cross-language interaction', function() {
3434
describe('Node.js Subcription', function() {
3535
it('Node.js subscription should receive msg from C++ publisher', (done) => {
3636
var node = rclnodejs.createNode('cpp_pub_js_sub');
37-
const rclString = 'std_msgs/msg/String';
37+
const RclString = 'std_msgs/msg/String';
3838
var destroy = false;
3939
var cppTalkPath = path.join(process.env['AMENT_PREFIX_PATH'], 'lib', 'demo_nodes_cpp', 'talker');
4040
var cppTalker = childProcess.spawn(cppTalkPath, ['-t', 'cpp_js_chatter']);
41-
var subscription = node.createSubscription(rclString, 'cpp_js_chatter', (msg) => {
41+
var subscription = node.createSubscription(RclString, 'cpp_js_chatter', (msg) => {
4242
assert.ok(/Hello World:/.test(msg.data));
4343
if (!destroy) {
4444
node.destroy();
@@ -52,10 +52,10 @@ describe('Cross-language interaction', function() {
5252

5353
it('Node.js subscription should receive msg from Python publisher', (done) => {
5454
var node = rclnodejs.createNode('cpp_pub_py_sub');
55-
const rclString = 'std_msgs/msg/String';
55+
const RclString = 'std_msgs/msg/String';
5656
var destroy = false;
5757
var pyTalker = utils.launchPythonProcess([`${__dirname}/py/talker.py`]);
58-
var subscription = node.createSubscription(rclString, 'py_js_chatter', (msg) => {
58+
var subscription = node.createSubscription(RclString, 'py_js_chatter', (msg) => {
5959
assert.ok(/Hello World/.test(msg.data));
6060
if (!destroy) {
6161
node.destroy();
@@ -71,13 +71,13 @@ describe('Cross-language interaction', function() {
7171
describe('Node.js publisher', function() {
7272
it('Cpp subscription should receive msg from Node.js publisher', (done) => {
7373
var node = rclnodejs.createNode('js_pub_cpp_sub');
74-
const rclString = 'std_msgs/msg/String';
74+
const RclString = 'std_msgs/msg/String';
7575
var destroy = false;
7676

7777
let text = 'Greeting from Node.js publisher';
7878
let cppListenerPath = path.join(process.env['AMENT_PREFIX_PATH'], 'lib', 'demo_nodes_cpp', 'listener');
7979
var cppListener = childProcess.spawn(cppListenerPath, ['-t', 'js_cpp_chatter']);
80-
var publisher = node.createPublisher(rclString, 'js_cpp_chatter');
80+
var publisher = node.createPublisher(RclString, 'js_cpp_chatter');
8181
const msg = text;
8282
var timer = setInterval(() => {
8383
publisher.publish(msg);
@@ -98,12 +98,12 @@ describe('Cross-language interaction', function() {
9898

9999
it('Python subscription should receive msg from Node.js publisher', function(done) {
100100
var node = rclnodejs.createNode('js_pub_py_sub');
101-
const rclString = 'std_msgs/msg/String';
101+
const RclString = 'std_msgs/msg/String';
102102
var destroy = false;
103103

104104
let text = 'Greeting from Node.js publisher to Python subscription';
105105
var pyListener = utils.launchPythonProcess([`${__dirname}/py/listener.py`]);
106-
var publisher = node.createPublisher(rclString, 'js_py_chatter');
106+
var publisher = node.createPublisher(RclString, 'js_py_chatter');
107107
var msg = text;
108108

109109
var timer = setInterval(() => {

test/test-destruction.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ describe('Node destroy testing', function() {
8181
var pub2 = node.createPublisher(float32, 'pub2_topic');
8282
assert.deepStrictEqual(2, node._publishers.length);
8383

84-
var rclString = 'std_msgs/msg/String';
85-
var sub1 = node.createSubscription(rclString, 'sub1_topic', function(msg) {
84+
var RclString = 'std_msgs/msg/String';
85+
var sub1 = node.createSubscription(RclString, 'sub1_topic', function(msg) {
8686
console.log(`Received ${msg}`);
8787
});
8888
assert.deepStrictEqual(1, node._subscriptions.length);

test/test-existance.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,12 +146,12 @@ describe('rclnodejs class existance testing', function() {
146146
});
147147

148148
describe('Publisher class', function() {
149-
var node, rclString, publisher;
149+
var node, RclString, publisher;
150150

151151
before(function() {
152152
node = rclnodejs.createNode('Publisher');
153-
rclString = 'std_msgs/msg/String';
154-
publisher = node.createPublisher(rclString, 'chatter');
153+
RclString = 'std_msgs/msg/String';
154+
publisher = node.createPublisher(RclString, 'chatter');
155155
});
156156

157157
after(function() {

test/test-node.js

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ describe('rclnodejs node test suite', function() {
113113

114114
describe('rcl node methods testing', function() {
115115
var node;
116-
var rclString, GetParameters;
116+
var RclString, GetParameters;
117117
this.timeout(60 * 1000);
118118

119119
before(function() {
@@ -126,7 +126,7 @@ describe('rcl node methods testing', function() {
126126

127127
beforeEach(function() {
128128
node = rclnodejs.createNode('my_node', '/my_ns');
129-
rclString = 'std_msgs/msg/String';
129+
RclString = 'std_msgs/msg/String';
130130
GetParameters = 'rcl_interfaces/srv/GetParameters';
131131
});
132132

@@ -142,7 +142,7 @@ describe('rcl node methods testing', function() {
142142
});
143143

144144
it('node.createPublisher', function() {
145-
node.createPublisher(rclString, 'chatter');
145+
node.createPublisher(RclString, 'chatter');
146146

147147
var invalidParams = [
148148
['chatter?', Error, /topic name is invalid/],
@@ -152,7 +152,7 @@ describe('rcl node methods testing', function() {
152152

153153
invalidParams.forEach(function(invalidParam) {
154154
assertThrowsError(() => {
155-
node.createPublisher(rclString, invalidParam[0]);
155+
node.createPublisher(RclString, invalidParam[0]);
156156
}, invalidParam[1], invalidParam[2], 'Failed to createPublisher');
157157
});
158158
});
@@ -166,12 +166,12 @@ describe('rcl node methods testing', function() {
166166
[true, 'validServiceName'],
167167
[{f: 'abc'}, 'validServiceName'],
168168
[['a', 'b', 'c'], 'validSerivceName'],
169-
[rclString, 2],
170-
[rclString, undefined],
171-
[rclString, null],
172-
[rclString, false],
173-
[rclString, {n: 'invalidServiceName'}],
174-
[rclString, [1, 2, 3]],
169+
[RclString, 2],
170+
[RclString, undefined],
171+
[RclString, null],
172+
[RclString, false],
173+
[RclString, {n: 'invalidServiceName'}],
174+
[RclString, [1, 2, 3]],
175175
[undefined, null]
176176
];
177177

@@ -183,7 +183,7 @@ describe('rcl node methods testing', function() {
183183
});
184184

185185
it('node.createSubscription', function() {
186-
node.createSubscription(rclString, 'chatter', () => {});
186+
node.createSubscription(RclString, 'chatter', () => {});
187187

188188
var invalidParams = [
189189
['chatter?', /topic name is invalid/],
@@ -193,7 +193,7 @@ describe('rcl node methods testing', function() {
193193

194194
invalidParams.forEach(function(invalidParam) {
195195
assertThrowsError(() => {
196-
node.createSubscription(rclString, invalidParam[0], () => {});
196+
node.createSubscription(RclString, invalidParam[0], () => {});
197197
}, Error, invalidParam[1], 'Failed to createSubscription');
198198
});
199199
});
@@ -207,12 +207,12 @@ describe('rcl node methods testing', function() {
207207
[true, 'validTopicName', undefined],
208208
[{f: 'abc'}, 'validTopicName', null],
209209
[['a', 'b', 'c'], 'validTopicName', undefined],
210-
[rclString, 2, null],
211-
[rclString, undefined, undefined],
212-
[rclString, null, null],
213-
[rclString, false, undefined],
214-
[rclString, {n: 'invalidServiceName'}, null],
215-
[rclString, [1, 2, 3], undefined],
210+
[RclString, 2, null],
211+
[RclString, undefined, undefined],
212+
[RclString, null, null],
213+
[RclString, false, undefined],
214+
[RclString, {n: 'invalidServiceName'}, null],
215+
[RclString, [1, 2, 3], undefined],
216216
[undefined, null, null]
217217
];
218218

test/test-single-process.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ describe('Test rclnodejs nodes in a single process', function() {
3737
var subscription = subscriptionNode.createSubscription(RclString, 'single_ps_channel1', (msg) => {
3838
timer.cancel();
3939
assert.deepStrictEqual(msg.data, 'Hello World');
40+
publisherNode.destroy();
41+
subscriptionNode.destroy();
4042
done();
4143
});
4244

@@ -57,6 +59,7 @@ describe('Test rclnodejs nodes in a single process', function() {
5759
var subscription = node.createSubscription(RclString, 'new_style_require1', (msg) => {
5860
timer.cancel();
5961
assert.deepStrictEqual(msg.data, 'Hello World');
62+
node.destroy();
6063
done();
6164
});
6265

@@ -68,7 +71,7 @@ describe('Test rclnodejs nodes in a single process', function() {
6871
rclnodejs.spin(node);
6972
});
7073

71-
it('Client/Service is a one process', function(done) {
74+
it('Client/Service in one process', function(done) {
7275
var clientNode = rclnodejs.createNode('single_ps_client');
7376
var serviceNode = rclnodejs.createNode('single_ps_service');
7477
const AddTwoInts = 'example_interfaces/srv/AddTwoInts';
@@ -96,7 +99,7 @@ describe('Test rclnodejs nodes in a single process', function() {
9699
rclnodejs.spin(clientNode);
97100
});
98101

99-
it('Client/Service is a one process - service callback syntax #2', function(done) {
102+
it('Client/Service in one process - service callback syntax #2', function(done) {
100103
var clientNode = rclnodejs.createNode('single_ps_client_2');
101104
var serviceNode = rclnodejs.createNode('single_ps_service_2');
102105
const AddTwoInts = 'example_interfaces/srv/AddTwoInts';
@@ -124,7 +127,7 @@ describe('Test rclnodejs nodes in a single process', function() {
124127
rclnodejs.spin(clientNode);
125128
});
126129

127-
it('Client/Service is a one process - service callback syntax #3', function(done) {
130+
it('Client/Service in one process - service callback syntax #3', function(done) {
128131
var clientNode = rclnodejs.createNode('single_ps_client_3');
129132
var serviceNode = rclnodejs.createNode('single_ps_service_3');
130133
const AddTwoInts = 'example_interfaces/srv/AddTwoInts';
@@ -170,6 +173,7 @@ describe('Test rclnodejs nodes in a single process', function() {
170173
client.sendRequest(request, (response) => {
171174
timer.cancel();
172175
assert.deepStrictEqual(response.sum, 3);
176+
node.destroy();
173177
done();
174178
});
175179
});

0 commit comments

Comments
 (0)