User avatar
mkopack
Posts: 242
Joined: Mon Nov 07, 2011 8:46 pm

RPi + Roostick to control Roomba?

Fri Nov 09, 2012 2:24 am

Hey gang...

After seeing the recent story on the front page about the RPi controlled Roomba, I decided to dust off my old 500 Discovery series, and my old USB Roostick+cable.

I installed PySerial

Then I hooked up the Pi, plugged the roostick+cable into the Roomba and into the Pi's USB Hub.

lsusb shows:

the Hub
3 "Standard Microsystems Corp" entries
The mouse
The Keyboard
and finally: "Cygnal Integrated Products, Inc. CP210x UART Bridge / myAVR mySmartUSB light"

Unplugging the roostick and running lsusb again shows that it's that last item in the list that is the roostick.

I threw together a little python test program, basically exactly what's in the Roomba SCI interface document:

Code: Select all

import serial

ser = serial.Serial(0, baudrate=19200,
timeout=0.1)
ser.open()
# wake up robot
ser.setRTS (0)
time.sleep (0.1)
ser.setRTS (1)
time.sleep (2)
# pulse device-detect three times
for i in range (3):
       ser.setRTS (0)
       time.sleep (0.25)
       ser.setRTS (1)
       time.sleep (0.25)

Seems like no matter what I put in for the device it comes back saying it can't connect.

Looking in /dev, I see /ttyUSB0 show up when I plug the Roostick in... But trying to use /dev/ttyUSB0 as the port gives an exception "Port is already open" error.

Any ideas???

User avatar
mkopack
Posts: 242
Joined: Mon Nov 07, 2011 8:46 pm

Re: RPi + Roostick to control Roomba?

Sat Nov 10, 2012 1:35 am

Ok, nevermind, got it working!

Here's a little test program that establishes connection, turns on a couple of the lights, and plays a tone...
(And Python is NOT my primary language, so I'm sure there's plenty to be done to make this better/easier...)

Code: Select all

import serial
import time

# main....
ser = serial.Serial("/dev/ttyUSB0",baudrate=57600, timeout=0.1)
ser.write(serial.to_bytes("\x80"))

# everything has to be sent as hex code bytes. So using the SCI programmer's 
# guide to get the decimal codes, convert to hex
# and put them in here with \x in front of each 2 digit byte to denote hex...

time.sleep(0.1)
ser.write(serial.to_bytes("\x82"))
time.sleep(0.1)
ser.write(serial.to_bytes("\x8b\x19\x00\x80"))
time.sleep(6)
# make a song with some tones
ser.write(serial.to_bytes("\x8c\x00\x06\x60\xff\x30\xff"))
#now play it.
ser.write(serial.to_bytes("\x8d\x00"))
time.sleep(20)
ser.close()

My wifi adaptor, and webcam came in. Just waiting on the powered hub (should have arrived today, so probably tomorrow or Monday) and I should be able to start putting it all together into a little roving telepresence bot :)

doitnowlabs
Posts: 1
Joined: Wed Nov 14, 2012 6:16 pm

Re: RPi + Roostick to control Roomba?

Wed Nov 14, 2012 6:20 pm

Cool! I probably should have bought a RooStick too, but I'm too cheap for that. ;)

User avatar
mkopack
Posts: 242
Joined: Mon Nov 07, 2011 8:46 pm

Re: RPi + Roostick to control Roomba?

Sat Nov 17, 2012 5:16 pm

Well, I actually found a full library for talking to Roomba over Python.

http://bilibot-ros-pkg.googlecode.com/s ... _driver.py

Looks pretty easy to control the Roomba via that...

I'm also trying to figure out how I want to do the control/interface... Was thinking maybe some sort of Web interface. Not sure yet... Also trying to figure out how I want to stream video from the webcam.

--Mike

Return to “Automation, sensing and robotics”