Message Boards

Connection to Sphero robot from Mathematica

I have been an intern at Wolfram Research for the summer and ended up writing this package for connecting to a Sphero robot. Sphero is a little spherical robot that you can drive on land or in water from your iPhone, iPad, Android, tablet and (now) from Mathematica.

The package uses SerialIO and Bluetooth to connect to Sphero. I included a sample notebook to help people get started that shows how to load the package, connect via bluetooth, etc. I embedded the SerialIO package as well.

You'll need to find figure out which virtual serial port was opened by Bluetooth, but once you do so, this command gets you up and running. I've only done this on Mac, so if anyone succeeds on a Windows or Linux machine, would you post how you did it?

mySphero = SpheroDeviceConnect["/dev/tty.Sphero-BWR-RN-SPP"]

The package is in its infancy, but already lets you do some pretty cool stuff. My favorite uses Sphero to control a Graphics3D object - twist and turn Sphero in your hand and watch your Graphics3D object mimic its twists and turns on the screen. If you find some other cool ways to interact with Sphero from within Mathematica, please post.

Access Sphero's data with this command, which returns a List of rules that can be used to access the various data fields that Sphero streams.

SpheroDeviceData[mySphero]

I would love feedback on how to improve the package. By the way, Sphero 2.0 (looks very cool) came out today - not sure if this package will still work with it, but let me know if it does.

Thanks for developing such a cool package Phil! I was able to get things working on Windows 7 with a minor modification to SerialIO. The solution for me was to remove the unsupported LinkProtocol. The steps that I took appear below.

Now, SpheroConnector.nb should work as expected. Note that windows serial ports are specified as "COM#" (where # is replaced by the actual number of the COM port), the connection code should appear like the following.