I have installed sphero_ros on my laptop running Ubuntu 12.04 LTS, and I've made it as far as being able to issue single rostopic commands to the Sphero via the Terminal. However, I would like to use the Python API instead, only I can't find any documentation on where I would even start to accomplish this. In essence, I'm looking for a step-by-step guide or a "Hello World" script of some sort. Can anyone help me?
Your help is much appreciated.
I followed davinellulinvega's instructions on the project's GitHub Issues page. Here is my adapted version of the test.py file that comes with the driver:
#!/usr/bin/python
from sphero_driver import sphero_driver
import time
sphero = sphero_driver.Sphero()
while True:
try:
sphero.connect()
break
except:
print '\nTrying to connect again!'
pass
time.sleep(2)
sphero.set_rgb_led(255, 0, 0, 0, False)
time.sleep(1)
sphero.set_rgb_led(0, 255, 0, 0, False)
time.sleep(1)
sphero.set_rgb_led(0, 0, 255, 0, False)
time.sleep(1)
If you want to connect to a specific Sphero, use
sphero = sphero_driver.Sphero('Sphero','01:23:45:67:89:AB')
instead, where the second argument is your Sphero's address.