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
107 changes: 58 additions & 49 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -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
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}
},
}
```

Expand Down
2 changes: 1 addition & 1 deletion lib/lifecycle_publisher.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
4 changes: 2 additions & 2 deletions lib/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.'
);
Expand Down Expand Up @@ -1696,7 +1696,7 @@ Node.getDefaultOptions = function () {
isRaw: false,
qos: QoS.profileDefault,
contentFilter: undefined,
willCheckConsistency: false
willCheckConsistency: false,
};
};

Expand Down
23 changes: 12 additions & 11 deletions lib/service.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion lib/time_source.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}

Expand Down
5 changes: 4 additions & 1 deletion rosidl_gen/message_translator.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 3 additions & 3 deletions rosidl_gen/packages.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions rosidl_gen/primitive_types.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
);
Expand Down
4 changes: 2 additions & 2 deletions rostsd_gen/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
);
}

Expand Down
4 changes: 2 additions & 2 deletions scripts/npmjs-readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ npm i [email protected]

#### 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)<br>[Jazzy](https://github.com/RobotWebTools/rclnodejs/tree/jazzy) |

## Documentation
Expand Down
6 changes: 3 additions & 3 deletions test/test-fixed-array.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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();
Expand Down Expand Up @@ -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: [],
};
Expand Down
10 changes: 8 additions & 2 deletions test/test-node-oo.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
});
10 changes: 8 additions & 2 deletions test/test-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
});
Expand Down
8 changes: 6 additions & 2 deletions test/test-security-related.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
Expand Down Expand Up @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion test/test-service-introspection.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ describe('service introspection', function () {
let serviceEventSubscriber;
let eventQueue;

before( function() {
before(function () {
if (!isServiceIntrospectionSupported()) {
this.skip();
}
Expand Down
Loading
Loading