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: 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(variable=None, title=None, label=None, rotate_by_deg=0.0, theme='suspension', font_config=None, layout_config=None, colorbar_config=None)[source]#

Visualizes the track, optionally coloured by a scalar variable.

When variable is None, the track is coloured by radius of curvature. Otherwise, variable is mapped to the colour axis and must have the same length as the track arrays.

Parameters:
  • variable (NDArray[float64] or None) – Per-point scalar values to map as colours. None uses radius of curvature.

  • title (str, optional) – Plot title.

  • label (str, optional) – Colorbar label. Defaults to "Radius (m)" when variable is None.

  • rotate_by_deg (float, optional) – Rotation angle in degrees counterclockwise around the first point.

  • theme (str, optional) – Colour theme name (default: "suspension").

  • font_config (FontConfig, optional)

  • layout_config (LayoutConfig, optional)

  • colorbar_config (ColorbarConfig, optional)

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

radius_of_curvature(d)[source]#

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

Interpolates the precomputed radius array for both continuous and discrete tracks.

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