suboptimumg.track.track#

class suboptimumg.track.track.Track(dx, radius, cumulative_dist, x_m, y_m, distance_step, continuous, **kwargs)[source]#

Bases: object

Represents a racing track with discrete or continuous curvature representation.

Parameters:
  • dx (NDArray[float64]) – Array of distance steps

  • radius (NDArray[float64]) – Array of radius of curvature values

  • cumulative_dist (NDArray[float64]) – Array of cumulative distances along the track

  • x_m (NDArray[float64]) – Array of x coordinates in meters

  • y_m (NDArray[float64]) – Array of y coordinates in meters

  • distance_step (float) – Length of each step in meters

  • continuous (bool) – If True, track uses continuous representation; if False, uses discrete corner-based representation

  • **kwargs (dict) – Additional keyword arguments: - For discrete tracks: original_corners (List[List]), arcs (List[ArcData]) - For continuous tracks: sample_dist (float), tck (B-spline representation)

get_curvature_array()[source]#

Get a copy of the radius of curvature array.

Returns:

Copy of the radius array

Return type:

NDArray[float64]

get_dist_from_start_array()[source]#

Get a copy of the cumulative distance array.

Returns:

Copy of the cumulative distance array

Return type:

NDArray[float64]

get_dx_array()[source]#

Get a copy of the distance step array.

Returns:

Copy of the dx array

Return type:

NDArray[float64]

get_simulation_seeds()[source]#

Get a copy of the simulation seed indices.

Returns:

Copy of the seed index array

Return type:

NDArray[int32]

plot(theme=None, font_config=None, layout_config=None)[source]#

Visualizes the track.

Parameters:
  • theme (str, optional) – The color theme to use (default: None, uses default theme)

  • font_config (FontConfig, optional) – Font configuration object (default: None, uses DEFAULT_FONT_CONFIG)

  • layout_config (LayoutConfig, optional) – Layout configuration object (default: None, uses DEFAULT_LAYOUT_CONFIG)

Returns:

Plotly figure object

Return type:

go.Figure

plot_3d(variable, title=None, z_label=None, theme=None, font_config=None, layout_config=None, scene_config=None)[source]#

Maps a variable onto the z-axis of the track for 3D visualization using Plotly. Creates a 3D stem plot with vertical lines extending from baseline to data points.

Parameters:
  • variable (NDArray[float64]) – Array of values to map to z-axis (e.g., velocity, power)

  • title (str, optional) – Plot title (default: None)

  • z_label (str, optional) – Z-axis label (default: None)

  • theme (str, optional) – The color theme to use (default: None)

  • font_config (FontConfig, optional) – Font configuration object (default: None, uses DEFAULT_FONT_CONFIG)

  • layout_config (LayoutConfig, optional) – Layout configuration object (default: None, uses DEFAULT_LAYOUT_CONFIG)

  • scene_config (SceneConfig, optional) – Scene configuration object for 3D view (default: None, uses DEFAULT_SCENE_CONFIG)

Returns:

Plotly figure object

Return type:

go.Figure

plot_arcs(figsize=(20, 12), show_endpoints=True)[source]#

Plot the track using Matplotlib Arc objects. Only available for discrete (corner-based) tracks. A validation tool to visualize our corners.

Parameters:
  • figsize (tuple, optional) – Figure size as (width, height) in inches (default: (20, 12))

  • show_endpoints (bool, optional) – Whether to show arc endpoints as blue dots (default: True)

Returns:

(fig, ax) - matplotlib figure and axes objects

Return type:

tuple

plot_with_overlay(variable, label=None, theme=None, font_config=None, layout_config=None, colorbar_config=None)[source]#

Visualizes a scalar variable as color along the 2D track.

Parameters:
  • variable (NDArray[float64]) – Array of values to map as colors (e.g., velocity, power)

  • label (str, optional) – Colorbar label (default: None)

  • theme (str, optional) – The color theme to use (default: None, uses default theme)

  • font_config (FontConfig, optional) – Font configuration object (default: None, uses DEFAULT_FONT_CONFIG)

  • layout_config (LayoutConfig, optional) – Layout configuration object (default: None, uses DEFAULT_LAYOUT_CONFIG)

  • colorbar_config (ColorbarConfig, optional) – Colorbar configuration object (default: None, uses DEFAULT_COLORBAR_CONFIG)

Returns:

Plotly figure object

Return type:

go.Figure

radius_of_curvature(d)[source]#

Get the radius of curvature at distance d along the track.

For continuous tracks: Uses Menger curvature for smooth calculation For discrete tracks: Returns the discretized radius value

Parameters:

d (float) – Distance along the track in meters

Returns:

Radius of curvature in meters

Return type:

float

to_data()[source]#

Serialize the Track to a TrackData model for Pydantic serialization.

Returns:

A ContinuousTrackData or DiscreteTrackData instance containing all track data

Return type:

TrackData