예제 #1
0
def range_test():
    io = IO()
    while True:
        io.go_forward()
        # time.sleep(5)
        # io._IO__move()
        # debug_print(io.move_degrees)
        # io.move_degrees += 10
        time.sleep(5)
예제 #2
0
def Main():
    map_var = Map(Ghost_mapping_type.none)
    io = IO()
    logic = Logic(map_var)
    button = Button()
    saver = Map_saver(map_var, button)
    saver.wait_for_load()
    print("READY")
    motors = {
        Moves.fwd: lambda: io.go_forward(),
        Moves.left: lambda: io.go_left(),
        Moves.right: lambda: io.go_right(),
        Moves.back: lambda: io.go_back()
    }
    mapping = {
        Moves.fwd: lambda: map_var.go_forward(),
        Moves.left: lambda: map_var.go_left(),
        Moves.right: lambda: map_var.go_right(),
        Moves.back: lambda: map_var.go_back()
    }
    motors[Moves.fwd]()
    mapping[Moves.fwd]()
    while (True):
        clr_sensor = io.directions_free()
        us_sensor = io.ghost_distance()
        map_var.write_sensor_values(clr_sensor, us_sensor)
        debug_print(map_var)
        move = logic.get_next_move()
        debug_print(map_var)
        switch[move]()
        if button.any():
            saver.wait_for_load()

        ok = motors[move]()
        if (ok is False):
            io.after_crash()
            map_var.rotation += int(move)
            continue
        elif (ok is None):
            saver.wait_for_load()
            continue
        mapping[move]()
        saver.save_map()
예제 #3
0
def test():
    io = IO()
    while True:
        io._IO__turn_right()
        time.sleep(1)
        io._IO__turn_left()
        time.sleep(1)
예제 #4
0
def setup_configuration(cfg):
    '''Setup IO and plants according to configuration file'''

    # Create dict containing all IO objects
    io_object_dict = dict()
    for io_name, specification in cfg.get('io').items():
        io = IO(io_name, specification)
        io_object_dict.update({io_name: io})

    for pump_name, specification in cfg.get('pump').items():
        pump = Pump(pump_name, specification, io_object_dict)
        io_object_dict.update({pump_name: pump})

    # Create dict containing all plant objects
    plant_object_dict = dict()
    for plant_name, specification in cfg.get('plants').items():
        plant = Plant(plant_name, specification, io_object_dict)
        plant_object_dict.update({plant_name: plant})

    return plant_object_dict
예제 #5
0
def sensors_test():
    io = IO()
    for _ in range(8):
        io.read_sensors()
        debug_print("us", io.ultrasonic_sensor_values)
        debug_print("color", io.color_sensor_values)
예제 #6
0
def reg_test():
    io = IO()
    while True:
        io._IO__move_reg()
        io.read_sensors()
예제 #7
0
def touch_sensor_test():
    io = IO()
    val = False
    while True:
        debug_print(io.go_forward())
        time.sleep(1)
예제 #8
0
def io_test():
    io = IO()
    io.go_forward()
    io.read_sensors()
    io.go_left()
    io.read_sensors()
    io.go_forward()
    io.read_sensors()
    io.go_back()
    io.read_sensors()
    io.go_forward()
    io.read_sensors()
    io.go_right()