visualization
commonroad_control.util.visualization.visualize_trajectories
make_gif(path_to_img_dir, scenario_name, num_imgs, duration=0.1, abort_img_threshold=100)
Generates a .gif from a folder of .png images. Assumes images sorted by name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path_to_img_dir
|
Union[Path, str]
|
Path to the image folder |
required |
scenario_name
|
str
|
Name of the scenario for the .gif |
required |
num_imgs
|
int
|
how many images should the folder contain |
required |
duration
|
float
|
time duration between two consecutive images |
0.1
|
abort_img_threshold
|
int
|
Safety threshold of number of images in folder, above which execution is aborted |
100
|
Source code in commonroad_control/util/visualization/visualize_trajectories.py
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 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 | |
obtain_plot_limits_from_reference_path(trajectory, margin=10.0)
Obtains plot limits from a given trajectory
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
trajectory
|
TrajectoryInterface
|
trajectory for extracting plot limits |
required |
Returns:
| Type | Description |
|---|---|
List[int]
|
list [xmin, xmax, ymin, xmax] of plot limits |
Source code in commonroad_control/util/visualization/visualize_trajectories.py
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 | |
visualize_trajectories(scenario, planning_problem, planner_trajectory, controller_trajectory, vehicle_width=1.8, vehicle_length=4.5, size_x=10.0, save_img=False, save_path=None, opacity_planning=0.3, opacity_control=1.0, use_icon_controlled_traj=True, use_icon_planned_traj=False)
Visualize scenario with planned and driven trajectory. Per default, the driven trajectory is depicted as an orange car and the planned trajectory as a black rectangle.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scenario
|
Scenario
|
CommonRoad scenario. |
required |
planning_problem
|
PlanningProblem
|
Commonroad planning problem |
required |
planner_trajectory
|
TrajectoryInterface
|
Planned trajectory |
required |
controller_trajectory
|
TrajectoryInterface
|
Actual trajectory (from controller or simulation) |
required |
vehicle_width
|
float
|
vehicle width |
1.8
|
vehicle_length
|
float
|
vehicle length |
4.5
|
size_x
|
float
|
abscissa size of the figure |
10.0
|
save_img
|
bool
|
if true and save_path is valid, saves figure. If false, figure is displayed. |
False
|
save_path
|
Union[str, Path]
|
if valid and save_img is true, saves figure |
None
|
opacity_planning
|
float
|
If planned trajectory does not use icon (default), opacity of black rectangle. |
0.3
|
opacity_control
|
float
|
If actual trajectory does not use icon (not default default), opacity of orange rectangle. |
1.0
|
use_icon_controlled_traj
|
bool
|
If true, uses car icon for actual trajectory, else rectangle. |
True
|
use_icon_planned_traj
|
bool
|
If true, uses car icon for planned trajectory, else rectangle. |
False
|
Returns:
| Type | Description |
|---|---|
None
|
|
Source code in commonroad_control/util/visualization/visualize_trajectories.py
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 | |
commonroad_control.util.visualization.visualize_control_state
visualize_reference_vs_actual_states(reference_trajectory, actual_trajectory, time_steps=None, state_names=None, save_img=False, save_path=None)
Plots selected components of the reference and actual (simulated or driven) trajectories as well as the respective tracking error.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
reference_trajectory
|
Union[TrajectoryInterface]
|
reference trajectory |
required |
actual_trajectory
|
Union[TrajectoryInterface]
|
actual (simulated or driven) trajectory |
required |
time_steps
|
List[int]
|
simulation time steps |
None
|
state_names
|
Optional[List[str]]
|
(optional) list of state components, which should be plotted - valid values are attribute names of the StateInterface objects |
None
|
save_img
|
bool
|
boolean indicting whether the plot should be saved or not |
False
|
save_path
|
Union[str, Path]
|
path for saving the plot |
None
|
Returns:
| Type | Description |
|---|---|
None
|
|
Source code in commonroad_control/util/visualization/visualize_control_state.py
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 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 | |