GIS#

class physics.environment.gis.GIS(route_data, origin_coord, current_coord=None)#

Bases: BaseGIS

calculate_closest_gis_indices(distances)#

Takes in an array of point distances from starting point, returns a list of self.path indices of coordinates which have a distance from the starting point closest to the point distances.

Parameters:

distances (np.ndarray) – (float[N]) array of distances, where cumulative_distances[x] > cumulative_distances[x-1]

Returns:

(float[N]) array of indices of path

Return type:

np.ndarray

calculate_current_heading_array()#

Calculates the bearing of the vehicle between consecutive points https://www.movable-type.co.uk/scripts/latlong.html

Returns:

array of bearings

Return type:

np.ndarray

calculate_driving_speeds(average_lap_speeds: _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes], simulation_dt: int, driving_allowed: _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes], idle_time: int, laps_per_speed: int) ndarray[Any, dtype[float]]#

Generate valid driving speeds as a simulation-time array given a set of average speeds for each simulated lap. Driving speeds will only be non-zero when we are allowed to drive, and the speed for every tick during a lap will be that lap’s corresponding desired average speed for as long as it takes to complete the lap.

Parameters:
  • average_lap_speeds – An array of average speeds in m/s, one for each simulated lap. If there are more speeds given than laps available, the unused speeds will be silently ignored. If there are too few, an error will be returned.

  • simulation_dt – The simulated tick length.

  • driving_allowed – A simulation-time boolean where the True elements are when we are allowed to drive, and False is when we are not. Requires that (at least) the first element is False due to the race beginning in the morning before we are allowed to drive.

  • idle_time – The length of time to pause driving upon processing a “0m/s” average speed.

  • laps_per_speed – The amount of laps that we expect to use with each speed value.

Returns:

A simulation-time array of driving speeds in m/s, or an error if there weren’t enough laps provided to fill the entire simulation time.

calculate_path_min_max()#
calculate_speeds_and_position(speeds_kmh: ndarray[Any, dtype[_ScalarType_co]], track_speeds: ndarray[Any, dtype[_ScalarType_co]], dt: int)#
get_gradients(gis_indices)#

Takes in an array of path indices, returns the road gradient at each index

Parameters:

gis_indices (np.ndarray) – (float[N]) array of path indices

Returns:

(float[N]) array of road gradients

Rtype np.ndarray:

get_path()#

Returns all N coordinates of the path in a NumPy array [N][latitude, longitude]

Return type:

np.ndarray

get_path_distances()#

Returns all N-1 distances of the path in a NumPy array [N-1][elevation]

Return type:

np.ndarray

get_path_elevations()#

Returns all N elevations of the path in a NumPy array [N][elevation]

Return type:

np.ndarray

get_path_gradients()#

Returns all N-1 gradients of a path in a NumPy array [N-1][gradient]

Return type:

np.ndarray

get_time_zones(gis_indices)#

Takes in an array of path indices, returns the time zone at each index

Parameters:

gis_indices (np.ndarray) – (float[N]) array of path indices

Returns:

(float[N]) array of time zones in seconds

Return type:

np.ndarray

static process_KML_file(route_file)#

Load the FSGP Track from a KML file exported from a Google Earth project.

Ensure to follow guidelines enumerated in this directory’s README.md when creating and loading new route files.

Returns:

Array of N coordinates (latitude, longitude) in the shape [N][2].

class physics.environment.gis.BaseGIS#

Bases: ABC

abstract calculate_closest_gis_indices(cumulative_distances) ndarray#
abstract calculate_current_heading_array() ndarray#
calculate_driving_speeds(average_lap_speeds: _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes], simulation_dt: int, driving_allowed: _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes], idle_time: int, laps_per_speed: int) ndarray[Any, dtype[float]]#
abstract static calculate_speeds_and_position(speeds_kmh: ndarray[Any, dtype[_ScalarType_co]], track_speeds, path_distances, dt)#
abstract get_gradients(gis_indices) ndarray#
abstract get_path() ndarray#
abstract get_path_elevations() ndarray#
abstract get_time_zones(gis_indices) ndarray#