Introduction
Car is an object defined in car_model.py that consumes a self, m, Crr, CdA, max_force, speed_min_ms, speed_max_ms
With a Car object, we can generate the following:
The force required for the car to accelerate to a certain velocity , using the
force_req()
methodThe maximum velocity of the car at a certain point in the elevation map, using the
max_velocity()
methodThe energy used by the car to move through the course with the given elevation map and velocity profile , using the
energy_used()
method
The object initialization
6 parameters (excluding self
)
m
: Mass of the car, defaulted to 720kg
Crr
: Rolling resistance coefficient of the car, defaulted to 0.0015
CdA
: Drag coefficient of the car, defaulted to 0.15
max_force
: Max force of the car’s motors, defaulted to 100N
speed_min_ms
: Minimum speed to travel, defaulted to 15m/s
speed_max_ms
: Minimum speed to travel, defaulted to 45m/s
All values instance variables to be used in functions below, as well as
g = 9.81 # Acceleration due to gravity in m/s^2 rho = 1.225 # Density of air at room temperature
as static variable constants.
Functions
The force_req()
function
Parameters
v
: (Numbers) final velocity of the car to accelerate to, (m/s)vwind
: (Numbers) velocity of the wind relative to the car, (m/s)v_old
: (Numbers) initial velocity of the car, (m/s)theta
: (Numbers) angle that must be climbed (radians) personally don’t understand why “climb” matters and not just angle of elevationtimestep
: (Numbers) Time between measurements, (s)usually calculated
dist / ((v + old_v)/2)
,dist
being the distance between two points in elevation profile,e_profile
.
Returns
Fmotor
: (Numbers) Force of motors required to accelerate to a certain velocity in a certain time (N)
Note
If
v
orv_old
greater than maximum speed or less than minimum speed, it is caught in the function and whatever is out of bounds is set to maximum speed or minimum speedFfric
,Fdrag
,Fg
,Fa
, and ultimatelyFmotor
to be all calculated inside the function, using parameters and constants
The max_velocity()
function
Parameters
v
: (Numbers) final velocity of the car to accelerate to, (m/s)vwind
: (Numbers) velocity of the wind relative to the car, (m/s)v_old
: (Numbers) initial velocity of the car, (m/s)theta
: (Numbers) angle that must be climbed (radians) personally don’t understand why “climb” matters and not just angle of elevationtimestep
: (Numbers) Time between measurements, (s)usually calculated
dist / ((v + old_v)/2)
,dist
being the distance between two points in elevation profile,e_profile
.
Returns
Fmotor
: (Numbers) Force of motors required to accelerate to a certain velocity in a certain time (N)
Note
If
v
orv_old
greater than maximum speed or less than minimum speed, it is caught in the function and whatever is out of bounds is set to maximum speed or minimum speedFfric
,Fdrag
,Fg
,Fa
, and ultimatelyFmotor
to be all calculated inside the function, using parameters and constants
The energy_used()
function
Parameters
v
: (Numbers) final velocity of the car to accelerate to, (m/s)vwind
: (Numbers) velocity of the wind relative to the car, (m/s)v_old
: (Numbers) initial velocity of the car, (m/s)theta
: (Numbers) angle that must be climbed (radians) personally don’t understand why “climb” matters and not just angle of elevationtimestep
: (Numbers) Time between measurements, (s)usually calculated
dist / ((v + old_v)/2)
,dist
being the distance between two points in elevation profile,e_profile
.
Returns
Fmotor
: (Numbers) Force of motors required to accelerate to a certain velocity in a certain time (N)
Note
If
v
orv_old
greater than maximum speed or less than minimum speed, it is caught in the function and whatever is out of bounds is set to maximum speed or minimum speedFfric
,Fdrag
,Fg
,Fa
, and ultimatelyFmotor
to be all calculated inside the function, using parameters and constants