Exemplo n.º 1
0
def exploration(exp):
    global started
    if not started:
        return False

    global sensors
    cur = exp.getRealTimeMap(sensors, robot.explored_map)
    if not cur[1]:
        robot.action(cur[0])
        print(robot.current)
        sensors = robot.get_sensors()
        delay_call(exploration, exp)
    else:
        inform("Exploration done!")

        inform(robot.descriptor_one())
        inform(robot.descriptor_two())

        sp = ShortestPath(robot.explored_map, robot.direction, robot.current,
                          robot.start)
        sp_list = sp.shortest_path(-1)
        sp_sequence = sp_list['trim_seq']
        sp_sequence.reverse()  # will pop from the back
        inform(sp_sequence)

        # call sp to start
        delay_call(sp_to_start, sp_sequence)
Exemplo n.º 2
0
def exploration(exp):
    global started
    if not started:
        return False

    global sensors
    cur = exp.getRealTimeMap(sensors, robot.explored_map)
    if not cur[1]:
        robot.action(cur[0])
        print(robot.current)
        sensors = robot.get_sensors()
        delay_call(exploration, exp)
    else:
        inform("Exploration done!")

        inform(robot.descriptor_one())
        inform(robot.descriptor_two())


        sp = ShortestPath(robot.explored_map, robot.direction, robot.current, robot.start)
        sp_list = sp.shortest_path(-1)
        sp_sequence = sp_list['trim_seq']
        sp_sequence.reverse() # will pop from the back
        inform(sp_sequence)

        # call sp to start
        delay_call(sp_to_start, sp_sequence)
Exemplo n.º 3
0
def start_sp_to_goal():
    global robot
    ## Don't "started" so the map won't update
    #global started
    global sp_to_goal_started
    if sp_to_goal_started:
        return
    sp_to_goal_started = True

    # # TESTING
    # exp_done = True
    # started = True
    # for i in range(robot.MAX_ROW):
    #     for j in range(robot.MAX_COL):
    #         robot.explored_map[i][j] = 1
    # for i in range(6):
    #     robot.explored_map[13][i] = 2
    # robot.explored_map[0][8] = 2
    # robot.direction = NORTH
    # send_cmd(REQ_SENSOR)
    # # END TESTING

    if not exp_done:
        return False
    #started = True
    inform("ShortestPath started!")

    sp = ShortestPath(robot.explored_map, robot.direction, robot.current,
                      robot.goal)
    sp_list = sp.shortest_path()
    sp_sequence = sp_list['trim_seq']
    sp_sequence.reverse()
    inform(sp_sequence)
    gevent.joinall([gevent.spawn(sp_to_goal, sp_sequence)])
Exemplo n.º 4
0
def start_sp_to_goal():
    global robot
    ## Don't "started" so the map won't update
    #global started
    global sp_to_goal_started
    if sp_to_goal_started:
        return
    sp_to_goal_started = True

    # # TESTING
    # exp_done = True
    # started = True
    # for i in range(robot.MAX_ROW):
    #     for j in range(robot.MAX_COL):
    #         robot.explored_map[i][j] = 1
    # for i in range(6):
    #     robot.explored_map[13][i] = 2
    # robot.explored_map[0][8] = 2
    # robot.direction = NORTH
    # send_cmd(REQ_SENSOR)
    # # END TESTING

    if not exp_done:
        return False
    #started = True
    inform("ShortestPath started!")

    sp = ShortestPath(robot.explored_map, robot.direction, robot.current, robot.goal)
    sp_list = sp.shortest_path()
    sp_sequence = sp_list['trim_seq']
    sp_sequence.reverse()
    inform(sp_sequence)
    gevent.joinall([
        gevent.spawn(sp_to_goal, sp_sequence)
    ])
Exemplo n.º 5
0
def start_sp_to_goal():
    global robot
    if not exp_done:
        return False
    sp = ShortestPath(robot.explored_map, robot.direction, robot.current, robot.goal)
    sp_list = sp.shortest_path()
    sp_sequence = sp_list['trim_seq']
    sp_sequence.reverse() # will pop from the back
    inform(sp_sequence)
    delay_call(sp_to_goal, sp_sequence)

    inform("ShortestPath started!")
Exemplo n.º 6
0
def start_sp_to_goal():
    global robot
    if not exp_done:
        return False
    sp = ShortestPath(robot.explored_map, robot.direction, robot.current,
                      robot.goal)
    sp_list = sp.shortest_path()
    sp_sequence = sp_list['trim_seq']
    sp_sequence.reverse()  # will pop from the back
    inform(sp_sequence)
    delay_call(sp_to_goal, sp_sequence)

    inform("ShortestPath started!")
Exemplo n.º 7
0
def done_exploration():
    global started
    inform("Exploration done!")

    started = False

    inform(robot.descriptor_one())
    inform(robot.descriptor_two())
    # inform(robot.msg_for_android())

    sp = ShortestPath(robot.explored_map, robot.direction, robot.current,
                      robot.start)
    sp_list = sp.shortest_path(-1)
    sp_sequence = sp_list['trim_seq']
    sp_sequence.reverse()
    inform(sp_sequence)

    # call sp to start
    gevent.joinall([gevent.spawn(sp_to_start, sp_sequence)])
Exemplo n.º 8
0
def done_exploration():
    global started
    inform("Exploration done!")

    started = False

    inform(robot.descriptor_one())
    inform(robot.descriptor_two())
    # inform(robot.msg_for_android())

    sp = ShortestPath(robot.explored_map, robot.direction, robot.current, robot.start)
    sp_list = sp.shortest_path(-1)
    sp_sequence = sp_list['trim_seq']
    sp_sequence.reverse()
    inform(sp_sequence)

    # call sp to start
    gevent.joinall([
        gevent.spawn(sp_to_start, sp_sequence)
    ])