Trajectory Class

Overview

Trajectory Definition

Racing line defined by control points

Trajectory formed by interpolating between control points using SciPy make_interp_spline (https://docs.scipy.org/doc/scipy/reference/generated/scipy.interpolate.make_interp_spline.html#scipy.interpolate.make_interp_spline)

(2D) curvature calculated as Menger curvature (https://en.wikipedia.org/wiki/Menger_curvature), made signed by determining if the points curve left (negative) or right (positive)

Track Limits

From the track left/right edge coordinates, “gates” are drawn perpendicular to the track centreline

Each gate is represented with a Shapely LineString (https://shapely.readthedocs.io/en/stable/reference/shapely.LineString.html#shapely.LineString**)**

Checks the number of track limits gates skipped by making a Shapely LineString from the discretized trajectory coordinates, iterating through all gates and using the intersects function

However the current approach causes problems with gradient descent since the “track limits punishment” function is stepped so gradient descent is bad with it

Attributes

Attribute Type Description
*trajType String Trajectory type (’Closed Circuit’, ‘Point to Point’, ‘Point to Point with Run Up’, ‘Single Lap’)
CP *2D NumPy array Control point locations in [x, y] coordinate form
spline SciPy BSpline object Spline object of the trajectory generated from the control points
pStart Float Control point value crossing the start line
*pFinish Float Control point value crossing the finish line
sTotal Float Total distance of the trajectory from start to finish (excluding the distances before the start line and after the finish line for non-closed circuit trajectories)
sDelta Float Actual discretization step size used
S NumPy array (Signed) distances of the trajectory from the start line at each discretized trajectory point (where positive means after the start line and negative means before the start line)
P NumPy array Control point values corresponding to the s array
XYZ 3D NumPy array Trajectory points in [x, y, z] coordinate form corresponding to the s array
curvature NumPy array (Signed) curvature at each trajectory point corresponding to the s array (where positive means left hand corner and negative means right hand corner)
valid NumPy array Booleans whether the trajectory point is within track limits (True) or not (False) corresponding to the s array
sInvalid Float Length of track limits violated - CHANGE THIS TO AREA OF TRACK LIMITS VIOLATION

init()

Track limits

Inputs

A * indicates the input is optional

Name Type Description
trajType String Trajectory type (’Closed Circuit’, ‘Point to Point’, ‘Point to Point with Run Up’, ‘Single Lap’)
track Track object Track object that the trajectory is made for - note that this object already includes the track limits considerations of the car’s width
CP 2D list or 2D NumPy array Control point locations in [x, y] coordinate form
sDelta Float Desired discretization step distance
carWidth Float Width of the car at its widest point
*margin Float Extra width to leave as a margin to left and right bounds (defaults to 0)
*marginExtend Float Extra width to leave as a margin to leftExtend and rightExtend bounds (defaults to 0)
*degree Int B-spline degree to use for the interpolation between control points (defaults to 3)

To Do

Ideas