Examples
Get Robots
import { RocosSDK } from "@dronedeploy/rocos-js-sdk"; // Browser application
const url = "api-automate.dronedeploy.com";
const appId = "<your application ID>";
const appKey = "<your application secret>";
const projectId = "<your project ID>";
const sdk = new RocosSDK({ url, appId, appKey });
const result = await sdk.getRobotService().getRobots(projectId);
Get Telemetry
import { RocosSDK } from "@dronedeploy/rocos-js-sdk";
const url = "api-automate.dronedeploy.com";
const appId = "<your application ID>";
const appKey = "<your application secret>";
const sdk = new RocosSDK({ url, appId, appKey });
const projectId = "<your project ID>";
const callsigns = ["callsign-1", "callsign-2"]; // The robot callsigns that you want to get the telemetry data from.
const sources = ["/ros/odom", "/system/cpu"]; // The data urls of the telemetry data
// get telemetry subscription
const subscription = sdk
.getTelemetryService()
.subscribe({ projectId, callsigns, sources });
// get subscribe to messages
const subject = subscription.subscribe((msg) => {
console.log("msg", msg);
});
// unsubscribe
subject.unsubscribe();
Service Call
const serviceCall = sdk.getCallerService().call({
projectId: "<your project ID>",
callsign: "<your robot callsign>",
source: "/ros/getServices",
payload: {
query: {
type: 0,
data: {
depth: 0,
path: "*",
showHidden: false,
},
},
},
});
const subscription = serviceCall.return$.subscribe((msg) => {
console.log("payload", msg);
});
Robot Command
const params = {
projectId,
callsign,
commandId: "drive", // remote drive command
parameters: { linear: "0.5", angular: "1" },
};
const result = sdk.getCommandService().invokeRequest(params);
result.subscribe((msg) => {
const payload = msg?.response;
if (payload) {
console.log("payload", payload);
}
});
Please note that the parameter value needs to be flat string (number of JSON object is not supported at the moment). The final content that being injected into the command execution engine will depend on the payload template as described here.