Skip to content

Commit 6e46c4e

Browse files
authored
Update README (#1449)
Updates the project’s README content (repo README and npm package README) to reflect current supported ROS 2 distros, modernized API usage, and clearer install/docs guidance. **Changes:** - Refresh README messaging (supported ROS distros, reorganized documentation links, added Quick Start). - Update README code snippets to use OO-style APIs (`new rclnodejs.Node()` + `node.spin()`). - Improve installation/prebuilt-binary notes and clarify message generation workflow. ### Reviewed changes Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments. | File | Description | | ---- | ----------- | | scripts/npmjs-readme.md | Updates the npm-published README content: modernizes example code, adds docs/examples links, and documents message generation and prebuilt-binary fallback behavior. | | README.md | Updates the repo README: supported distro note, reorganized documentation section, adds Quick Start, clarifies TypeScript typing exposure, and adds benchmark methodology disclaimer. | Fix: #1448
1 parent 1fe9257 commit 6e46c4e

2 files changed

Lines changed: 64 additions & 63 deletions

File tree

README.md

Lines changed: 36 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
| :----------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: |
77
| Rolling<br>Kilted<br>Jazzy<br>Humble | [![Linux](https://github.com/RobotWebTools/rclnodejs/actions/workflows/linux-x64-push-test.yml/badge.svg?branch=develop)](https://github.com/RobotWebTools/rclnodejs/actions/workflows/linux-x64-push-test.yml?query=branch%3Adevelop)<br>[![Linux](https://github.com/RobotWebTools/rclnodejs/actions/workflows/linux-arm64-push-test.yml/badge.svg?branch=develop)](https://github.com/RobotWebTools/rclnodejs/actions/workflows/linux-arm64-push-test.yml?query=branch%3Adevelop)<br>[![Windows](https://github.com/RobotWebTools/rclnodejs/actions/workflows/windows-push-test.yml/badge.svg?branch=develop)](https://github.com/RobotWebTools/rclnodejs/actions/workflows/windows-push-test.yml?query=branch%3Adevelop)<br>[![ASan](https://github.com/RobotWebTools/rclnodejs/actions/workflows/linux-x64-asan-test.yml/badge.svg?branch=develop)](https://github.com/RobotWebTools/rclnodejs/actions/workflows/linux-x64-asan-test.yml?query=branch%3Adevelop) |
88

9-
> **Note:** rclnodejs development and maintenance is limited to the ROS 2 LTS releases and the Rolling development branch
9+
> **Note:** Supported ROS 2 distributions include Humble, Jazzy, Kilted, and Rolling.
1010
1111
**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.
1212

@@ -22,19 +22,14 @@ rclnodejs.init().then(() => {
2222

2323
## Documentation
2424

25-
- [Installation](#installation)
26-
- [rclnodejs-cli](#rclnodejs-cli)
27-
- [API Documentation](#api-documentation)
28-
- [Tutorials](./tutorials/)
29-
- [Electron-based Visualization](#electron-based-visualization)
30-
- [Using TypeScript](#using-rclnodejs-with-typescript)
31-
- [Observable Subscriptions](#observable-subscriptions)
32-
- [ROS2 Interface Message Generation](#ros2-interface-message-generation)
33-
- [Performance Benchmarks](#performance-benchmarks)
34-
- [Efficient Usage Tips](./docs/EFFICIENCY.md)
35-
- [FAQ and Known Issues](./docs/FAQ.md)
36-
- [Building from Scratch](./docs/BUILDING.md)
37-
- [Contributing](./docs/CONTRIBUTING.md)
25+
- Get started:
26+
[Installation](#installation), [Quick Start](#quick-start), [Tutorials](./tutorials/)
27+
- Reference:
28+
[API Documentation](#api-documentation), [Using TypeScript](#using-rclnodejs-with-typescript), [ROS2 Interface Message Generation](#ros2-interface-message-generation)
29+
- Features and examples:
30+
[rclnodejs-cli](#rclnodejs-cli), [Electron-based Visualization](#electron-based-visualization), [Observable Subscriptions](#observable-subscriptions), [Performance Benchmarks](#performance-benchmarks)
31+
- Project docs:
32+
[Efficient Usage Tips](./docs/EFFICIENCY.md), [FAQ and Known Issues](./docs/FAQ.md), [Building from Scratch](./docs/BUILDING.md), [Contributing](./docs/CONTRIBUTING.md)
3833

3934
## Installation
4035

@@ -66,6 +61,8 @@ rclnodejs ships with prebuilt native binaries for common Linux configurations si
6661
- **Architectures:** x64, arm64
6762
- **Node.js:** >= 16.20.2 (N-API compatible)
6863

64+
Installations outside this prebuilt matrix automatically fall back to building from source.
65+
6966
**Force Building from Source:**
7067

7168
If you need to build from source even when a prebuilt binary is available, set the environment variable:
@@ -75,22 +72,34 @@ export RCLNODEJS_FORCE_BUILD=1
7572
npm install rclnodejs
7673
```
7774

78-
## rclnodejs-cli
75+
## Quick Start
76+
77+
1. Source your ROS 2 environment.
78+
79+
```bash
80+
source /opt/ros/<distro>/setup.bash
81+
```
7982

80-
[rclnodejs-cli](https://github.com/RobotWebTools/rclnodejs-cli/) is a companion project we recently launched to provide a commandline interface to a set of developer tools for working with this `rclnodejs`. You may find `rclnodejs-cli` particularly useful if you plan to create ROS 2 node(s) and launch files for working with multiple node orchestrations.
83+
2. Install the repository dependencies.
8184

8285
```bash
83-
Usage: rclnodejs [command] [options]
86+
npm install
87+
```
8488

85-
Options:
86-
-h, --help display help for command
89+
3. Run a publisher example from this checkout.
8790

88-
Commands:
89-
create-package [options] <package-name> Create a ROS2 package for Nodejs development.
90-
generate-ros-messages Generate JavaScript code from ROS2 IDL interfaces
91-
help [command] display help for command
91+
```bash
92+
node example/topics/publisher/publisher-example.js
9293
```
9394

95+
You should see messages being published once per second. Explore more runnable examples in [example/](https://github.com/RobotWebTools/rclnodejs/tree/develop/example) and step-by-step guides in [tutorials/](./tutorials/).
96+
97+
## rclnodejs-cli
98+
99+
[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.
100+
101+
See the rclnodejs-cli repository for installation instructions and the current command set.
102+
94103
## API Documentation
95104

96105
API documentation is available [online](https://robotwebtools.github.io/rclnodejs/docs/index.html) or generate locally with `npm run docs`.
@@ -108,7 +117,7 @@ Explore more examples in [electron_demo](https://github.com/RobotWebTools/rclnod
108117

109118
## Using rclnodejs with TypeScript
110119

111-
TypeScript declaration files are included in the `types/` folder. Configure your `tsconfig.json`:
120+
TypeScript declaration files are included in the package and exposed through the `types` entry in `package.json`. In most projects, configuring your `tsconfig.json` is sufficient:
112121

113122
```jsonc
114123
{
@@ -177,7 +186,7 @@ npx generate-ros-messages
177186

178187
Generated files are located at `<yourproject>/node_modules/rclnodejs/generated/`.
179188

180-
> **Note:** This step is not needed for rclnodejs > 1.5.0
189+
> **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.
181190
182191
### IDL Message Generation
183192

@@ -193,14 +202,14 @@ npm run generate-messages-idl
193202

194203
Benchmark results for 1000 iterations with 1024KB messages (Ubuntu 24.04.3 WSL2, i7-1185G7):
195204

205+
These numbers are workload- and environment-specific. See [benchmark/README.md](./benchmark/README.md) for the full setup and methodology.
206+
196207
| Library | Topic (ms) | Service (ms) |
197208
| ----------------------- | ---------- | ------------ |
198209
| **rclcpp (C++)** | 168 | 627 |
199210
| **rclnodejs (Node.js)** | 744 | 927 |
200211
| **rclpy (Python)** | 1,618 | 15,380 |
201212

202-
See [benchmark/README.md](benchmark/README.md) for details.
203-
204213
## Contributing
205214

206215
Please read the [Contributing Guide](./docs/CONTRIBUTING.md) before making a pull request.

scripts/npmjs-readme.md

Lines changed: 28 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
1-
# rclnodejs [![Linux](https://github.com/RobotWebTools/rclnodejs/actions/workflows/linux-x64-push-test.yml/badge.svg?branch=develop)](https://github.com/RobotWebTools/rclnodejs/actions/workflows/linux-x64-push-test.yml?query=branch%3Adevelop)[![Linux](https://github.com/RobotWebTools/rclnodejs/actions/workflows/linux-arm64-push-test.yml/badge.svg?branch=develop)](https://github.com/RobotWebTools/rclnodejs/actions/workflows/linux-arm64-push-test.yml?query=branch%3Adevelop)
1+
# rclnodejs
22

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.
3+
`rclnodejs` is a Node.js client library for ROS 2 that provides JavaScript and TypeScript APIs for building ROS 2 applications.
44

5-
\* rclnodejs development and maintenance is limited to all active ROS 2 LTS releases and the Rolling development branch
5+
Supported ROS 2 distributions include Humble, Jazzy, Kilted, and Rolling.
66

7-
Here's an example for how to create a ROS 2 node that publishes a string message in a few lines of JavaScript.
8-
9-
```JavaScript
7+
```javascript
108
const rclnodejs = require('rclnodejs');
119
rclnodejs.init().then(() => {
12-
const node = rclnodejs.createNode('publisher_example_node');
10+
const node = new rclnodejs.Node('publisher_example_node');
1311
const publisher = node.createPublisher('std_msgs/msg/String', 'topic');
1412
publisher.publish(`Hello ROS 2 from rclnodejs`);
15-
rclnodejs.spin(node);
13+
node.spin();
1614
});
1715
```
1816

@@ -29,11 +27,11 @@ rclnodejs.init().then(() => {
2927
npm i rclnodejs
3028
```
3129

32-
- **Note:** to install rclnodejs from GitHub: add `"rclnodejs":"RobotWebTools/rclnodejs#<branch>"` to your `package.json` dependency section.
30+
- **Note:** To install rclnodejs from GitHub, add `"rclnodejs":"RobotWebTools/rclnodejs#<branch>"` to your `package.json` dependencies.
3331

3432
### Prebuilt Binaries
3533

36-
rclnodejs ships with prebuilt native binaries for common Linux configurations since `v1.5.2`, eliminating the need for compilation during installation. This significantly speeds up installation and reduces dependencies.
34+
rclnodejs ships with prebuilt native binaries for common Linux configurations since `v1.5.2`, eliminating the need for compilation during installation.
3735

3836
**Supported Platforms:**
3937

@@ -42,26 +40,36 @@ rclnodejs ships with prebuilt native binaries for common Linux configurations si
4240
- **Architectures:** x64, arm64
4341
- **Node.js:** >= 16.20.2 (N-API compatible)
4442

45-
**Force Building from Source:**
43+
Installations outside this prebuilt matrix automatically fall back to building from source.
4644

47-
If you need to build from source even when a prebuilt binary is available, set the environment variable:
45+
**Force Building from Source:**
4846

4947
```bash
5048
export RCLNODEJS_FORCE_BUILD=1
5149
npm install rclnodejs
5250
```
5351

54-
## Documentation
52+
## Documentation and Examples
53+
54+
- API documentation: [robotwebtools.github.io/rclnodejs/docs](https://robotwebtools.github.io/rclnodejs/docs/index.html)
55+
- JavaScript examples: [example/](https://github.com/RobotWebTools/rclnodejs/tree/develop/example)
56+
- TypeScript demos: [ts_demo/](https://github.com/RobotWebTools/rclnodejs/tree/develop/ts_demo)
57+
- Electron demos: [electron_demo/](https://github.com/RobotWebTools/rclnodejs/tree/develop/electron_demo)
58+
- Companion CLI: [rclnodejs-cli](https://github.com/RobotWebTools/rclnodejs-cli/)
5559

56-
API [documentation](https://robotwebtools.github.io/rclnodejs/docs/index.html) is available online.
60+
## Message Generation
5761

58-
## JavaScript Examples
62+
rclnodejs generates JavaScript message interfaces and TypeScript declarations during installation for `rclnodejs > 1.5.0`. If you install additional ROS packages later, rerun:
5963

60-
Try the [examples](https://github.com/RobotWebTools/rclnodejs/tree/develop/example) to get started.
64+
```bash
65+
npx generate-ros-messages
66+
```
67+
68+
Generated files are written to `<your-project>/node_modules/rclnodejs/generated/`.
6169

6270
## Using rclnodejs with TypeScript
6371

64-
TypeScript declaration files are included in the `types/` folder. Configure your `tsconfig.json`:
72+
TypeScript declaration files are included in the package. In most projects, configuring your `tsconfig.json` is sufficient:
6573

6674
```jsonc
6775
{
@@ -73,33 +81,17 @@ TypeScript declaration files are included in the `types/` folder. Configure your
7381
}
7482
```
7583

76-
TypeScript example:
77-
7884
```typescript
7985
import * as rclnodejs from 'rclnodejs';
86+
8087
rclnodejs.init().then(() => {
81-
const node = rclnodejs.createNode('publisher_example_node');
88+
const node = new rclnodejs.Node('publisher_example_node');
8289
const publisher = node.createPublisher('std_msgs/msg/String', 'topic');
8390
publisher.publish(`Hello ROS 2 from rclnodejs`);
84-
rclnodejs.spin(node);
91+
node.spin();
8592
});
8693
```
8794

88-
See [TypeScript demos](https://github.com/RobotWebTools/rclnodejs/tree/develop/ts_demo) for more examples.
89-
90-
**Note** that the interface.d.ts file is updated each time the generate_messages.js script is run.
91-
92-
## Electron-based Visualization
93-
94-
Create rich, interactive desktop applications using Electron and web technologies like Three.js. Build 3D visualizations, monitoring dashboards, and control interfaces that run on Windows, macOS, and Linux.
95-
96-
| Demo | Description | Screenshot |
97-
| :-----------------------------------------------------------------------------------------------------: | :-----------------------------------------------------------------------------------------------------------------------------------: | :-----------------------------------------------------------------------------------------------------------------------------: |
98-
| **🐢 [turtle_tf2](https://github.com/RobotWebTools/rclnodejs/tree/develop/electron_demo/turtle_tf2)** | Real-time coordinate frame visualization with turtle control. Features TF2 transforms, keyboard control, and dynamic frame updates. | ![turtle_tf2](https://github.com/RobotWebTools/rclnodejs/blob/develop/electron_demo/turtle_tf2/turtle-tf2-demo.png?raw=true) |
99-
| **🦾 [manipulator](https://github.com/RobotWebTools/rclnodejs/tree/develop/electron_demo/manipulator)** | Interactive two-joint robotic arm simulation. Features 3D joint visualization, manual/automatic control, and visual movement markers. | ![manipulator](https://github.com/RobotWebTools/rclnodejs/blob/develop/electron_demo/manipulator/manipulator-demo.png?raw=true) |
100-
101-
Explore more examples in [electron_demo](https://github.com/RobotWebTools/rclnodejs/tree/develop/electron_demo).
102-
10395
## License
10496

10597
Apache License Version 2.0

0 commit comments

Comments
 (0)