diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index f45d3da9..85e078af 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -1,54 +1,63 @@ -rclnodejs contributors (sorted alphabetically) -============================================== +# rclnodejs contributors (sorted alphabetically) + +- **[Alaa El Jawad](https://github.com/ejalaa12), [Ian McElroy](https://github.com/imcelroy)** -* **[Alaa El Jawad](https://github.com/ejalaa12), [Ian McElroy](https://github.com/imcelroy)** - Fix compatibility with ROS2 parameters array types - Unit tests for all parameter types - Handle concurrent ROS2 client calls, with unit tests -* **[Alex Mikhalev](https://github.com/amikhalev)** - * Fix build for AMENT_PREFIX_PATH with multiple entries - -* **[Felix Divo](https://github.com/felixdivo)** - * Code cleanup of index.js, tests cases & message generation - * Improved shutdown behavior - * Fixed compilation warnings - -* **[Hanyia](https://github.com/hanyia)** - * Benchmark test script - -* **[Kenny Yuan](https://github.com/kenny-y)** - * Message features: JS generation, typed arrays, plain JS object, compound msgs, many others... - * npm publish scripts - * Mac support - -* **[Matt Richard](https://github.com/mattrichard)** - * ROS2 Actions - * Guard conditions - * Node utility methods (countPublishers/subscribers...) - * TypeScript improvements - * Node 12 compatibility - -* **[Minggang Wang](https://github.com/minggangw)** - * Author, lead developer, maintainer - * Core, CI - -* **[Martins Mozeiko](https://github.com/martins-mozeiko)** - * QoS new/delete fix - -* **[Qiuzhong](https://github.com/qiuzhong)** - * Test coverage for actions, topics, multi-array messages, cross platform, security - * Converted from setTimeout to ROS2 Timer - -* **[Teo Koon Peng](https://github.com/koonpeng)** - * TypeScript improvements - * Added Client#waitForService - * Code style improvements, e.g., Prettier formatting - * Improved code generation smarts and efficiency - -* **[Wayne Parrott](https://github.com/wayneparrott)** - * TypeScript support with interface generation - * ROS2 parameter support - * ROS2 lifecycle node - * Rate class - * Node class hierarchy +- **[Alex Mikhalev](https://github.com/amikhalev)** + + - Fix build for AMENT_PREFIX_PATH with multiple entries + +- **[Felix Divo](https://github.com/felixdivo)** + + - Code cleanup of index.js, tests cases & message generation + - Improved shutdown behavior + - Fixed compilation warnings + +- **[Hanyia](https://github.com/hanyia)** + + - Benchmark test script + +- **[Kenny Yuan](https://github.com/kenny-y)** + + - Message features: JS generation, typed arrays, plain JS object, compound msgs, many others... + - npm publish scripts + - Mac support + +- **[Matt Richard](https://github.com/mattrichard)** + + - ROS2 Actions + - Guard conditions + - Node utility methods (countPublishers/subscribers...) + - TypeScript improvements + - Node 12 compatibility + +- **[Minggang Wang](https://github.com/minggangw)** + + - Author, lead developer, maintainer + - Core, CI + +- **[Martins Mozeiko](https://github.com/martins-mozeiko)** + + - QoS new/delete fix + +- **[Qiuzhong](https://github.com/qiuzhong)** + + - Test coverage for actions, topics, multi-array messages, cross platform, security + - Converted from setTimeout to ROS2 Timer + +- **[Teo Koon Peng](https://github.com/koonpeng)** + + - TypeScript improvements + - Added Client#waitForService + - Code style improvements, e.g., Prettier formatting + - Improved code generation smarts and efficiency + +- **[Wayne Parrott](https://github.com/wayneparrott)** + - TypeScript support with interface generation + - ROS2 parameter support + - ROS2 lifecycle node + - Rate class + - Node class hierarchy diff --git a/README.md b/README.md index 78cec1e5..91236867 100644 --- a/README.md +++ b/README.md @@ -3,8 +3,8 @@ [![npm](https://img.shields.io/npm/v/rclnodejs.svg)](https://www.npmjs.com/package/rclnodejs)[![Coverage Status](https://coveralls.io/repos/github/RobotWebTools/rclnodejs/badge.svg?branch=develop)](https://coveralls.io/github/RobotWebTools/rclnodejs?branch=develop)[![npm](https://img.shields.io/npm/dm/rclnodejs)](https://www.npmjs.com/package/rclnodejs)[![GitHub license](https://img.shields.io/github/license/RobotWebTools/rclnodejs.svg)](https://github.com/RobotWebTools/rclnodejs/blob/develop/LICENSE)[![node](https://img.shields.io/node/v/rclnodejs.svg)](https://nodejs.org/en/download/releases/)[![npm type definitions](https://img.shields.io/npm/types/rclnodejs)](https://www.npmjs.com/package/rclnodejs)[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier) | **ROS Distro\*** | **Linux** | **Windows** | -| :--------------: | :------------------------------------------------------------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------------------------: | -| Jazzy | ![GitHub Workflow Status](https://github.com/RobotWebTools/rclnodejs/actions/workflows/linux-build-and-test.yml/badge.svg?branch=jazzy) | ![GitHub Workflow Status](https://github.com/RobotWebTools/rclnodejs/actions/workflows/windows-build-and-test.yml/badge.svg?branch=jazzy) | +| :--------------: | :------------------------------------------------------------------------------------------------------------------------------------------------: | :--------------------------------------------------------------------------------------------------------------------------------------------------: | +| Jazzy | ![GitHub Workflow Status](https://github.com/RobotWebTools/rclnodejs/actions/workflows/linux-build-and-test.yml/badge.svg?branch=jazzy) | ![GitHub Workflow Status](https://github.com/RobotWebTools/rclnodejs/actions/workflows/windows-build-and-test.yml/badge.svg?branch=jazzy) | | Humble | ![GitHub Workflow Status](https://github.com/RobotWebTools/rclnodejs/actions/workflows/linux-build-and-test.yml/badge.svg?branch=humble-hawksbill) | ![GitHub Workflow Status](https://github.com/RobotWebTools/rclnodejs/actions/workflows/windows-build-and-test.yml/badge.svg?branch=humble-hawksbill) | \* rclnodejs development and maintenance is limited to the ROS 2 LTS releases and the Rolling development branch @@ -106,9 +106,9 @@ Your `tsconfig.json` file should include the following compiler options: "compilerOptions": { "module": "commonjs", "moduleResolution": "node", - "target": "es6" + "target": "es6", // your additional options here - } + }, } ``` diff --git a/lib/lifecycle_publisher.js b/lib/lifecycle_publisher.js index 5716dd35..03f7ff74 100644 --- a/lib/lifecycle_publisher.js +++ b/lib/lifecycle_publisher.js @@ -27,7 +27,7 @@ const Publisher = require('./publisher.js'); */ class LifecyclePublisher extends Publisher { constructor(handle, typeClass, topic, options) { - super(handle, typeClass, /*topic=*/'', options); + super(handle, typeClass, /*topic=*/ '', options); this._enabled = false; this._loggger = Logging.getLogger('LifecyclePublisher'); diff --git a/lib/node.js b/lib/node.js index e608ede0..89213d51 100644 --- a/lib/node.js +++ b/lib/node.js @@ -116,7 +116,7 @@ class Node extends rclnodejs.ShadowNode { // override cli parameterOverrides with those specified in options if (options.parameterOverrides.length > 0) { for (const parameter of options.parameterOverrides) { - if (!parameter instanceof Parameter) { + if ((!parameter) instanceof Parameter) { throw new TypeError( 'Parameter-override must be an instance of Parameter.' ); @@ -1696,7 +1696,7 @@ Node.getDefaultOptions = function () { isRaw: false, qos: QoS.profileDefault, contentFilter: undefined, - willCheckConsistency: false + willCheckConsistency: false, }; }; diff --git a/lib/service.js b/lib/service.js index 9508f63b..3083018a 100644 --- a/lib/service.js +++ b/lib/service.js @@ -75,18 +75,19 @@ class Service extends Entity { const plainObj = request.toPlainObject(this.typedArrayEnabled); const response = new Response(this, headerHandle); - Promise.resolve(this._callback(plainObj, response)).then((responseToReturn) => { - - if (!response.sent && responseToReturn) { - responseToReturn = new this._typeClass.Response(responseToReturn); - const rawResponse = responseToReturn.serialize(); - rclnodejs.sendResponse(this._handle, rawResponse, headerHandle); + Promise.resolve(this._callback(plainObj, response)).then( + (responseToReturn) => { + if (!response.sent && responseToReturn) { + responseToReturn = new this._typeClass.Response(responseToReturn); + const rawResponse = responseToReturn.serialize(); + rclnodejs.sendResponse(this._handle, rawResponse, headerHandle); + } + + debug( + `Service has processed the ${this._serviceName} request and sent the response.` + ); } - - debug( - `Service has processed the ${this._serviceName} request and sent the response.` - ); - }); + ); } static createService(nodeHandle, serviceName, typeClass, options, callback) { diff --git a/lib/time_source.js b/lib/time_source.js index d08928a1..2f1e8302 100644 --- a/lib/time_source.js +++ b/lib/time_source.js @@ -102,7 +102,7 @@ class TimeSource { * @return {undefined} */ attachNode(node) { - if (!node instanceof rclnodejs.ShadowNode) { + if ((!node) instanceof rclnodejs.ShadowNode) { throw new TypeError('Invalid argument, must be type of Node'); } diff --git a/rosidl_gen/message_translator.js b/rosidl_gen/message_translator.js index 2a59be5f..b8bb048f 100644 --- a/rosidl_gen/message_translator.js +++ b/rosidl_gen/message_translator.js @@ -149,7 +149,10 @@ function toPlainObject(message, enableTypedArray = true) { // TODO(Kenny): make sure Int64 & Uint64 type can be copied here obj[name] = message[name]; } - } else if (def.fields[i].type.isArray && def.fields[i].type.type === 'Constants') { + } else if ( + def.fields[i].type.isArray && + def.fields[i].type.type === 'Constants' + ) { // For a constants array, because its field is empty we just return an empty array here. obj[name] = []; } else { diff --git a/rosidl_gen/packages.js b/rosidl_gen/packages.js index 10eab8c0..a7ee7a54 100644 --- a/rosidl_gen/packages.js +++ b/rosidl_gen/packages.js @@ -148,10 +148,10 @@ async function generateMsgForSrv(filePath, interfaceInfo, pkgMap) { await fsp.writeFile(path.join(packagePath, responseMsgName), arr[1]); let requestInfo = Object.assign({}, interfaceInfo); requestInfo.filePath = path.join(packagePath, requestMsgName); - requestInfo.interfaceName = requestInfo.interfaceName + "_Request" + requestInfo.interfaceName = requestInfo.interfaceName + '_Request'; let responseInfo = Object.assign({}, interfaceInfo); responseInfo.filePath = path.join(packagePath, responseMsgName); - responseInfo.interfaceName = responseInfo.interfaceName + "_Response" + responseInfo.interfaceName = responseInfo.interfaceName + '_Response'; addInterfaceInfo(requestInfo, 'messages', pkgMap); addInterfaceInfo(responseInfo, 'messages', pkgMap); @@ -199,7 +199,7 @@ async function findAmentPackagesInDirectory(dir) { const rosFiles = Array.prototype.flat ? files.flat() : flat(files); const pkgMap = new Map(); await Promise.all( - rosFiles.map(filePath => addInterfaceInfos(filePath, dir, pkgMap)) + rosFiles.map((filePath) => addInterfaceInfos(filePath, dir, pkgMap)) ); return pkgMap; } diff --git a/rosidl_gen/primitive_types.js b/rosidl_gen/primitive_types.js index e86ed1c2..a2d60998 100644 --- a/rosidl_gen/primitive_types.js +++ b/rosidl_gen/primitive_types.js @@ -28,14 +28,14 @@ const StringRefStruct = StructType({ function initString(str, own = false) { if (own) { - if (!str instanceof Buffer) { + if ((!str) instanceof Buffer) { throw new TypeError( 'Invalid argument: should provide a Node Buffer to bindingsStringInit()' ); } rclnodejs.initString(str); } else { - if (!str instanceof StringRefStruct) { + if ((!str) instanceof StringRefStruct) { throw new TypeError( 'Invalid argument: should provide a type of StringRefStruct' ); diff --git a/rostsd_gen/index.js b/rostsd_gen/index.js index d438cdb1..07c0ab7d 100644 --- a/rostsd_gen/index.js +++ b/rostsd_gen/index.js @@ -363,8 +363,8 @@ function isInternalServiceEventMsgInterface(rosMsgInterface) { let subFolder = rosMsgInterface.type().subFolder; // Some package puts .srv files under srvs/, e.g., slam_toolbox. return ( - (subFolder == 'srv' || subFolder == 'srvs' || subFolder == 'action') - && name.endsWith('_Event') + (subFolder == 'srv' || subFolder == 'srvs' || subFolder == 'action') && + name.endsWith('_Event') ); } diff --git a/scripts/npmjs-readme.md b/scripts/npmjs-readme.md index 8e564b66..95d2d1e7 100644 --- a/scripts/npmjs-readme.md +++ b/scripts/npmjs-readme.md @@ -43,8 +43,8 @@ npm i rclnodejs@x.y.z #### RCLNODEJS - ROS 2 Version Compatibility -| RCLNODEJS Version | Compatible ROS 2 LTS | -| :------------------------------------------------------------------------------------------: | :-----------------------------------------------------------------------------------------------------------------------------------------------: | +| RCLNODEJS Version | Compatible ROS 2 LTS | +| :------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------------------: | | latest version (currently [v0.27.4](https://github.com/RobotWebTools/rclnodejs/tree/0.27.4)) | [Humble](https://github.com/RobotWebTools/rclnodejs/tree/humble-hawksbill)
[Jazzy](https://github.com/RobotWebTools/rclnodejs/tree/jazzy) | ## Documentation diff --git a/test/test-fixed-array.js b/test/test-fixed-array.js index cb55b8a4..a8f60caa 100644 --- a/test/test-fixed-array.js +++ b/test/test-fixed-array.js @@ -112,7 +112,7 @@ describe('Test message which has a fixed array of 36', function () { const node = rclnodejs.createNode('set_map_client'); const client = node.createClient('nav_msgs/srv/SetMap', 'set_map'); assert.throws(() => { - client.sendRequest(mapData, (response) => { }); + client.sendRequest(mapData, (response) => {}); }, RangeError); node.destroy(); done(); @@ -126,7 +126,7 @@ describe('Test message which has a fixed array of 36', function () { const node = rclnodejs.createNode('set_map_client'); const client = node.createClient('nav_msgs/srv/SetMap', 'set_map'); assert.throws(() => { - client.sendRequest(mapData, (response) => { }); + client.sendRequest(mapData, (response) => {}); }, RangeError); node.destroy(); done(); @@ -219,7 +219,7 @@ describe('Test message which has a fixed array of 36', function () { uint32_values_default: Uint32Array.from([0, 1, 4294967295]), int64_values_default: [0, 9223372036854775807, -9223372036854775808], uint64_values_default: [0, 1, '18446744073709551615'], - string_values_default: ["", "max value", "min value"], + string_values_default: ['', 'max value', 'min value'], alignment_check: 100, constants_values: [], }; diff --git a/test/test-node-oo.js b/test/test-node-oo.js index 46abee44..4641a29c 100644 --- a/test/test-node-oo.js +++ b/test/test-node-oo.js @@ -456,14 +456,20 @@ describe('topic & serviceName getter/setter', function () { it('client: serviceName property getter', function () { var node = new rclnodejs.Node('client', '/servicename_getter'); var client = node.createClient(AddTwoInts, 'add_two_ints'); - assert.deepStrictEqual(client.serviceName, '/servicename_getter/add_two_ints'); + assert.deepStrictEqual( + client.serviceName, + '/servicename_getter/add_two_ints' + ); node.destroy(); }); it('service: topic property getter', function () { var node = new rclnodejs.Node('service', '/servicename_getter'); var service = node.createService(AddTwoInts, 'add_two_ints', (req) => {}); - assert.deepStrictEqual(service.serviceName, '/servicename_getter/add_two_ints'); + assert.deepStrictEqual( + service.serviceName, + '/servicename_getter/add_two_ints' + ); node.destroy(); }); }); diff --git a/test/test-node.js b/test/test-node.js index 3bf980eb..c9dc3c37 100644 --- a/test/test-node.js +++ b/test/test-node.js @@ -457,14 +457,20 @@ describe('topic & serviceName getter/setter', function () { it('client: serviceName property getter', function () { var node = rclnodejs.createNode('client', '/servicename_getter'); var client = node.createClient(AddTwoInts, 'add_two_ints'); - assert.deepStrictEqual(client.serviceName, '/servicename_getter/add_two_ints'); + assert.deepStrictEqual( + client.serviceName, + '/servicename_getter/add_two_ints' + ); node.destroy(); }); it('service: topic property getter', function () { var node = rclnodejs.createNode('service', '/servicename_getter'); var service = node.createService(AddTwoInts, 'add_two_ints', (req) => {}); - assert.deepStrictEqual(service.serviceName, '/servicename_getter/add_two_ints'); + assert.deepStrictEqual( + service.serviceName, + '/servicename_getter/add_two_ints' + ); node.destroy(); }); }); diff --git a/test/test-security-related.js b/test/test-security-related.js index c8566d6d..f4345c84 100644 --- a/test/test-security-related.js +++ b/test/test-security-related.js @@ -217,7 +217,9 @@ describe('Fuzzing API calls testing', function () { var node = rclnodejs.createNode('node1', '/inconsistent'); const RclString = 'std_msgs/msg/String'; - var publisher = node.createPublisher(RclString, 'chatter7', {willCheckConsistency: true}); + var publisher = node.createPublisher(RclString, 'chatter7', { + willCheckConsistency: true, + }); assertThrowsError( () => { publisher.publish({ a: 1 }); @@ -247,7 +249,9 @@ describe('Fuzzing API calls testing', function () { var node = rclnodejs.createNode('node2', '/inconsistent'); const AddTwoInts = 'example_interfaces/srv/AddTwoInts'; - var client = node.createClient(AddTwoInts, 'add_two_ints', {willCheckConsistency: true}); + var client = node.createClient(AddTwoInts, 'add_two_ints', { + willCheckConsistency: true, + }); var service = node.createService( AddTwoInts, 'add_two_ints', diff --git a/test/test-service-introspection.js b/test/test-service-introspection.js index e75b63e2..f6801393 100644 --- a/test/test-service-introspection.js +++ b/test/test-service-introspection.js @@ -54,7 +54,7 @@ describe('service introspection', function () { let serviceEventSubscriber; let eventQueue; - before( function() { + before(function () { if (!isServiceIntrospectionSupported()) { this.skip(); } diff --git a/test/test-service-with-async-callback.js b/test/test-service-with-async-callback.js index af0ed5ea..ad549bbe 100644 --- a/test/test-service-with-async-callback.js +++ b/test/test-service-with-async-callback.js @@ -17,8 +17,7 @@ const assert = require('assert'); const rclnodejs = require('../index.js'); -describe('Test creating a service with an async callback', function(){ - +describe('Test creating a service with an async callback', function () { this.timeout(60 * 1000); before(function () { @@ -43,14 +42,14 @@ describe('Test creating a service with an async callback', function(){ assert.deepStrictEqual(request.b, 2); let result = response.template; result.sum = request.a + request.b; - // to trigger the bug, two conditions must hold: + // to trigger the bug, two conditions must hold: // - the response is send assynchronously(!) by the callback // via side effect // - the callback returns something unrelated to the // actual response. For an async function, if I do not // explicitly return anything, it will return a Promise resolving to // undefined. - setTimeout(()=>response.send(result), 0); + setTimeout(() => response.send(result), 0); } ); var client = clientNode.createClient(AddTwoInts, 'single_ps_channel2'); diff --git a/test/test-single-process.js b/test/test-single-process.js index ce59e9ed..223a64eb 100644 --- a/test/test-single-process.js +++ b/test/test-single-process.js @@ -176,7 +176,6 @@ describe('Test rclnodejs nodes in a single process', function () { rclnodejs.spin(clientNode); }); - it('New style requiring for services', function (done) { var node = rclnodejs.createNode('new_style_require_services'); const AddTwoInts = rclnodejs.require('example_interfaces/srv/AddTwoInts'); diff --git a/test/test-subscription-content-filter.js b/test/test-subscription-content-filter.js index a44a2b31..57c147e3 100644 --- a/test/test-subscription-content-filter.js +++ b/test/test-subscription-content-filter.js @@ -19,7 +19,13 @@ function isContentFilteringSupported() { ); } -function createAndRunPublisher(node, typeclass, topic, msgValue, interval=PUBLISHER_INTERVAL) { +function createAndRunPublisher( + node, + typeclass, + topic, + msgValue, + interval = PUBLISHER_INTERVAL +) { const publisher = node.createPublisher(typeclass, topic); const msg = rclnodejs.createMessage(typeclass); msg.data = msgValue; @@ -36,7 +42,7 @@ describe('subscription content-filtering', function () { this.timeout(30 * 1000); - before(function() { + before(function () { if (!isContentFilteringSupported()) { this.skip(); } @@ -50,7 +56,7 @@ describe('subscription content-filtering', function () { }); afterEach(function () { - this.intervals.forEach(interval => clearInterval(interval)); + this.intervals.forEach((interval) => clearInterval(interval)); this.publisherNode.destroy(); this.subscriberNode.destroy(); rclnodejs.shutdown(); @@ -82,24 +88,22 @@ describe('subscription content-filtering', function () { done(); }); - it('no parameters', async function() { + it('no parameters', async function () { const typeclass = 'std_msgs/msg/String'; - const publisherTimer1 = - createAndRunPublisher( - this.publisherNode, - typeclass, - TOPIC, - 'FilteredData' - ); + const publisherTimer1 = createAndRunPublisher( + this.publisherNode, + typeclass, + TOPIC, + 'FilteredData' + ); this.intervals.push(publisherTimer1); - - const publisherTimer2 = - createAndRunPublisher( - this.publisherNode, - typeclass, - TOPIC, - 'Data' - ); + + const publisherTimer2 = createAndRunPublisher( + this.publisherNode, + typeclass, + TOPIC, + 'Data' + ); this.intervals.push(publisherTimer2); let options = Node.getDefaultOptions(); @@ -115,7 +119,7 @@ describe('subscription content-filtering', function () { options, (msg) => { msgCnt++; - if (msg.data != 'FilteredData') fail = true; + if (msg.data != 'FilteredData') fail = true; } ); @@ -123,7 +127,7 @@ describe('subscription content-filtering', function () { this.subscriberNode.spin(); - const p = new Promise((resolve) => + const p = new Promise((resolve) => setTimeout(() => { resolve(msgCnt && !fail); }, SUBSCRIBER_WAIT_TIME) @@ -133,24 +137,23 @@ describe('subscription content-filtering', function () { assert.ok(result); }); - it('single parameter', async function() { + it('single parameter', async function () { const typeclass = 'std_msgs/msg/String'; - const publisherTimer1 = - createAndRunPublisher( - this.publisherNode, - typeclass, - TOPIC, - 'FilteredData' - ); + const publisherTimer1 = createAndRunPublisher( + this.publisherNode, + typeclass, + TOPIC, + 'FilteredData' + ); this.intervals.push(publisherTimer1); - - const publisherTimer2 = - createAndRunPublisher( - this.publisherNode, - typeclass, - TOPIC, - 'Data', - 200); + + const publisherTimer2 = createAndRunPublisher( + this.publisherNode, + typeclass, + TOPIC, + 'Data', + 200 + ); this.intervals.push(publisherTimer2); let options = Node.getDefaultOptions(); @@ -158,7 +161,7 @@ describe('subscription content-filtering', function () { expression: 'data = %0', parameters: ["'FilteredData'"], }; - + let msgCnt = 0; let fail = false; let subscription = this.subscriberNode.createSubscription( @@ -175,7 +178,7 @@ describe('subscription content-filtering', function () { this.subscriberNode.spin(); - const p = new Promise((resolve) => + const p = new Promise((resolve) => setTimeout(() => { resolve(msgCnt && !fail); }, 1000) @@ -185,24 +188,23 @@ describe('subscription content-filtering', function () { assert.ok(result); }); - it('multiple parameters', async function() { + it('multiple parameters', async function () { const typeclass = 'std_msgs/msg/Int32'; - const publisherTimer1 = - createAndRunPublisher( - this.publisherNode, - typeclass, - TOPIC, - 0 - ); + const publisherTimer1 = createAndRunPublisher( + this.publisherNode, + typeclass, + TOPIC, + 0 + ); this.intervals.push(publisherTimer1); - - const publisherTimer2 = - createAndRunPublisher( - this.publisherNode, - typeclass, - TOPIC, - 7, - 200); + + const publisherTimer2 = createAndRunPublisher( + this.publisherNode, + typeclass, + TOPIC, + 7, + 200 + ); this.intervals.push(publisherTimer2); let options = Node.getDefaultOptions(); @@ -210,7 +212,7 @@ describe('subscription content-filtering', function () { expression: 'data >= %0 AND data <= %1', parameters: [5, 10], }; - + let msgCnt = 0; let fail = false; const subscription = this.subscriberNode.createSubscription( @@ -227,7 +229,7 @@ describe('subscription content-filtering', function () { this.subscriberNode.spin(); - const p = new Promise((resolve) => + const p = new Promise((resolve) => setTimeout(() => { resolve(msgCnt && !fail); }, 1000) @@ -237,24 +239,23 @@ describe('subscription content-filtering', function () { assert.ok(result); }); - it('setContentFilter', async function() { + it('setContentFilter', async function () { const typeclass = 'std_msgs/msg/Int32'; - const publisherTimer1 = - createAndRunPublisher( - this.publisherNode, - typeclass, - TOPIC, - 0 - ); + const publisherTimer1 = createAndRunPublisher( + this.publisherNode, + typeclass, + TOPIC, + 0 + ); this.intervals.push(publisherTimer1); - - const publisherTimer2 = - createAndRunPublisher( - this.publisherNode, - typeclass, - TOPIC, - 5, - 200); + + const publisherTimer2 = createAndRunPublisher( + this.publisherNode, + typeclass, + TOPIC, + 5, + 200 + ); this.intervals.push(publisherTimer2); let options = Node.getDefaultOptions(); @@ -288,7 +289,7 @@ describe('subscription content-filtering', function () { this.subscriberNode.spin(); - const p1 = new Promise((resolve) => + const p1 = new Promise((resolve) => setTimeout(() => { let msgCnt = msgCnt0 + msgCnt5; const contentFilter5 = { @@ -301,7 +302,7 @@ describe('subscription content-filtering', function () { let result = await p1; assert.strictEqual(result, 0); - const p2 = new Promise((resolve) => + const p2 = new Promise((resolve) => setTimeout(() => { resolve(!fail && msgCnt5 && !msgCnt0); }, SUBSCRIBER_WAIT_TIME) @@ -310,24 +311,23 @@ describe('subscription content-filtering', function () { assert.ok(result); }); - it('set undefined content filter', async function() { + it('set undefined content filter', async function () { const typeclass = 'std_msgs/msg/Int32'; - const publisherTimer1 = - createAndRunPublisher( - this.publisherNode, - typeclass, - TOPIC, - 0 - ); + const publisherTimer1 = createAndRunPublisher( + this.publisherNode, + typeclass, + TOPIC, + 0 + ); this.intervals.push(publisherTimer1); - - const publisherTimer2 = - createAndRunPublisher( - this.publisherNode, - typeclass, - TOPIC, - 5, - 200); + + const publisherTimer2 = createAndRunPublisher( + this.publisherNode, + typeclass, + TOPIC, + 5, + 200 + ); this.intervals.push(publisherTimer2); let options = Node.getDefaultOptions(); @@ -361,7 +361,7 @@ describe('subscription content-filtering', function () { this.subscriberNode.spin(); - const p1 = new Promise((resolve) => + const p1 = new Promise((resolve) => setTimeout(() => { const result = !msgCnt0 && msgCnt5 && !fail; subscription.setContentFilter(); @@ -372,7 +372,7 @@ describe('subscription content-filtering', function () { assert.ok(result); assert.ok(!subscription.hasContentFilter()); - const p2 = new Promise((resolve) => + const p2 = new Promise((resolve) => setTimeout(() => { resolve(msgCnt0 && msgCnt5 && !fail); }, SUBSCRIBER_WAIT_TIME) @@ -381,7 +381,7 @@ describe('subscription content-filtering', function () { assert.ok(result); }); - it('clearContentFilter', function(done) { + it('clearContentFilter', function (done) { const typeclass = 'std_msgs/msg/Int32'; let options = Node.getDefaultOptions(); options.contentFilter = { @@ -403,7 +403,7 @@ describe('subscription content-filtering', function () { done(); }); - it('multiple clearContentFilter', function(done) { + it('multiple clearContentFilter', function (done) { const typeclass = 'std_msgs/msg/Int32'; let options = Node.getDefaultOptions(); options.contentFilter = { @@ -449,5 +449,4 @@ describe('subscription content-filtering', function () { done(); }); - });