suboptimumg.vehicle.vehicle#

class suboptimumg.vehicle.vehicle.Car(vehicle_model)[source]#

Bases: object

Parameters:

vehicle_model (VehicleModel)

accelerate_forwards_dx(radius, distance_step, state)[source]#

Redesigned Move function that determines how the car should accelerate.

Parameters:
  • radius (float) – Radius of the current corner

  • distance_step (float)

  • state (SimulationState)

Returns:

(dt, p, acc) time step [s], power [W], and longitudinal acceleration [m/s^2] respectively

Return type:

tuple

brake_backwards_dx(radius, distance_step, state)[source]#
Parameters:
calculate_and_return_longitudinal_forces()[source]#
calculate_and_update_lateral_forces(lat_acc)[source]#

Calculates the lateral force exerted on each tire based on the normal force and the centripetal force acting on the vehicle. If the front or rear axle is completely off the ground, the correponding tire lateral forces will be evaluated as 0.

calculate_norm_and_aero(acc, lat_acc, roll, pitch, vel, backwards_pass=False)[source]#

Calculates the aero moment based on current velocity, frontal area, and coefficient of lift.

Returns:

Aero moment.

Return type:

float

calculate_top_speed(max_steps=20, v_low=0, v_high=50)[source]#

binary searches what velocity drag and rolling resistance equals max motor force

car_reset()[source]#

Resets the car’s state variables to their initial values for a fresh start.

car_weight_distributor(backwards_pass=False, acc=None, lat_acc=None)[source]#

does weight transfer, returns normal force of tires in N

check_all_tires_valid_lateral_force()[source]#
coast_forwards_dx(radius, distance_step, state)[source]#

Lifts and coasts for endurance.

Parameters:
  • radius (float) – Corner radius of the current corner.

  • distance_step (float)

  • state (SimulationState)

Returns:

A tuple containing the time step (dt), power (p), and acceleration (acc).

Return type:

tuple

get_current_params(var_name)[source]#

Retrieves the current value of a car parameter given its name.

Parameters:

var_name (str) – The name of the parameter to retrieve (e.g., ‘pwrtn.motor.max_rpm’).

Returns:

The current value of the specified parameter.

Return type:

any

max_stable_speed(radius, converge_steps=20, resolution=0.008, stabilize_steps=1)[source]#

Experimentally binary searches for the maximum speed at which the car can safely navigate a corner. DO NOT use this function in the middle of a simulated lap! This calculation will involve resetting the car’s state variables. Note that self.acc does not necessarily need to be near-zero when the solution is converged to be valid. (i.e., an understeery car) Note that stabilize_steps must be >1 (probably >5) for accurate results when roll/pitch/etc. sensitivity is used.

Parameters:
  • radius (float) – The radius of the corner [m]

  • converge_steps (int) – The maximum number of solution iterations. Default: 20.

  • resolution (float) – Tolerance of final velocity solution. Default: 0.008 [m/s]

  • stabilize_steps (int) – How many times to iterate each velocity check. Necessary for roll/pitch/etc. Default: 1

Returns:

The maximum stable cornering speed [m/s]

Return type:

float

modify_params(var_name, new_var_value)[source]#

Modifies a car parameter given its name and new value.

Parameters:
  • var_name (str) – The name of the parameter to modify (e.g., ‘pwrtn.motor.max_rpm’).

  • new_var_value (any) – The new value to set for the specified parameter.

try_accelerate_forwards_for_max_speed_calc(radius, state)[source]#
Parameters:

state (SimulationState)