other utils
commonroad_control.util.state_conversion
convert_state_db2kb(db_state)
Converts dynamic bicycle state to kinematic bicycle state.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
db_state
|
DBState
|
DB state |
required |
Returns:
| Type | Description |
|---|---|
KBState
|
KB State |
Source code in commonroad_control/util/state_conversion.py
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | |
convert_state_kb2db(kb_state, vehicle_params)
Converts kinematic bicycle state to dynamic bicycle state.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
kb_state
|
KBState
|
KB state |
required |
vehicle_params
|
VehicleParameters
|
Vehicle parameters |
required |
Returns:
| Type | Description |
|---|---|
DBState
|
KB state |
Source code in commonroad_control/util/state_conversion.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | |
commonroad_control.util.geometry
signed_distance_point_to_linestring(point, linestring)
Signed distance between a shapely point and shapely linestring. Positive means left of line vector
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
point
|
Point
|
shapely point |
required |
linestring
|
LineString
|
shapely linestring |
required |
Returns:
| Type | Description |
|---|---|
float
|
signed distance, positive meaning left of linestring segment vector |
Source code in commonroad_control/util/geometry.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | |
commonroad_control.util.cr_logging_utils
configure_toolbox_logging(level=logging.INFO)
Configures toolbox level logging
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
level
|
logging level |
INFO
|
Source code in commonroad_control/util/cr_logging_utils.py
4 5 6 7 8 9 10 11 12 13 14 15 16 17 | |
commonroad_control.util.conversion_util
compute_position_of_cog_from_ra_cc(l_r, position_ra_x, position_ra_y, heading)
Given the position of the center of the rear-axle, this function returns the position of the center of gravity; each represented in Cartesian coordinates.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
l_r
|
float
|
distance from center of rear-axle to the center of gravity |
required |
position_ra_x
|
float
|
longitudinal component of the position of the rear-axle (Cartesian coordinates) |
required |
position_ra_y
|
float
|
lateral component of the position of the rear-axle (Cartesian coordinates) |
required |
heading
|
float
|
orientation of the vehicle |
required |
Returns:
| Type | Description |
|---|---|
Tuple[float, float]
|
position of the center of gravity (Cartesian coordinates) |
Source code in commonroad_control/util/conversion_util.py
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 | |
compute_position_of_ra_from_cog_cartesian(l_r, position_cog_x, position_cog_y, heading)
Given the position of the center of the center of gravity (COG), this function returns the position of the rear axle; each represented in Cartesian coordinates.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
l_r
|
float
|
distance from center of rear-axle to the center of gravity |
required |
position_cog_x
|
float
|
longitudinal component of the position of the rear-axle (Cartesian coordinates) |
required |
position_cog_y
|
float
|
lateral component of the position of the rear-axle (Cartesian coordinates) |
required |
heading
|
float
|
orientation of the vehicle |
required |
Returns:
| Type | Description |
|---|---|
Tuple[float, float]
|
position of the rear axle(Cartesian coordinates) |
Source code in commonroad_control/util/conversion_util.py
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 | |
compute_slip_angle_from_steering_angle_in_cog(steering_angle, velocity, l_wb, l_r)
Compute slip angle in center of gravity from steering angle and wheelbase.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
steering_angle
|
float
|
steering angle |
required |
velocity
|
float
|
longitudinal velocity - float |
required |
l_wb
|
float
|
wheelbase |
required |
l_r
|
float
|
distance from center of rear-axle to the center of gravity |
required |
Returns:
| Type | Description |
|---|---|
float
|
slip angle in radian |
Source code in commonroad_control/util/conversion_util.py
7 8 9 10 11 12 13 14 15 16 17 18 | |
compute_slip_angle_from_velocity_components(v_lon, v_lat)
Computes the slip angle from the long. and lat. velocity (body frame) at the center of gravity.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
v_lon
|
float
|
longitudinal velocity at the center of gravity - float |
required |
v_lat
|
float
|
lateral velocity at the center of gravity - float |
required |
Returns:
| Type | Description |
|---|---|
float
|
|
Source code in commonroad_control/util/conversion_util.py
21 22 23 24 25 26 27 28 | |
compute_velocity_components_from_slip_angle_and_velocity_in_cog(slip_angle, velocity)
Compute velocity components in long. and lat. direction (body frame) at the center of gravity from slip angle.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
slip_angle
|
float
|
slip angle |
required |
velocity
|
float
|
total velocity |
required |
Returns:
| Type | Description |
|---|---|
Tuple[float, float]
|
v_lon, v_lat |
Source code in commonroad_control/util/conversion_util.py
31 32 33 34 35 36 37 38 39 40 | |
compute_velocity_components_from_steering_angle_in_cog(steering_angle, velocity_cog, l_wb, l_r)
Computes velocity components at center of gravity. To this end, the slip angle is derived from the steering angle using kinematic relations.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
steering_angle
|
float
|
steering angle |
required |
velocity_cog
|
float
|
velocity at center of gravity |
required |
l_wb
|
float
|
wheelbase |
required |
l_r
|
float
|
distance from center of rear-axle to the center of gravity |
required |
Returns:
| Type | Description |
|---|---|
Tuple[float, float]
|
v_lon, v_lat |
Source code in commonroad_control/util/conversion_util.py
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | |
compute_velocity_from_components(v_long, v_lat)
Computes the total velocity from its components.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
v_long
|
float
|
longitudinal velocity |
required |
v_lat
|
float
|
lateral velocity |
required |
Returns:
| Type | Description |
|---|---|
float
|
v |
Source code in commonroad_control/util/conversion_util.py
62 63 64 65 66 67 68 69 | |
map_velocity_from_cog_to_ra(l_wb, l_r, velocity_cog, steering_angle)
Given the velocity at the center of gravity, this function computes the velocity at the vehicle's rear axle.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
l_wb
|
float
|
wheelbase |
required |
l_r
|
float
|
distance from center of rear-axle to the center of gravity |
required |
velocity_cog
|
float
|
velocity at the center of gravity |
required |
steering_angle
|
float
|
steering angle |
required |
Returns:
| Type | Description |
|---|---|
float
|
velocity at the center of gravity |
Source code in commonroad_control/util/conversion_util.py
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 | |
map_velocity_from_ra_to_cog(l_wb, l_r, velocity_ra, steering_angle)
Given the velocity at the center of the rear axle, this function computes the velocity at the vehicle's center of gravity using kinematic relations.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
l_wb
|
float
|
wheelbase |
required |
l_r
|
float
|
distance from center of rear-axle to the center of gravity |
required |
velocity_ra
|
float
|
velocity at the center of the rear axle |
required |
steering_angle
|
float
|
steering angle |
required |
Returns:
| Type | Description |
|---|---|
float
|
velocity at the center of gravity |
Source code in commonroad_control/util/conversion_util.py
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 | |
unwrap_angle(alpha_prev, alpha_next)
This function returns an alpha_next adjusted to be "continuous" with alpha_prev. To this end, alpha_next is mapped to ]-pi, pi]. As an example, if the desired heading of the vehicle is 10° and the current heading is 340°, wrapping the angle makes the vehicle turn 30° clockwise, not 330° counter-clockwise.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
alpha_prev
|
float
|
previous angle - float |
required |
alpha_next
|
float
|
next angle before wrapping - float |
required |
Returns:
| Type | Description |
|---|---|
float
|
next angle after wrapping - float |
Source code in commonroad_control/util/conversion_util.py
151 152 153 154 155 156 157 158 159 160 161 162 163 | |
commonroad_control.util.clcs_control_util
extend_kb_reference_trajectory_lane_following(x_ref, u_ref, lanelet_network, vehicle_params, delta_t, horizon)
Extends kinematic bicycle trajectory using the CommonRoad reference path planner to account for extended MPC horizons, or controllers with look-ahead etc.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x_ref
|
TrajectoryInterface
|
State trajectory |
required |
u_ref
|
TrajectoryInterface
|
Input trajectory |
required |
lanelet_network
|
LaneletNetwork
|
CommonRoad lanelet network |
required |
vehicle_params
|
VehicleParameters
|
Vehicle parameters object |
required |
delta_t
|
float
|
sampling time in seconds - float |
required |
horizon
|
int
|
time horizon for extension (number of time steps) - int |
required |
Returns:
| Type | Description |
|---|---|
Tuple[CurvilinearCoordinateSystem, TrajectoryInterface, TrajectoryInterface]
|
Curvilinear coordinate system, extended state trajectory, extended input trajectory |
Source code in commonroad_control/util/clcs_control_util.py
171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 | |
extend_ref_path_with_route_planner(positional_trajectory, lanelet_network, final_state_time_step=0, planning_problem_id=30000)
Extends the positional information of the trajectory using the CommonRoad route planner.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
positional_trajectory
|
ndarray
|
(n,2) positional trajectory |
required |
lanelet_network
|
LaneletNetwork
|
CommonRoad lanelet network object. |
required |
planning_problem_id
|
int
|
Id of current planning problem |
30000
|
Returns:
| Type | Description |
|---|---|
ndarray
|
(n,2) positional trajectory of extended reference path |
Source code in commonroad_control/util/clcs_control_util.py
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | |
extend_reference_trajectory_lane_following(positional_trajectory, lanelet_network, final_state, horizon, delta_t, l_wb)
Extends planned trajectory using the CommonRoad reference path planner to account for extended MPC horizons, controller overshoot etc.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
positional_trajectory
|
ndarray
|
(n,2) positional planner trajectory |
required |
lanelet_network
|
LaneletNetwork
|
CommonRoad lanelet network |
required |
final_state
|
Union[StateInterface, KBState, DBState, Any]
|
Final planner trajectory state |
required |
horizon
|
int
|
time horizon in steps |
required |
delta_t
|
float
|
time step size in seconds |
required |
l_wb
|
float
|
wheelbase length |
required |
Returns:
| Type | Description |
|---|---|
Tuple[CurvilinearCoordinateSystem, List[ndarray], List[ndarray], List[float], List[float], List[float], List[float]]
|
Curvilinear coordinate system object, (n,2) positions in cartesian coordinates, acceleration, heading, yaw_rate, steering angle, steering angle velocity, |
Source code in commonroad_control/util/clcs_control_util.py
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 | |
commonroad_control.util.planner_execution_util.reactive_planner_exec_util
run_reactive_planner(scenario, scenario_xml_file_name, planning_problem, planning_problem_set, reactive_planner_config_path, logging_level='ERROR', show_planner_debug_plots=False, maximum_iterations=200, evaluate_planner=False)
Util wrapper to easily run the reactive planner
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scenario
|
Scenario
|
CommonRoad scenario object |
required |
scenario_xml_file_name
|
str
|
e.g. ZAM-1_1.xml |
required |
planning_problem
|
PlanningProblem
|
CommonRoad planning problem object |
required |
planning_problem_set
|
PlanningProblemSet
|
planning problem set orbject |
required |
reactive_planner_config_path
|
Union[str, Path]
|
path to reactive planner config |
required |
logging_level
|
str
|
logging level as string (see reactive planner documentation) |
'ERROR'
|
show_planner_debug_plots
|
bool
|
if true shows debug plots |
False
|
maximum_iterations
|
int
|
maximum planner iterations to solve a problem before raising an exception |
200
|
evaluate_planner
|
bool
|
if true planner output is evaluated and plotted |
False
|
Returns:
| Type | Description |
|---|---|
Tuple[List[ReactivePlannerState], List[InputState]]
|
Tuple[list of reactive planner states, list of reactive planner inputs] |
Source code in commonroad_control/util/planner_execution_util/reactive_planner_exec_util.py
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 | |