Пример #1
0
def main():
    try:
        agent_config = AgentConfig.parse_file(Path("./ROAR_Jetson/configurations/agent_configuration.json"))
        jetson_config = JetsonConfig.parse_file(Path("./ROAR_Jetson/configurations/configuration.json"))

        try:
            prepare(jetson_config=jetson_config)
        except Exception as e:
            logging.error(f"Ignoring Error during setup: {e}")
        agent = PIDAgent(vehicle=Vehicle(), agent_settings=agent_config, should_init_default_cam=False)
        jetson_runner = JetsonRunner(agent=agent, jetson_config=jetson_config)
        jetson_runner.start_game_loop(use_manual_control=False)
    except Exception as e:
        print(f"Something bad happened {e}")
Пример #2
0
def main():
    agent_config = AgentConfig.parse_file(
        Path("./ROAR_Sim/configurations/agent_configuration.json"))
    carla_config = CarlaConfig.parse_file(
        Path("./ROAR_Sim/configurations/configuration.json"))

    carla_runner = CarlaRunner(carla_settings=carla_config,
                               agent_settings=agent_config,
                               npc_agent_class=PurePursuitAgent)
    try:
        my_vehicle = carla_runner.set_carla_world()
        agent = PIDAgent(vehicle=my_vehicle, agent_settings=agent_config)
        carla_runner.start_game_loop(agent=agent, use_manual_control=False)
    except Exception as e:
        logging.error(f"Something bad happened during initialization: {e}")
        carla_runner.on_finish()
        logging.error(f"{e}. Might be a good idea to restart Server")
Пример #3
0
def main():
    """Starts game loop"""
    carla_config = CarlaConfig.parse_file(Path("./ROAR_Sim/configurations/configuration.json"))
    agent_config = AgentConfig.parse_file(Path("./ROAR_Sim/configurations/agent_configuration.json"))

    """
    Pit Stop:
        Use different kinds of 'set' functions at PitStop to tune/fix your own car!
    """
    pitstop = PitStop(carla_config, agent_config)
    pitstop.set_carla_version(version = "0.9.9")
    pitstop.set_carla_sync_mode(False)
    pitstop.set_autopilot_mode(True)
    pitstop.set_car_color(CarlaCarColor(r = 255,g = 200,b = 00,a = 255))
    pitstop.set_num_laps(num=1)
    pitstop.set_output_data_folder_path("./data/output")
    pitstop.set_output_data_file_name(time.strftime("%Y%m%d-%H%M%S-") + "map-waypoints")
    pitstop.set_max_speed(speed = 200)
    pitstop.set_target_speed(speed = 30)
    print(agent_config.target_speed, " target speed")
    pitstop.set_steering_boundary(boundary = (-1.0, 1.0))
    pitstop.set_throttle_boundary(boundary = (0, 0.5))
    pitstop.set_waypoints_look_ahead_values(values={
                                                    "60": 5,
                                                    "80": 10,
                                                    "120": 20,
                                                    "180": 50})
    pid_value = {
                    "longitudinal_controller": {
                        "40": {
                            "Kp": 0.8,
                            "Kd": 0.2,
                            "Ki": 0
                        },
                        "60": {
                            "Kp": 0.5,
                            "Kd": 0.2,
                            "Ki": 0
                        },
                        "150": {
                            "Kp": 0.2,
                            "Kd": 0.1,
                            "Ki": 0.1
                            }
                    },
                    "latitudinal_controller": {
                        "60": {
                            "Kp": 0.8,
                            "Kd": 0.1,
                            "Ki": 0.1
                        },
                        "100": {
                            "Kp": 0.6,
                            "Kd": 0.2,
                            "Ki": 0.1
                        },
                        "150": {
                            "Kp": 0.5,
                            "Kd": 0.2,
                            "Ki": 0.1
                            }
                    }
                }
    pitstop.set_pid_values(pid_value)

    """Passing configurations to Carla and Agent"""
    carla_runner = CarlaRunner(carla_settings=carla_config, # ROAR Academy: fine
                               agent_settings=agent_config, # ROAR Academy: fine
                               npc_agent_class=PurePursuitAgent)
    try:
        my_vehicle = carla_runner.set_carla_world()

        agent = PIDAgent(vehicle=my_vehicle, agent_settings=agent_config)
        # agent = WaypointGeneratigAgent(vehicle=my_vehicle, agent_settings=agent_config)
        
        carla_runner.start_game_loop(agent=agent, use_manual_control=False) # for PIDAgent
        # carla_runner.start_game_loop(agent=agent, use_manual_control=True) # for WaypointGeneratingAgent
    
    except Exception as e:
        logging.error(f"Something bad happened during initialization: {e}")
        carla_runner.on_finish()
        logging.error(f"{e}. Might be a good idea to restart Server")