You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+58-98Lines changed: 58 additions & 98 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,7 +13,7 @@
13
13
14
14
**rclnodejs** is a Node.js client library for [ROS 2](https://www.ros.org/) that provides comprehensive JavaScript and TypeScript APIs for developing ROS 2 solutions.
15
15
16
-
**Key features:** Topics, Services, Actions, Parameters, Lifecycle Nodes, TypeScript support, RxJS Observables, Electron integration, and prebuilt binaries for Linux x64/arm64.
16
+
**Key features:** Topics, Services, Actions, Parameters, Lifecycle Nodes, TypeScript support, RxJS Observables, Electron integration, browser ↔ ROS 2 WebSocket bridge (rosocket), and prebuilt binaries for Linux x64/arm64.
17
17
18
18
```javascript
19
19
constrclnodejs=require('rclnodejs');
@@ -32,18 +32,15 @@ This example assumes your ROS 2 environment is already sourced.
[Efficient Usage Tips](./docs/EFFICIENCY.md), [FAQ and Known Issues](./docs/FAQ.md), [Building from Scratch](./docs/BUILDING.md), [Contributing](./docs/CONTRIBUTING.md)
40
40
41
41
## Installation
42
42
43
-
Choose the path that matches how you plan to use rclnodejs:
44
-
45
-
- Install from npm: add rclnodejs to your own application.
46
-
- Quick Start: run the examples from this repository checkout.
43
+
Most users only need [Install from npm](#install-from-npm) below. If you have cloned this repository and want to run the bundled examples, see [Quick Start](#quick-start) instead.
47
44
48
45
### Prerequisites
49
46
@@ -68,23 +65,19 @@ After installation, use the example at the top of this README as a minimal publi
68
65
69
66
### Install from GitHub
70
67
71
-
Use this path only if you need a branch or commit that is not yet published to npm.
72
-
73
-
GitHub installs normally build from source. The published npm package includes prebuilt binaries for supported Linux targets, but this repository does not track those prebuilt artifacts.
68
+
Use this path only if you need a branch or commit not yet published to npm. GitHub installs build from source.
74
69
75
70
```bash
76
71
npm install RobotWebTools/rclnodejs#<branch>
77
72
```
78
73
79
-
Or add `"rclnodejs":"RobotWebTools/rclnodejs#<branch>"` to your `package.json` dependency section.
80
-
81
74
> **Docker:** For containerized development, see the included [Dockerfile](./Dockerfile) for building and testing with different ROS distributions and Node.js versions.
82
75
83
76
See the [features](./docs/FEATURES.md) and try the [examples](https://github.com/RobotWebTools/rclnodejs/tree/develop/example) to get started.
84
77
85
78
### Prebuilt Binaries
86
79
87
-
rclnodejs ships with prebuilt native binaries for common Linux configurations since `v1.5.2`, eliminating the need for compilation during installation. This applies to supported Linux environments when installing the published npm package.
80
+
rclnodejs ships with prebuilt native binaries for common Linux configurations, so most installs skip compilation.
88
81
89
82
**Supported Platforms:**
90
83
@@ -94,11 +87,7 @@ rclnodejs ships with prebuilt native binaries for common Linux configurations si
94
87
-**Architectures:** x64, arm64
95
88
-**Node.js:** >= 20.20.2 (N-API compatible)
96
89
97
-
Installations outside this prebuilt matrix automatically fall back to building from source.
98
-
99
-
**Force Building from Source:**
100
-
101
-
If you need to build from source even when a prebuilt binary is available, set the environment variable:
90
+
Installations outside this matrix automatically fall back to building from source. To force a source build even when a prebuilt binary is available:
102
91
103
92
```bash
104
93
export RCLNODEJS_FORCE_BUILD=1
@@ -107,9 +96,7 @@ npm install rclnodejs
107
96
108
97
## Quick Start
109
98
110
-
Use these steps if you are working from this repository checkout and want to run one of the included examples.
111
-
112
-
These steps assume the [installation prerequisites](#prerequisites) are already satisfied and your ROS 2 environment has been sourced.
99
+
From a clone of this repository, after sourcing your ROS 2 environment:
113
100
114
101
1. Install the repository dependencies from the project root.
You should see messages being published once per second.
113
+
More runnable examples in [example/](https://github.com/RobotWebTools/rclnodejs/tree/develop/example) and step-by-step guides in [tutorials/](./tutorials/).
127
114
128
-
If you want to build an application instead of running the repository examples, install rclnodejs into your own project with [Install from npm](#install-from-npm) and start from the sample code near the top of this README.
115
+
## ROS 2 Interface Message Generation
129
116
130
-
Explore more runnable examples in [example/](https://github.com/RobotWebTools/rclnodejs/tree/develop/example)and step-by-step guides in [tutorials/](./tutorials/).
117
+
rclnodejs auto-generates JavaScript bindings and TypeScript declarations for every ROS 2 `.msg`, `.srv`, and `.action` interface available in your sourced ROS 2 environment. This happens during `npm install`, so in most projects you do not need to run anything by hand.
131
118
132
-
## rclnodejs-cli
119
+
Use the generated types directly:
120
+
121
+
```javascript
122
+
import*asrclnodejsfrom'rclnodejs';
123
+
let stringMsgObject =rclnodejs.createMessageObject('std_msgs/msg/String');
124
+
stringMsgObject.data='hello world';
125
+
```
133
126
134
-
[rclnodejs-cli](https://github.com/RobotWebTools/rclnodejs-cli/) is a separate companion project that provides command-line tooling for working with rclnodejs-based ROS 2 applications. It is particularly useful for creating ROS 2 Node.js packages and working with launch files for multi-node orchestration.
127
+
### Re-running message generation
135
128
136
-
See the rclnodejs-cli repository for installation instructions and the current command set.
129
+
If you install additional ROS packages **after**rclnodejs was installed, re-run the generator from your project so the new interfaces are picked up:
137
130
138
-
## API Documentation
131
+
```bash
132
+
npx generate-ros-messages
133
+
```
139
134
140
-
API documentation is available [online](https://robotwebtools.github.io/rclnodejs/docs/index.html). To generate it locally from this repository checkout, run `npm run docs`.
135
+
Generated files are written to `<your-project>/node_modules/rclnodejs/generated/`.
141
136
142
-
##Electron-based Visualization
137
+
### IDL Message Generation
143
138
144
-
Create rich, interactive desktop applications using Electron and web technologies like Three.js. Demos leverage **Electron Forge**for easy packaging on Windows, macOS, and Linux.
139
+
In addition to the standard ROS 2 message generation (`.msg`, `.srv`, `.action`), rclnodejs can also generate JavaScript message files directly from IDL (Interface Definition Language) files. This is useful for custom IDL files or when you need finer control over the generation process.
|**🐢 [turtle_tf2](./demo/electron/turtle_tf2)**| Real-time coordinate frame visualization with turtle control. Features TF2 transforms, keyboard control, and dynamic frame updates. ||
149
-
|**🦾 [manipulator](./demo/electron/manipulator)**| Interactive two-joint robotic arm simulation. Features 3D joint visualization, manual/automatic control, and visual movement markers. ||
141
+
To generate messages from IDL files:
150
142
151
-
Explore more examples in [demo/electron](https://github.com/RobotWebTools/rclnodejs/tree/develop/demo/electron).
143
+
```bash
144
+
npm run generate-messages-idl
145
+
```
152
146
153
147
## Using rclnodejs with TypeScript
154
148
@@ -164,46 +158,11 @@ TypeScript declaration files are included in the package and exposed through the
164
158
}
165
159
```
166
160
167
-
TypeScript example:
161
+
Then `import * as rclnodejs from 'rclnodejs'` works the same as the JavaScript example at the top of this README. See [TypeScript demos](https://github.com/RobotWebTools/rclnodejs/tree/develop/demo/typescript) for more.
See [TypeScript demos](https://github.com/RobotWebTools/rclnodejs/tree/develop/demo/typescript) for more examples.
180
-
181
-
## Observable Subscriptions
163
+
## rosocket — Browser ↔ ROS 2 bridge
182
164
183
-
rclnodejs supports [RxJS](https://rxjs.dev/) Observable subscriptions for reactive programming with ROS 2 messages. Use operators like `throttleTime()`, `debounceTime()`, `map()`, and `combineLatest()` to build declarative message processing pipelines.
See [rosocket/README.md](./rosocket/README.md) for the URL scheme, service calls, and the programmatic `startRosocket()` API.
224
183
225
-
## ROS 2 Interface Message Generation
226
-
227
-
ROS client libraries convert IDL message descriptions into target language source code. rclnodejs provides the `generate-ros-messages` script to generate JavaScript message interface files and TypeScript declarations.
184
+
## Observable Subscriptions
228
185
229
-
**Example usage:**
186
+
rclnodejs supports [RxJS](https://rxjs.dev/) Observable subscriptions for reactive programming with ROS 2 messages. Use operators like `throttleTime()`, `debounceTime()`, `map()`, and `combineLatest()` to build declarative message processing pipelines.
230
187
231
188
```javascript
232
-
import*asrclnodejsfrom'rclnodejs';
233
-
let stringMsgObject =rclnodejs.createMessageObject('std_msgs/msg/String');
234
-
stringMsgObject.data='hello world';
235
-
```
236
-
237
-
### Running Message Generation
238
-
239
-
Run the message generation script in your project when new ROS packages are installed:
Generated files are located at `<yourproject>/node_modules/rclnodejs/generated/`.
246
-
247
-
> **Note:** This step is not needed for `rclnodejs > 1.5.0` because bundled interfaces are generated during installation. Rerun this command only after adding new ROS packages to your environment.
203
+
See the [Observable Subscriptions Tutorial](./tutorials/observable-subscriptions.md) for more details.
248
204
249
-
### IDL Message Generation
205
+
##Electron-based Visualization
250
206
251
-
In addition to the standard ROS2 message generation (`.msg`, `.srv`, and `.action`), rclnodejs provides advanced support for generating JavaScript message files directly from IDL (Interface Definition Language) files. This feature is particularly useful when working with custom IDL files or when you need more control over the message generation process.
207
+
Build interactive desktop ROS 2 apps with Electron + Three.js, packaged for Windows/macOS/Linux via **Electron Forge**. Featured demo: 🦾 **[manipulator](./demo/electron/manipulator)** — a two-joint arm with manual/automatic control.
252
208
253
-
To generate messages from IDL files, use the `generate-messages-idl` npm script:
More in [demo/electron](https://github.com/RobotWebTools/rclnodejs/tree/develop/demo/electron).
258
214
259
215
## Performance Benchmarks
260
216
@@ -266,7 +222,11 @@ Benchmark results for 1000 iterations with 1024 KB messages (Ubuntu 24.04 WSL2,
266
222
|**rclnodejs** (Node.js) | 744 | 927 |
267
223
|**rclpy** (Python) | 1,618 | 15,380 |
268
224
269
-
These numbers are workload- and environment-specific. See [benchmark/README.md](./benchmark/README.md) for the full setup and methodology.
225
+
See [benchmark/README.md](./benchmark/README.md) for the full setup and methodology.
226
+
227
+
## rclnodejs-cli
228
+
229
+
[rclnodejs-cli](https://github.com/RobotWebTools/rclnodejs-cli/) is a companion project providing command-line tooling for scaffolding rclnodejs application skeletons and working with launch files for multi-node orchestration.
Copy file name to clipboardExpand all lines: scripts/npmjs-readme.md
+20-19Lines changed: 20 additions & 19 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -41,11 +41,9 @@ To install from GitHub instead of npm, run:
41
41
npm install RobotWebTools/rclnodejs#<branch>
42
42
```
43
43
44
-
Or add `"rclnodejs":"RobotWebTools/rclnodejs#<branch>"` to your `package.json` dependencies.
45
-
46
44
### Prebuilt Binaries
47
45
48
-
rclnodejs ships with prebuilt native binaries for common Linux configurations since `v1.5.2`, eliminating the need for compilation during installation. This applies to supported Linux environments when installing the published npm package.
46
+
rclnodejs ships with prebuilt native binaries for common Linux configurations, so most installs skip compilation.
49
47
50
48
**Supported Platforms:**
51
49
@@ -55,9 +53,7 @@ rclnodejs ships with prebuilt native binaries for common Linux configurations si
55
53
-**Architectures:** x64, arm64
56
54
-**Node.js:** >= 20.20.2 (N-API compatible)
57
55
58
-
Installations outside this prebuilt matrix automatically fall back to building from source.
59
-
60
-
**Force Building from Source:**
56
+
Installations outside this matrix automatically fall back to building from source. To force a source build even when a prebuilt binary is available:
rclnodejs generates JavaScript message interfaces and TypeScript declarations during installation for `rclnodejs > 1.5.0`. If you install additional ROS packages later, rerun the generator in your project:
75
+
rclnodejs auto-generates JavaScript message interfaces and TypeScript declarations during `npm install`, so in most projects you do not need to run anything by hand. If you install additional ROS packages **after** rclnodejs was installed, re-run the generator from your project so the new interfaces are picked up:
80
76
81
77
```bash
82
78
npx generate-ros-messages
83
79
```
84
80
85
81
Generated files are written to `<your-project>/node_modules/rclnodejs/generated/`.
86
82
87
-
This step is only needed after adding ROS packages that were not present when rclnodejs was installed.
88
-
89
83
## Using rclnodejs with TypeScript
90
84
91
85
TypeScript declaration files are included in the package. In most projects, configuring your `tsconfig.json` is sufficient:
@@ -100,17 +94,24 @@ TypeScript declaration files are included in the package. In most projects, conf
100
94
}
101
95
```
102
96
103
-
```typescript
104
-
import*asrclnodejsfrom'rclnodejs';
97
+
Then `import * as rclnodejs from 'rclnodejs'` works the same as the JavaScript example at the top of this README.
A tiny WebSocket gateway to ROS 2, built into `rclnodejs`. Exposes ROS 2 topics and services as plain WebSocket URLs — a lightweight alternative to the rosbridge + roslibjs stack. Browsers use only built-in `WebSocket` + `JSON`; no JavaScript library required.
See the [rosocket guide](https://github.com/RobotWebTools/rclnodejs/tree/develop/rosocket) for the URL scheme, service calls, and the programmatic `startRosocket()` API.
0 commit comments