A collection of open source libraries to help build your custom robot platform on top of Formant APIs.
With this repo’s tools you can make custom web and 3D experiences on top of Formant using ThreeJS, get information about your fleet of devices, create realtime visualizations of your robots, and more.
We understand you want complete control over your user experience, so Formant provides:
This depends on the type of app you’re making:
Using user login credentials or service accounts, you can use the Data SDK to get access to device data.
import { Authentication, Fleet } from "@formant/data-sdk";
await Authentication.login("sam@robot.xyz", "12345");
// Get all devices
const allDevices = await Fleet.getDevices();
// find the device(s) you want
const device = allDevices.find((d) => d.name === "spot");
// Get data ...
const data = await device.getLatestTelemetry();
The Data SDK will be able to figure out from url the authentication needed to access the current viewing device.
import { Authentication, Fleet } from "@formant/data-sdk";
await Authentication.waitTilAuthenticated();
// Get the context of a device is passed along as a query string
const device = await Fleet.getCurrentDevice();
// Get data ...
const data = await device.getLatestTelemetry();
cd examples/teleop
npm install
npm run dev
For more detailed instruction on custom views, see our custom view readme.
This ThreeJS element will show a URDF of a robot using the zipped URDF uploaded for formant and control it’s joint states in realtime.
This ThreeJS element will show a realtime video stream of your device as a plane.
If your just interested in using our APIs, there’s two main steps
await fetch("https://api.formant.io/v1/admin/auth/login", {
method: "POST",
body: JSON.stringify(),
headers: {
"Content-Type": "application/json"
}
});
curl -X POST "https://api.formant.io/v1/admin/auth/login" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-d '{"email":"sam@robot.xyz","password":"12345"}'
This will return a JWT token.
{
"authentication":{
"accessToken": "abc......xyz",
...
},
...
}
// the token from above
cons token = "abc......xyz"
await fetch("https://api.formant.io/v1/admin/device-details/query", {
method: "POST",
body: JSON.stringify(),
headers: {
"Content-Type": "application/json",
"Authorization": "Bearer "+token
}
});
curl -X POST "https://api.formant.io/v1/admin/device-details/query" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer abc......xyz" \
-d '{"enabled":true,"type":"default"}'
Yes, you can do it in two ways, first as an ES6 module:
<script type="module">
import {
Authentication,
Fleet,
} from "https://cdn.jsdelivr.net/npm/@formant/data-sdk/dist/data-sdk.es6.js";
await Authentication.waitTilAuthenticated();
const devices = await Fleet.getDevices();
window.document.body.innerHTML = devices.map((_) => _.name).join("<br>");
</script>
or as a non-module:
<script src="https://cdn.jsdelivr.net/npm/@formant/data-sdk/dist/data-sdk.umd.js"></script>
<script type="module">
const { Authentication, Fleet } = window.FormantDataSDK;
await Authentication.waitTilAuthenticated();
const device = await Fleet.getCurrentDevice();
window.document.body.innerHTML = JSON.stringify(
await device.getLatestTelemetry()
);
</script>
To prepare a URDF for the web, you must collect the .urdf file from ROS. You will be consructing a zip that contains the:
Currently formant only supports .dae
models. You can easily convert models using ctmconv
.
Install using ubuntu:
apt-get install openctm-tools
ctmconv leg.stl leg.dae
An example zip layout will look like
It’s important that your meshes be referenced by relative links. Remove absolute paths that start with “package://”.
<mesh filename="meshes/base_link.dae" />
Yep, checkout the example.
await device.startRealtimeConnection();
const j = await device.createCustomDataChannel("string_command");
await j.waitTilReady();
j.send("konami");
j.addListener((message) => {
console.log(message);
});
def string_command_callback(message):
print(str(message))
if __name__ == "__main__":
c = FormantClient()
c.register_custom_data_channel_message_callback(
string_command_callback, channel_name_filter=["string_command"])
You can change your connection network reliability settings
const options = { ... };
const j = await device.createCustomDataChannel("joystick", options);
Here’s some combinations we find useful
Reliable TCP-like: `{ ordered: true }`
- This is the default option `createCustomDataChannel` uses
High Speed UDP-like: `{ ordered: false, maxRetransmits: 0 }`
- Good for non-critical one shot messages
Time Constrained UDP-like: `{ ordered: false, maxPacketLifeTime: 300 }`
- Good for things like joysticks
When building an embedded app, you might want a quick way to get a website that looks like Formant. This css augments class-less semantic HTML making it incredibly easy to use.
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/gh/formantio/toolkit/css/formant.css"
/>
See an example here.
Yes, we even provide a simple component ui-sdk-login
to handle authorization for you if you just want to focus on user experience.
See an example here
Our partners building on Formant.