Module Visualization

This module implements functions to visualize all kind of objects from commonroad scenarios. Please refer to the Visualization Manual for detailed instructions and examples for using the API.

draw_dispatch_cr

commonroad.visualization.draw_dispatch_cr.draw_object(obj, plot_limits=None, ax=None, draw_params=None, draw_func=None, handles=None, call_stack=None)[source]

Main function for drawing objects from the scenario and planning modules.

Parameters:
  • obj (Union[list, Scenario, Trajectory, LaneletNetwork, Lanelet, Obstacle, Shape, GoalRegion, PlanningProblem, PlanningProblemSet, State, Occupancy]) – the object or list of objects (with all the same type) to be plotted
  • plot_limits (Optional[List[Union[int, float]]]) – list of [x_min, x_max, y_min, y_max that defines the plotted area of the scenario
  • ax (Union[None, Axes]) – axes object from matplotlib
  • draw_params (Union[None, dict]) – parameters for plotting given by a nested dict that recreates the structure of an object, see documentation for full overview over the structure. If parameters are not set, the default setting are used. An example for specifying the color of circle obstacles: {‘scenario’: {‘static_obstacle’:{‘shape’:{‘circle’:{‘facecolor’:#3399ff, edgecolor’: ‘#0066cc’}}}}}
  • draw_func (Union[None, Dict[type, Callable]]) – specify the drawing function (usually not necessary to change default)
  • handles (Optional[Dict[int, List[Patch]]]) – dict that assign to every object_id of all plotted obstacles the corresponding patch handles
  • call_stack (Union[None, Tuple[str, …]]) – tuple of string containing the call stack, which allows for differentiation of plotting styles depending on the call stack of draw_object, (usually ‘None’!)
Return type:

Union[None, List[Patch]]

Returns:

Returns matplotlib patch object for draw_funcs that actually draw a patch (used internally for creating handles dict)

plot_Helper

commonroad.visualization.plot_helper.set_non_blocking()[source]

Ensures that interactive plotting is enabled for non-blocking plotting.

Return type:None
Returns:None
commonroad.visualization.plot_helper.redraw_obstacles(scenario, handles, figure_handle, draw_params=None, plot_limits=None)[source]

This function is used for fast updating dynamic obstacles of an already drawn plot. Saves about 80% time compared to a complete plot. Deletes all dynamic obstacles which are specified in handles and draws dynamic obstacles of a scenario.

Parameters:
  • scenario (Scenario) – scenario from which obstacle should be plotted
  • handles (Dict[int, List[Patch]]) – dict of obstacle_ids and corresponding patch handles (generated by draw_object function)
  • plot_limits (Optional[List[Union[int, float]]]) – axis limits for plot [x_min, x_max, y_min, y_max]
  • figure_handle (Figure) – figure handle of current plot
Return type:

None

Returns:

None