コード例 #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)
コード例 #2
0
ファイル: server.py プロジェクト: kenrick95/mdp-algo
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)
コード例 #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)])
コード例 #4
0
ファイル: server_pi.py プロジェクト: kenrick95/mdp-algo
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)
    ])
コード例 #5
0
ファイル: server.py プロジェクト: kenrick95/mdp-algo
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!")
コード例 #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!")
コード例 #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)])
コード例 #8
0
ファイル: server_pi.py プロジェクト: kenrick95/mdp-algo
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)
    ])