Module Common

File Reader

CommonRoadFileReader class

class commonroad.common.file_reader.CommonRoadFileReader(filename)[source]

Class which reads CommonRoad XML-files. The XML-files are composed of (1) a formal representation of the road network, (2) static and dynamic obstacles, (3) the planning problem of the ego vehicle(s).

open()[source]

Reads a CommonRoad XML-file.

Return type:Tuple[Scenario, PlanningProblemSet]
Returns:the scenario containing the road network and the obstacles and the planning problem set containing the planning problems—initial states and goal regions–for all ego vehicles.
open_lanelet_network()[source]

Reads the lanelet network of a CommonRoad XML-file.

Return type:LaneletNetwork
Returns:object of class LaneletNetwork

File Writer

File Writer for scenarios to commonroad xml-format

CommonRoadFileWriter class

class commonroad.common.file_writer.CommonRoadFileWriter(scenario, planning_problem_set, author, affiliation, source, tags, decimal_precision=8)[source]
static check_validity_of_commonroad_file(commonroad_str)[source]

Check the validity of a generated xml_string in terms of commonroad with an existing XSD schema. Throw an error if it is not valid.

Args:
commonroad_str: XML formatted string which should be checked.
write_scenario_to_file(filename=None, overwrite_existing_file=<OverwriteExistingFile.ASK_USER_INPUT: 0>)[source]

Write a scenario without planning-problem. If file already exists, it will be overwritten of skipped.

Parameters:
  • filename (Optional[str]) – filename of the xml output file. If ‘None’, the Benchmark ID is taken
  • OverwriteExistingFile – Specify whether an already existing file should be overwritten or skipped
Returns:

None

write_scenario_to_file_io(file_io)[source]

Write a scenario without planning-problem to file_io.

Args:
file_io: File to write to.
write_to_file(filename=None, overwrite_existing_file=<OverwriteExistingFile.ASK_USER_INPUT: 0>)[source]

Write a scenario including planning-problem. If file already exists, it will be overwritten of skipped

Parameters:
  • filename (Optional[str]) – filename of the xml output file. If ‘None’, the Benchmark ID is taken
  • overwrite_existing_file (OverwriteExistingFile) – Specify whether an already existing file should be overwritten or skipped
Returns:

write_to_file_io(file_io)[source]

Write a scenario including planning-problem to file_io.

Args:
file_io: File to write to.

OverwriteExistingFile class

class commonroad.common.file_writer.OverwriteExistingFile[source]

Specifies whether an existing file will be overwritten or skipped

ASK_USER_INPUT = 0
ALWAYS = 1
SKIP = 2

Solution Writer

Solution writer for uploading motion plans to commonroad.in.tum.de

VehicleType class

class commonroad.common.solution_writer.VehicleType[source]

An enumeration.

FORD_ESCORT = 1
BMW_320i = 2
VW_VANAGON = 3

VehicleModel class

class commonroad.common.solution_writer.VehicleModel[source]

An enumeration.

PM = 0
ST = 1
KS = 2
MB = 3

Detailed information about the listed vehicle models in Vehicle Model Documentation.

CostFunction class

class commonroad.common.solution_writer.CostFunction[source]

An enumeration.

JB1 = 0
SA1 = 1
WX1 = 2
SM1 = 3
SM2 = 4
SM3 = 5

Detailed information about the listed cost functions in Cost Function Documentation.

CommonRoadSolutionWriter class

class commonroad.common.solution_writer.CommonRoadSolutionWriter(output_dir, scenario_id, step_size, vehicle_type=<VehicleType.FORD_ESCORT: 1>, vehicle_model=<VehicleModel.KS: 2>, cost_function=<CostFunction.JB1: 0>)[source]
add_solution_input_vector(input_vector, planning_problem_id)[source]

Add an input vector to the xml tree

Note: the entries of the input vector is not checked. It is assumed to contain the correct states in correct order: For PointMass Model: x_acceleration, y_acceleration, time (not time_step!). For Other Models: acceleration, steering_angle_speed, time (not time_step!). The cost function is not checked for existence.

Parameters:
  • input_vector (ndarray) – list of states, each state is a list of the three above named values
  • planning_problem_id (int) – Id of the planning problem that is solved with the trajectory.
add_solution_trajectory(trajectory, planning_problem_id)[source]

Add a trajectory to the xml tree.

Parameters:
  • trajectory (Trajectory) – Trajectory with states for the given vehicle_model.
  • planning_problem_id (int) – Id of the planning problem that is solved with the trajectory.
Returns:

Error, if not enough states for the given vehicle model

write_to_file(overwrite=False)[source]

Write xml file to ouput_dir

Parameters:overwrite (bool) – if true, existing files are overwritten, else not

Util

Interval class

class commonroad.common.util.Interval(start, end)[source]

AngleInterval class

class commonroad.common.util.AngleInterval(start, end)[source]

Allows only angles from interval [-2pi,2pi]