Ejemplo n.º 1
0
    away_comms = Comms(gamestate, AWAY_TEAM, True)
    simulator = Simulator(gamestate)
    home_strategy = Strategy(gamestate, HOME_TEAM)
    away_strategy = Strategy(gamestate, AWAY_TEAM)

    # choose which modules to run based on run conditions
    print('Spinning up Threads...')
    if IS_SIMULATION:
        # spin up simulator to replace actual vision data + comms
        simulator.start_simulating(SIMULATION_SETUP, SIMULATION_LOOP_SLEEP)
    else:
        # spin up ssl-vision data polling to update gamestate
        vision.start_updating(VISION_LOOP_SLEEP)
        if not VISION_ONLY:
            # spin up comms to send commands to robots
            home_comms.start_sending(COMMS_SEND_LOOP_SLEEP)
            # home_comms.start_receiving(COMMS_RECEIVE_LOOP_SLEEP)
            if CONTROL_BOTH_TEAMS:
                away_comms.start_sending(COMMS_SEND_LOOP_SLEEP)
                # away_comms.start_sending(COMMS_RECEIVE_LOOP_SLEEP)
        refbox.start_updating()
    # spin up strategy threads to control the robots
    home_strategy.start_controlling(HOME_STRATEGY, CONTROL_LOOP_SLEEP)
    if CONTROL_BOTH_TEAMS:
        away_strategy.start_controlling(AWAY_STRATEGY, CONTROL_LOOP_SLEEP)
    # initialize visualizer to show robots on screen
    visualizer = Visualizer(gamestate, home_strategy, away_strategy)
    # start the game  - now everything should be going
    gamestate.start_game(GAME_LOOP_SLEEP)

    # Prepare to be interrupted by user