Exemple #1
0
    def _run_scenarios(self):
        """
        Run conventional scenarios (e.g. implemented using the Python API of ScenarioRunner)
        """
        result = False
        # Setup and run the scenarios for repetition times
        for _ in range(int(self._args.repetitions)):

            # Load the scenario configurations provided in the config file
            scenario_configurations = None
            scenario_config_file = ScenarioConfigurationParser.find_scenario_config(
                self._args.scenario, self._args.configFile)
            if scenario_config_file is None:
                print("Configuration for scenario {} cannot be found!".format(
                    self._args.scenario))
                continue

            scenario_configurations = ScenarioConfigurationParser.parse_scenario_configuration(
                scenario_config_file, self._args.scenario)

            # Execute each configuration
            for config in scenario_configurations:
                result = self._load_and_run_scenario(config)

            self._cleanup()
        return result
    def _run_scenarios(self, args):
        """
        Run conventional scenarios (e.g. implemented using the Python API of ScenarioRunner)
        """

        # Setup and run the scenarios for repetition times
        for _ in range(int(args.repetitions)):

            # Load the scenario configurations provided in the config file
            scenario_configurations = None
            scenario_config_file = ScenarioConfigurationParser.find_scenario_config(
                args.scenario, args.configFile)
            if scenario_config_file is None:
                print("Configuration for scenario {} cannot be found!".format(
                    args.scenario))
                continue

            scenario_configurations = ScenarioConfigurationParser.parse_scenario_configuration(
                scenario_config_file, args.scenario)

            # Execute each configuration
            for config in scenario_configurations:
                self._load_and_run_scenario(args, config)

            self._cleanup(ego=(not args.waitForEgo))

            print("No more scenarios .... Exiting")
    def run(self, args):
        scenario_config_file = ScenarioConfigurationParser.find_scenario_config(args.scenario, args.configFile) # xml file

        ####################################
        print(args.configFile)
        print(scenario_config_file)
        print(args.scenario)
        scenario_configurations = parse_rss_scenario_configuration(scenario_config_file, args.scenario)
        config = scenario_configurations[0] # since we work only with one scenario!

	# Defaults except for ones we set
        # Lon accel max: 3.500
        # Lon brake max: 8.000
        # Lon brake min: 4.000
        # Lon brake min correct: 0.100
        # Lat accel max: 0.200
        # Lat brake min: 0.800
        # Lat fluct mar: 0.000
        # Response time: 0.200

        g = 9.8
        rss_params = {}
        rss_params['alpha_lon_accel_max'] = 0.5*g
        rss_params['alpha_lon_brake_max'] = 0.7*g
        rss_params['response_time'] = 0.2
        rss_params['alpha_lon_brake_min'] = 0.5*g
        print('RSS params: %s' % rss_params)

        # Load the world once
        self.load_world(config.town)

        settings = self.world.get_settings()
        settings.fixed_delta_seconds = 0.015
        self.world.apply_settings(settings)

        # Set the sun to be directly overhead
        weather = carla.WeatherParameters(sun_altitude_angle=90)
        self.world.set_weather(weather)

        return self.simulate(config, args, rss_params)
Exemple #4
0
    def run(self, args):
        scenario_config_file = ScenarioConfigurationParser.find_scenario_config(
            args.scenario, args.configFile)  # xml file

        num_simult_runs = 1
        nruns = 20
        ####################################

        search_names = [
            'alpha_lon_accel_max', 'alpha_lon_brake_max',
            'alpha_lon_brake_min', 'response_time', 'alpha_lat_accel_max',
            'alpha_lat_brake_min', 'lateral_fluctuation_margin'
        ]  #, 'alpha_lon_brake_min_correct']

        # extra params for lateral and opposite directions :
        # 'alpha_lat_brake_min', 'lateral_fluctuation_margin', 'alpha_lon_brake_min_correct', 'alpha_lat_accel_max'

        ## initial values ?
        alpha_lon_accel_max = 3.5
        response_time = 1.0
        alpha_lon_brake_max = 6.0
        alpha_lon_brake_min = 3.5
        alpha_lat_accel_max = 0.1
        alpha_lat_brake_min = 0.1
        lateral_fluctuation_margin = 0.1
        alpha_lon_brake_min_correct = 1.0

        # alpha_lon_accel_max = 4.01
        # response_time       = 0.53
        # alpha_lon_brake_max = 8.03
        # alpha_lon_brake_min = 4.64
        # alpha_lat_accel_max = 0.43
        # alpha_lat_brake_min = 0.96
        # lateral_fluctuation_margin = 0.07
        # alpha_lon_brake_min_correct = 1.76

        ####################################
        x0, searchSpace = RssParamsInit().getInit(
            search_names,
            alpha_lon_accel_max=alpha_lon_accel_max,
            response_time=response_time,
            alpha_lon_brake_max=alpha_lon_brake_max,
            alpha_lon_brake_min=alpha_lon_brake_min,
            alpha_lat_accel_max=alpha_lat_accel_max,
            alpha_lat_brake_min=alpha_lat_brake_min,
            lateral_fluctuation_margin=lateral_fluctuation_margin)
        # ,                                            alpha_lon_brake_min_correct = alpha_lon_brake_min_correct)

        # search_names = ['alpha_lon_accel_max', 'response_time']
        # alpha_lon_accel_max = 3.5
        # response_time = 1.0
        # ####################################
        # x0, searchSpace = RssParamsInit().getInit(search_names,
        #                                            alpha_lon_accel_max = alpha_lon_accel_max,
        #                                            response_time = response_time)
        print('X0 = %s' % x0)
        print('SearchSpace = %s\n' % searchSpace)
        #-------------------------------
        X0 = []
        for _ in range(num_simult_runs):
            X0.append(x0)
        ####################################

        ####################################
        def ff(x):
            scenario_configurations = parse_rss_scenario_configuration(
                scenario_config_file, args.scenario)
            config = scenario_configurations[
                0]  # since we work only with one scenario!

            rss_params = defineRssParams(x, search_names)
            rss_params['alpha_lon_brake_min_correct'] = 0.1
            print('RSS params: %s' % rss_params)

            return self.simulate(config, args, rss_params)

        # reproduce trajs
        '''
        for i in range(10):
            self.filename_traj = os.path.join(RES_FOLDER, ('trajectory'+str(i)+'.csv'))
            ff(x0)
        '''
        best_x_history, best_f_history, x_history, f_history, accept_x_history, accept_flags = annealing.runFunc(
            ff, X0, searchSpace, nruns, num_simult_runs, RES_FOLDER)