Overview
There are several methods to interact with Misty II robot as indicated in the official website. These are also summarized below.
- Command Center : It is a Graphical User Interface (GUI) with several commands to choose from and interact with Misty II. One would simply need to connect to Misty II robot using its IP address and once it is connected to the PC, the user can send any commands that are available in the Command Center such as to move it around, or move its limbs, etc. It also shows the live data from the robot sensor and its state, when enabled/subscribed. So, this comes handy when the user either wants to study some aspects of Misty’s sensors or simply wants to have a minimal interaction with the robot. However, if a user intends to do something more advanced such as make Misty II have a conversation or anything else that is not included in the Command Center, then there are at least two other options available. Those are, using the SDKs or APIs.
- SDKs: Currently, Misty Robotics has three official SDKs (JavaScript SDK, .NET SDK and Python SDK). The programs written to have Misty do something called Skills written using the SDKs are run directly on the robot. That is, there is no external processor needed run the skills. (Note: this does not mean that one cannot use Misty II’s REST API when using the SDKs! The API can still be used to extend the capabilities that are not part of the SDKs). For the JavaScript and .NET SDK, there is excellent documentation available on Misty II website. However, Python SDK is fairly new (released on June 1st, 2021), it does not have extensive documentation yet. This github repository is available as a starter.
- One difference to note between the JavaScript SDK/.NET SDK and Python SDK is that the skills written in Javascript and .NET can be uploaded on the Skill Runner and can be run on the robot from here. However, the Skill Runner does not have such support for the skills written in Python. So, those have to be run run from elsewhere, such as the Terminal from your PC.
- API: Finally, MIsty II can also be programmed using the REST API. The programs that make use of the API are called “applications” (per Misty Robotics terminology). These applications are run on an external device and they communicate with Misty II using the HTTP requests and Websockets. APIs can be written in any programming language. Some examples using REST API for Misty II (using JavaScript) are provided here.
- API Explorer: This is GUI that allows to send HTTPS requests. However, this is still being developed.
Programming Misty II using Python SDK
Installation
Code
Helpful terms/concepts
- Application Programming Interface (API): It is a software interface that allows two applications to talk to each other. As an example, when we search for a flight using services such as Google Flights, Kayak, Expedia, etc., we are essentially using an API. These sites are all different APIs that interact with websites for different airlines individually and bring desired data (available flights) back to us. In simple terms, an API is analogous to a waiter in a restaurant. Just like a waiter is an interface who allows us to interact with the kitchen (gives us the menu, takes the order to the kitchen and delivers the food), APIs in software allow two applications to communicate with each other. See [2].
- REST / RESTful: Representational State Transfer defines a set of constraints on an architecture as to how the communication must happen between the server and a client. It has at least 6 constraints as explained in [10, 11]
- REST/RESTful API: The APIs that meet the constraints of the REST architecture are called REST or RESTful APIs. See [11]
- API Endpoints: These are unique URLs, where the client must point its HTTP request at, to communicate with the server. See [3]
- HTTP: This is a protocol that defines a set of request methods to indicate the desired action to be performed for a given resource. The RESTful APIs use HTML requests to facilitate communication between the server and a client.
- HHTP request in Python: Python has a requests library that is popular. See [14,15]
- HTTP verbs: The intent of the communication/request is contained in HTTP verbs that make up the HTTP request. In other words, HTTP verbs tell the server what to do with the data identified in the URL. Example POST, GET, DELETE, etc. See 6,7,8,9.
- GET: Retrieve information from the server that is identified in the URL included in the request.
- Syntax of a GET request for Misty II:
- POST: Submit an entity to a specified resource, causing a change in the state on the server side.
- Syntax for a POST request for Misty II:
- PUT: Replaces the target resource with payload identified in the request.
- Syntax for a PUT request for Misty II:
- GET: Retrieve information from the server that is identified in the URL included in the request.
- Uniform Resource Locator (URL)/ Uniform Resource Identifier (URI): URI includes both URL and URN. See [4]
- Webservices: There are few different definitions of webservices. According to one of them, webservices provide a way for two applications to communicate with each other just like the APIs. The difference is that the webservices must be available over the network, whereas not all APIs are required to be available over the network. Therefore, all APIs are webservices but not all web services are APIs. See [5], [13].
- Websockets vs HTTP request: Websocket allow communication/data flow between two applications (server and a client). The difference between a websocket and an API is that REST API (which uses HTTP) is based on a request/response protocol (a client sends a request and the server responds to the request), whereas websocket based communication is a two way (such as publisher/subscriber method). The server is always sending data. If a client has subscribed to this data then the server pushes data to the client whenever there is a change. The HTTP request is stateless whereas websocket communication is stateful. The real time applications typically use websockets, such as getting sensor data. See [16]
- SDK vs API: See [17]
- Events:
- Skills vs Application: In Misty Robotics terminology, Skills are programs that are able to run on a robot using its onboard software, whereas applications are programs that are run on external devices such as PC, raspberry PI and communicate with Misty II using the APIs (REST API to be specific).
References
- https://docs.mistyrobotics.com/misty-ii/get-started/meet-misty/ – Misty II official documentation
- https://www.mulesoft.com/resources/api/what-is-an-api – What is API?
- https://dev.socrata.com/docs/endpoints.html – API Endpoints
- https://rapidapi.com/blog/url-vs-url/ – URI/URL
- https://rapidapi.com/blog/api-vs-web-service/ – API vs web services
- https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods – HTTP verbs
- https://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html – HTTP verbs
- https://www.c-sharpcorner.com/UploadFile/47fc0a/working-with-http-verbs/ – HTTP verbs
- https://dev.socrata.com/docs/verbs.html – HTTP verbs
- https://www.ics.uci.edu/~fielding/pubs/dissertation/rest_arch_style.htm – REST explained – original thesis
- https://blog.ndepend.com/rest-vs-restful/ – RESTful
- https://nordicapis.com/what-is-the-difference-between-an-api-and-an-sdk/ – SDK vs API
- https://www.tutorialspoint.com/webservices/what_are_web_services.htm – what are webservices?
- https://www.datacamp.com/community/tutorials/making-http-requests-in-python – How to define HTTP requests in Python?
- https://docs.python-requests.org/en/master/ – How to define HTTP requests in Python?
- https://blog.stanko.io/do-you-really-need-websockets-343aed40aa9b – websockets
- https://squareup.com/us/en/townsquare/sdk-vs-api – SDK vs API
- https://www.mistyrobotics.com/blog/what-can-the-misty-ii-platform-do/ – MISTY internal architecture