robotics-dev
v1.0.39
Published
Robotics.dev P2P SDK client for robot control
Maintainers
Readme
ROBOTICS.DEV App Builder
Run ROS2 AI P2P robotics apps anywhere!
This Robotics.dev NodeJS SDK automatically connects to Robotics.dev and uses peer-to-peer data channels to send and receive ROS2 messages between robots and cloud, edge, and developer machines as well as send twist movement commands and text to speak on the robot.
ROS2 topic namespacing is configured per robot in the robotics.dev portal (rosNamespace), not in SDK connect options. See CHANGELOG.md.
WebRTC ICE servers are fetched from GET /webrtc/ice-servers on connect (STUN by default). TURN relay requires turnRelayEnabled: true on your Firestore user document (users/{uid}) — a paid add-on (billing coming soon). All paid users share the same server-side Metered.ca credentials.
npm install robotics-devHere's an example of basic robotics.dev P2P app using this SDK.
//import robotics from 'robotics-dev';
const robotics = require('robotics-dev');
// Define movement commands
const moveForward = {
linear: {x: 0.2, y: 0.0, z: 0.0},
angular: {x: 0.0, y: 0.0, z: 0.0}
};
const turnLeft = {
linear: {x: 0.0, y: 0.0, z: 0.0},
angular: {x: 0.0, y: 0.0, z: 0.2}
};
const turnRight = {
linear: {x: 0.0, y: 0.0, z: 0.0},
angular: {x: 0.0, y: 0.0, z: -0.2}
};
const stop = {
linear: {x: 0.0, y: 0.0, z: 0.0},
angular: {x: 0.0, y: 0.0, z: 0.0}
};
var robotId = 'eeeaa722-...-9a53-c945a5822b60';
// Connect to robotics.dev
robotics.connect({
server: 'ws://192.168.0.47:3001',
robot: robotId,
token: '5a66b323-...-9169-77a95014f339'
}, (rosMessage) => {
// rosMessage is already parsed by the SDK
if (rosMessage.topic === '/camera2d') {
console.log("Base64 image: ", rosMessage.data.data);
}
if(oneTime){
oneTime = false;
robotics.speak('eeeaa722-b7b0-4799-9a53-c945a5822b60', 'this is a test')
console.log('Moving robot forward at 20% speed...');
robotics.twist('eeeaa722-b7b0-4799-9a53-c945a5822b60', forwardTwist);
// Stop after 5 seconds
setTimeout(() => {
console.log('Stopping robot...');
robotics.twist('eeeaa722-b7b0-4799-9a53-c945a5822b60', stopTwist);
}, 5000);
}
});See examples directory for demos.
