Skip to content

Commit 4f21988

Browse files
committed
Address comments
1 parent 5d22ab0 commit 4f21988

3 files changed

Lines changed: 23 additions & 35 deletions

File tree

demo/web/README.md

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -46,22 +46,3 @@ await ros.publish('/cmd_vel', { linear: { x: 0.5 } });
4646
That's the whole API. No connection state machine, no `roslibjs`, no
4747
operations dictionary. See [`web/README.md`](../../web/README.md)
4848
for the full guide.
49-
50-
## Things you'll likely ask
51-
52-
- **Will my browser need a ROS install?** No. The browser only speaks
53-
to the WebSocket (or HTTP) endpoint that `rclnodejs/web` exposes.
54-
- **Can the browser reach `/dangerous_topic` if it knows the name?**
55-
No — anything not listed in `web.json` is rejected with
56-
`code: 'not_exposed'`. The allow-list is the contract.
57-
- **HTTPS / `wss://`?** Put nginx, Caddy, or any TLS proxy in front
58-
of `rclnodejs-web`. The runtime itself speaks plain `ws://` /
59-
`http://`.
60-
- **Auth?** Today: gate at the connection level via the
61-
`verifyClient(req)` / `verifyRequest(req)` hooks on
62-
`WebSocketTransport` / `HttpTransport`. Per-capability scopes are
63-
on the roadmap.
64-
- **Actions?** Not yet — coming in a follow-up release.
65-
- **64-bit integers look weird** (`"42n"`)? — That's how JavaScript
66-
handles `int64` on the wire. Both the SDK and your ROS 2 messages
67-
round-trip them transparently.

scripts/npmjs-readme.md

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ npm install rclnodejs
6666
- Tutorials: [tutorials/](https://github.com/RobotWebTools/rclnodejs/tree/develop/tutorials)
6767
- JavaScript examples: [example/](https://github.com/RobotWebTools/rclnodejs/tree/develop/example)
6868
- TypeScript demos: [demo/typescript/](https://github.com/RobotWebTools/rclnodejs/tree/develop/demo/typescript)
69-
- WebSocket gateway demo (rosocket): [demo/rosocket/](https://github.com/RobotWebTools/rclnodejs/tree/develop/demo/rosocket)
69+
- Browser demos: [demo/web/](https://github.com/RobotWebTools/rclnodejs/tree/develop/demo/web) (typed Web SDK) and [demo/rosocket/](https://github.com/RobotWebTools/rclnodejs/tree/develop/demo/rosocket) (raw WebSocket gateway)
7070
- Electron demos: [demo/electron/](https://github.com/RobotWebTools/rclnodejs/tree/develop/demo/electron)
7171
- Companion CLI: [rclnodejs-cli](https://github.com/RobotWebTools/rclnodejs-cli/)
7272

@@ -96,21 +96,29 @@ TypeScript declaration files are included in the package. In most projects, conf
9696

9797
Then `import * as rclnodejs from 'rclnodejs'` works the same as the JavaScript example at the top of this README.
9898

99-
## rosocket — ROS 2 gateway for the browser
99+
## ROS 2 in the browser
100100

101-
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.
101+
`rclnodejs` ships **two** ways to reach ROS 2 from the browser — pick one based on how much glue you want to write.
102102

103-
```bash
104-
npx rosocket --port 9000 --topic /chatter:std_msgs/msg/String
105-
```
103+
- **`rclnodejs/web`** — typed, allow-listed, `curl`-able browser SDK. A `web.json` file is your public API; the browser SDK types `call` / `publish` / `subscribe` end-to-end from your ROS 2 message types; every capability is also a plain HTTP endpoint (`curl -X POST http://<host>/capability/call/<name>`), so shell scripts, Postman, and AI-agent tool-use just work. _New in `2.0.0-beta.0`._
106104

107-
```js
108-
const ws = new WebSocket('ws://host:9000/topic/chatter');
109-
ws.onmessage = (e) => console.log(JSON.parse(e.data).data);
110-
ws.onopen = () => ws.send(JSON.stringify({ data: 'hi' }));
111-
```
105+
```ts
106+
import { connect } from 'rclnodejs/web';
107+
const ros = await connect('ws://host:9000/capability');
108+
const reply = await ros.call<'example_interfaces/srv/AddTwoInts'>(
109+
'/add_two_ints', { a: '2n', b: '40n' }
110+
); // reply.sum is typed as `${number}n`
111+
```
112+
113+
See the [Web SDK guide](https://github.com/RobotWebTools/rclnodejs/tree/develop/web).
114+
115+
- **`rosocket`** — thin WebSocket gateway, zero browser dependencies (just built-in `WebSocket` + `JSON`). Best for quick prototypes and `roslibjs`-style apps.
116+
117+
```bash
118+
npx rosocket --port 9000 --topic /chatter:std_msgs/msg/String
119+
```
112120

113-
See the [rosocket guide](https://github.com/RobotWebTools/rclnodejs/tree/develop/rosocket) for the URL scheme, service calls, and the programmatic `startRosocket()` API.
121+
See the [rosocket guide](https://github.com/RobotWebTools/rclnodejs/tree/develop/rosocket).
114122

115123
## License
116124

web/README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
module plus a server runtime that together expose a declarative
77
subset of your ROS 2 graph over WebSocket **and** plain HTTP. The
88
browser API is three verbs — `call`, `publish`, `subscribe` — typed
9-
end-to-end from rclnodejs's auto-generated message and service
10-
maps.
9+
end-to-end from your ROS 2 message and service types.
1110

1211
For runnable code see [`demo/web/`](../demo/web/):
1312

@@ -84,7 +83,7 @@ const ros = await connect({
8483

8584
The snippet below is **TypeScript** — the `<'pkg/.../Type'>` generic
8685
in angle brackets is what drives end-to-end typing of the payload
87-
and reply, sourced from rclnodejs's generated maps (no codegen, no
86+
and reply from your ROS 2 message types (no codegen, no
8887
shared types module). From plain JavaScript, drop the generic and
8988
the calls behave identically.
9089

@@ -155,5 +154,5 @@ HTTP works**:
155154
| | **`rclnodejs/web`** | `rosbridge` + `roslibjs` |
156155
| --------------------------- | -------------------------------------------------------------------- | --------------------------------- |
157156
| **Public API surface** | **`web.json` allow-list — reviewable artifact** | The whole live ROS graph |
158-
| **TypeScript types** | Single string generic → request/response/message from generated maps | `any`; bolt-on community packages |
157+
| **TypeScript types** | One ROS 2 type name → fully typed request/response/message | `any`; bolt-on community packages |
159158
| **HTTP `call` / `publish`** | ✅ — `curl`, Postman, AI-agent tool-use just work | ❌ (WebSocket only) |

0 commit comments

Comments
 (0)