text stringlengths 0 93.6k |
|---|
# |
# DO NOT CALL THIS FUNCTION! |
# call readSensors instead - it will integrate odometry |
# for what that's worth, admittedly... |
# if you call this without integrating odometry, the |
# distance and rawAngle reported will be lost... |
# |
def _getRawSensorFrameAsList(self, packetnumber): |
""" gets back a raw string of sensor data |
which then can be used to create a SensorFrame |
""" |
if type(packetnumber) != type(1): |
packetnumber = 6 |
if packetnumber < 0 or packetnumber > 6: |
packetnumber = 6 |
self._write( SENSORS ) |
self._write( chr(packetnumber) ) |
if packetnumber == 0: |
r = self.ser.read(size=26) |
if packetnumber == 1: |
r = self.ser.read(size=10) |
if packetnumber == 2: |
r = self.ser.read(size=6) |
if packetnumber == 3: |
r = self.ser.read(size=10) |
if packetnumber == 4: |
r = self.ser.read(size=14) |
if packetnumber == 5: |
r = self.ser.read(size=12) |
if packetnumber == 6: |
r = self.ser.read(size=52) |
r = [ ord(c) for c in r ] # convert to ints |
return r |
def _getRawSensorDataAsList(self, listofsensors): |
""" gets the chosen sensors |
and returns the raw bytes, as a string |
needs to be converted to integers... |
""" |
numberOfSensors = len(listofsensors) |
self._write( QUERYLIST ) |
self._write( chr(numberOfSensors) ) |
resultLength = 0 |
for sensornum in listofsensors: |
self._write( chr(sensornum) ) |
resultLength += SENSOR_DATA_WIDTH[sensornum] |
r = self.ser.read(size=resultLength) |
r = [ ord(c) for c in r ] # convert to ints |
#print 'r is ', r |
return r |
def seekDock(self): |
""" sends the force-seeking-dock signal |
""" |
self.demo(1) |
def demo(self, demoNumber=-1): |
""" runs one of the built-in demos for Create |
if demoNumber is |
<omitted> or |
-1 stop current demo |
0 wander the surrounding area |
1 wander and dock, when the docking station is seen |
2 wander a more local area |
3 wander to a wall and then follow along it |
4 figure 8 |
5 "wimp" demo: when pushed, move forward |
when bumped, move back and away |
6 home: will home in on a virtual wall, as |
long as the back and sides of the IR receiver |
are covered with tape |
7 tag: homes in on sequential virtual walls |
8 pachelbel: plays the first few notes of the canon in D |
9 banjo: plays chord notes according to its cliff sensors |
chord key is selected via the bumper |
""" |
if (demoNumber < -1 or demoNumber > 9): |
demoNumber = -1 # stop current demo |
self._write( DEMO ) |
if demoNumber < 0 or demoNumber > 9: |
# invalid values are equivalent to stopping |
self._write( chr(255) ) # -1 |
else: |
self._write( chr(demoNumber) ) |
def setSong(self, songNumber, songDataList): |
""" this stores a song to roomba's memory to play later |
with the playSong command |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.