Module Scenario

Scenario

Scenario class

class commonroad.scenario.scenario.Scenario(dt, scenario_id=<commonroad.scenario.scenario.ScenarioID object>, author=None, tags=None, affiliation=None, source=None, location=None)[source]

Class which describes a Scenario entity according to the CommonRoad specification. Each scenario is described by a road network consisting of lanelets (see commonroad.scenario.lanelet.LaneletNetwork) and a set of obstacles which can be either static or dynamic (see commonroad.scenario.obstacle.Obstacle).

property dt: float

Global time step size of the time-discrete scenario.

property lanelet_network: LaneletNetwork

Road network composed of lanelets.

property dynamic_obstacles: List[DynamicObstacle]

Returns a list of all dynamic obstacles in the scenario.

property static_obstacles: List[StaticObstacle]

Returns a list of all static obstacles in the scenario.

property obstacles: List[Obstacle | StaticObstacle | DynamicObstacle | EnvironmentObstacle | PhantomObstacle]

Returns a list of all obstacles roles in the scenario.

property environment_obstacle: List[EnvironmentObstacle]

Returns a list of all environment obstacles in the scenario.

property phantom_obstacle: List[PhantomObstacle]

Returns a list of all phantom obstacles in the scenario.

add_objects(scenario_object, lanelet_ids=None)[source]

Function to add objects, e.g., lanelets, dynamic and static obstacles, to the scenario.

Parameters:
Raises:

ValueError – a value error is raised if the type of scenario_object is invalid.

remove_obstacle(obstacle)[source]

Removes an obstacle or a list of obstacles from the scenario. If the obstacle ID is not assigned, a warning message is given.

Parameters:

obstacle (Union[Obstacle, DynamicObstacle, PhantomObstacle, EnvironmentObstacle, StaticObstacle, List[Union[Obstacle, StaticObstacle, DynamicObstacle, EnvironmentObstacle, PhantomObstacle]]]) – obstacle to be removed

erase_lanelet_network()[source]

Removes all elements from lanelet network.

replace_lanelet_network(lanelet_network)[source]

Removes lanelet network with all its elements from the scenario and replaces it with new lanelet network.

Parameters:

lanelet_network (LaneletNetwork) – new lanelet network

remove_hanging_lanelet_members(remove_lanelet)[source]

After removing lanelet(s) from remove_lanelet, this function removes all traffic lights and signs that are not used by other lanelets.

Parameters:

remove_lanelet (Union[List[Lanelet], Lanelet]) – Lanelet that should be removed from scenario.

remove_lanelet(lanelet, referenced_elements=True)[source]

Removes a lanelet or a list of lanelets from a scenario.

Parameters:
  • lanelet (Union[List[Lanelet], Lanelet]) – Lanelet which should be removed from scenario.

  • referenced_elements (bool) – Boolean indicating whether references of lanelet should also be removed.

remove_traffic_sign(traffic_sign)[source]

Removes a traffic sign or a list of traffic signs from the scenario.

Parameters:

traffic_sign (Union[List[TrafficSign], TrafficSign]) – Traffic sign which should be removed from scenario.

remove_traffic_light(traffic_light)[source]

Removes a traffic sign or a list of traffic signs from the scenario.

Parameters:

traffic_light (Union[List[TrafficLight], TrafficLight]) – Traffic light which should be removed from scenario.

remove_intersection(intersection)[source]

Removes an intersection or a list of intersections from the scenario.

Parameters:

intersection (Union[List[Intersection], Intersection]) – Intersection which should be removed from scenario.

generate_object_id()[source]

Generates a unique ID which is not assigned to any object in the scenario.

Return type:

int

Returns:

unique object ID

occupancies_at_time_step(time_step, obstacle_role=None)[source]

Returns the occupancies of all static and dynamic obstacles at a specific time step.

Parameters:
  • time_step (int) – occupancies of obstacles at this time step

  • obstacle_role (Optional[ObstacleRole]) – obstacle role as defined in CommonRoad, e.g., static or dynamic

Return type:

List[Occupancy]

Returns:

list of occupancies of the obstacles

obstacle_by_id(obstacle_id)[source]

Finds an obstacle for a given obstacle_id

Parameters:

obstacle_id (int) – ID of the queried obstacle

Return type:

Union[Obstacle, DynamicObstacle, StaticObstacle, None]

Returns:

the obstacle object if the ID exists, otherwise None

obstacles_by_role_and_type(obstacle_role=None, obstacle_type=None)[source]

Filters the obstacles by their role and type.

Parameters:
  • obstacle_role (Optional[ObstacleRole]) – obstacle role as defined in CommonRoad, e.g., static or dynamic

  • obstacle_type (Optional[ObstacleType]) – obstacle type as defined in CommonRoad, e.g., car, train, or bus

Return type:

List[Obstacle]

Returns:

list of all obstacles satisfying the given obstacle_role and obstacle_type

obstacles_by_position_intervals(position_intervals, obstacle_role=(<ObstacleRole.DYNAMIC: 'dynamic'>, <ObstacleRole.STATIC: 'static'>), time_step=None)[source]

Returns obstacles which center is located within in the given x-/y-position intervals.

Parameters:
  • position_intervals (List[Interval]) – list of intervals for x- and y-coordinates [interval_x, interval_y]

  • obstacle_role (Tuple[ObstacleRole]) – tuple containing the desired obstacle roles

  • time_step (int) – Time step of interest.

Return type:

List[Obstacle]

Returns:

list of obstacles in the position intervals

obstacle_states_at_time_step(time_step)[source]

Returns all obstacle states which exist at a provided time step.

Parameters:

time_step (int) – time step of interest

Return type:

Dict[int, Union[State, InitialState, PMState, KSState, KSTState, STState, STDState, MBState, InputState, PMInputState, LateralState, LongitudinalState, CustomState, ExtendedPMState]]

Returns:

dictionary which maps id to obstacle state at time step

assign_obstacles_to_lanelets(time_steps=None, obstacle_ids=None, use_center_only=False)[source]

Assigns center points and shapes of obstacles to lanelets by setting the attributes Obstacle.prediction.initial_shape_lanelet_ids, .shape_lanelet_assignment, .initial_center_lanelet_ids, & .center_lanelet_assignment, and Lanelet.dynamic_obstacles_on_lanelet & .static_obstacles_on_lanelet.

Parameters:
  • time_steps (Optional[List[int]]) – time step for which the obstacles should be assigned. If None, all time_steps are assigned.

  • obstacle_ids (Optional[Set[int]]) – ids for which the assignment should be computed. If None, all obstacles are

  • use_center_only – if False, the shape is used to find occupied lanelets. Otherwise, only the center is used.

translate_rotate(translation, angle)[source]

Translates and rotates all objects, e.g., obstacles and road network, in the scenario.

Parameters:
  • translation (ndarray) – translation vector [x_off, y_off] in x- and y-direction

  • angle (float) – rotation angle in radian (counter-clockwise)

convert_to_2d(map_name=None)[source]

Convert the scenario to 2D by removing the z-coordinate from all objects in the scenario.

Parameters:

map_name (Optional[str]) – name for the 2D map to be used in the scenario ID (if None, “2D” is appended to the current name)

Return type:

None

draw(renderer, draw_params=None)[source]

Draw the object

Parameters:
  • renderer (IRenderer) – Renderer to use for drawing

  • draw_params (Optional[MPDrawParams]) – optional parameters for plotting, overriding the parameters of the renderer

Returns:

None

Tag class

class commonroad.scenario.scenario.Tag(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Enum containing all possible tags of a CommonRoad scenario.

INTERSTATE = 'interstate'
URBAN = 'urban'
HIGHWAY = 'highway'
COMFORT = 'comfort'
CRITICAL = 'critical'
EVASIVE = 'evasive'
CUT_IN = 'cut_in'
ILLEGAL_CUTIN = 'illegal_cutin'
INTERSECTION = 'intersection'
LANE_CHANGE = 'lane_change'
LANE_FOLLOWING = 'lane_following'
MERGING_LANES = 'merging_lanes'
MULTI_LANE = 'multi_lane'
ONCOMING_TRAFFIC = 'oncoming_traffic'
NO_ONCOMING_TRAFFIC = 'no_oncoming_traffic'
PARALLEL_LANES = 'parallel_lanes'
RACE_TRACK = 'race_track'
ROUNDABOUT = 'roundabout'
RURAL = 'rural'
SIMULATED = 'simulated'
SINGLE_LANE = 'single_lane'
SLIP_ROAD = 'slip_road'
SPEED_LIMIT = 'speed_limit'
TRAFFIC_JAM = 'traffic_jam'
TURN_LEFT = 'turn_left'
TURN_RIGHT = 'turn_right'
TWO_LANE = 'two_lane'
EMERGENCY_BRAKING = 'emergency_braking'

GeoTransformation class

class commonroad.scenario.scenario.GeoTransformation(geo_reference=None, x_translation=None, y_translation=None, z_rotation=None, scaling=None)[source]

Class which describes the transformation from geodetic to projected Cartesian coordinates according to the CommonRoad specification

property geo_reference: str
property x_translation: float
property y_translation: float
property z_rotation: float
property scaling: float

Location class

class commonroad.scenario.scenario.Location(geo_name_id=-999, gps_latitude=999, gps_longitude=999, geo_transformation=None, environment=None)[source]

Class which describes a location according to the CommonRoad specification.

property geo_name_id: int
property gps_latitude: float
property gps_longitude: float
property geo_transformation: GeoTransformation
property environment: Environment

Road network

LaneletNetwork class

class commonroad.scenario.lanelet.LaneletNetwork(information=MapInformation(commonroad_version=2023a, map_id=map_id, date=Year 2024, month 5, day 6, hour 1, minute 9, author=author, affiliation=affiliation, source=source, licence_name=licence_name, licence_text=)[source]

Class which represents a network of connected lanelets

property information: MapInformation

Map information of the lanelet network.

property lanelets: List[Lanelet]

List of lanelets of the lanelet network.

property lanelet_polygons: List[Polygon]

List of polygons of the lanelet network.

property intersections: List[Intersection]

List of intersections of the lanelet network.

property traffic_signs: List[TrafficSign]

List of traffic signs of the lanelet network.

property traffic_lights: List[TrafficLight]

List of traffic lights of the lanelet network.

property areas: List[Area]

List of areas of the lanelet network.

property map_inc_lanelets_to_intersections: Dict[int, Intersection]

dict that maps lanelet ids to the intersection of which it is an incoming lanelet.

classmethod create_from_lanelet_list(lanelets, cleanup_ids=True)[source]

Creates a LaneletNetwork object from a given list of lanelets

Parameters:
  • lanelets (List[Lanelet]) – The list of lanelets

  • cleanup_ids (bool) – cleans up unused ids

Returns:

The LaneletNetwork for the given list of lanelets

classmethod create_from_lanelet_network(lanelet_network, shape_input=None, exclude_lanelet_types=None, cleanup_ids=True)[source]

Creates a lanelet network from a given lanelet network (copy); adding a shape reduces the lanelets to those that intersect the shape provided and specifying a lanelet_type set excludes the lanelet types in the new created network.

Parameters:
  • lanelet_network (LaneletNetwork) – The existing lanelet network

  • shape_input (Optional[Shape]) – The lanelets intersecting this shape will be in the new network

  • exclude_lanelet_types (Optional[Set[LaneletType]]) – Removes all lanelets with these lanelet_types

  • cleanup_ids (bool) – Boolean indicating whether unused IDs should be deleted

Returns:

The new lanelet network

remove_lanelet(lanelet_id, rtree=True)[source]

Removes a lanelet from a lanelet network and deletes all references.

Parameters:
  • lanelet_id (int) – ID of lanelet which should be removed.

  • rtree (bool) – Boolean indicating whether rtree should be initialized

cleanup_lanelet_references()[source]

Deletes lanelet IDs which do not exist in the lanelet network. Useful when cutting out lanelet networks.

remove_traffic_sign(traffic_sign_id)[source]

Removes a traffic sign from a lanelet network and deletes all references.

Parameters:

traffic_sign_id (int) – ID of traffic sign which should be removed.

get_traffic_sign_referenced_lanelets(traffic_sign_id)[source]

Retrieves the lanelets which have a reference to the given traffic_sign_id

Parameters:

traffic_sign_id – Id of the Traffic Sign of which the lanelets should be searched

Return type:

List[Lanelet]

Returns:

List of Lanelets which have a reference to the Traffic Sign

get_traffic_lights_referenced_lanelets(traffic_light_id)[source]

Retrieves the lanelets which have a reference to the given traffic_light_id

Parameters:

traffic_light_id – Id of the Traffic Light of which the lanelets should be searched

Return type:

List[Lanelet]

Returns:

List of Lanelets which have a reference to the Traffic Light

cleanup_traffic_sign_references()[source]

Deletes traffic sign IDs which do not exist in the lanelet network. Useful when cutting out lanelet networks.

remove_traffic_light(traffic_light_id)[source]

Removes a traffic light from a lanelet network and deletes all references.

Parameters:

traffic_light_id (int) – ID of traffic sign which should be removed.

cleanup_traffic_light_references()[source]

Deletes traffic light IDs which do not exist in the lanelet network. Useful when cutting out lanelet networks.

remove_area(area_id)[source]

Removes an area from a lanelet network and deletes all references.

@param area_id: ID of area which should be removed.

remove_intersection(intersection_id)[source]

Removes an intersection from a lanelet network and deletes all references.

Parameters:

intersection_id (int) – ID of intersection which should be removed.

find_lanelet_by_id(lanelet_id)[source]

Finds a lanelet for a given lanelet_id

Parameters:

lanelet_id (int) – The id of the lanelet to find

Return type:

Lanelet

Returns:

The lanelet object if the id exists and None otherwise

find_traffic_sign_by_id(traffic_sign_id)[source]

Finds a traffic sign for a given traffic_sign_id

Parameters:

traffic_sign_id (int) – The id of the traffic sign to find

Return type:

TrafficSign

Returns:

The traffic sign object if the id exists and None otherwise

find_traffic_light_by_id(traffic_light_id)[source]

Finds a traffic light for a given traffic_light_id

Parameters:

traffic_light_id (int) – The id of the traffic light to find

Return type:

TrafficLight

Returns:

The traffic light object if the id exists and None otherwise

find_area_by_id(area_id)[source]

Finds an area for a given area id

Parameters:

area_id (int) – The id of the area to find

Return type:

Area

Returns:

The area object if the id exists and None otherwise

find_intersection_by_id(intersection_id)[source]

Finds a intersection for a given intersection_id

Parameters:

intersection_id (int) – The id of the intersection to find

Return type:

Intersection

Returns:

The intersection object if the id exists and None otherwise

add_lanelet(lanelet, rtree=True)[source]

Adds a lanelet to the LaneletNetwork

Parameters:
  • lanelet (Lanelet) – The lanelet to add

  • rtree (bool) – Boolean indicating whether rtree should be initialized

Returns:

True if the lanelet has successfully been added to the network, false otherwise

add_traffic_sign(traffic_sign, lanelet_ids)[source]

Adds a traffic sign to the LaneletNetwork

Parameters:
  • traffic_sign (TrafficSign) – The traffic sign to add

  • lanelet_ids (Set[int]) – Lanelets the traffic sign should be referenced from

Returns:

True if the traffic sign has successfully been added to the network, false otherwise

add_traffic_light(traffic_light, lanelet_ids)[source]

Adds a traffic light to the LaneletNetwork

Parameters:
  • traffic_light (TrafficLight) – The traffic light to add

  • lanelet_ids (Set[int]) – Lanelets the traffic sign should be referenced from

Returns:

True if the traffic light has successfully been added to the network, false otherwise

add_area(area, lanelet_ids)[source]

Adds an area to the LaneletNetwork

Parameters:
  • area (Area) – The area to add

  • lanelet_ids (Set[int]) – Lanelets the area should be referenced from

Returns:

True if the area has successfully been added to the network, false otherwise

add_intersection(intersection)[source]

Adds an intersection to the LaneletNetwork

Parameters:

intersection (Intersection) – The intersection to add

Returns:

True if the traffic light has successfully been added to the network, false otherwise

add_lanelets_from_network(lanelet_network)[source]

Adds lanelets from a given network object to the current network

Parameters:

lanelet_network (LaneletNetwork) – The lanelet network

Returns:

True if all lanelets have been added to the network, false otherwise

translate_rotate(translation, angle)[source]

Translates and rotates the complete lanelet network

Parameters:
  • translation (ndarray) – The translation given as [x_off,y_off] for the x and y translation

  • angle (float) – The rotation angle in radian (counter-clockwise defined)

convert_to_2d()[source]

Convert the lanelet network to 2D by removing the z-coordinate from all lanelets and traffic signs/lights.

This has no effect if the lanelet network is already 2D.

Return type:

None

find_lanelet_by_position(point_list)[source]

Finds the lanelet id of a given position

Parameters:

point_list (List[ndarray]) – The list of positions to check

Return type:

List[List[int]]

Returns:

A list of lanelet ids. If the position could not be matched to a lanelet, an empty list is returned

find_lanelet_by_shape(shape)[source]

Finds the lanelet id of a given shape

Parameters:

shape (Shape) – The shape to check

Return type:

List[int]

Returns:

A list of lanelet ids. If the position could not be matched to a lanelet, an empty list is returned

find_most_likely_lanelet_by_state(state_list)[source]

Finds the lanelet id of the position of a given state; in case of multiple overlapping lanelets, return the most likely lanelet according to the orientation difference between lanelets and given state

Parameters:

state_list (List[Union[State, InitialState, PMState, KSState, KSTState, STState, STDState, MBState, InputState, PMInputState, LateralState, LongitudinalState, CustomState, ExtendedPMState]]) – The list of states to check

Return type:

List[int]

Returns:

A list of lanelet ids. If the position could not be matched to a lanelet, an empty list is returned

filter_obstacles_in_network(obstacles)[source]

Returns the list of obstacles which are located in the lanelet network

Parameters:

obstacles (List[Obstacle]) – The list of obstacles to check

Return type:

List[Obstacle]

Returns:

The list of obstacles which are located in the lanelet network

map_obstacles_to_lanelets(obstacles)[source]

Maps a given list of obstacles to the lanelets of the lanelet network

Parameters:

obstacles (List[Obstacle]) – The list of CR obstacles

Return type:

Dict[int, List[Obstacle]]

Returns:

A dictionary with the lanelet id as key and the list of obstacles on the lanelet as a List[Obstacles]

lanelets_in_proximity(point, radius)[source]

Finds all lanelets which intersect a given circle, defined by the center point and radius

Parameters:
  • point (ndarray) – The center of the circle

  • radius (float) – The radius of the circle

Return type:

List[Lanelet]

Returns:

The list of lanelets which intersect the given circle

draw(renderer, draw_params=None)[source]

Draw the object

Parameters:
Returns:

None

Lanelet class

class commonroad.scenario.lanelet.Lanelet(left_vertices, center_vertices, right_vertices, lanelet_id, predecessor=None, successor=None, adjacent_left=None, adjacent_left_same_direction=None, adjacent_right=None, adjacent_right_same_direction=None, line_marking_left_vertices=LineMarking.NO_MARKING, line_marking_right_vertices=LineMarking.NO_MARKING, stop_line=None, lanelet_type=None, user_one_way=None, user_bidirectional=None, traffic_signs=None, traffic_lights=None, adjacent_areas=None)[source]

Class which describes a Lanelet entity according to the CommonRoad specification. Each lanelet is described by a left and right boundary (polylines). Furthermore, lanelets have relations to other lanelets, e.g. an adjacent left neighbor or a predecessor.

property distance: ndarray

cumulative distance along center vertices

property inner_distance: ndarray

minimum cumulative distance along left and right vertices, i.e., along the inner curve:

property lanelet_id: int
property left_vertices: ndarray
property right_vertices: ndarray
property center_vertices: ndarray
property line_marking_left_vertices: LineMarking
property line_marking_right_vertices: LineMarking
property predecessor: list
property successor: list
property adj_left: int
property adj_left_same_direction: bool
property adj_right: int
property adj_right_same_direction: bool
property dynamic_obstacles_on_lanelet: Dict[int, Set[int]]
property static_obstacles_on_lanelet: None | Set[int]
property stop_line: StopLine
property lanelet_type: Set[LaneletType]
property user_one_way: Set[RoadUser]
property user_bidirectional: Set[RoadUser]
property traffic_signs: Set[int]
property traffic_lights: Set[int]
property adjacent_areas: Set[int]
property polygon: Polygon
add_predecessor(lanelet)[source]

Adds the ID of a predecessor lanelet to the list of predecessors. :type lanelet: int :param lanelet: Predecessor lanelet ID.

remove_predecessor(lanelet)[source]

Removes the ID of a predecessor lanelet from the list of predecessors. :type lanelet: int :param lanelet: Predecessor lanelet ID.

add_successor(lanelet)[source]

Adds the ID of a successor lanelet to the list of successors. :type lanelet: int :param lanelet: Successor lanelet ID.

remove_successor(lanelet)[source]

Removes the ID of a successor lanelet from the list of successors. :type lanelet: int :param lanelet: Successor lanelet ID.

translate_rotate(translation, angle)[source]

This method translates and rotates a lanelet

Parameters:
  • translation (ndarray) – The translation given as [x_off,y_off] for the x and y translation

  • angle (float) – The rotation angle in radian (counter-clockwise defined)

convert_to_2d()[source]

Convert the lanelet to 2D by removing the z-coordinate from all vertices.

This has no effect if the lanelet is already 2D.

Return type:

None

interpolate_position(distance)[source]

Computes the interpolated positions on the center/right/left polyline of the lanelet for a given distance along the lanelet

Parameters:

distance (float) – The distance for the interpolation

Return type:

Tuple[ndarray, ndarray, ndarray, int]

Returns:

The interpolated positions on the center/right/left polyline and the segment id of the polyline where the interpolation takes place in the form ([x_c,y_c],[x_r,y_r],[x_l,y_l], segment_id)

convert_to_polygon()[source]

Converts the given lanelet to a polygon representation

Return type:

Polygon

Returns:

The polygon of the lanelet

contains_points(point_list)[source]

Checks if a list of points is enclosed in the lanelet

Parameters:

point_list (ndarray) – The list of points in the form [[px1,py1],[px2,py2,],…]

Return type:

List[bool]

Returns:

List of Boolean values with True indicating point is enclosed and False otherwise

get_obstacles(obstacles, time_step=0)[source]

Returns the subset of obstacles, which are located in the lanelet, of a given candidate set

Parameters:
  • obstacles (List[Obstacle]) – The set of obstacle candidates

  • time_step (int) – The time step for the occupancy to check

Return type:

List[Obstacle]

Returns:

classmethod merge_lanelets(lanelet1, lanelet2)[source]

Merges two lanelets which are in predecessor-successor relation

Parameters:
  • lanelet1 (Lanelet) – The first lanelet

  • lanelet2 (Lanelet) – The second lanelet

Return type:

Lanelet

Returns:

Merged lanelet (predecessor => successor)

classmethod all_lanelets_by_merging_successors_from_lanelet(lanelet, network, max_length=150.0)[source]

Computes all reachable lanelets starting from a provided lanelet and merges them to a single lanelet for each route.

Parameters:
  • lanelet (Lanelet) – The lanelet to start from

  • network (LaneletNetwork) – The network which contains all lanelets

  • max_length (float) – maximal length of merged lanelets can be provided

Return type:

Tuple[List[Lanelet], List[List[int]]]

Returns:

List of merged lanelets, Lists of lanelet ids of which each merged lanelet consists

classmethod all_lanelets_by_merging_predecessors_from_lanelet(lanelet, network, max_length=150.0)[source]

Computes all predecessor lanelets starting from a provided lanelet and merges them to a single lanelet for each route.

Parameters:
  • lanelet (Lanelet) – The lanelet to start from

  • network (LaneletNetwork) – The network which contains all lanelets

  • max_length (float) – maximal length of merged lanelets can be provided

Return type:

Tuple[List[Lanelet], List[List[int]]]

Returns:

List of merged lanelets, Lists of lanelet ids of which each merged lanelet consists

find_lanelet_successors_in_range(lanelet_network, max_length=50.0)[source]

Finds all possible successor paths (id sequences) within max_length.

Parameters:
  • lanelet_network (LaneletNetwork) – lanelet network

  • max_length – abort once length of path is reached

Return type:

List[List[int]]

Returns:

list of lanelet IDs

find_lanelet_predecessors_in_range(lanelet_network, max_length=50.0)[source]

Finds all possible predecessor paths (id sequences) within max_length.

Parameters:
  • lanelet_network (LaneletNetwork) – lanelet network

  • max_length – abort once length of path is reached

Return type:

List[List[int]]

Returns:

list of lanelet IDs

add_dynamic_obstacle_to_lanelet(obstacle_id, time_step)[source]

Adds a dynamic obstacle ID to lanelet

Parameters:
  • obstacle_id (int) – obstacle ID to add

  • time_step (int) – time step at which the obstacle should be added

add_static_obstacle_to_lanelet(obstacle_id)[source]

Adds a static obstacle ID to lanelet

Parameters:

obstacle_id (int) – obstacle ID to add

add_traffic_sign_to_lanelet(traffic_sign_id)[source]

Adds a traffic sign ID to lanelet

Parameters:

traffic_sign_id (int) – traffic sign ID to add

add_traffic_light_to_lanelet(traffic_light_id)[source]

Adds a traffic light ID to lanelet

Parameters:

traffic_light_id (int) – traffic light ID to add

add_adjacent_area_to_lanelet(area_id)[source]

Adds an area ID to lanelet

Parameters:

area_id (int) – adjacent area ID to add

dynamic_obstacle_by_time_step(time_step)[source]

Returns all dynamic obstacles on lanelet at specific time step

Parameters:

time_step – time step of interest

Return type:

Set[int]

Returns:

list of obstacle IDs

orientation_by_position(position)[source]

Returns lanelet orientation closest to a given position :type position: ndarray :param position: position of interest :rtype: float :return: orientation in interval [-pi,pi]

LaneletType class

class commonroad.scenario.lanelet.LaneletType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Enum describing different types of lanelets

URBAN = 'urban'
COUNTRY = 'country'
HIGHWAY = 'highway'
DRIVE_WAY = 'driveWay'
MAIN_CARRIAGE_WAY = 'mainCarriageWay'
ACCESS_RAMP = 'accessRamp'
EXIT_RAMP = 'exitRamp'
SHOULDER = 'shoulder'
BUS_LANE = 'busLane'
BUS_STOP = 'busStop'
BICYCLE_LANE = 'bicycleLane'
SIDEWALK = 'sidewalk'
CROSSWALK = 'crosswalk'
INTERSTATE = 'interstate'
INTERSECTION = 'intersection'
BORDER = 'border'
PARKING = 'parking'
RESTRICTED = 'restricted'
UNKNOWN = 'unknown'

RoadUser class

class commonroad.scenario.lanelet.RoadUser(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Enum describing different types of road users

VEHICLE = 'vehicle'
CAR = 'car'
TRUCK = 'truck'
BUS = 'bus'
PRIORITY_VEHICLE = 'priorityVehicle'
MOTORCYCLE = 'motorcycle'
BICYCLE = 'bicycle'
PEDESTRIAN = 'pedestrian'
TRAIN = 'train'
TAXI = 'taxi'

Traffic Sign

TrafficSign class

class commonroad.scenario.traffic_sign.TrafficSign(traffic_sign_id, traffic_sign_elements, first_occurrence, position, virtual=False)[source]

Class to represent a traffic sign

property traffic_sign_id: int
property position: ndarray
property traffic_sign_elements: List[TrafficSignElement]
property virtual: bool
property first_occurrence: Set[int]
translate_rotate(translation, angle)[source]

This method translates and rotates a traffic sign

Parameters:
  • translation (ndarray) – The translation given as [x_off,y_off] for the x and y translation

  • angle (float) – The rotation angle in radian (counter-clockwise defined)

convert_to_2d()[source]

Convert the traffic sign to 2D by removing the z-coordinate from its position.

This has no effect if the traffic sign is already 2D.

Return type:

None

draw(renderer, draw_params=None)[source]

Draw the object

Parameters:
  • renderer (IRenderer) – Renderer to use for drawing

  • draw_params (Union[TrafficSignParams, MPDrawParams, None]) – optional parameters for plotting, overriding the parameters of the renderer

Returns:

None

TrafficSignElement class

class commonroad.scenario.traffic_sign.TrafficSignElement(traffic_sign_element_id, additional_values=[])[source]

Class which represents a collection of traffic signs at one position

property traffic_sign_element_id: <module 'enum' from '/usr/local/lib/python3.11/enum.py'>
property additional_values: List[str]

SupportedTrafficSignCountry class

class commonroad.scenario.traffic_sign.SupportedTrafficSignCountry(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]
GERMANY = 'DEU'
USA = 'USA'
CHINA = 'CHN'
SPAIN = 'ESP'
RUSSIA = 'RUS'
ARGENTINA = 'ARG'
BELGIUM = 'BEL'
FRANCE = 'FRA'
GREECE = 'GRC'
CROATIA = 'HRV'
ITALY = 'ITA'
PUERTO_RICO = 'PRI'
ZAMUNDA = 'ZAM'

TrafficSignIDZamunda class

commonroad.scenario.traffic_sign.TrafficSignIDZamunda

alias of TrafficSignIDGermany

TrafficSignIDGermany class

class commonroad.scenario.traffic_sign.TrafficSignIDGermany(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]
WARNING_DANGER_SPOT = '101'
WARNING_RIGHT_BEFORE_LEFT = '102'
WARNING_LEFT_CURVE = '103-10'
WARNING_RIGHT_CURVE = '103-20'
WARNING_STEEP_HILL_DOWNWARDS = '108'
WARNING_SLIPPERY_ROAD = '114'
WARNING_CONSTRUCTION_SITE = '123'
WARNING_TRAFFIC_QUEUES_LIKELY = '124'
WARNING_ONCOMING_TRAFFIC = '125'
WARNING_TRAFFIC_LIGHTS_AHEAD = '131'
WARNING_PEDESTRIANS_RIGHT = '133-10'
WARNING_PEDESTRIANS_LEFT = '133-20'
WARNING_CROSSING_CYCLIST = '138'
WARNING_ANIMAL_CROSSING_RIGHT = '142-10'
WARNING_LOOSE_GRAVEL = '145-50'
RAILWAY = '201'
YIELD = '205'
STOP = '206'
PRIORITY_OPPOSITE_DIRECTION = '208'
TURN_RIGHT_AHEAD = '209-10'
TURN_LEFT_AHEAD = '209-20'
KEEP_STRAIGHT_AHEAD = '209-30'
PRESCRIBED_DIRECTION_RIGHT = '211-20'
ROUNDABOUT = '215'
ONEWAY_RIGHT = '220-10'
ONEWAY_LEFT = '220-20'
PRESCRIBED_PASSING_LEFT = '222-10'
PRESCRIBED_PASSING_RIGHT = '222-20'
DO_NOT_DRIVE_ON_SHOULDER_LANE = '223.2'
DO_NOT_DRIVE_ON_SHOULDER_LANE_2_LANE = '223.2-50'
DO_NOT_DRIVE_ON_SHOULDER_LANE_3_LANE = '223.2-51'
BUS_STOP = '224-50'
BIKEWAY = '237'
PEDESTRIAN_SIDEWALK = '239'
PEDESTRIAN_AND_BICYCLE_ROAD = '240'
PEDESTRIAN_ZONE_START = '242.1'
PEDESTRIAN_ZONE_END = '242.2'
BICYCLE_ROAD_START = '244.1'
BICYCLE_ROAD_END = '244.2'
BUS_LANE = '245'
BAN_ALL_VEHICLES = '250'
BAN_CARS = '251'
BAN_TRUCKS = '253'
BAN_BICYCLE = '254'
BAN_MOTORCYCLE = '255'
BAN_BUS = '257-54'
BAN_PEDESTRIAN = '259'
BAN_CAR_TRUCK_BUS_MOTORCYCLE = '260'
BAN_VEHICLES_CARRYING_DANGEROUS_GOODS = '261'
MAX_WEIGHT = '262'
MAX_WIDTH = '264'
MAX_HEIGHT = '265'
MAX_LENGTH = '266'
NO_ENTRY = '267'
ENVIRONMENTAL_ZONE_START = '270.1'
ENVIRONMENTAL_ZONE_END = '270.2'
U_TURN = '272'
MAX_SPEED = '274'
MAX_SPEED_ZONE_START = '274.1'
MAX_SPEED_ZONE_END = '274.2'
MIN_SPEED = '275'
NO_OVERTAKING_START = '276'
NO_OVERTAKING_TRUCKS_START = '277'
MAX_SPEED_END = '278'
NO_OVERTAKING_END = '280'
NO_OVERTAKING_TRUCKS_END = '281'
ALL_MAX_SPEED_AND_OVERTAKING_END = '282'
NO_STOP_START_RIGHT = '283-10'
NO_STOP_CENTER_RIGHT = '283-30'
RESTRICTED_STOP_CENTER_RIGHT = '286-30'
RIGHT_OF_WAY = '301'
PRIORITY = '306'
PRIORITY_OVER_ONCOMING = '308'
TOWN_SIGN = '310'
TOWN_SIGN_BACK = '311'
PARKING_AREA = '314'
PARKING_AREA_LEFT = '314-10'
PARKING_AREA_RIGHT = '314-20'
PARKING_AREA_RIGHT_LEFT = '314-30'
TRAFFIC_CALMED_AREA_START = '325.1'
TRAFFIC_CALMED_AREA_END = '325.2'
TUNNEL = '327'
EMERGENCY_STOP = '328'
INTERSTATE_START = '330.1'
INTERSTATE_END = '330.2'
HIGHWAY_START = '331.1'
HIGHWAY_END = '331.2'
HIGHWAY_EXIT_WITH_PLACE_NAME = '332'
EXIT_ROUTE = '332.1'
HIGHWAY_EXIT = '333'
EXIT_BUILT_UP = '333-21'
EXIT_GENERAL = '333-22'
PEDESTRIANS_CROSSING = '350'
WATER_PROTECTION_ZONE = '354'
TRAFFIC_ASSISTANTS = '356'
DEAD_END = '357'
POLICE = '363'
EMERGENCY_CALL_STATION = '365-51'
GAS_STATION = '365-52'
CAMP_AND_CARAVAN_SITE = '365-60'
ATTRACTION_POINT = '386.1'
TOURISTIC_ROUTE = '386.2'
NEARBY_ATTRACTION_POINT = '386.3'
HIGHWAY_INTERSECTION = '406-50'
DIRECTION_ARROW_SIGN_MULTI = '418-20'
DIRECTION_ARROW_SIGN_SINGLE = '419-20'
DIRECTION_SIGN_CONSOLIDATED = '434-50'
EXPRESSWAY_ARROW_DIRECTION = '430-20'
ARROW_SIGN_POST_POINT_OF_INTEREST_LEFT = '432-10'
STATION = '432-20'
GUIDE_SIGN_TABLE = '434'
ADVANCE_DIRECTION = '438'
DIRECTIONS_SIGN = '439'
EXPRESSWAY_ENTRANCE_DIRECTIONS = '440'
INTERSTATE_ANNOUNCEMENT = '448'
INTERSTATE_ADVANCE_DIRECTION = '449'
HIGHWAY_EXIT_AHEAD_100_METER = '450-50'
HIGHWAY_EXIT_AHEAD_200_METER = '450-51'
HIGHWAY_EXIT_AHEAD_300_METER = '450-52'
EXPRESSWAY_EXIT_100_METRES = '450-53'
EXPRESSWAY_EXIT_200_METRES = '450-54'
EXPRESSWAY_EXIT_300_METRES = '450-55'
INTERSTATE_DISTANCE = '453'
DETOUR_SKETCH = '458'
DETOUR_STRAIGHT = '455.1-30'
DETOUR_ON_DEMAND_LEFT = '460-10'
DETOUR_ON_DEMAND_GET_IN_LEFT_LANE = '460-12'
DETOUR_ON_DEMAND_ANNOUNCEMENT_RIGHT = '460-20'
DETOUR_ON_DEMAND_RIGHT = '460-21'
DETOUR_ON_DEMAND_GET_IN_RIGHT_LANE = '460-22'
DETOUR_ON_DEMAND_STRAIGHTFORWARD = '460-30'
TRANSITION_3_LEFT_2_TRANSITIONED = '501-15'
TRANSITION_1_LEFT_1_STRAIGHT = '501-16'
TRANSITION_3_RIGHT = '511-22'
LANE_BOARD_NO_OPPOSITE_TWO_LANES = '521-30'
THREE_LANES_NO_ONCOMING_LANES = '521-31'
FOUR_LANES_NO_ONCOMING_LANES = '521-32'
FIVE_LANES_NO_ONCOMING_LANES = '521-33'
LANE_BOARD_3_LANES_NO_OPPOSITE_WITH_SIGNS = '525'
NARROWING_LANES_1_LANE_FROM_RIGHT = '531-10'
NARROWING_LANES_1_LANE_FROM_LEFT = '531-20'
NARROWING_LANES_2_LANES_PLUS_1_LEFT = '531-21'
FOUR_LANES_NO_ONCOMING_TRAFFIC_TWO_RIGHT_LANES_TURN_RIGHT = '533-22'
MERGING_LANES_1_LANE_PLUS_1_LANE_RIGHT = '550-20'
BARRIER = '600-35'
BARRIER_GATE_100_800 = '600-30'
BARRIER_GATE_100_1200 = '600-31'
BARRIER_GATE_100_1600 = '600-32'
BARRIER_GATE_250_1600 = '600-34'
BARRIER_GATE = '600-38'
ROAD_WARNING_POST_SCRAPER_BEACON_RIGHT = '605-10'
ROAD_WARNING_POST_ARROW_BEACON_RIGHT = '605-11'
ROAD_WARNING_POST_SCRAPER_BEACON_LEFT = '605-20'
ROAD_WARNING_POST_SCRAPER_BEACON_ARROW_RIGHT = '605-21'
ROAD_WARNING_POST_GUIDE_UP_THREE_ARROWS = '605-31'
DIRECTION_SIGN_LEFT_SINGLE = '625-10'
DIRECTION_SIGN_LEFT_SMALL = '625-11'
DIRECTION_SIGN_LEFT_MEDIUM = '625-12'
DIRECTION_SIGN_LEFT_LARGE = '625-13'
DIRECTION_SIGN_RIGHT_SINGLE = '625-20'
DIRECTION_SIGN_RIGHT_SMALL = '625-21'
DIRECTION_SIGN_RIGHT_MEDIUM = '625-22'
DIRECTION_SIGN_RIGHT_LARGE = '625-23'
WARNING_PANEL_RIGHT = '626-10'
WARNING_PANEL_LEFT = '626-20'
WARNING_PANEL_STRAIGHT_BROAD = '626-30'
WARNING_PANEL_STRAIGHT_HIGH = '626-31'
GUIDE_SILL_WITH_GUIDE_BEACON_RIGHT = '628-10'
GUIDE_RAIL_WITH_GUIDE_BEACON_RIGHT = '629-10'
GUIDE_PANEL_WITH_GUIDE_BEACON_RIGHT = '629-20'
GREEN_ARROW = '720'
ADDITION_LEFT_DIRECTION = '1000'
ADDITION_LEFT_DIRECTION_1 = '1000-10'
ADDITION_LEFT_DIRECTION_DANGER_POINT = '1000-11'
ADDITION_RIGHT_DIRECTION_1 = '1000-20'
ADDITION_RIGHT_DIRECTION_DANGER_POINT = '1000-21'
ADDITION_BOTH_DIRECTIONS_HORIZONTAL = '1000-30'
ADDITION_BOTH_DIRECTIONS_VERTICAL = '1000-31'
ADDITION_VALID_FOR_X_METERS = '1001-30'
ADDITION_VALID_FOR_X_KILOMETERS = '1001-31'
ADDITION_LEFT_TURNING_PRIORITY_WITH_OPPOSITE_RIGHT_YIELD = '1002-10'
ADDITION_LEFT_TRAFFIC_PRIORITY_WITH_STRAIGHT_RIGHT_YIELD = '1002-11'
ADDITION_LEFT_TURNING_PRIORITY_WITH_OPPOSITE_YIELD = '1002-12'
ADDITION_LEFT_TURNING_PRIORITY_WITH_RIGHT_YIELD = '1002-13'
ADDITION_LEFT_TRAFFIC_PRIORITY_WITH_STRAIGHT_YIELD = '1002-14'
ADDITION_RIGHT_TURNING_PRIORITY_WITH_OPPOSITE_LEFT_YIELD = '1002-20'
ADDITION_RIGHT_TRAFFIC_PRIORITY_WITH_STRAIGHT_LEFT_YIELD = '1002-21'
ADDITION_RIGHT_TURNING_PRIORITY_WITH_OPPOSITE_YIELD = '1002-22'
ADDITION_RIGHT_TURNING_PRIORITY_WITH_LEFT_YIELD = '1002-23'
ADDITION_RIGHT_TRAFFIC_PRIORITY_WITH_STRAIGHT_YIELD = '1002-24'
ADDITION_VALID_IN_X_METERS = '1004-30'
ADDITION_VALID_IN_X_KILOMETERS = '1004-31'
ADDITION_VALID_IN_200_KILOMETERS = '1004-32'
ADDITION_VALID_IN_400_METRES = '1004-33'
ADDITION_VALID_IN_600_METRES = '1004-34'
ADDITION_VALID_IN_2_KILOMETERS = '1004-35'
ADDITION_OIL_ON_ROAD = '1006-30'
ADDITION_SMOKE = '1006-31'
ADDITION_LOOSE_GRAVEL = '1006-32'
ADDITION_BUILDING_SITE_EXIT = '1006-33'
ADDITION_DAMAGED_ROAD = '1006-34'
ADDITION_DIRTY_ROAD = '1006-35'
ADDITION_DANGER_OF_COLLISION = '1006-36'
ADDITION_TOAD_MIGRATION = '1006-37'
ADDITION_DANGER_OF_CONGESTION = '1006-38'
ADDITION_RESTRICTED_VIEW_DUE_TO_TREES = '1006-39'
DANGER_INDICATION_SMOKE = '1007-31'
ADDITION_CHILDREN_PLAYING_ON_ROAD = '1010-10'
ADDITION_WINTER_SPORTS_ALLOWED = '1010-11'
ADDITION_TRAILERS_ALLOWED_TO_PARK_MORE_THAN_14_DAYS = '1010-12'
ADDITION_CARAVANS_ALLOWED_TO_PARK_MORE_THAN_14_DAYS = '1010-13'
ADDITION_ROLLING_HIGHWAY = '1010-14'
ADDITION_LOADING_AREA = '1012-30'
ADDITION_END = '1012-31'
ADDITION_GET_OFF_BICYCLES = '1012-32'
ADDITION_NO_MOPEDS = '1012-33'
ADDITION_GREEN_WAVE_AT_KM_H = '1012-34'
ADDITION_STOP_HERE_AT_RED = '1012-35'
ADDITION_NOISE_CONTROL = '1012-36'
ADDITION_INFLOW_REGULATION = '1012-37'
ADDITION_SECONDARY_LANE = '1012-38'
ADDITION_SCHOOL = '1012-50'
ADDITION_KINDERGARTEN = '1012-51'
ADDITION_RETIREMENT_HOME = '1012-52'
ADDITION_HOSPITAL = '1012-53'
ADDITION_RESIDENTS_PERMITTED = '1020-30'
ADDITION_BICYCLES_PERMITTED = '1022-10'
ADDITION_CARS_PERMITTED = '1024-10'
ADDITION_AGRICULTURE_PERMITTED = '1026-36'
ADDITION_FOREST_PERMITTED = '1026-37'
ADDITION_AGRICULTURE_FOREST_PERMITTED = '1026-38'
ADDITION_GREEN_STICKER_PERMITTED = '1031-52'
ADDITION_TIME_PERIOD_PERMITTED = '1040-30'
ADDITION_MOTOR_VEHICLES_ALLOWED_MASS_3_5_TONS = '1048-12'
ADDITION_MIN_MASS_3_5_TONS = '1049-13'
ADDITION_NO_WATER_POLLUTANTS_LOADED = '1052-31'
ALLOWED_MASS_7_5_TONS = '1053-33'
ADDITION_VALID_ON_SHOULDER = '1053-34'
ADDITION_VALID_WHEN_WET = '1053-35'
LINE_MARKING_MISSING = '2113'
UNKNOWN = ''

TrafficSignIDUsa class

class commonroad.scenario.traffic_sign.TrafficSignIDUsa(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]
MAX_SPEED = 'R2-1'
U_TURN = 'R3-4'
ROAD_WORK_AHEAD = 'CW20-1'
NO_PARKING_ANY_TIME = 'R7-1'
NO_STANDING = 'R7-4'
TOW_AWAY_ZONE = 'R7-201a'
ONE_WAY_LEFT = 'R6-1L'
ONE_WAY_RIGHT = 'R6-1R'
DO_NOT_ENTER = 'R5-1'
NO_LEFT_TURN = 'R3-2'
RIGHT_TURN_ONLY = 'R3-5R'
TURN_ONLY_LANES = 'R3-8b'
NO_RIGHT_TURN = 'R3-1'
KEEP_RIGHT = 'R4-7'
SIGNAL_AHEAD = 'W3-3'
LOADING_ZONE = 'R8-3gP'
NO_PARKING = 'R8-3'
LEFT_TURN_ONLY = 'R3-5L'
NO_STRAIGHT_THROUGH = 'R3-27'
LEFT_REVERSE_TURN = 'W1-3L'
PEDESTRIAN_WARNING = 'W11-2'
DIAGONAL_DOWNWARD_LEFT_ARROW = 'M6-2aL'
RIGHT_LANE_ENDS = 'W4-2R'
RESERVED_HANDICAP_PARKING = 'R7-8'
NO_PARKING_BUS_STOP = 'R7-107'
ON_PAVEMENT = 'R8-3C'
DO_NOT_BLOCK_INTERSECTION = 'R10-7'
WARNING_ARROW_LEFT = 'W1-6L'
UNKNOWN = ''

TrafficSignIDChina class

class commonroad.scenario.traffic_sign.TrafficSignIDChina(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]
MAX_SPEED = '274'
UNKNOWN = ''

TrafficSignIDSpain class

class commonroad.scenario.traffic_sign.TrafficSignIDSpain(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]
YIELD = 'r1'
STOP = 'r2'
BAN_ALL_VEHICLES = 'r100'
NO_ENTRY = 'r101'
BAN_TRUCKS = 'r106'
MAX_WEIGHT = 'r107'
MAX_HEIGHT = 'r205'
MAX_SPEED = 'r301'
NO_OVERTAKING_START = 'r305'
NO_STOPPING = 'r307'
NO_WAITING = 'r308'
PEDESTRIANS_CROSSING = 's13'
UNKNOWN = ''

TrafficSignIDRussia class

class commonroad.scenario.traffic_sign.TrafficSignIDRussia(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]
MAX_SPEED = '3.24'
UNKNOWN = ''

Traffic Light

TrafficLight class

class commonroad.scenario.traffic_light.TrafficLight(traffic_light_id, position, traffic_light_cycle=None, color=None, active=True, direction=TrafficLightDirection.ALL, shape=None)[source]

Class to represent a traffic light

property traffic_light_id: int

ID of the traffic light.

property position: ndarray

Position of the traffic light.

property traffic_light_cycle: None | TrafficLightCycle

Traffic light cycle of the traffic light.

property color: List[TrafficLightState]

List of traffic light color light states.

property active: None | bool

Boolean indicating if the traffic light is currently active.

property direction: TrafficLightDirection

Driving directions for which the traffic light is valid.

property shape: Rectangle

Shape of rectangle.

translate_rotate(translation, angle)[source]

This method translates and rotates a traffic light

Parameters:
  • translation (ndarray) – The translation given as [x_off,y_off] for the x and y translation

  • angle (float) – The rotation angle in radian (counter-clockwise defined)

convert_to_2d()[source]

Convert the traffic light to 2D by removing the z-coordinate from its position.

This has no effect if the traffic light is already 2D.

Return type:

None

draw(renderer, draw_params=None)[source]

Draw the object

Parameters:
Returns:

None

get_state_at_time_step(time_step)[source]
Return type:

TrafficLightState

TrafficLightDirection class

class commonroad.scenario.traffic_light.TrafficLightDirection(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Enum for all the possible directions for a traffic signal

RIGHT = 'right'
STRAIGHT = 'straight'
LEFT = 'left'
LEFT_STRAIGHT = 'leftStraight'
STRAIGHT_RIGHT = 'straightRight'
LEFT_RIGHT = 'leftRight'
ALL = 'all'

TrafficLightCycleElement class

class commonroad.scenario.traffic_light.TrafficLightCycleElement(state, duration)[source]

Class to represent a traffic light cycle

property state: TrafficLightState
property duration: int

TrafficLightState class

class commonroad.scenario.traffic_light.TrafficLightState(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Enum for the possible types of traffic light in signals

RED = 'red'
YELLOW = 'yellow'
RED_YELLOW = 'redYellow'
GREEN = 'green'
INACTIVE = 'inactive'

Traffic Sign Interpreter

TrafficSignInterpreter class

class commonroad.scenario.traffic_sign_interpreter.TrafficSignInterpreter(country, lanelet_network)[source]

Class to extract traffic sign information from the road network

speed_limit(lanelet_ids)[source]

Extracts the maximum speed limit of provided lanelets

Parameters:

lanelet_ids (FrozenSet[int]) – set of lanelets which should be considered

Return type:

Optional[float]

Returns:

speed limit of provided lanelets or None if no speed limit exists

required_speed(lanelet_ids)[source]

Extracts the required speed a vehicle has to drive on a set of lanelets

Parameters:

lanelet_ids (FrozenSet[int]) – IDs of lanelets the vehicle is on

Return type:

Optional[float]

Returns:

minimum required speed of provided lanelets or None if no required speed exists

IntersectionIncomingElement class

class commonroad.scenario.intersection.IntersectionIncomingElement(incoming_id, incoming_lanelets=None, successors_right=None, successors_straight=None, successors_left=None, left_of=None)[source]

This class represents an incoming element of an intersection. An incoming can consist of several adjacent lanelets which lead to an intersection, right, straight, and left successor lanelets, and a reference to the incoming located on the left side. The right/straight/left successors are used to infer for which lanelets the traffic light is valid for and to facilitate the calculation of priorities at intersections. The left incoming is used to infer the right-before-left-rule.

property incoming_id: int

ID of incoming

property incoming_lanelets: Set[int]

set of IDs of incoming lanelets

property successors_right: Set[int]

set of IDs of incoming lanelets which turn right

property successors_straight: Set[int]

set of IDs of incoming lanelets which go straight

property successors_left: Set[int]

set of IDs of incoming lanelets which turn left

property left_of: int

incoming element ID of incoming element located left of this incoming element

Intersection

Intersection class

class commonroad.scenario.intersection.Intersection(intersection_id, incomings, crossings=None)[source]

This class represent an intersection. An intersection element is defined by at least one incoming and an optional crossing element. The crossing element models lanelets which cross other lanelets, e.g., these are usually lanelets of type crosswalk.

property intersection_id: int

ID of intersection element

property incomings: List[IntersectionIncomingElement]

set of incoming elements in intersection

property crossings: Set[int]

set of crossing elements in intersection

property map_incoming_lanelets: Dict[int, IntersectionIncomingElement]

Maps all incoming lanelet ids to IntersectionIncomingElement

Obstacles

Different kinds of traffic participants are modeled as obstacles within the scenario. An obstacle is either static or dynamic.

Inheritance diagram of StaticObstacle, DynamicObstacle

ObstacleRole class

class commonroad.scenario.obstacle.ObstacleRole(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Enum containing all possible obstacle roles defined in CommonRoad.

STATIC = 'static'
DYNAMIC = 'dynamic'
ENVIRONMENT = 'environment'
Phantom = 'phantom'

ObstacleType class

class commonroad.scenario.obstacle.ObstacleType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Enum containing all possible obstacle types defined in CommonRoad.

UNKNOWN = 'unknown'
CAR = 'car'
TRUCK = 'truck'
BUS = 'bus'
BICYCLE = 'bicycle'
PEDESTRIAN = 'pedestrian'
PRIORITY_VEHICLE = 'priorityVehicle'
PARKED_VEHICLE = 'parkedVehicle'
CONSTRUCTION_ZONE = 'constructionZone'
TRAIN = 'train'
ROAD_BOUNDARY = 'roadBoundary'
MOTORCYCLE = 'motorcycle'
TAXI = 'taxi'
BUILDING = 'building'
PILLAR = 'pillar'
MEDIAN_STRIP = 'median_strip'

SignalState class

class commonroad.scenario.obstacle.SignalState(**kwargs)[source]

A signal state is a boolean value indicating the activity of the signal source at a time step. The possible signal state elements are defined as slots:

Variables:
  • horn (bool) – boolean indicating activity of horn

  • indicator_left (bool) – boolean indicating activity of left indicator

  • indicator_right (bool) – boolean indicating activity of right indicator

  • braking_lights (bool) – boolean indicating activity of braking lights

  • hazard_warning_lights (bool) – boolean indicating activity of hazard warning lights

  • flashing_blue_lights (bool) – boolean indicating activity of flashing blue lights (police, ambulance)

  • time_step (bool) – the discrete time step. Exact values are given as integers, uncertain values are given as commonroad.common.util.Interval

Obstacle class

class commonroad.scenario.obstacle.Obstacle(obstacle_id, obstacle_role, obstacle_type, obstacle_shape, initial_state=None, initial_center_lanelet_ids=None, initial_shape_lanelet_ids=None, initial_signal_state=None, signal_series=None)[source]

Superclass for dynamic and static obstacles holding common properties defined in CommonRoad.

property initial_center_lanelet_ids: None | Set[int]

Initial lanelets of obstacle center, e.g., obtained through localization.

property initial_shape_lanelet_ids: None | Set[int]

Initial lanelets of obstacle shape, e.g., obtained through localization.

property initial_signal_state: SignalState

Signal state as defined in CommonRoad.

property initial_state: InitialState

Initial state of the obstacle, e.g., obtained through sensor measurements.

property obstacle_id: int

Unique ID of the obstacle.

property obstacle_role: ObstacleRole

Obstacle role as defined in CommonRoad.

property obstacle_shape: Shape | Rectangle | Circle | Polygon

Obstacle shape as defined in CommonRoad.

property obstacle_type: ObstacleType

Obstacle type as defined in CommonRoad.

property signal_series: List[SignalState]

Signal series as defined in CommonRoad.

signal_state_at_time_step(time_step)[source]

Extracts signal state at a time step

Parameters:

time_step (int) – time step of interest

Return type:

Optional[SignalState]

Returns:

signal state or None if time step does not exist

StaticObstacle class

class commonroad.scenario.obstacle.StaticObstacle(obstacle_id, obstacle_type, obstacle_shape, initial_state, initial_center_lanelet_ids=None, initial_shape_lanelet_ids=None, initial_signal_state=None, signal_series=None)[source]

Class representing static obstacles as defined in CommonRoad.

draw(renderer, draw_params=None)[source]

Draw the object

Parameters:
Returns:

None

property initial_center_lanelet_ids: None | Set[int]

Initial lanelets of obstacle center, e.g., obtained through localization.

property initial_shape_lanelet_ids: None | Set[int]

Initial lanelets of obstacle shape, e.g., obtained through localization.

property initial_signal_state: SignalState

Signal state as defined in CommonRoad.

property initial_state: InitialState

Initial state of the obstacle, e.g., obtained through sensor measurements.

property obstacle_id: int

Unique ID of the obstacle.

property obstacle_role: ObstacleRole

Obstacle role as defined in CommonRoad.

property obstacle_shape: Shape | Rectangle | Circle | Polygon

Obstacle shape as defined in CommonRoad.

property obstacle_type: ObstacleType

Obstacle type as defined in CommonRoad.

occupancy_at_time(time_step)[source]

Returns the predicted occupancy of the obstacle at a specific time step.

Parameters:

time_step (int) – discrete time step

Return type:

Occupancy

Returns:

occupancy of the static obstacle at time step

property signal_series: List[SignalState]

Signal series as defined in CommonRoad.

signal_state_at_time_step(time_step)

Extracts signal state at a time step

Parameters:

time_step (int) – time step of interest

Return type:

Optional[SignalState]

Returns:

signal state or None if time step does not exist

state_at_time(time_step)[source]

Returns the state the obstacle at a specific time step.

Parameters:

time_step (int) – discrete time step

Return type:

Union[State, InitialState, PMState, KSState, KSTState, STState, STDState, MBState, InputState, PMInputState, LateralState, LongitudinalState, CustomState, ExtendedPMState]

Returns:

state of the static obstacle at time step

translate_rotate(translation, angle)[source]

First translates the static obstacle, then rotates the static obstacle around the origin.

Parameters:
  • translation (ndarray) – translation vector [x_off, y_off] in x- and y-direction

  • angle (float) – rotation angle in radian (counter-clockwise)

DynamicObstacle class

class commonroad.scenario.obstacle.DynamicObstacle(obstacle_id, obstacle_type, obstacle_shape, initial_state, prediction=None, initial_center_lanelet_ids=None, initial_shape_lanelet_ids=None, initial_signal_state=None, signal_series=None, initial_meta_information_state=None, meta_information_series=None, external_dataset_id=None, history=None, signal_history=None, center_lanelet_ids_history=None, shape_lanelet_ids_history=None, **kwargs)[source]

Class representing dynamic obstacles as defined in CommonRoad. Each dynamic obstacle has stored its predicted movement in future time steps.

draw(renderer, draw_params=None)[source]

Draw the object

Parameters:
Returns:

None

property external_dataset_id: int | None

ID of the external dataset.

property initial_center_lanelet_ids: None | Set[int]

Initial lanelets of obstacle center, e.g., obtained through localization.

property initial_meta_information_state: None | MetaInformationState

Meta information of the dynamic obstacle.

property initial_shape_lanelet_ids: None | Set[int]

Initial lanelets of obstacle shape, e.g., obtained through localization.

property initial_signal_state: SignalState

Signal state as defined in CommonRoad.

property initial_state: InitialState

Initial state of the obstacle, e.g., obtained through sensor measurements.

property meta_information_series: None | List[MetaInformationState]

List of meta information.

property obstacle_id: int

Unique ID of the obstacle.

property obstacle_role: ObstacleRole

Obstacle role as defined in CommonRoad.

property obstacle_shape: Shape | Rectangle | Circle | Polygon

Obstacle shape as defined in CommonRoad.

property obstacle_type: ObstacleType

Obstacle type as defined in CommonRoad.

occupancy_at_time(time_step)[source]

Returns the predicted occupancy of the obstacle at a specific time step.

Parameters:

time_step (int) – discrete time step

Return type:

Optional[Occupancy]

Returns:

predicted occupancy of the obstacle at time step

property prediction: None | Prediction | TrajectoryPrediction | SetBasedPrediction

Prediction describing the movement of the dynamic obstacle over time.

property signal_series: List[SignalState]

Signal series as defined in CommonRoad.

signal_state_at_time_step(time_step)

Extracts signal state at a time step

Parameters:

time_step (int) – time step of interest

Return type:

Optional[SignalState]

Returns:

signal state or None if time step does not exist

state_at_time(time_step)[source]

Returns the predicted state of the obstacle at a specific time step.

Parameters:

time_step (int) – discrete time step

Return type:

Union[None, State, InitialState, PMState, KSState, KSTState, STState, STDState, MBState, InputState, PMInputState, LateralState, LongitudinalState, CustomState, ExtendedPMState]

Returns:

predicted state of the obstacle at time step

translate_rotate(translation, angle)[source]

First translates the dynamic obstacle, then rotates the dynamic obstacle around the origin.

Parameters:
  • translation (ndarray) – translation vector [x_off, y_off] in x- and y-direction

  • angle (float) – rotation angle in radian (counter-clockwise)

update_initial_state(current_state, current_signal_state=None, current_center_lanelet_ids=None, current_shape_lanelet_ids=None, max_history_length=6000)[source]

Updates the initial state to the given current state, appends the current initial state to the history, and invalidates the prediction.

Parameters:
  • current_state (Union[State, InitialState, PMState, KSState, KSTState, STState, STDState, MBState, InputState, PMInputState, LateralState, LongitudinalState, CustomState, ExtendedPMState]) – current state of the dynamic obstacle, will become the new initial state

  • current_signal_state (Optional[SignalState]) – current signal state of the dynamic obstacle, will become the new initial signal state

  • current_center_lanelet_ids (Optional[Set[int]]) – current center lanelet ids of the dynamic obstacle, will become the new initial center lanelet ids

  • current_shape_lanelet_ids (Optional[Set[int]]) – current shape lanelet ids of the dynamic obstacle, will become the new initial shape lanelet ids

  • max_history_length (int) – maximum length of the history, if the history exceeds this it will be truncated, dropping the oldest elements first; must be greater than 0

update_prediction(prediction, signal_series=None)[source]

Updates the prediction of the dynamic obstacle.

Parameters:

Trajectories

Trajectory class

class commonroad.scenario.trajectory.Trajectory(initial_time_step, state_list)[source]

Class to model the movement of an object over time. The states of the trajectory can be either exact or uncertain (see commonroad.scenario.trajectory.State); however, only exact time_step are allowed.

append_state(state)[source]

Append the state to the trajectory.

Parameters:

state (Union[State, InitialState, PMState, KSState, KSTState, STState, STDState, MBState, InputState, PMInputState, LateralState, LongitudinalState, CustomState, ExtendedPMState]) – The new state. It’s time step must be larger than the time step of the last state in the trajectory

check_state_list(state_list)[source]

Checks whether state list is valid.

Parameters:

state_list (List[Union[State, InitialState, PMState, KSState, KSTState, STState, STDState, MBState, InputState, PMInputState, LateralState, LongitudinalState, CustomState, ExtendedPMState]]) – state list which should be evaluated

Return type:

List[Union[State, InitialState, PMState, KSState, KSTState, STState, STDState, MBState, InputState, PMInputState, LateralState, LongitudinalState, CustomState, ExtendedPMState]]

Returns:

evaluated state list

draw(renderer, draw_params=None)[source]

Draw the object

Parameters:
  • renderer (IRenderer) – Renderer to use for drawing

  • draw_params (Union[TrajectoryParams, MPDrawParams, None]) – optional parameters for plotting, overriding the parameters of the renderer

Returns:

None

property final_state: State | InitialState | PMState | KSState | KSTState | STState | STDState | MBState | InputState | PMInputState | LateralState | LongitudinalState | CustomState | ExtendedPMState

Final state of the trajectory.

property initial_time_step: int

Initial time step of the trajectory.

classmethod resample_continuous_time_state_list(states, time_stamps_cont, resampled_dt, num_resampled_states, initial_time_cont=0)[source]

This method resamples a given state list with continuous time vector in a fixed time resolution. The interpolation is done in a linear fashion. :type states: List[Union[State, InitialState, PMState, KSState, KSTState, STState, STDState, MBState, InputState, PMInputState, LateralState, LongitudinalState, CustomState, ExtendedPMState]] :param states: The list of states to interpolate :type time_stamps_cont: ndarray :param time_stamps_cont: The vector of continuous time stamps (corresponding to the states) :type resampled_dt: float :param resampled_dt: Target time step length :type num_resampled_states: int :param num_resampled_states: The resulting number of states. It must hold (t_0+N*dT) in time interval :type initial_time_cont: float :param initial_time_cont: The initial continuous time stamp (default 0). It must hold tin time interval :rtype: Trajectory :return: The resampled trajectory

state_at_time_step(time_step)[source]

Function to get the state of a trajectory at a specific time instance.

Parameters:

time_step (int) – considered time step

Return type:

Union[State, InitialState, PMState, KSState, KSTState, STState, STDState, MBState, InputState, PMInputState, LateralState, LongitudinalState, CustomState, ExtendedPMState, None]

Returns:

state of the trajectory at time_step

property state_list: List[State | InitialState | PMState | KSState | KSTState | STState | STDState | MBState | InputState | PMInputState | LateralState | LongitudinalState | CustomState | ExtendedPMState]

List of states of the trajectory over time.

states_in_time_interval(time_begin, time_end)[source]

Function to get the states of a trajectory at a specific time interval.

Parameters:
  • time_begin (int) – first considered time step

  • time_end (int) – last considered time step

Return type:

List[Union[State, InitialState, PMState, KSState, KSTState, STState, STDState, MBState, InputState, PMInputState, LateralState, LongitudinalState, CustomState, ExtendedPMState, None]]

Returns:

list of states

translate_rotate(translation, angle)[source]

First translates each state of the trajectory, then rotates each state of the trajectory around the origin.

Parameters:
  • translation (ndarray) – translation vector [x_off, y_off] in x- and y-direction

  • angle (float) – rotation angle in radian (counter-clockwise)

States

State class

class commonroad.scenario.state.State(time_step=None)[source]

This is a class representing the Base State.

Parameters:

time_step (Union[int, Interval]) – Discrete time step \(t_i\)

property attributes: List[str]

Returns all attributes used in state space.

Attributes

convert_state_to_state(state)[source]

Converts state to state from different state types.

Parameters:

state ([<class ‘commonroad.scenario.state.InitialState’>, <class ‘commonroad.scenario.state.PMState’>, <class ‘commonroad.scenario.state.KSState’>, <class ‘commonroad.scenario.state.KSTState’>, <class ‘commonroad.scenario.state.STState’>, <class ‘commonroad.scenario.state.STDState’>, <class ‘commonroad.scenario.state.MBState’>, <class ‘commonroad.scenario.state.InputState’>, <class ‘commonroad.scenario.state.PMInputState’>, <class ‘commonroad.scenario.state.LateralState’>, <class ‘commonroad.scenario.state.LongitudinalState’>, <class ‘commonroad.scenario.state.ExtendedPMState’>]) – State for converting

Return type:

[<class ‘commonroad.scenario.state.InitialState’>, <class ‘commonroad.scenario.state.PMState’>, <class ‘commonroad.scenario.state.KSState’>, <class ‘commonroad.scenario.state.KSTState’>, <class ‘commonroad.scenario.state.STState’>, <class ‘commonroad.scenario.state.STDState’>, <class ‘commonroad.scenario.state.MBState’>, <class ‘commonroad.scenario.state.InputState’>, <class ‘commonroad.scenario.state.PMInputState’>, <class ‘commonroad.scenario.state.LateralState’>, <class ‘commonroad.scenario.state.LongitudinalState’>, <class ‘commonroad.scenario.state.ExtendedPMState’>]

draw(renderer, draw_params=None)[source]

Draws state.

Parameters:
fill_with_defaults()[source]

Fills all state fields with default values.

has_value(attr)[source]

Checks whether an attribute is given and is initialized with a value.

Parameters:

attr (str) – Name of attribute

Return type:

bool

property is_uncertain_orientation

Checks whether the orientation is uncertain.

Uncertain or not

property is_uncertain_position: bool

Checks whether the position is uncertain.

Uncertain or not

translate_rotate(translation, angle)[source]

First translates the state and then rotates the state around the origin.

Parameters:
  • translation (ndarray) – Translation vector [x_off, y_off] in x- and y-direction

  • angle (float) – Rotation angle in radian (counter-clockwise)

Return type:

Union[State, InitialState, PMState, KSState, KSTState, STState, STDState, MBState, InputState, PMInputState, LateralState, LongitudinalState, CustomState, ExtendedPMState]

Returns:

Transformed state

property used_attributes: List[str]

Returns all initialized attributed in state space.

Initialized attributes

InitialState class

class commonroad.scenario.state.InitialState(time_step=None, position=None, orientation=None, velocity=None, acceleration=None, yaw_rate=None, slip_angle=None)[source]

Bases: State

This is a class representing the Initial State.

Parameters:
  • position (Union[ndarray, Shape]) – Position \(s_x\)- and \(s_y\) in a global coordinate system

  • orientation (Union[float, AngleInterval]) – Yaw angle \(\Psi\)

  • velocity (Union[float, Interval]) – Velocity \(v_x\) in longitudinal direction

  • acceleration (Union[float, Interval]) – Acceleration \(a_x\)

  • yaw_rate (Union[float, Interval]) – Yaw rate \(\dot{\Psi}\)

  • slip_angle (Union[float, Interval]) – Slip angle \(\beta\)

PMState class

class commonroad.scenario.state.PMState(time_step=None, position=None, velocity=None, velocity_y=None)[source]

Bases: State

This is a class representing Point Mass State (PM State).

Parameters:
  • position (Union[ndarray, Shape]) – Position \(s_x\)- and \(s_y\) in a global coordinate system

  • velocity (Union[float, Interval]) – Velocity \(v_x\) in longitudinal direction

  • velocity_y (Union[float, Interval]) – Velocity \(v_x\) in lateral direction

property orientation: float | None

Orientation: Yaw angle \(\Psi\) Does not consider intervals.

KSState class

class commonroad.scenario.state.KSState(time_step=None, position=None, steering_angle=None, velocity=None, orientation=None)[source]

Bases: State

This is a class representing Kinematic Single Track State (KS State).

Parameters:
  • position (Union[ndarray, Shape]) – Position \(s_x\)- and \(s_y\) in a global coordinate system

  • steering_angle (Union[float, Interval]) – Steering angle \(\delta\)

  • velocity (Union[float, Interval]) – Velocity \(v_x\) in longitudinal direction

  • orientation (Union[float, AngleInterval]) – Yaw angle \(\Psi\)

KSTState class

class commonroad.scenario.state.KSTState(time_step=None, position=None, steering_angle=None, velocity=None, orientation=None, hitch_angle=None)[source]

Bases: KSState

This is a class representing Kinematic Single Track State (KST State).

Parameters:

hitch_angle (Union[float, AngleInterval]) – Hitch angle \(\alpha\)

STState class

class commonroad.scenario.state.STState(time_step=None, position=None, steering_angle=None, velocity=None, orientation=None, slip_angle=None, yaw_rate=None)[source]

Bases: KSState

This is a class representing Single Track State (ST State).

Parameters:
  • slip_angle (Union[float, Interval]) – Slip angle \(\beta\)

  • yaw_rate (Union[float, Interval]) – Yaw rate \(\dot{\Psi}\)

STDState class

class commonroad.scenario.state.STDState(time_step=None, position=None, steering_angle=None, velocity=None, orientation=None, slip_angle=None, yaw_rate=None, front_wheel_angular_speed=None, rear_wheel_angular_speed=None)[source]

Bases: STState

This is a class representing Single Track Drift State (STD State).

Parameters:
  • front_wheel_angular_speed (Union[float, Interval]) – Front wheel angular speed \(\omega_{f}\)

  • rear_wheel_angular_speed (Union[float, Interval]) – Rear wheel angular speed \(\omega_{r}\)

MBState class

class commonroad.scenario.state.MBState(time_step=None, position=None, steering_angle=None, velocity=None, orientation=None, yaw_rate=None, roll_angle=None, roll_rate=None, pitch_angle=None, pitch_rate=None, velocity_y=None, position_z=None, velocity_z=None, roll_angle_front=None, roll_rate_front=None, velocity_y_front=None, position_z_front=None, velocity_z_front=None, roll_angle_rear=None, roll_rate_rear=None, velocity_y_rear=None, position_z_rear=None, velocity_z_rear=None, left_front_wheel_angular_speed=None, right_front_wheel_angular_speed=None, left_rear_wheel_angular_speed=None, right_rear_wheel_angular_speed=None, delta_y_f=None, delta_y_r=None)[source]

Bases: State

This is a class representing Multi Body State (MB State).

Parameters:
  • position (Union[ndarray, Shape]) – Position \(s_x\)- and \(s_y\) in a global coordinate system

  • steering_angle (Union[float, Interval]) – Steering angle \(\delta\)

  • velocity (Union[float, Interval]) – Velocity \(v_x\) in longitudinal direction

  • orientation (Union[float, AngleInterval]) – Yaw angle \(\Psi\)

  • yaw_rate (Union[float, Interval]) – Yaw rate \(\dot{\Psi}\)

  • roll_angle (Union[float, Interval]) – Roll angle \(\Phi_S\)

  • roll_rate (Union[float, Interval]) – Roll rate \(\dot{\Phi}_S\)

  • pitch_angle (Union[float, Interval]) – Pitch angle \(\Theta_S\)

  • pitch_rate (Union[float, Interval]) – Pitch rate \(\dot{\Theta}_S\)

  • velocity_y (Union[float, Interval]) – Velocity \(v_y\) in lateral direction

  • position_z (Union[float, Interval]) – Position \(s_z\) (height) from ground

  • velocity_z (Union[float, Interval]) – Velocity \(v_z\) in vertical direction perpendicular to road plane

  • roll_angle_front (Union[float, Interval]) – Roll angle front \(\Phi_{UF}\)

  • roll_rate_front (Union[float, Interval]) – Roll rate front \(\dot{\Phi}_{UF}\)

  • velocity_y_front (Union[float, Interval]) – Velocity \(v_{y,UF}\) in y-direction front

  • position_z_front (Union[float, Interval]) – Position \(s_{z,UF}\) in z-direction front

  • velocity_z_front (Union[float, Interval]) – Velocity \(v_{z,UF}\) in z-direction front

  • roll_angle_rear (Union[float, Interval]) – Roll angle rear \(\Phi_{UR}\)

  • roll_rate_rear (Union[float, Interval]) – Roll rate rear \(\dot{\Phi}_{UR}\)

  • velocity_y_rear (Union[float, Interval]) – Velocity \(v_{y,UR}\) in y-direction rear

  • position_z_rear (Union[float, Interval]) – Position \(s_{z,UR}\) in z-direction rear

  • velocity_z_rear (Union[float, Interval]) – Velocity \(v_{z,UR}\) in z-direction rear

  • left_front_wheel_angular_speed (Union[float, Interval]) – Left front wheel angular speed \(\omega_{LF}\)

  • right_front_wheel_angular_speed (Union[float, Interval]) – Right front wheel angular speed \(\omega_{RF}\)

  • left_rear_wheel_angular_speed (Union[float, Interval]) – Left rear wheel angular speed \(\omega_{LR}\)

  • right_rear_wheel_angular_speed (Union[float, Interval]) – Right rear wheel angular speed \(\omega_{RR}\)

  • delta_y_f (Union[float, Interval]) – Front lateral displacement \(\delta_{y,f}\) of sprung mass due to roll

  • delta_y_r (Union[float, Interval]) – Rear lateral displacement \(\delta_{y,r}\) of sprung mass due to roll

LongitudinalState class

class commonroad.scenario.state.LongitudinalState(time_step=None, longitudinal_position=None, velocity=None, acceleration=None, jerk=None)[source]

Bases: State

This is a class representing the Longitudinal Motion State (Longitudinal State). The state cannot be read by the file reader because neither orientation nor velocity in y direction are specified.

Parameters:
  • longitudinal_position (Union[float, Interval]) – Longitudinal position \(s\) along reference path

  • velocity (Union[float, Interval]) – Velocity \(v_x\) in longitudinal direction

  • acceleration (Union[float, Interval]) – Acceleration \(a_x\) in longitudinal direction

  • jerk (Union[float, Interval]) – Jerk \(j\)

LateralState class

class commonroad.scenario.state.LateralState(time_step=None, lateral_position=None, orientation=None, curvature=None, curvature_rate=None)[source]

Bases: State

This is a class representing the Lateral Motion State (Lateral State). The state cannot be read by the file reader because position is not specified.

Parameters:
  • lateral_position (Union[float, Interval]) – Lateral distance \(d\) to reference path

  • orientation (Union[float, AngleInterval]) – Yaw angle \(\Psi\)

  • curvature (Union[float, Interval]) – Curvature math:kappa

  • curvature_rate (Union[float, Interval]) – Change of curvature math:dot{kappa}

InputState class

class commonroad.scenario.state.InputState(time_step=None, steering_angle_speed=None, acceleration=None)[source]

Bases: State

This is a class representing the input for most supported models.

Parameters:
  • steering_angle_speed (Union[float, Interval]) – Steering angle speed \(\dot{\delta}\) of front wheels

  • acceleration (Union[float, Interval]) – Acceleration \(a_x\)

PMInputState class

class commonroad.scenario.state.PMInputState(time_step=None, acceleration=None, acceleration_y=None)[source]

Bases: State

This is a class representing the input for PM model (PM Input).

Parameters:
  • acceleration (Union[float, Interval]) – Acceleration \(a_x\)

  • acceleration_y (Union[float, Interval]) – Acceleration \(a_y\)

CustomState class

class commonroad.scenario.state.CustomState(**attributes)[source]

Bases: State

This is a class representing the custom state. State variables can be added at runtime. The attributes position and orientation/velocity_y are necessary for successful file reading.

add_attribute(new_attr)[source]

Adds a new attribute to custom state.

Parameters:

new_attr (str) – Attribute name

set_value(attr, value)[source]

Sets value to attribute.

Parameters:
  • attr (str) – Attribute name

  • value (Any) – Value