diff --git a/Ollie_driver.py b/Ollie_driver.py
old mode 100644
new mode 100755
index a56dec5..c75a34c
--- a/Ollie_driver.py
+++ b/Ollie_driver.py
@@ -2,7 +2,7 @@
from bluepy import btle
-# import bluetooth
+#import bluetooth
import sys
import struct
import time
@@ -149,11 +149,11 @@ def __init__(self, deviceAddress):
# This startup sequence is also identical to the one for Ollie.
# It even uses the same unlock code.
- print 'Sending antidos'
+ print ('Sending antidos')
self.antidos.write('011i3', withResponse=True)
- print 'Sending txpower'
+ print ('Sending txpower')
self.txpower.write('\x0007', withResponse=True)
- print 'Sending wakecpu'
+ print ('Sending wakecpu')
self.wakecpu.write('\x01', withResponse=True)
def getSpheroCharacteristic(self, fragment):
@@ -161,9 +161,9 @@ def getSpheroCharacteristic(self, fragment):
def dumpCharacteristics(self):
for s in self.peripheral.getServices():
- print s
+ print (s)
for c in s.getCharacteristics():
- print c, hex(c.handle)
+ print (c, hex(c.handle))
def cmd(self, did, cid, data=[], answer=True, resetTimeout=True):
# Commands are as specified in Sphero API 1.50 PDF.
@@ -178,7 +178,7 @@ def cmd(self, did, cid, data=[], answer=True, resetTimeout=True):
chk ^= 255
msg = [0xff, sop2, did, cid, seq, dlen] + data + [chk]
- print 'cmd:', ' '.join([chr(c).encode('hex') for c in msg])
+ print ('cmd:', ' '.join([chr(c).encode('hex') for c in msg]))
# Note: withResponse is very important. Most commands won't work without it.
self.roll.write(''.join([chr(c) for c in msg]), withResponse=True)
@@ -240,8 +240,8 @@ def __init__(self, target_name='Sphero'):
threading.Thread.__init__(self)
self.target_name = target_name
self.bt = None
- # Use "sudo hcitool lescan" to find Ollie's MAC address input it at deviceAddress =
- self.deviceAddress = 'DF:79:DD:9C:B6:1D'
+ # Use "sudo hcitool lescan" to find Ollie's MAC address input it at deviceAddress = 'EC:61:42:58:09:41'
+ self.deviceAddress = 'EC:61:42:58:09:41'
self.shutdown = False
self.is_connected = False
self.mask_list = None
@@ -575,7 +575,7 @@ def set_data_strm(self, sample_div, sample_frames, sample_mask1, pcnt, sample_ma
self.create_mask_list(sample_mask1, sample_mask2)
self.stream_mask1 = sample_mask1
self.stream_mask2 = sample_mask2
- print data
+ print (data)
self.send(data, response)
def set_filtered_data_strm(self, sample_div, sample_frames, pcnt, response):
@@ -738,7 +738,7 @@ def set_raw_motor_values(self, l_mode, l_power, r_mode, r_power, response):
brake, 0x04 - ignored.
:param power: 0-255 scalar value (units?).
"""
- self.send(self.pack_cmd(REQ['CMD_RAW_MOTORS'], [l_mode, l_power, r_mode, r_power]), response)
+ self.send(self.pack_cmd(REQ['CMD_SET_RAW_MOTORS'], [l_mode, l_power, r_mode, r_power]), response)
def send(self, data, response):
"""
@@ -829,7 +829,7 @@ def recv(self, num_bytes):
data = self.raw_data_buf
while len(data) > 5:
if data[:2] == RECV['SYNC']:
- print "got response packet"
+ print ("got response packet")
# response packet
data_length = ord(data[4])
if data_length + 5 <= len(data):
@@ -857,7 +857,7 @@ def recv(self, num_bytes):
IDCODE['PWR_NOTIFY']):
self._async_callback_dict[IDCODE['PWR_NOTIFY']](self.parse_pwr_notify(data_packet, data_length))
else:
- print "got a packet that isn't streaming"
+ print ("got a packet that isn't streaming")
else:
raise RuntimeError("Bad SOF : " + self.data2hexstr(data))
self.raw_data_buf = data
@@ -918,8 +918,8 @@ def parse_data_strm(self, data, data_length):
for i in range((data_length - 1) / 2):
unpack = struct.unpack_from('>h', ''.join(data[5 + 2 * i:]))
output[self.mask_list[i]] = unpack[0]
- print self.mask_list
- print output
+ print (self.mask_list)
+ print (output)
return output
diff --git a/Ollietest.py b/Ollietest.py
old mode 100644
new mode 100755
index 57cdb96..2aac77b
--- a/Ollietest.py
+++ b/Ollietest.py
@@ -1,5 +1,4 @@
#!/usr/bin/python
-from bluepy import btle
import struct
import time
import Ollie_driver
@@ -16,7 +15,20 @@
time.sleep(1)
ollie.set_rgb_led(0,0,255,0,False)
time.sleep(3)
+ollie.set_stablization(False,'False')
+while 1:
+ key = raw_input("what is your character")
+ if(key == "l"):
+ ollie.set_raw_motor_values(1,60,1,40,'01h')
+ if(key== "j"):
+ ollie.set_raw_motor_values(1,40,1,60,'01h')
+ if(key== "i"):
+ ollie.set_raw_motor_values(1,60,1,60,'01h')
+ if(key == "k"):
+ ollie.set_raw_motor_values(2,60,2,60,'01h')
+ if(key=='g'):
+ break
+time.sleep(5)
ollie.join()
-ollie.disconnect()
sys.exit(1)
diff --git a/README.md b/README.md
index bc257ac..e823e93 100644
--- a/README.md
+++ b/README.md
@@ -1,15 +1,22 @@
# SpheroOllie-python
-**Sphero's Ollie**
+A library of functions to be used with the Sphero Ollie!
-Now even better with a python API library!
+#Setup
+Run the following commands in your terminal. You must be running this on a computer that has Bluetooth LE (Different from standard bluetooth)
+`sudo apt-get install python-pip libglib2.0-dev build-essential git`
+`sudo pip install bluepy`
+`git clone https://github.com/mkkeffeler/SpheroOllie-python`
+`git checkout patch_branch`
-Use "sudo hcitool lescan" to find Ollie's MAC address
-input it at "`deviceAddress =`" (line 244) in the Sphero class in Ollie_driver.py
+#Getting Ready
+Use `sudo hcitool lescan` to find Ollie's MAC address
-**
+input this device address "`deviceAddress =`" (line 244) in the Sphero class in Ollie_driver.py
+
+Currently, Ollietest.py allows you to direct your Ollie where to go using the I J K and L keys. The G key is used to end the program.
-***Included Scripts:***
+***Included Scripts:***
**
**OllieTest.py**
A simple program that connects to Ollie and flashes the internal RGB LED red to green to blue. You can take it a step further and add `ollie.roll` commands to make him move using the API.
@@ -17,7 +24,7 @@ A simple program that connects to Ollie and flashes the internal RGB LED red to
**OlliejoyDrive.py**
*requires PyGame library*
-Allow you to drive Ollie with a joystick/gamepad.
+Allows you to drive Ollie with a joystick/gamepad.
Shows on screen feedback of analog stick as well as speed and heading
Currently setup for a Xbox 360 controller.
@@ -38,3 +45,11 @@ Tie in the btle handleNotifcations to Sphero response API
- getting sensor info, command responses, etc. back from Ollie
+#Common Errors
+If `sudo hcitool lescan` throws an error involving 'input/output error' perform the following commands and try again
+
+`sudo systemctl daemon-reload`
+`sudo hciconfig hci0 down`
+`sudo hciconfig hci0 up`
+
+If that doesn't work please open an issue with details.