예제 #1
0
파일: beh.py 프로젝트: kgmstwo/THBCP
def bump_beh(tv):
    # act on the information from the message.  Note that this might be 
    # information stored from the last message we received, because message 
    # information remains active for a while
    global bump_time
    global bump_state
    bump_bits = rone.bump_sensors_get_value()

    # check bump sensors
    if bump_left_get_value(bump_bits):
        bump_state = BUMP_STATE_TURN_RIGHT
        bump_time = sys.time() + BUMP_TIME_SIDE 
    elif bump_right_get_value(bump_bits):
        bump_state = BUMP_STATE_TURN_LEFT
        bump_time = sys.time() + BUMP_TIME_SIDE 
    elif bump_front_get_value(bump_bits):
        bump_state = BUMP_STATE_ROTATE
        bump_time = sys.time() + BUMP_TIME_ROTATE
    
    if sys.time() > bump_time:
        bump_state = BUMP_STATE_IDLE

    # control the robot
    beh_out = BEH_INACTIVE
    if bump_state == BUMP_STATE_TURN_RIGHT:
        beh_out = (0, -tv * TVRV_RATIO, True)
    elif bump_state == BUMP_STATE_TURN_LEFT:
        beh_out = (0, tv * TVRV_RATIO, True)
    elif bump_state == BUMP_STATE_ROTATE:
        beh_out = (0, tv * TVRV_RATIO, True)
        
    return beh_out
예제 #2
0
def bump_beh(tv):
    # act on the information from the message.  Note that this might be
    # information stored from the last message we received, because message
    # information remains active for a while
    global bump_time
    global bump_state
    bump_bits = rone.bump_sensors_get_value()

    # check bump sensors
    if bump_left_get_value(bump_bits):
        bump_state = BUMP_STATE_TURN_RIGHT
        bump_time = sys.time() + BUMP_TIME_SIDE
    elif bump_right_get_value(bump_bits):
        bump_state = BUMP_STATE_TURN_LEFT
        bump_time = sys.time() + BUMP_TIME_SIDE
    elif bump_front_get_value(bump_bits):
        bump_state = BUMP_STATE_ROTATE
        bump_time = sys.time() + BUMP_TIME_ROTATE

    if sys.time() > bump_time:
        bump_state = BUMP_STATE_IDLE

    # control the robot
    beh_out = BEH_INACTIVE
    if bump_state == BUMP_STATE_TURN_RIGHT:
        beh_out = (0, -tv * TVRV_RATIO, True)
    elif bump_state == BUMP_STATE_TURN_LEFT:
        beh_out = (0, tv * TVRV_RATIO, True)
    elif bump_state == BUMP_STATE_ROTATE:
        beh_out = (0, tv * TVRV_RATIO, True)

    return beh_out
예제 #3
0
파일: beh.py 프로젝트: kgmstwo/THBCP
def bump_angle_get():
    bumps_raw = rone.bump_sensors_get_value()
    if bumps_raw == 0x00:
        return None
    else:
        sum_x = 0
        sum_y = 0
        for i in range(8):
            pressed = ((bumps_raw >> i) & 0x01) > 0
            if pressed:
                sum_y+= math.sin(SENSOR_ANGLES[i])
                sum_x+= math.cos(SENSOR_ANGLES[i])
        bump_angle = math2.normalize_angle(math.atan2(sum_y, sum_x))        
    return bump_angle
예제 #4
0
def bump_angle_get():
    bumps_raw = rone.bump_sensors_get_value()
    if bumps_raw == 0x00:
        return None
    else:
        sum_x = 0
        sum_y = 0
        for i in range(8):
            pressed = ((bumps_raw >> i) & 0x01) > 0
            if pressed:
                sum_y += math.sin(SENSOR_ANGLES[i])
                sum_x += math.cos(SENSOR_ANGLES[i])
        bump_angle = math2.normalize_angle(math.atan2(sum_y, sum_x))
    return bump_angle
예제 #5
0
def bump():
    bump_bits = rone.bump_sensors_get_value()
    return bump_bits != 0x00
예제 #6
0
def bump_front():
    # Returns true if any of the front 6 out of 8 sensors are triggered
    bump_bits = rone.bump_sensors_get_value()
    return (bump_bits & 231) > 0
예제 #7
0
파일: spring.py 프로젝트: kgmstwo/THBCP
def bump():
    bump_bits = rone.bump_sensors_get_value()
    return bump_bits != 0x00
예제 #8
0
파일: spring.py 프로젝트: kgmstwo/THBCP
def bump_front():
    # Returns true if any of the front 6 out of 8 sensors are triggered
    bump_bits = rone.bump_sensors_get_value()
    return (bump_bits & 231) > 0