OmniBot Realtime API
This page is intended for developers and internal beta testers only. The API is used by OmniBot and associated apps that control OmniBot using GyroPalm's secure websockets protocol.
Overview
Bidirectional communication between the robot and user over websockets is discussed. The user may be one or more operators controlling the robot. An edge-based mechanism to initiate and terminate user control (activation/deactivation) is preferred.
Both the robot and user must authenticate before any additional communication is performed.
Protocol Info
Endpoint: wss://gyropalm.com:3200
Payload Type: JSON
Payload Encoding: UTF-8
Authentication parameters: apiKey, robotID
Maximum send rate: 15 FPS (once every 66~67 ms)
Keep-Alive Heartbeat: Once every <60 seconds
The heartbeat payload is as follows:
{"action":"heartbeat"}
Note: Heartbeat payload can be sent at any time, even without authentication. Message and command payloads have a maximum send rate of 15 FPS. Any device exceeding this rate will be dropped.
Authentication
Authentication introduces a new client (either robot or user) to the server to indicate that it is online.
User Auth
Replace robotID and apiKey with the appropriate values. To authenticate a new operator, send the following payload:
{"action":"subRobot","robotID":"r555555","apiKey":"c00000000"}
Typical Reply
{
"action": "info",
"stat": "success",
"msg": "Subscribed to r555555"
}
Robot Auth
Replace robotID and secret with the appropriate values. To authenticate a new robot, send the following payload:
{"action":"newRobot","robotID":"r555555","secret":"r00000000000"}
Typical Reply
{
"action": "info",
"stat": "success",
"msg": "Device r555555 added"
}
Status Commands (User sent)
Replace robots with a string array containing the robotIDs that you want to request status for. To retrieve a JSON array of objects that contain robot online statuses, send the following payload:
{"action":"statusRobots","robots":["r555555","r333333"]}
Typical Reply
{
"action": "info",
"stat": "success",
"msg": "There are 1 robots online",
"robots": [
{
"robotID": "r555555",
"isOnline": true
},
{
"robotID": "r333333",
"isOnline": false
}
]
}
Operator Commands (User sent)
User can send requests to control the robot or request additional information.
Begin a New Session
To begin an OmniBot session, the user's websocket client must first request the robot to begin a new Agora video session. The "active LED" will be turned on. To request the robot to join, send the following:
{"action":"controlRobot","robotID":"r555555","outputVal":"{\"request\":\"autojoin\"}"}
Robot Incoming
When the user sends the "auto-join" command, the robot will receive the following packet:
{"action": "data","command": "{\"request\":\"autojoin\"}"}
Lock the Session
By locking a session, the OmniBot will illuminate the "busy LED" not accept other commands until the unlock command is sent. This prevents other participants from entering the session once started. This command must be run through the REST API for it to take effect.
{"action":"controlRobot","robotID":"r555555","outputVal":"{\"request\":\"locksession\"}"}
Unlock the Session
By unlocking a session, the "busy LED" will be turned off and the session will be active again. This command must be run through the REST API for it to take effect.
{"action":"controlRobot","robotID":"r555555","outputVal":"{\"request\":\"unlocksession\"}"}
End the Session
By ending a session, the OmniBot will leave the Agora video session. The "active LED" will be turned off. When the session is ended, the signageModal will pop up and show relevant slides or ads for this robot.
Warning: This command will not instruct the robot to return to the dock. It is advised that prior to running this command, the user be prompted to run the Docking command first. Failure to Dock the robot before ending the session may result in an offline abandoned robot due to low battery.
{"action":"controlRobot","robotID":"r555555","outputVal":"{\"request\":\"endsession\"}"}
Dock the Robot
When the OmniBot is docked, both the robot and PC battery will be recharged. It is recommended to dock the robot after every session. To dock the robot, send the following packet:
{"action":"controlRobot","robotID":"r555555","outputVal":"{\"request\":\"dock\"}"}
Undock the Robot
This command will be sent along with the "auto-join" command when a user joins a new session. It can be manually called as follows:
{"action":"controlRobot","robotID":"r555555","outputVal":"{\"request\":\"undock\"}"}
Drive the Robot
This command will be sent according to the virtual Joystick's values and mode, where Mode 1 is parked, Mode 2 is slow, and Mode 3 is fast. The robot will use onboard algorithms to control the motor driver:
{"action":"controlRobot","robotID":"r123456","outputVal":"{\"request\":\"drive\", \"x\":1000, \"y\":1000, \"powerSlider\":3}"}
Perform U-turn
This command is used when the operator wishes to request the robot to do a u-turn:
{"action":"controlRobot","robotID":"r555555","outputVal":"{\"request\":\"uturn\"}
Restart the Robot
This command can be used to reboot the OmniBot computer (and its software) should there be any issues. The robot will resume normal operation after reboot:
{"action":"controlRobot","robotID":"r555555","outputVal":"{\"request\":\"restart\",\"password\":\"55555555\"}"}
Exit Fullscreen Mode
This command is used in the event that an admin needs to exit the Fullscreen (kiosk) Mode:
{"action":"controlRobot","robotID":"r555555","outputVal":"{\"request\":\"exitfullscreen\",\"password\":\"55555555\"}"}
REST API Routes
The commands above are typically sent via GyroPalm's Realtime (secure websocket server). In some cases, it may be more appropriate to run requests through a one-shot REST API enpoint under https://gyropalm.com:3000/realtime. You must use HTTPS for security reasons. The key difference when using the REST API is that the JSON packet must contain apiKey since the API is stateless. Realtime events are not available in this version.
Please refer to the REST API documentation for details: https://documenter.getpostman.com/view/1747463/UyxdJoNr
Robot Events (Robot sent)
Robot events are sent out on two types of streams: an event stream and interval stream. With the exception of "offline" notification, both streams are sent only when the robot is online.
The action of each incoming packet will be indicated as either eventStream or intervalStream accordingly.
Online Statuses
The GyroPalm Realtime server will send events as follows when the subscribed robot is online or offline, respectively:
{
"action": "info",
"stat": "online",
"msg": "Robot r555555 is online"
}
{
"action": "info",
"stat": "offline",
"msg": "Robot r555555 is offline"
}
Event Stream
The event stream comprises packets sent whenever the robot has new information. This may include properties such as isObstructed, isBumped, isLifted, isExternalMoved, eStopPressed, battLow, etc. These events are typically shown to the operator through a notification. In some cases, a notification is sent to the admin (e.g. battLow or isLifted).
Example Payload
{
"action": "data",
"r555555": {
"isObstructed": true
}
}
Interval Stream
The interval stream comprises packets that are sent every 2 seconds which pertain to realtime information about the robot. This includes curStatus, obstructions, duration, PCBatt, RobotBatt, PCCharging, RobotCharging, RobotAdmin.
Example Payload
{
"action": "data",
"r555555": {
"curStatus": "Standby",
"obstructions": "Clear",
"duration": "00:00:00",
"comConnected": false,
"PCBatt": 1,
"RobotBatt": 0,
"PCCharging": true,
"RobotCharging": false,
"RobotAdmin": "f123456"
}
}
OmniBot JavaScript SDK
The OmniBot features a JavaScript SDK in which the methods included are very similar to that of the GyroPalm JavaScript SDK. The fundamental difference between the OmniBot SDK and GyroPalm SDK is that the OmniBot version interfaces with a robot while the GyroPalm version interfaces with a wearable device. In this context, the OmniBot SDK introduces the OmniBot class and the GyroPalm SDK introduces the GyroPalm class; both which authenticate and use the GyroPalmRealtime server as a basis for realtime communication.
Unlike the GyroPalm class, which connects a user to a wearableID, an object instantiated with the OmniBot class connects a user to a robotID. It is important to note that there are additional methods used by the OmniBot class that are designed with intention of robotic control.
Similarities between GyroPalm SDK and OmniBot SDK
- Both run on
GyroPalmRealtimeserver - Both require user to have a GyroPalm account
- Both are used to send commands wireless to hardware
- Both have same verbose and event callback options
- Both have functions such as autoReconnect, heartbeat, list devices, and getAccountInfo
Unique Features of OmniBot SDK
- OmniBot SDK connects using a
robotIDinstead ofwearableID - Both
hostandspectatorroles can connect to the SDK - Scheduled access privileges are still enforced in the OmniBot SDK
- OmniBot SDK provides both Event Stream and Interval Stream data
- OmniBot SDK provides request methods:
beginSession,endSession,lockSession,unlockSession - OmniBot SDK provides motion methods:
driveRobot,undock,dock - OmniBot SDK provides administrative methods:
restartRobot,exitFullscreen
Installation
There are three simple ways to include this library: By referencing our CDN hosted version, using GyroPalm's hosted version, or downloading the latest release from GyroPalm's GitHub repository.
CDN Hosted Link
To use the CDN Hosted Link, include the following in your HTML:
<script src="https://cdn.jsdelivr.net/gh/GyroPalm/GyroPalm-JavaScript-SDK@latest/omnibot.min.js"></script>
GyroPalm Hosted Link
To use the GyroPalm Hosted Link, include the following in your HTML:
<script src="https://app.gyropalm.com/api/sdk/javascript/omnibot.min.js"></script>
Download Release from GitHub
Download the latest release of gyropalm.min.js on the GitHub repository. Place the file relative to your script path and include it as follows:
<script src="omnibot.min.js"></script>
Common OmniBot Methods
The following is a typical list of coding snippets that can be used:
var omnibot = new OmniBot("yourAPIkey", "robotID"); // Instantiate robot
omnibot.enableVerbose(true); // Include to print console log
// Define Callback functions:
function onEventReceived(obj) {
console.log(obj);
}
function onConnection(obj) {
console.log(obj);
}
function onVerbose(obj) {
console.log(obj);
}
// Set Callbacks:
omnibot.setEventCallback(onEventReceived);
omnibot.setConnectionCallback(onConnection);
omnibot.setVerboseCallback(onVerbose);
omnibot.getRobots("", onEventReceived); // Retrieve user's robot list
omnibot.getAccountInfo("", onEventReceived); // Retrieve user info
// If you have already defined callbacks, connect with robotID:
omnibot.connect("robotID");
// OR if you have already connected prior and want to re-connect:
omnibot.connect();
// To disconnect robot:
omnibot.disconnect();
// To send command object to robot:
omnibot.sendDataObj(obj);
// To drive robot:
omnibot.driveRobot(x, y, powerSlider); // Joystick coordinates and 1/2/3 speed
// Where 1 = parked, 2 = slow, 3 = fast
omnibot.uturn(); //make a 180 degree turn
// Other Robot-specific methods:
omnibot.beginSession(); // Requests robot to initiate session
omnibot.endSession(); // Request robot to end session
omnibot.lockSession(); // Locks the robot so that nobody can enter
omnibot.unlockSession(); //Unlocks the robot so that new guests can enter
omnibot.undock(); // Undocks the robot from charging area
omnibot.dock(); // Requests the robot to auto-dock
omnibot.restartRobot(password); // Requests the on-board PC to reboot in 1 minute
omnibot.exitFullscreen(password); // Exits the kiosk mode for this session