rclnodejs 0.27.3 → 0.27.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/electron_demo/README.md +54 -0
- package/electron_demo/electron-demo.gif +0 -0
- package/electron_demo/index.html +25 -0
- package/electron_demo/main.js +66 -0
- package/electron_demo/package.json +22 -0
- package/electron_demo/renderer.js +22 -0
- package/package.json +19 -19
- package/scripts/npmjs-readme.md +2 -2
- package/src/rcl_bindings.cpp +1 -1
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# rclnodejs 
|
|
2
2
|
|
|
3
3
|
`rclnodejs` is a Node.js client for the Robot Operating System (ROS 2). It provides a simple and easy JavaScript API for ROS 2 programming. TypeScript declarations are included to support use of rclnodejs in TypeScript projects.
|
|
4
4
|
|
|
@@ -45,7 +45,7 @@ npm i rclnodejs@x.y.z
|
|
|
45
45
|
|
|
46
46
|
| RCLNODEJS Version | Compatible ROS 2 LTS |
|
|
47
47
|
| :------------------------------------------------------------------------------------------: | :-----------------------------------------------------------------------------------------------------------------------------------------------: |
|
|
48
|
-
| latest version (currently [v0.
|
|
48
|
+
| 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) |
|
|
49
49
|
|
|
50
50
|
## Documentation
|
|
51
51
|
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# Rclnodejs Electron demo
|
|
2
|
+
|
|
3
|
+
## Introduction
|
|
4
|
+
|
|
5
|
+
This is a minimal rclnodejs demo using Electron. More information about Electron, please check with [Electron documentation](https://electronjs.org/docs/latest/tutorial/quick-start).
|
|
6
|
+
|
|
7
|
+
The demo includes the following files:
|
|
8
|
+
|
|
9
|
+
- `package.json` - Points to the app's main file and lists its details and dependencies.
|
|
10
|
+
- `main.js` - Introduces the `rclnodejs` native module, starts the app and creates a browser window to render HTML. This is the app's **main process**.
|
|
11
|
+
- `index.html` - Includes a text editor where you can input the the topic to be published. This is the app's **renderer process**.
|
|
12
|
+
- `renderer.js` - Communicate with main process to publish a topic and get it through a subscription.
|
|
13
|
+
|
|
14
|
+
## To run the demo
|
|
15
|
+
|
|
16
|
+
Before starting, please ensure you have installed [nodejs](https://nodejs.org/en).
|
|
17
|
+
|
|
18
|
+
1. Clone this repository.
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
git clone https://github.com/RobotWebTools/rclnodejs.git
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
2. Go into the demo.
|
|
25
|
+
```bash
|
|
26
|
+
cd rclnodejs/electron_demo
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
3. [SOURCE THE ROS 2 SETUP FILE](https://docs.ros.org/en/jazzy/Tutorials/Beginner-CLI-Tools/Configuring-ROS2-Environment.html#source-the-setup-files)
|
|
30
|
+
|
|
31
|
+
4. Install dependencies
|
|
32
|
+
```bash
|
|
33
|
+
npm install
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
5. Rebuild rclnodejs for Electron
|
|
37
|
+
```bash
|
|
38
|
+
# Every time you run "npm install", run this:
|
|
39
|
+
./node_modules/.bin/electron-rebuild
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
6. Run the app
|
|
43
|
+
```
|
|
44
|
+
npm start
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
If it works, you can see the demo as:
|
|
48
|
+

|
|
49
|
+
|
|
50
|
+
## Resources for Learning Electron
|
|
51
|
+
|
|
52
|
+
- [electronjs.org/docs](https://electronjs.org/docs) - all of Electron's documentation.
|
|
53
|
+
- [Native Node Modules](https://www.electronjs.org/docs/latest/tutorial/using-native-node-modules) - Use a native node module.
|
|
54
|
+
|
|
Binary file
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
|
|
4
|
+
<head>
|
|
5
|
+
<meta charset="UTF-8">
|
|
6
|
+
<meta http-equiv="Content-Security-Policy"
|
|
7
|
+
content="default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'">
|
|
8
|
+
<title>RCLNODEJS Electron Demo</title>
|
|
9
|
+
</head>
|
|
10
|
+
|
|
11
|
+
<body>
|
|
12
|
+
<div>
|
|
13
|
+
<div style="height: 20px;"></div>
|
|
14
|
+
<div>
|
|
15
|
+
<input id="topic-input"></input>
|
|
16
|
+
<button id="publish-topic">Publish topic</button>
|
|
17
|
+
</div>
|
|
18
|
+
<div style="height: 20px;"></div>
|
|
19
|
+
<span>Received topic:</span>
|
|
20
|
+
<span id="received-topic"></span>
|
|
21
|
+
</div>
|
|
22
|
+
<script src="./renderer.js"></script>
|
|
23
|
+
</body>
|
|
24
|
+
|
|
25
|
+
</html>
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
2
|
+
// you may not use this file except in compliance with the License.
|
|
3
|
+
// You may obtain a copy of the License at
|
|
4
|
+
//
|
|
5
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
//
|
|
7
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
8
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
9
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
10
|
+
// See the License for the specific language governing permissions and
|
|
11
|
+
// limitations under the License.
|
|
12
|
+
|
|
13
|
+
const { app, BrowserWindow } = require('electron')
|
|
14
|
+
let rclnodejs = require("rclnodejs");
|
|
15
|
+
const { ipcMain } = require('electron');
|
|
16
|
+
|
|
17
|
+
function createWindow() {
|
|
18
|
+
// Create the browser window.
|
|
19
|
+
const mainWindow = new BrowserWindow({
|
|
20
|
+
width: 800,
|
|
21
|
+
height: 600,
|
|
22
|
+
webPreferences: {
|
|
23
|
+
// Add the following two lines in order to use require() in renderer, see details
|
|
24
|
+
// https://stackoverflow.com/questions/44391448/electron-require-is-not-defined
|
|
25
|
+
nodeIntegration: true,
|
|
26
|
+
contextIsolation: false,
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
mainWindow.loadFile('index.html');
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// This method will be called when Electron has finished
|
|
34
|
+
// initialization and is ready to create browser windows.
|
|
35
|
+
// Some APIs can only be used after this event occurs.
|
|
36
|
+
app.whenReady().then(() => {
|
|
37
|
+
createWindow();
|
|
38
|
+
rclnodejs.init().then(() => {
|
|
39
|
+
let sender = null;
|
|
40
|
+
const node = rclnodejs.createNode('publisher_example_node');
|
|
41
|
+
node.createSubscription('std_msgs/msg/String', 'topic', (msg) => {
|
|
42
|
+
if (sender) {
|
|
43
|
+
sender.send('topic-received', msg.data);
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
const publisher = node.createPublisher('std_msgs/msg/String', 'topic');
|
|
47
|
+
ipcMain.on('publish-topic', (event, topic) => {
|
|
48
|
+
publisher.publish(topic);
|
|
49
|
+
sender = event.sender;
|
|
50
|
+
});
|
|
51
|
+
rclnodejs.spin(node);
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
app.on('activate', function () {
|
|
55
|
+
// On macOS it's common to re-create a window in the app when the
|
|
56
|
+
// dock icon is clicked and there are no other windows open.
|
|
57
|
+
if (BrowserWindow.getAllWindows().length === 0) createWindow();
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
// Quit when all windows are closed, except on macOS. There, it's common
|
|
62
|
+
// for applications and their menu bar to stay active until the user quits
|
|
63
|
+
// explicitly with Cmd + Q.
|
|
64
|
+
app.on('window-all-closed', function () {
|
|
65
|
+
if (process.platform !== 'darwin') app.quit()
|
|
66
|
+
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "rclnodejs-electron-demo",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "A minimal rclnodejs Electron application",
|
|
5
|
+
"main": "main.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"start": "electron ."
|
|
8
|
+
},
|
|
9
|
+
"keywords": [
|
|
10
|
+
"Electron",
|
|
11
|
+
"rclnodejs",
|
|
12
|
+
"demo"
|
|
13
|
+
],
|
|
14
|
+
"license": "Apache",
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"rclnodejs": "^0.27.4"
|
|
17
|
+
},
|
|
18
|
+
"devDependencies": {
|
|
19
|
+
"@electron/rebuild": "^3.6.0",
|
|
20
|
+
"electron": "^31.0.0"
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
2
|
+
// you may not use this file except in compliance with the License.
|
|
3
|
+
// You may obtain a copy of the License at
|
|
4
|
+
//
|
|
5
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
//
|
|
7
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
8
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
9
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
10
|
+
// See the License for the specific language governing permissions and
|
|
11
|
+
// limitations under the License.
|
|
12
|
+
|
|
13
|
+
const { ipcRenderer } = require('electron');
|
|
14
|
+
|
|
15
|
+
ipcRenderer.on('topic-received', function (event, response) {
|
|
16
|
+
document.getElementById('received-topic').innerText = response;
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
document.getElementById('publish-topic').addEventListener('click', () => {
|
|
20
|
+
const topic = document.getElementById('topic-input').value;
|
|
21
|
+
ipcRenderer.send('publish-topic', topic);
|
|
22
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rclnodejs",
|
|
3
|
-
"version": "0.27.
|
|
3
|
+
"version": "0.27.5",
|
|
4
4
|
"description": "ROS2.0 JavaScript client with Node.js",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "types/index.d.ts",
|
|
@@ -42,24 +42,24 @@
|
|
|
42
42
|
"url": "git+https://github.com/RobotWebTools/rclnodejs.git"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@babel/eslint-parser": "^7.
|
|
46
|
-
"@typescript-eslint/eslint-plugin": "^6.
|
|
47
|
-
"@typescript-eslint/parser": "^6.
|
|
45
|
+
"@babel/eslint-parser": "^7.25.9",
|
|
46
|
+
"@typescript-eslint/eslint-plugin": "^6.21.0",
|
|
47
|
+
"@typescript-eslint/parser": "^6.21.0",
|
|
48
48
|
"babel-eslint": "^10.1.0",
|
|
49
49
|
"clang-format": "^1.8.0",
|
|
50
|
-
"commander": "^11.
|
|
50
|
+
"commander": "^11.1.0",
|
|
51
51
|
"deep-equal": "^1.1.1",
|
|
52
|
-
"eslint": "^8.
|
|
53
|
-
"eslint-config-prettier": "^9.
|
|
54
|
-
"eslint-plugin-prettier": "^5.
|
|
52
|
+
"eslint": "^8.57.1",
|
|
53
|
+
"eslint-config-prettier": "^9.1.0",
|
|
54
|
+
"eslint-plugin-prettier": "^5.2.1",
|
|
55
55
|
"husky": "^8.0.3",
|
|
56
|
-
"jsdoc": "^4.0.
|
|
56
|
+
"jsdoc": "^4.0.4",
|
|
57
57
|
"lint-staged": "^14.0.1",
|
|
58
|
-
"mocha": "^10.2
|
|
59
|
-
"prettier": "^3.
|
|
58
|
+
"mocha": "^10.8.2",
|
|
59
|
+
"prettier": "^3.4.2",
|
|
60
60
|
"sinon": "^15.2.0",
|
|
61
61
|
"tree-kill": "^1.2.2",
|
|
62
|
-
"typescript": "^4.9.
|
|
62
|
+
"typescript": "^4.9.5"
|
|
63
63
|
},
|
|
64
64
|
"dependencies": {
|
|
65
65
|
"@rclnodejs/ref-array-di": "^1.2.2",
|
|
@@ -67,18 +67,18 @@
|
|
|
67
67
|
"@rclnodejs/ref-struct-di": "^1.1.1",
|
|
68
68
|
"array.prototype.flat": "^1.3.2",
|
|
69
69
|
"bindings": "^1.5.0",
|
|
70
|
-
"compare-versions": "^6.1.
|
|
71
|
-
"debug": "^4.
|
|
70
|
+
"compare-versions": "^6.1.1",
|
|
71
|
+
"debug": "^4.4.0",
|
|
72
72
|
"dot": "^1.1.3",
|
|
73
73
|
"dtslint": "^4.2.1",
|
|
74
|
-
"fs-extra": "^11.
|
|
74
|
+
"fs-extra": "^11.2.0",
|
|
75
75
|
"int64-napi": "^1.0.2",
|
|
76
76
|
"is-close": "^1.3.3",
|
|
77
77
|
"mkdirp": "^3.0.1",
|
|
78
78
|
"mz": "^2.7.0",
|
|
79
|
-
"nan": "^2.
|
|
80
|
-
"rimraf": "^5.0.
|
|
81
|
-
"uuid": "^9.0.
|
|
79
|
+
"nan": "^2.22.0",
|
|
80
|
+
"rimraf": "^5.0.10",
|
|
81
|
+
"uuid": "^9.0.1",
|
|
82
82
|
"walk": "^2.3.15"
|
|
83
83
|
},
|
|
84
84
|
"husky": {
|
|
@@ -97,4 +97,4 @@
|
|
|
97
97
|
"engines": {
|
|
98
98
|
"node": ">= 16.13.0"
|
|
99
99
|
}
|
|
100
|
-
}
|
|
100
|
+
}
|
package/scripts/npmjs-readme.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# rclnodejs 
|
|
2
2
|
|
|
3
3
|
`rclnodejs` is a Node.js client for the Robot Operating System (ROS 2). It provides a simple and easy JavaScript API for ROS 2 programming. TypeScript declarations are included to support use of rclnodejs in TypeScript projects.
|
|
4
4
|
|
|
@@ -45,7 +45,7 @@ npm i rclnodejs@x.y.z
|
|
|
45
45
|
|
|
46
46
|
| RCLNODEJS Version | Compatible ROS 2 LTS |
|
|
47
47
|
| :------------------------------------------------------------------------------------------: | :-----------------------------------------------------------------------------------------------------------------------------------------------: |
|
|
48
|
-
| latest version (currently [v0.
|
|
48
|
+
| 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) |
|
|
49
49
|
|
|
50
50
|
## Documentation
|
|
51
51
|
|
package/src/rcl_bindings.cpp
CHANGED
|
@@ -325,7 +325,7 @@ NAN_METHOD(CreateTimer) {
|
|
|
325
325
|
reinterpret_cast<rcl_timer_t*>(malloc(sizeof(rcl_timer_t)));
|
|
326
326
|
*timer = rcl_get_zero_initialized_timer();
|
|
327
327
|
|
|
328
|
-
#if ROS_VERSION >
|
|
328
|
+
#if ROS_VERSION > 2305 // After Iron.
|
|
329
329
|
THROW_ERROR_IF_NOT_EQUAL(
|
|
330
330
|
RCL_RET_OK,
|
|
331
331
|
rcl_timer_init2(timer, clock, context, RCL_MS_TO_NS(period_ms), nullptr,
|