Platforms

Artoo has a extensible system for connecting to hardware devices.

Sphero


Repository Issues

The Sphero is a sophisticated and programmable robot housed in a polycarbonate sphere shell.

The artoo-sphero adaptor makes it easy to interact with Sphero using Ruby, once you have your Sphero setup and connected to your computer you can start writing code to make Sphero move, change direction, speed and colors, or detect Sphero events and execute some code when they occur.

+ info about the Sphero platform click here

How To Install

Install the Artoo module providing Sphero support through RubyGems:

$ gem install artoo-sphero

How To Use

Example of a simple program that makes the Sphero roll and change colors.

require 'artoo'

connection :sphero, :adaptor => :sphero, :port => '/dev/Sphero-WRW'
device :sphero, :driver => :sphero

work do
  @count = 1
  every(3.seconds) do
    sphero.set_color(@count % 2 == 0 ? :green : :blue)
    @count += 1
    sphero.roll 60, rand(360)
  end
end

How To Connect

OSX

The main steps are:

  • Pair your computer and the Sphero
  • Find out the sphero bluetooth address
  • Connect to the device via Artoo

First pair your computer and Sphero. You can do this using bluetooth preferences. (Sphero won't stay connected)

Find out serial port address by running this command:

$ ls /dev/tty.Sphero*

Now you are ready to run the example code, be sure to update this line with correct port

connection :sphero, :adaptor => :sphero, :port => '/dev/Sphero-WRW-RN-SPP'

Linux

The main steps are:

  • Find out the sphero bluetooth address
  • Pair your computer and the Sphero
  • Map your device to a unix port
  • Connect to the device via Artoo

First pair your computer and Sphero. We do this by finding the sphero bluetooth address and then running Gort´s gort bluetooth pair command, you might be prompted to confirm a passcode. Just accept whatever passcode prompted.

$ gort bluetooth scan
Scanning ...
  00:06:66:4A:14:99 Sphero-WRW

After finding the bluetooth address, we pair the device with the computer. The easiest way to do this is to use the gort bluetooth pair command:

$ gort bluetooth pair 00:06:66:4A:14:99

Next, you need to bind the Sphero to the system serial port. In the above example, /dev/Sphero-WRW. Use the gort bluetooth connect command:

$ gort bluetooth connect 00:06:66:4A:14:99 Sphero-WRW

Now you are ready to run the example code, be sure to update this line with correct port.

connection :sphero, :adaptor => :sphero, :port => '/dev/Sphero-WRW'

Drivers

There is only one driver for the Sphero.