Declan, Max, Phil and I have been working on this project for about a year. I’m pretty proud of it.
We built Reality as a Service, a free hosted robotics platform. From building robots like ZIPY, we know that reality can be very different from simulation, even for a simple system. RaaS allows everyone to test out control theory or reinforcement learning code on real hardware with features you’d find in the real world like latency, friction, and imperfect measurement. Until now, the only way to do this was to build your own robot. And who wants to do that?
What is RaaS?
Our system is based on OpenAI Gym. Gym is a really cool project. It provides simulations of some simple interactive physical systems and exposes a common interface for controlling inputs and measuring the state. Our first robots are designed to match Gym’s
Pendulum-v0 environment, which allows users to control the torque on the pivot of a simple pendulum with the goal of balancing it in the inverted position.
RaaS is really easy to use, especially if you’re already familiar with Gym.
import gym import gym_raas # import our extra RaaS Pendulum environment env = gym.make('RaasPendulum-v0') # initialize the RaaS Pendulum environment env.reset() for _ in range(1000): # run for 1000 steps env.render() action = my_controller.get_action(observation) # <-- 🚨 your controller goes here 🚨 observation, reward, done, info = env.step(action) # execute the chosen action env.close()
gym_raas adds a special new environment called
RaasPendulum-v0 to the stock
gym module. This environment’s interface is the same as
Pendulum-v0. When code like this is run on our hardware, it controls a DC motor mounted to the base of the pendulum and reads back position and angular velocity information from a rotary encoder. When run on other computers, the code controls a simulation tuned to approximately match our hardware. Users can develop their code locally using the simulation and then test it on RaaS.
How do I try it?
You can try it by going to raas.perciplex.com and submitting a job. All you have to do is provide the URL to a Github project with a controller defined in a function called
run.py in the main branch. We wrote an example controller that’s easy to try right away:
https://github.com/perciplex/raas-example. If you want to write your own code, you can start by forking our starter repository.
After you submit a job, it will be added to the queue. Once your job is complete, you’ll be able to see a graph of the results, an animation showing you what happened, read the standard out, and download the data.
How does it work?
The center of the RaaS universe is a Flask server running on AWS Elastic Beanstalk. It maintains a list of queued, running, and completed jobs. Jobs can be added the the queue and viewed using a web app built with React.
The robots are Raspberry Pi 4s connected to motor with built in rotary encoders. Each robot continually polls the server for jobs. If one is waiting in the queue, that job is popped and assigned to the requesting robot. It spins up a Docker container, downloads the user’s code from Github, and attempts to run the code. When it completes or crashes, the data is saved to AWS S3, and metadata about the run is returned to the server, which marks the job as complete. The block diagram below outlines the system.
Go try it out!
Seriously, we’re begging you. Go try it out. 🙏