Send a goal, follow the feedback, get the result. rclnodejs 2.3.0, the ROS 2 client library for Node.js, brings ROS 2 actions to web apps over WebSocket and HTTP/SSE.
ROS 2 Actions from the Browser
The browser SDK derives TypeScript goal, feedback and result types from generated ROS declarations. OpenAPI export also includes action schemas.
With an HTTP runtime on port 9001 exposing a running Fibonacci action server as /fibonacci:
import { connect } from 'rclnodejs/web';
const ros = await connect({ http: 'http://localhost:9001' });
try {
const goal = await ros.action(
'/fibonacci',
{ order: 5 },
{ onFeedback: (feedback) => console.log(feedback.sequence) }
);
console.log(await goal.result, goal.status);
} finally {
await ros.close();
}
Web capabilities at a glance
Together with the topic and service support from earlier releases, actions round out the following client-facing operations, controlled by the same capability allow-list:
| ROS 2 operation | WebSocket | HTTP / SSE |
|---|---|---|
| Publish topic messages | Yes | HTTP POST |
| Subscribe to topics | Yes | HTTP GET + SSE (opt-in) |
| Call services | Yes | HTTP POST |
| Send action goals, receive feedback/results (new) | Yes | HTTP POST + SSE |
| Request cancellation of an action goal (new) | Yes; server may reject | Not supported |
Try the JavaScript and TypeScript demos for runnable examples.
For background on the typed Web SDK and capability runtime first introduced in 2.0.0, see our original announcement.