This project is a maintained fork of the original Roslibjs library
npm install --save @robostack/roslib
You can also use the CDN version directly in the browser.
Note: The library relies on ES modules, any script that references it must use type="module"
<script type="module">
import * as ROSLIB from "https://cdn.jsdelivr.net/npm/@robostack/roslib/build/roslib.js"
</script>
- Install dependencies:
npm install
- Build and watch the code for changes:
npm start
- In a new terminal, run the examples:
npm run examples
- Open http://localhost:8000/examples/simple to see the examples
- Better documentation for the available Classes
The code below lets you connect to a remote Rosbridge endpoint. Other common examples and code snippets can be found in the examples folder
import { Ros } from '@robostack/roslib';
const ros = new Ros();
ros.on('error', (error) => {
console.log(error);
});
ros.on('connection', () => {
console.log('Connection successful!');
});
ros.on('close', () => {
console.log('Connection closed.');
});
ros.connect('ws://localhost:9090');
- Connect, disconnect to a remote Rosbridge endpoint
- Get the list of topics, services, params
- Subscribe, unsubscribe, publish, advertise and unadvertise a topic
- Get, set and delete the value of a param
- Advertise a service, call a service
- Add examples with a working Websocket endpoint
- Verify and update tests
- Check and fix working with node.js
- Add better documentation
- Fix typescript types
Detailed API documentation for class methods is available in the docs folder
roslibjs is released with a BSD license. For full terms and conditions, see the LICENSE file.
See the AUTHORS.md file for a full list of contributors.