text
stringlengths
1
93.6k
self._getTwoBytesSigned, # 19 DISTANCE
self._getTwoBytesSigned, # 20 ANGLE
self._getOneByteUnsigned, # 21 CHARGING_STATE
self._getTwoBytesUnsigned, # 22 VOLTAGE
self._getTwoBytesSigned, # 23 CURRENT
self._getOneByteSigned, # 24 BATTERY_TEMP
self._getTwoBytesUnsigned, # 25 BATTERY_CHARGE
self._getTwoBytesUnsigned, # 26 BATTERY_CAPACITY
self._getTwoBytesUnsigned, # 27 WALL_SIGNAL
self._getTwoBytesUnsigned, # 28 CLIFF_LEFT_SIGNAL
self._getTwoBytesUnsigned, # 29 CLIFF_FRONT_LEFT_SIGNAL
self._getTwoBytesUnsigned, # 30 CLIFF_FRONT_RIGHT_SIGNAL
self._getTwoBytesUnsigned, # 31 CLIFF_RIGHT_SIGNAL
self._getLower5Bits, # 32 CARGO_BAY_DIGITAL_INPUTS
self._getTwoBytesUnsigned, # 33 CARGO_BAY_ANALOG_SIGNAL
self._getOneByteUnsigned, # 34 CHARGING_SOURCES_AVAILABLE
self._getOneByteUnsigned, # 35 OI_MODE
self._getOneByteUnsigned, # 36 SONG_NUMBER
self._getOneByteUnsigned, # 37 SONG_PLAYING
self._getOneByteUnsigned, # 38 NUM_STREAM_PACKETS
self._getTwoBytesSigned, # 39 REQUESTED_VELOCITY
self._getTwoBytesSigned, # 40 REQUESTED_RADIUS
self._getTwoBytesSigned, # 41 REQUESTED_RIGHT_VELOCITY
self._getTwoBytesSigned, # 42 REQUESTED_LEFT_VELOCITY
self._getTwoBytesUnsigned, # 43 Left Encoder Counts
self._getTwoBytesUnsigned, # 44 Right Encoder Counts
self._getOneByteUnsigned, # 45 LIGH_BUMP
self._getTwoBytesUnsigned, # 46 LIGHTBUMP_LEFT
self._getTwoBytesUnsigned, # 47 LIGHTBUMP_FRONT_LEFT
self._getTwoBytesUnsigned, # 48 LIGHTBUMP_CENTER_LEFT
self._getTwoBytesUnsigned, # 49 LIGHTBUMP_CENTER_RIGHT
self._getTwoBytesUnsigned, # 50 LIGHTBUMP_FRONT_RIGHT
self._getTwoBytesUnsigned, # 51 LIGHTBUMP_RIGHT
None # only 51 as of right now
]
startofdata = 0
distance = 0
angle = 0
update_pose = False
for sensorNum in sensor_data_list:
width = SENSOR_DATA_WIDTH[sensorNum]
dataGetter = sensorDataInterpreter[sensorNum]
interpretedData = 0
if (width == 1):
if startofdata >= len(r):
print "Incomplete Sensor Packet"
break
else: interpretedData = dataGetter(r[startofdata])
if (width == 2):
if startofdata >= len(r) - 1:
print "Incomplete Sensor Packet"
break
else: interpretedData = dataGetter(r[startofdata], r[startofdata+1] )
# add to our dictionary
self.sensord[sensorNum] = interpretedData
# POSE = 100 - later
#LEFT_BUMP = 101
#RIGHT_BUMP = 102
#LEFT_WHEEL_DROP = 103
#RIGHT_WHEEL_DROP = 104
#CENTER_WHEEL_DROP = 105
if sensorNum == BUMPS_AND_WHEEL_DROPS:
self.sensord[CENTER_WHEEL_DROP] = interpretedData[0]
self.sensord[LEFT_WHEEL_DROP] = interpretedData[1]
self.sensord[RIGHT_WHEEL_DROP] = interpretedData[2]
self.sensord[LEFT_BUMP] = interpretedData[3]
self.sensord[RIGHT_BUMP] = interpretedData[4]
#LEFT_WHEEL_OVERCURRENT = 106
#RIGHT_WHEEL_OVERCURRENT = 107
if sensorNum == LSD_AND_OVERCURRENTS:
self.sensord[LEFT_WHEEL_OVERCURRENT] = interpretedData[0]
self.sensord[RIGHT_WHEEL_OVERCURRENT] = interpretedData[1]
#ADVANCE_BUTTON = 108
#PLAY_BUTTON = 109
if sensorNum == BUTTONS:
self.sensord[ADVANCE_BUTTON] = interpretedData[0]
self.sensord[PLAY_BUTTON] = interpretedData[1]
if sensorNum == DIRT_DETECTED:
self.sensord[DIRT_DETECTED] = interpretedData
# handle special cases
if (sensorNum == DISTANCE):
distance = interpretedData
if (sensorNum == ANGLE):
angle = interpretedData
if (sensorNum == ENCODER_LEFT):
self.leftEncoder = interpretedData
update_pose = True
if (sensorNum == ENCODER_RIGHT):
self.rightEncoder = interpretedData