Run ROS2 AI robotics apps anywhere!
This Robotics SDK automatically connects to Robotics.dev and uses sockets to send and receive ROS2 messages between robots and cloud and/or edge servers. If the robot id is passed on the connect event, the SDK tries to establish a peer-to-peer session with the robot directly bypassing the cloud/edge server creating improved latency.
npm install robotics-dev
Cloud Usage:
//import robotics from 'robotics-dev';
const robotics = require('robotics-dev');
robotics.connect(); //robotics.connect({url: 'ws://192.168.0.47:3001'});
robotId = "3bbb40c5-...-58a12bc6893e"
robotics.twist(robotId, twist: {
"linear": {"x": 0.20, "y": 0.0, "z": 0.0},
"angular": {"x": 0.0, "y": 0.0, "z": 0.0}
})
robotics.speak(robotId, "beep boop"); // robot must have espeak installed (sudo apt install espeak)
robotics.subscribe(robotId, (imageData) => {
console.log('Received image data:');
console.log('- Base64 length:', imageData.base64.length);
console.log('- First 100 chars:', imageData.base64.substring(0, 100));
console.log('- Timestamp:', new Date().toISOString());
console.log('-------------------');
});
Peer-to-Peer Usage:
//import robotics from 'robotics-dev';
const robotics = require('robotics-dev');
const robotId = "3bbb40c5-...-58a12bc6893e"
robotics.connect({robot: robotId}, (ros) => {
var dataObj = JSON.parse(ros)
console.log('Received p2p ROS2 data:', dataObj);
if(dataObj.topic === "/camera2d"){
// console.log("Base64 image: ", dataObj.data.data);
robotics.speak(robotId, "beep boop"); // robot must have espeak installed (sudo apt install espeak)
robotics.twist(robotId, twist: {
"linear": {"x": 0.20, "y": 0.0, "z": 0.0},
"angular": {"x": 0.0, "y": 0.0, "z": 0.0}
})
}
});
See examples directory for demos.