1 Million Dollar Roboter

Today is a good day, because I'm getting finally my new and shiny Sphero! My goal with this little friend is, to bring the fun in programming to kids. I think the best trigger for showing kids the fun part in programming is with direct and funny results. So I will use Sphero to build a little Framework for the young kids to play with the Sphero.

First Step, Let Him Run

Once the Sphero was unpacked, the fun begins. My little son Jacob (nearly 2 Years), had fun at the very beginning. Pressing the button on the loading station and Sphero begins to blink and change color And then the first run, It is really cool to see the Sphero drives in the room. Playing catch and run was really funny. But, I'm a programmer, I don't want to controll him mannually. I want to give him a 'B R A I N'.

Join The Navy

At the ruby conf in Miami, I've seen the cool Ruby Framework Artoo. Next try is, to communicate with artoo to my Sphero. First step, installing Ruby 2.0.0 and Artoo. I'm loving brew and rvm, so not new but relevant first steps:

brew update
rvm get head

After that making a new dir and rvm files:

cd dev
mkdir sphero
cd sphero
echo 'ruby-2.0.0' > .ruby-version
echo 'artoo-sphero' > .ruby-gemset
cd ..
cd -
rvm install ruby-2.0.0-p353

And after successfully installing ruby, I need to have the required Gems. I will use bundler for this:

gem install bundler
bundle init
echo 'gem "artoo"' >> Gemfile
echo 'gem "artoo-joystick"' >> Gemfile
echo 'gem "artoo-sphero"' >> Gemfile
echo 'gem "hybridgroup-sphero"' >> Gemfile
echo 'gem "hybridgroup-serialport"' >> Gemfile

Why I'm using "artoo-sphero"? Because my goal is to have a PS3 Controller for controlling the ball. But in the first step, we use the good old keyboard for controlling.

First Try

First of all, we need to connect our Laptop with Sphero. Be sure to disconnect your phone first After the connect, we can use artoo to find the right port:

artoo connect scan

I've found "/dev/tty.Sphero-YPB-AMP-SPP" and will connect to this.

artoo connect serial Sphero-WRW 8023

Now, code:

vi sphero-go.rb
require 'artoo'

connection :sphero, :adaptor => :sphero, :port => '/dev/tty.Sphero-YPB-AMP-SPP'
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)
And after that, let it roll:
ruby sphero-go.rb

After a successful connect, he changes color and drives in random directions So we are done, our new super roboter is ready to rule the word!

Get The Head Through The Wall

One of the sensor of the ball can detect collisions, so we want to make a test for that:

(brew install sdl)

Torben small

Your Contact

Torben Toepper