trajectory_supervisor.visualization.src.PlotHandler module

class trajectory_supervisor.visualization.src.PlotHandler.PlotHandler(plot_title='Log Visualization Tool')[source]

Bases: object

This class provides several functions to plot the debug visualization for safety assessment logs.

Authors
Created on

24.01.2020

Parameters

plot_title – string specifying the figure title

force_update()None[source]

This function triggers an forced update.

highlight_path(path_coords: numpy.ndarray, id_in: str = 'default', color_str: str = 'red', linewidth: float = 1.4, zorder: int = 99)None[source]

Highlight a given coordinate sequence.

Parameters
  • path_coords – coordinates of path to be plotted (each coordinate in separate column)

  • id_in – (optional) id used for the handle (plots with same id will be removed before plot of next)

  • color_str – (optional) color to be used for path highlight

  • linewidth – (optional) linewidth of the highlighted path (default: 1.4)

  • zorder – (optional) z-order of the highlighted path (default: 99)

highlight_pos(pos_coords: list, color_str: str = 'y', zorder: int = 10, radius=None, marker: str = 'o', id_in: str = 'default')None[source]

Highlight a position with an plot marker (‘´marker´’) or a circle with a parametrizable radius (‘radius’). If ‘radius’ is not provided or ‘None’, the marker option is used.

Parameters
  • pos_coords – coordinates of the position ot be highlighted

  • color_str – (optional) string specifying the color of the highlight

  • zorder – (optional) z-order of the highlight marker (default: 10)

  • radius – (optional) radius of the marker to be displayed (if not provided, a standard marker is used)

  • marker – (optional) string specifying the marker style

  • id_in – (optional) string specifying the id (used to delete the same type of vehicle plotted prev.)

highlight_time(time_coords: list, color_str: str = 'y', zorder: int = 10, marker: str = 'o', id_in: str = 'default')None[source]

Highlight a position with an plot marker (‘´marker´’) in the temporal plot.

Parameters
  • time_coords – coordinates of the time entry to be highlighted

  • color_str – (optional) string specifying the color of the highlight

  • zorder – (optional) z-order of the highlight marker (default: 10)

  • marker – (optional) string specifying the marker style

  • id_in – (optional) string specifying the id (used to delete the same type of vehicle plotted prev.)

highlight_timeline(time_stamp: float, type_in: str, message: str)None[source]

Display a text message from the log file, with an arrow pointing to the relevant timestamp.

Parameters
  • time_stamp – timestamp the arrow should point to

  • type_in – string specifying the type of error (relevant for color)

  • message – string of message to be displayed

init_acc_plot(a_lat_max_tires: float, a_lon_max_tires: float, dyn_model_exp: float)None[source]

Initialize acceleration data plot (friction circle)

Parameters
  • a_lat_max_tires – maximum allowed pure lateral acceleration

  • a_lon_max_tires – maximum allowed pure longitudinal acceleration

  • dyn_model_exp – dynamic model exponent

onhover(event)[source]

Function called, when the mouse is moved over the plot window.

Parameters

event – mouse event (also holding the position of the pointer)

open_plot_window(_)None[source]

Called when the ‘Open Plot’-button is clicked.

plot_map(bound_l: numpy.ndarray, bound_r: numpy.ndarray)None[source]

Visualization of the map.

Parameters
  • bound_l – coordinates of the left bound

  • bound_r – coordinates of the right bound

plot_polygon(polygon_list: list, zorder: int = 10, color_str: str = 'blue', color_e_str: str = 'k', id_in: str = 'default', alpha: float = 0.5)None[source]

Plot one / multiple polygon patches.

Parameters
  • polygon_list – list of polygon coordinates (each given as an np.ndarray with columns [x, y])

  • zorder – (optional) z-order of the vehicle

  • color_str – (optional) string specifying the color of the plotted vehicle

  • color_e_str – (optional) string specifying the color of the outline for the plotted vehicle

  • id_in – (optional) string specifying the id (used to delete the same type of vehicle plotted prev.)

  • alpha – (optional) transparency setting [0, 1]

plot_text(pos: numpy.ndarray, heading: list, text_list: list, text_dist: float = 10.0, plot_ith: int = 2, avoid_pos: Optional[numpy.ndarray] = None, zorder: int = 100, id_in: str = 'default')None[source]

Plot text (perpendicular) next to poses. The heading is used to determine in a perpendicular direction the offset of the text to the pose (allows to plot text next to certain poses on a spline). If empty arrays are provided, all previous instances with the specified ‘id_in’ will be removed.

Parameters
  • pos – numpy array holding one or multiple positions (columns x, y; each row a pose)

  • heading – list of floats holding the heading for each position (if only one pose, list with one float)

  • text_list – list of texts to be printed next to each pose (if only one pose, list with one text)

  • text_dist – (optional) distance the text should be away from ‘pos’ in m

  • plot_ith – (optional) plot only the text for every i-th pose (e.g. if ‘1’ every pose, if ‘2’ every 2nd)

  • avoid_pos – (optional) numpy array of positions to be avoided by text -> Select favored side (left/right) of heading

  • zorder – (optional) z-order of the vehicle

  • id_in – (optional) string specifying the id (used to delete same type of vehicle plotted previously)

Returns

plot_time_rel_line(line_coords_list: list)None[source]

Highlight a list of given coordinate sequences (each with a different color)

Parameters

line_coords_list – list of lists (grouped sets) of lists holding the coordinates of paths each

plot_timeline_course(line_coords_list: list)None[source]

Plot three curves in the temporal information subplot.

Parameters

line_coords_list – list of cuvre courses

plot_timeline_stamps(time_stamps: list, types: list, lambda_fct)None[source]

Plot a timeline information for a log file

Parameters
  • time_stamps – list of float values holding time in seconds

  • types – list of strings indicating the type of the provided timestamp

  • lambda_fct – lambda function to be handed (to be called when mouse hovers over time-line)

plot_vehicle(pos: numpy.ndarray, heading: list, width: float, length: float, zorder: int = 10, color_str: str = 'blue', id_in: str = 'default', alpha: float = 1.0)None[source]

Plot the pose and shape of one or multiple vehicles.

Parameters
  • pos – numpy array holding one or multiple positions

  • heading – list of floats holding the heading for each position

  • width – width of the vehicle in meters

  • length – length of the vehicle in meters

  • zorder – (optional) z-order of the vehicle

  • color_str – (optional) string specifying the color of the plotted vehicle

  • id_in – (optional) string specifying the id (used to delete the same type of vehicle plotted prev.)

  • alpha – (optional) transparency setting [0, 1]

set_time_markers(time_line_marker, lambda_fct)None[source]

Store the timeline-marker and event lambda function.

Parameters
  • time_line_marker – timeline-marker to be stored

  • lambda_fct – lambda function ot be stored

static show_plot(non_blocking=False)[source]
toggled_radio(_)None[source]

Function called when the radio buttons are toggled.

Parameters

_ – parameter that is handed by event, but unused

update_acc_plot(acc_limit_valid: list, acc_limit_invalid: list)None[source]

Update acceleration data in friction circle plot.

Parameters
  • acc_limit_valid – acceleration coordinates (lat / long) holding an valid entry, plotted in green

  • acc_limit_invalid – acceleration coordinates (lat / long) holding an invalid entry, plotted in red

update_text_field(text_str: str, color_str: str = 'k', text_field_id: int = 1)None[source]

Update the text field in the plot window

Parameters
  • text_str – text string to be displayed

  • color_str – (optional) string specifying the color of the plotted text

  • text_field_id – (optional) id specifying the text field to be updated (default: 1)