Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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/lifecycle_publisher.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class LifecyclePublisher extends Publisher {
* Publish a message only when activated; otherwise do nothing (nop);
*
* @param {object|Buffer} message - The message to be sent, could be kind of JavaScript message generated from .msg
* or be a Buffer for a raw message.
* or be a Buffer for a raw message.
* @returns {undefined}
*/
publish(message) {
Expand Down
2 changes: 1 addition & 1 deletion lib/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -1496,7 +1496,7 @@ class Node extends rclnodejs.ShadowNode {
);
}

// publish ParameterEvent
// Publish ParameterEvent.
this._parameterEventPublisher.publish(parameterEvent);

return {
Expand Down
5 changes: 2 additions & 3 deletions lib/parameter.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable camelcase */

// Copyright (c) 2020 Wayne Parrott. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -21,8 +19,9 @@

'use strict';

/* eslint-disable camelcase */

const IsClose = require('is-close');
const rclnodejs = require('bindings')('rclnodejs');

/**
* The plus/minus tolerance for determining number equivalence.
Expand Down
1 change: 1 addition & 0 deletions lib/parameter_service.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const { Parameter, PARAMETER_SEPARATOR } = require('./parameter.js');
* rcl_interfaces/srv/GetParameters
* rcl_interfaces/srv/SetParameters
* rcl_interfaces/srv/SetParametersAtomically
* rcl_interfaces/srv/GetParameterTypes
*
* Call start() to begin receiving client request.
* All service requests are forwarded to the node this service works for.
Expand Down
2 changes: 1 addition & 1 deletion lib/publisher.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class Publisher extends Entity {
/**
* Publish a message
* @param {object|Buffer} message - The message to be sent, could be kind of JavaScript message generated from .msg
* or be a Buffer for a raw message.
* or be a Buffer for a raw message.
* @return {undefined}
*/
publish(message) {
Expand Down
1 change: 0 additions & 1 deletion lib/rate.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
Expand Down
12 changes: 12 additions & 0 deletions lib/rmw.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

'use strict';

const DistroUtils = require('./distro');
Expand Down
14 changes: 14 additions & 0 deletions rosidl_gen/filter.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

'use strict';

const fs = require('fs');
const path = require('path');
const os = require('os');
Expand Down
8 changes: 2 additions & 6 deletions rosidl_gen/message_translator.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@

/* eslint-disable max-depth */

const debug = require('debug')('rclnodejs:message_translator');

function isTypedArray(value) {
return ArrayBuffer.isView(value) && !(value instanceof DataView);
}
Expand All @@ -39,7 +37,6 @@ function copyMsgObject(msg, obj) {
// It's an array
if (typeof obj[i][0] === 'object') {
// It's an array of objects: converting to ROS message objects

// 1. Extract the element-type first
// 2. Build the array by translate every elements
let msgArray = [];
Expand All @@ -66,8 +63,7 @@ function copyMsgObject(msg, obj) {
function verifyMessage(message, obj) {
if (message.constructor.isROSArray) {
// It's a ROS message array
// Note: there won't be any JavaScript array in message

// Note: there won't be any JavaScript array in message.
if (!Array.isArray(obj)) {
return false;
}
Expand Down Expand Up @@ -131,7 +127,7 @@ function toPlainObject(message, enableTypedArray = true) {

if (message.constructor.isROSArray) {
// It's a ROS message array
// Note: there won't be any JavaScript array in message
// Note: there won't be any JavaScript array in message.
let array = [];
message.data.forEach((e) => {
array.push(toPlainObject(e, enableTypedArray)); // Translate every elements
Expand Down
7 changes: 4 additions & 3 deletions rostsd_gen/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/* eslint-disable max-depth */
/* eslint-disable no-sync */
/* eslint-disable camelcase */
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
Expand All @@ -26,6 +23,10 @@ declare module "rclnodejs" {
}
*/

/* eslint-disable max-depth */
/* eslint-disable no-sync */
/* eslint-disable camelcase */

'use strict';

const path = require('path');
Expand Down
2 changes: 1 addition & 1 deletion scripts/generate_messages.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#!/usr/bin/env node

/* eslint-disable camelcase */
// Copyright (c) 2018 Intel Corporation. All rights reserved.

// Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -15,6 +14,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

/* eslint-disable camelcase */
'use strict';

const generator = require('../rosidl_gen/index.js');
Expand Down
12 changes: 12 additions & 0 deletions scripts/ros_distro.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at

// http://www.apache.org/licenses/LICENSE-2.0

// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

'use strict';

const DistroUtils = require('../lib/distro');
Expand Down
2 changes: 0 additions & 2 deletions scripts/run_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ const Mocha = require('mocha');
const os = require('os');
const path = require('path');

let rootDir = path.dirname(__dirname);

fs.remove(path.join(path.dirname(__dirname), 'generated'), (err) => {
if (!err) {
let mocha = new Mocha();
Expand Down
1 change: 0 additions & 1 deletion src/rcl_bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -710,7 +710,6 @@ NAN_METHOD(HasContentFilter) {
info.GetReturnValue().Set(Nan::False());
return;
#else

RclHandle* subscription_handle = RclHandle::Unwrap<RclHandle>(
Nan::To<v8::Object>(info[0]).ToLocalChecked());
rcl_subscription_t* subscription =
Expand Down
14 changes: 0 additions & 14 deletions test/array_generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,6 @@ function noRound(v) {
return v;
}

// const arrayGen = require('./array_generator.js');
// const arrayLength = 100 * 1024;
// arrayGen.generateValues(Float32Array, arrayLength, 100000000, arrayGen.negative, arrayGen.noRound);
// arrayGen.generateValues(Float32Array, arrayLength, 10000, arrayGen.negative, arrayGen.noRound);
// arrayGen.generateValues(Float64Array, arrayLength, Number.MAX_VALUE, arrayGen.negative, arrayGen.noRound);
// arrayGen.generateValues(Float64Array, arrayLength, 10000, arrayGen.negative, arrayGen.noRound);
// arrayGen.generateValues(Int8Array, arrayLength, 128, arrayGen.negative, Math.floor);
// arrayGen.generateValues(Int16Array, arrayLength, 32768, arrayGen.negative, Math.floor);
// arrayGen.generateValues(Int32Array, arrayLength, 2147483648, arrayGen.negative, Math.floor);
// arrayGen.generateValues(Uint8Array, arrayLength, 256, arrayGen.positive, Math.floor);
// arrayGen.generateValues(Uint16Array, arrayLength, 65536, arrayGen.positive, Math.floor);
// arrayGen.generateValues(Uint32Array, arrayLength, 4294967296, arrayGen.positive, Math.floor);
// arrayGen.generateValues(Array, arrayLength, 256, arrayGen.positive, Math.floor);

module.exports = {
generateValues: generateValues,
positive: positive,
Expand Down
3 changes: 1 addition & 2 deletions test/blocklist.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"Linux": [
"test-raw-pub-sub.js",
"test-multi-nodes.js",
"test-msg-type-py-node.js",
"test-msg-type-cpp-node.js",
Expand All @@ -15,7 +14,7 @@
"test-subscription-content-filter.js"
],
"Windows_NT": [
"test-raw-pub-sub.js",
"test-raw-pub-sub.js",
"test-multi-nodes.js",
"test-msg-type-py-node.js",
"test-msg-type-cpp-node.js",
Expand Down
1 change: 0 additions & 1 deletion test/test-compound-msg-type-check.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

const assert = require('assert');
const rclnodejs = require('../index.js');
const assertThrowsError = require('./utils.js').assertThrowsError;

describe('Compound types', function () {
this.timeout(60 * 1000);
Expand Down
13 changes: 12 additions & 1 deletion test/test-distro.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

'use strict';

const assert = require('assert');
const childProcess = require('child_process');
const rclnodejs = require('../index.js');

const DistroUtils = rclnodejs.DistroUtils;
Expand Down
4 changes: 0 additions & 4 deletions test/test-extra-destroy-methods.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ describe('Node extra destroy methods testing', function () {
it('destroyPublisher()', function () {
var node = rclnodejs.createNode('node1');
const RclString = 'std_msgs/msg/String';
// const RclString = rclnodejs.require('std_msgs/msg/String');
var publisher = node.createPublisher(RclString, 'chatter');
assert.deepStrictEqual(node._publishers.length, 2);

Expand All @@ -51,7 +50,6 @@ describe('Node extra destroy methods testing', function () {
it('destroySubscription()', function () {
var node = rclnodejs.createNode('node2');
const RclString = 'std_msgs/msg/String';
// const RclString = rclnodejs.require('std_msgs/msg/String');
var subscription = node.createSubscription(RclString, 'chatter', () => {});
assert.deepStrictEqual(node._subscriptions.length, 1);

Expand All @@ -71,7 +69,6 @@ describe('Node extra destroy methods testing', function () {
it('destroyClient()', function () {
var node = rclnodejs.createNode('node3');
const AddTwoInts = 'example_interfaces/srv/AddTwoInts';
// const AddTwoInts = rclnodejs.require('example_interfaces/srv/AddTwoInts');
var client = node.createClient(AddTwoInts, 'add_two_ints');
assert.deepStrictEqual(node._clients.length, 1);

Expand All @@ -91,7 +88,6 @@ describe('Node extra destroy methods testing', function () {
it('destroyService()', function () {
var node = rclnodejs.createNode('node4');
const AddTwoInts = 'example_interfaces/srv/AddTwoInts';
// const AddTwoInts = rclnodejs.require('example_interfaces/srv/AddTwoInts');
var service = node.createService(AddTwoInts, 'add_two_ints', () => {});
assert.deepStrictEqual(node._services.length, 7);

Expand Down
3 changes: 0 additions & 3 deletions test/test-lifecycle-publisher.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ const assertThrowsError = assertUtils.assertThrowsError;

const NODE_NAME = 'lifecycle_node';

// let StateInterface = rclnodejs.createMessage('lifecycle_msgs/msg/State').constructor;
// let TransitionInterface = rclnodejs.createMessage('lifecycle_msgs/msg/Transition').constructor;

describe('LifecyclePublisher test suite', function () {
let node;
this.timeout(60 * 1000);
Expand Down
3 changes: 0 additions & 3 deletions test/test-lifecycle.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
Expand All @@ -18,7 +17,6 @@ const assert = require('assert');
const rclnodejs = require('../index.js');
const childProcess = require('child_process');
const assertUtils = require('./utils.js');
const assertThrowsError = assertUtils.assertThrowsError;

const NODE_NAME = 'lifecycle_node';

Expand Down Expand Up @@ -332,7 +330,6 @@ describe('LifecycleNode test suite', function () {
if (version < GALACTIC_VERSION) return;

let rosDistro = process.env.ROS_DISTRO;
let firstChar = rosDistro.charAt(0);
let testNode = new rclnodejs.lifecycle.LifecycleNode(
'TEST_NODE',
undefined,
Expand Down
41 changes: 4 additions & 37 deletions test/test-message-type.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,6 @@ const assert = require('assert');
const childProcess = require('child_process');
const rclnodejs = require('../index.js');

// function checkType(m, rclType, jsType, value, callback) {
// // rclnodejs, 'Bool', 'boolean', '"true"', callback
// if ((typeof rclType !== 'string') || (typeof value !== 'string')) {
// throw TypeError('Invalid type of parameters!');
// }

// var node = m.createNode(rclType + '_subscription');
// var msgType = m.require('std_msgs').msg[rclType];
// var publisher = childProcess.fork(`${__dirname}/publisher_msg.js`, [rclType, value]);
// var subscription = node.createSubscription(msgType, rclType + '_type_channel', (msg) => {
// publisher.send('quit');
// callback(msg, jsType, value);
// });
// m.spin(node);
// }

describe('Rclnodejs message type testing', function () {
this.timeout(60 * 1000);

Expand Down Expand Up @@ -126,19 +110,6 @@ describe('Rclnodejs message type testing', function () {
rclnodejs.spin(node);
});

// it('InitString', function(done) {
// var node = rclnodejs.createNode('init_string_subscription');
// var msgString = 'std_msgs/msg/String';
// var publisher = childProcess.fork(`${__dirname}/publisher_msg.js`, ['InitString', '"RCL String"']);
// var subscription = node.createSubscription(msgString, 'InitString_channel', (msg) => {
// publisher.send('quit');
// assert.deepStrictEqual(typeof msg.data, 'string');
// assert.deepStrictEqual(msg.data, 'RCL String');
// done();
// });
// rclnodejs.spin(node);
// });

it('Int8', function (done) {
var node = rclnodejs.createNode('int8_subscription');
const msgInt8 = 'std_msgs/msg/Int8';
Expand Down Expand Up @@ -354,27 +325,23 @@ describe('Rclnodejs message type testing', function () {
(msg) => {
publisher.kill('SIGINT');
assert.ok('r' in msg);
// assert.deepStrictEqual(typeof msg.r, 'number');
assert.deepStrictEqual(typeof msg.r, 'number');
assert.deepStrictEqual(msg.r, 127);
assert.ok('g' in msg);
// assert.deepStrictEqual(typeof msg.g, 'number');
assert.deepStrictEqual(typeof msg.g, 'number');
assert.deepStrictEqual(msg.g, 255);
assert.ok('b' in msg);
// assert.deepStrictEqual(typeof msg.b, 'number');
assert.deepStrictEqual(typeof msg.b, 'number');
assert.deepStrictEqual(msg.b, 255);
assert.ok('a' in msg);
// assert.deepStrictEqual(typeof msg.a, 'number');
assert.deepStrictEqual(typeof msg.a, 'number');
assert.ok(Math.abs(msg.a - 0.5) < 0.000001);
done();
}
);
rclnodejs.spin(node);
});

// it('Array', function(done) {

// });

it('Object with Header', function (done) {
var node = rclnodejs.createNode('header_subscription');
const Header = 'std_msgs/msg/Header';
Expand Down
Loading
Loading