text
stringlengths 1
93.6k
|
|---|
CLIFF_LEFT_SIGNAL = 28
|
CLIFF_FRONT_LEFT_SIGNAL = 29
|
CLIFF_FRONT_RIGHT_SIGNAL = 30
|
CLIFF_RIGHT_SIGNAL = 31
|
CARGO_BAY_DIGITAL_INPUTS = 32
|
CARGO_BAY_ANALOG_SIGNAL = 33
|
CHARGING_SOURCES_AVAILABLE = 34
|
OI_MODE = 35
|
SONG_NUMBER = 36
|
SONG_PLAYING = 37
|
NUM_STREAM_PACKETS = 38
|
REQUESTED_VELOCITY = 39
|
REQUESTED_RADIUS = 40
|
REQUESTED_RIGHT_VELOCITY = 41
|
REQUESTED_LEFT_VELOCITY = 42
|
ENCODER_LEFT = 43
|
ENCODER_RIGHT = 44
|
LIGHTBUMP = 45
|
LIGHTBUMP_LEFT = 46
|
LIGHTBUMP_FRONT_LEFT = 47
|
LIGHTBUMP_CENTER_LEFT = 48
|
LIGHTBUMP_CENTER_RIGHT = 49
|
LIGHTBUMP_FRONT_RIGHT = 50
|
LIGHTBUMP_RIGHT = 51
|
# others just for easy access to particular parts of the data
|
POSE = 100
|
LEFT_BUMP = 101
|
RIGHT_BUMP = 102
|
LEFT_WHEEL_DROP = 103
|
RIGHT_WHEEL_DROP = 104
|
CENTER_WHEEL_DROP = 105
|
LEFT_WHEEL_OVERCURRENT = 106
|
RIGHT_WHEEL_OVERCURRENT = 107
|
ADVANCE_BUTTON = 108
|
PLAY_BUTTON = 109
|
# 0 1 2 3 4 5 6 7 8 9101112131415161718192021222324252627282930313233343536373839404142434445464748495051
|
SENSOR_DATA_WIDTH = [0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,1,2,2,2,2,2,2,2,1,2,1,1,1,1,1,2,2,2,2,2,2,1,2,2,2,2,2,2]
|
#The original value was 258.0 but my roomba has 235.0
|
WHEEL_SPAN = 235.0
|
WHEEL_DIAMETER = 72.0
|
TICK_PER_REVOLUTION = 508.8 # original 508.8
|
TICK_PER_MM = TICK_PER_REVOLUTION/(math.pi*WHEEL_DIAMETER)
|
# on my floor, a full turn is measured as sth like 450 deg
|
# add an error to the computation to account for that.
|
ANGULAR_ERROR = 360.0/450.0
|
# for printing the SCI modes
|
def modeStr( mode ):
|
""" prints a string representing the input SCI mode """
|
if mode == OFF_MODE: return 'OFF_MODE'
|
if mode == PASSIVE_MODE: return 'PASSIVE_MODE'
|
if mode == SAFE_MODE: return 'SAFE_MODE'
|
if mode == FULL_MODE: return 'FULL_MODE'
|
print 'Warning: unknown mode', mode, 'seen in modeStr'
|
return 'UNKNOWN_MODE'
|
#
|
# some module-level functions for dealing with bits and bytes
|
#
|
def _bytesOfR( r ):
|
""" for looking at the raw bytes of a sensor reply, r """
|
print 'raw r is', r
|
for i in range(len(r)):
|
print 'byte', i, 'is', ord(r[i])
|
print 'finished with formatR'
|
def _bitOfByte( bit, byte ):
|
""" returns a 0 or 1: the value of the 'bit' of 'byte' """
|
if bit < 0 or bit > 7:
|
print 'Your bit of', bit, 'is out of range (0-7)'
|
print 'returning 0'
|
return 0
|
return ((byte >> bit) & 0x01)
|
def _toBinary( val, numbits ):
|
""" prints numbits digits of val in binary """
|
if numbits == 0: return
|
_toBinary( val>>1 , numbits-1 )
|
print (val & 0x01), # print least significant bit
|
def _fromBinary( s ):
|
""" s is a string of 0's and 1's """
|
if s == '': return 0
|
lowbit = ord(s[-1]) - ord('0')
|
return lowbit + 2*_fromBinary( s[:-1] )
|
def _twosComplementInt1byte( byte ):
|
""" returns an int of the same value of the input
|
int (a byte), but interpreted in two's
|
complement
|
the output range should be -128 to 127
|
"""
|
# take everything except the top bit
|
topbit = _bitOfByte( 7, byte )
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.