Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Version History

« Previous Version 3 Next »

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() method

  • The maximum velocity of the car at a certain point in the elevation map, using the max_velocity() method

  • The 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 elevation

    • timestep: (Numbers) Time between measurements, (s)

      • usually calculated dist / ((v + old_v)/2), dist being the distance between two points in elevation profile, e_profile. v

  • Returns

    • Fmotor: (Numbers) Force of motors required to achieve the movement specified by the parameter (N)

  • Calculations

Fa = self.m * (v - v_old) / timestep
Fmotor = Fa + Ffric + Fdrag + Fg

mass of car * change in velocity

The max_velocity() function

Consumes a string, filename, and saves a csv of the interpolated route as <filename>.csv in current directory

The energy_used() function

Consumes a string, filename, and saves a csv of the interpolated route as <filename>.csv in current directory

Sample code

 
  • No labels