Why We Call Sphero a Programmable Robot

The term “robot” is recklessly tossed about by most product designers. A common opinion has emerged over the past 20 years that defines a robot as a) able to respond to external stimuli and b) have its functions reprogrammed. The word robot actually means “slave” but here at Orbotix, we believe the intention has always been to recreate life. And life a) responds to the world and b) learns and adjusts its behavior. That’s why we’ve built Sphero to be even more than a multi-platform gaming system. We’ve created a robot that can be dynamically reprogrammed to respond differently to external stimuli. We are not referring to firmware updates, but yet another powerful function of Sphero – the local execution of macros and orbBasic programs.

orbBasic is an advanced capability of Sphero to hold decision making programs within itself and execute them with or without smartphone interaction. The people that write smartphone apps rely upon the phone services to decide what to do next and how to display information to the user (where someone touches on the screen, how they angle the phone, where to display a message or play a sound, etc). orbBasic is the equivalent of a smartphone app that reads all of the high level sensors in Sphero and outputs its information by rolling around, controlling the RGB LED or sending messages back to the connected smartphone. It’s just one of the ways Sphero has evolved as a programmable robot.

Macros for Sphero solve a different problem; namely the timed sequencing of events. One of the more difficult issues we had to address early in Sphero’s system development was “packet latency” in our Bluetooth connection. This is the amount of time between the app sending a message and Sphero actually receiving it. If you have ever called your friend’s cellphone and then had a cell-to-cell conversation with them in the same room, you’ll understand. Normally you don’t notice that latency between cell phones, but Sphero is always in the same room with you, thus the challenge.

We can’t do anything about this time delay. It rests in the domain of the smartphone OS programmers and the Bluetooth chip suppliers. It varies between phones, and changes with their OS updates. And typically you won’t notice it, but for higher performance games we needed a powerful and clever solution. To solve the problem, we came up with the concept of “helper applications.”

Imagine a smartphone game that sends a part of itself down to the device, exporting a chunk of game intelligence to be executed in parallel with minimal communication back to the device. That is what macros, and to a much greater extent, orbBasic programs for Sphero offer. Both systems run very fast (macros execute at 1ms resolution, orbBasic up to 9,000 lines/second) and are sandboxed for safety. App developers for Sphero get this functionality for free.

Consider the following program that implements a “geofence” around Sphero using real-time sampling of the built-in Locator agent. An app would download this program to RAM, execute it and then send roll commands via the SDK joystick:

10 locate 0,0
20 if sqrt(xpos*xpos + ypos*ypos) < 25 then LEDC 1 else LEDC 2
30 delay 50
40 goto 20

Line 10 sets the current position to the origin on the X,Y grid. The variables xpos and ypos are updated in the background by the Locator as Sphero drives around, so line 20 uses the radial distance formula to compute where Sphero is on the grid. If it is less that 25 cm from the origin, then the RGB LED is red (color #1). Otherwise, it is green (color #2). Line 30 delays 50 milliseconds giving this helper application a monitoring frequency of 20 Hz. You could accomplish this with direct Bluetooth transactions through our API but a) this is easier and faster, b) this is more powerful and c) this is much cooler. And ultimately, this capability is what makes Sphero a robot, not just an R/C toy.

Here in the firmware engineering group at Orbotix, we have done our best to launch Sphero with a powerful set of tools to make the development of cool new apps easier and more enjoyable. So take us up on this and use our creative magic invisibly to support yours. Learn more about Sphero’s API and SDK on our developer page and find additional information on the technology behind the robot on the blog. You can also see the robot’s reprogrammablility in a recent firmware update that completely changed the user experience with Sphero – check out the video here.