Commit cd299969 authored by Edmond Irani Liu's avatar Edmond Irani Liu 🌊
Browse files

change placement of motion primitive generator/

parent 28ff4ce0
# paths can be either relative or absolute, units shown in brackets []
outputs:
# output directory for generated motion primitives
output_directory: ../motion_primitives/
vehicles:
# id of vehicle. 1: FORD_ESCORT, 2: BMW_320i, 3: VW_VANAGON
veh_type_id: 2
primitives:
# time length of trajectory [s]
T: 0.5
# time step for forward state simulation [s]
# note that commonroad scenarios have a discrete time step dt of 0.1 seconds; for higher accuracy
# of forward simulation, here dt is set to 0.05. the simulated states will be downsampled afterwards
dt_simulation: 0.05
# sampling range [m/s]
velocity_sample_min: 0.0
velocity_sample_max: 20.0
# for a step of 1.0 m/s, num = (v_max - v_min) / 1.0 + 1
num_sample_velocity: 21
# steer to one side only, we can mirror the primitives afterwards [rad]
steering_angle_sample_min: 0.0
# if steering_angle_sample_max set to 0, it will be assigned the maximum value
# given by the selected vehicle parameter
steering_angle_sample_max: 0.0
num_sample_steering_angle: 9
sample_trajectories:
# number of segments of trajectory
num_segment_trajectory: 10
# number of sample trajectories to be generated
num_simulations: 2
%% Cell type:markdown id: tags:
# Tutorial: Batch Processing
%% Cell type:markdown id: tags:
This tutorial shows how [Batch Processing](https://gitlab.lrz.de/tum-cps/commonroad_io/tree/batch_processing) is used to solve for solutions to different scenarios. It is composed of
* a configuration file (.yaml format),
* some helper functions,
* and the script below to call the planer function.
Before proceeding, you should make sure the configuration file is set correctly. Here are the explanation for each of the parameters in the configuration file:
* **input_path**: input directory of CommonRoad scenarios that you indend to solve.
* **output_path**: output directory of the solution files.
* **overwrite**: flag to determine whether the existing solution files should be overwritten.
* **timeout**: timeout time for your motion planner, unit in seconds
* **motion_planner_path**: directory where the module containing the function to execute your motion planner is located
* **motion_planner_module_name**: name of the module that contains the function to execute your motion planner
* **motion_planner_function_name**: name of the function that executes your motion planner
* **default**: parameters specified under this section will be applied to all scenarios. If you wish to specify a different paramter for specific scenarios, simply copy the section and replace 'default' with the id of your scenario.
* **vehicle_model**: model of the vehicle, valid values: **PM, KS, ST and MB**. Please refer to [Vehicle Models](https://gitlab.lrz.de/tum-cps/commonroad-vehicle-models/blob/master/vehicleModels_commonRoad.pdf) for more information.
* **vehicle_type**: type of the vehicle, valid values: **FORD_ESCORT, BMW_320i and VW_VANAGON**.
* **cost_function**: identifier of cost function. Please refer to [Cost Functions](https://gitlab.lrz.de/tum-cps/commonroad-cost-functions/blob/master/costFunctions_commonRoad.pdf) for more information.
* **planner_id**: id of the planner that is used to solve for solutions. in this example, 1 = Greedy Best First Search, 2 = A*, else = Your own planner.
* **planning_problem_idx**: planner problem index. for cooperative scenarios: 0, 1, 2, ..., otherwise: 0
* **max_tree_depth**: maximum permissible depth of the search tree
Note: the paths can be either **relative** to this script or **absolute**.
Simply run the following script to start batch processing. The results here is just exemplary, you will see different output as your configuration varies.
%% Cell type:code id: tags:
``` python
# import helper functions
import helper_functions
# specify path to configuration file
path_file_config = "../configuration/batch_processing_config.yaml"
# load configuration file
configuration = helper_functions.load_configuration(path_file_config)
# get target function
function_target = helper_functions.get_target_function(configuration)
# get a list of scenario files
list_files_input = helper_functions.get_input_files(configuration)
# get length of the list and time before timeout
num_files = len(list_files_input)
time_timeout = configuration['timeout']
print("Total number of files to be processed: {}".format(num_files))
print("Timeout setting: {} seconds\n".format(time_timeout))
count_processed = 0
# iterate through scenarios
for file_scenario in list_files_input:
count_processed += 1
print("Processing file No. {} / {}. Scenario ID: {}".format(count_processed, num_files, file_scenario[:-4]))
# parse the scenario file
result_parse = helper_functions.parse_scenario_file(configuration, file_scenario)
# execute target function
solution_trajectories = helper_functions.execute_target_function(function_target, result_parse, time_timeout)
# save solution file
helper_functions.save_solution(configuration, solution_trajectories, result_parse)
print("\n=========================================================\n")
```
%% Output
Total number of files to be processed: 10
Timeout setting: 60 seconds
Processing file No. 1 / 10. Scenario ID: RUS_Bicycle-3_3_T-1
Reading motion primitives...
Automata created.
Number of loaded primitives: 3066
Planning..
=========> Motion planner timeout.
<FAILURE> Solution for planning problem with ID=9 is not provided. Skipped.
=========================================================
Processing file No. 2 / 10. Scenario ID: RUS_Bicycle-2_2_T-1
Reading motion primitives...
Automata created.
Number of loaded primitives: 3066
Planning..
Solving this scenario took 4.07 seconds
Planning finished.
<SUCCESS> Solution written.
=========================================================
Processing file No. 3 / 10. Scenario ID: RUS_Bicycle-1_2_T-1
Reading motion primitives...
Automata created.
Number of loaded primitives: 3066
Planning..
Solving this scenario took 3.46 seconds
Planning finished.
<SUCCESS> Solution written.
=========================================================
Processing file No. 4 / 10. Scenario ID: RUS_Bicycle-3_1_T-1
Reading motion primitives...
Automata created.
Number of loaded primitives: 3066
Planning..
Solving this scenario took 25.81 seconds
Planning finished.
<SUCCESS> Solution written.
=========================================================
Processing file No. 5 / 10. Scenario ID: RUS_Bicycle-2_1_T-1
Reading motion primitives...
Automata created.
Number of loaded primitives: 3066
Planning..
Solving this scenario took 3.4 seconds
Planning finished.
<SUCCESS> Solution written.
=========================================================
Processing file No. 6 / 10. Scenario ID: RUS_Bicycle-5_1_T-1
Reading motion primitives...
Automata created.
Number of loaded primitives: 3066
Planning..
Solving this scenario took 5.95 seconds
Planning finished.
<SUCCESS> Solution written.
=========================================================
Processing file No. 7 / 10. Scenario ID: RUS_Bicycle-4_2_T-1
Reading motion primitives...
Automata created.
Number of loaded primitives: 3066
Planning..
=========> Motion planner timeout.
<FAILURE> Solution for planning problem with ID=15 is not provided. Skipped.
=========================================================
Processing file No. 8 / 10. Scenario ID: RUS_Bicycle-3_2_T-1
Reading motion primitives...
Automata created.
Number of loaded primitives: 3066
Planning..
Solving this scenario took 0.65 seconds
Planning finished.
<FAILURE> Solution for planning problem with ID=9 is not provided. Skipped.
=========================================================
Processing file No. 9 / 10. Scenario ID: RUS_Bicycle-1_1_T-1
Reading motion primitives...
Automata created.
Number of loaded primitives: 3066
Planning..
Solving this scenario took 3.1 seconds
Planning finished.
<SUCCESS> Solution written.
=========================================================
Processing file No. 10 / 10. Scenario ID: RUS_Bicycle-4_1_T-1
Reading motion primitives...
Automata created.
Number of loaded primitives: 3066
Planning..
=========> Motion planner timeout.
<FAILURE> Solution for planning problem with ID=15 is not provided. Skipped.
=========================================================
%% Cell type:code id: tags:
``` python
```