Message Boards Message Boards

Connection to Sphero robot from Mathematica

Posted 11 years ago
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.
POSTED BY: Phil Ngo
3 Replies
Posted 10 years ago
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.
  1. open the SerialIO init.m file 
    SpheroConnector \\ SerialIO \\ Kernel \\ init.m 
  2. find the following code
    Install["SerialIO", LinkProtocol -> "Pipes"]
  3. delete the LinkProtocol option (this was causing an error on my system since Pipes is not supported)
    [b][color=#555555][font=Courier][size=2]LinkProtocol -> "Pipes"[/size][/font][/color][/b]
  4. your final code should look likeInstall["SerialIO"]
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.
mySphero = SpheroDeviceConnect["COM5"]
POSTED BY: Updating Name
Dear author of the last Comment, could you please reply here with your full name you use on Community so we can fix "Updating Name" status on your comment?
POSTED BY: Moderation Team
This is very cool!..
You could try to use Cristopher's Mathematica leap motion link to control Sphero (also with Mathematica).
POSTED BY: Rodrigo Murta
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract