text stringlengths 0 93.6k |
|---|
the sensor data into the next packet to send back. |
""" |
self._write( SENSORS ) |
self._write( chr(6) ) |
def _getNextDataFrame(self): |
""" This function then gets back ALL of |
the sensor data and organizes it into the sensor |
dictionary, sensord. |
""" |
r = self.ser.read(size=52) |
r = [ ord(c) for c in r ] |
#return self._readSensorList(r) |
def _rawSend( self, listofints ): |
for x in listofints: |
self._write( chr(x) ) |
def _rawRecv( self ): |
nBytesWaiting = self.ser.inWaiting() |
#print 'nBytesWaiting is', nBytesWaiting |
r = self.ser.read(size=nBytesWaiting) |
r = [ ord(x) for x in r ] |
#print 'r is', r |
return r |
def _rawRecvStr( self ): |
nBytesWaiting = self.ser.inWaiting() |
#print 'nBytesWaiting is', nBytesWaiting |
r = self.ser.read(size=nBytesWaiting) |
return r |
def sensors( self, list_of_sensors_to_poll=6 ): |
""" this function updates the robot's currently maintained |
state of its robot sensors for those sensors requested |
If none are requested, then all of the sensors are updated |
(which takes a bit more time...) |
""" |
if type(list_of_sensors_to_poll) == type([]): |
# first, we change any pieces of sensor values to |
# the single digit that is required here |
distangle = 0 |
if POSE in list_of_sensors_to_poll: |
list_of_sensors_to_poll.remove(POSE) |
# should check if they're already there |
list_of_sensors_to_poll.append(DISTANCE) |
list_of_sensors_to_poll.append(ANGLE) |
if LEFT_BUMP in list_of_sensors_to_poll: |
list_of_sensors_to_poll.remove(LEFT_BUMP) |
if BUMPS_AND_WHEEL_DROPS not in list_of_sensors_to_poll: |
list_of_sensors_to_poll.append(BUMPS_AND_WHEEL_DROPS) |
if RIGHT_BUMP in list_of_sensors_to_poll: |
list_of_sensors_to_poll.remove(RIGHT_BUMP) |
if BUMPS_AND_WHEEL_DROPS not in list_of_sensors_to_poll: |
list_of_sensors_to_poll.append(BUMPS_AND_WHEEL_DROPS) |
if RIGHT_WHEEL_DROP in list_of_sensors_to_poll: |
list_of_sensors_to_poll.remove(RIGHT_WHEEL_DROP) |
if BUMPS_AND_WHEEL_DROPS not in list_of_sensors_to_poll: |
list_of_sensors_to_poll.append(BUMPS_AND_WHEEL_DROPS) |
if LEFT_WHEEL_DROP in list_of_sensors_to_poll: |
list_of_sensors_to_poll.remove(LEFT_WHEEL_DROP) |
if BUMPS_AND_WHEEL_DROPS not in list_of_sensors_to_poll: |
list_of_sensors_to_poll.append(BUMPS_AND_WHEEL_DROPS) |
if CENTER_WHEEL_DROP in list_of_sensors_to_poll: |
list_of_sensors_to_poll.remove(CENTER_WHEEL_DROP) |
if BUMPS_AND_WHEEL_DROPS not in list_of_sensors_to_poll: |
list_of_sensors_to_poll.append(BUMPS_AND_WHEEL_DROPS) |
if LEFT_WHEEL_OVERCURRENT in list_of_sensors_to_poll: |
list_of_sensors_to_poll.remove(LEFT_WHEEL_OVERCURRENT) |
if LSD_AND_OVERCURRENTS not in list_of_sensors_to_poll: |
list_of_sensors_to_poll.append(LSD_AND_OVERCURRENTS) |
if RIGHT_WHEEL_OVERCURRENT in list_of_sensors_to_poll: |
list_of_sensors_to_poll.remove(RIGHT_WHEEL_OVERCURRENT) |
if LSD_AND_OVERCURRENTS not in list_of_sensors_to_poll: |
list_of_sensors_to_poll.append(LSD_AND_OVERCURRENTS) |
if ADVANCE_BUTTON in list_of_sensors_to_poll: |
list_of_sensors_to_poll.remove(ADVANCE_BUTTON) |
if BUTTONS not in list_of_sensors_to_poll: |
list_of_sensors_to_poll.append(BUTTONS) |
if PLAY_BUTTON in list_of_sensors_to_poll: |
list_of_sensors_to_poll.remove(PLAY_BUTTON) |
if BUTTONS not in list_of_sensors_to_poll: |
list_of_sensors_to_poll.append(BUTTONS) |
r = self._getRawSensorDataAsList(list_of_sensors_to_poll) |
else: |
# if it's an integer, its a frame number |
r = self._getRawSensorFrameAsList( list_of_sensors_to_poll ) |
# now, we set list_of_sensors_to_poll |
frameNumber = list_of_sensors_to_poll |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.