vehiclesimulator script

vehiclesimulator

vehiclesimulator.init_vehiclesimulator()[source]

Initialize the vehicle simulator.

Returns the tuple (temperature_simulator, speed_simulator, canbus)

vehiclesimulator.loop_vehiclesimulator(temperature_simulator, speed_simulator, canbus)[source]
vehiclesimulator.main()[source]

vehiclesimulation utilities

class vehiclesimulationutilities.CabinTemperatureSimulator[source]

Bases: object

Simulate the indoor temperature of a vehicle.

The temperature will increase to TEMPERATURE_HOT, but will decrease to TEMPERATURE_COLD when the air conditioner is turned on.

The warming and cooling speeds are affected by GAIN_WARMING and GAIN_COOLING. A random temperature noise is added to the measurement.

This class holds no timer or timing information, so the average rate of temperature change is dependent on how frequently you call getNewTemperature().

temperature

float

Indoor temperature in deg C

aircondition_state

bool

Boolean indicating whether the AC is on

GAIN_COOLING = 0.05
GAIN_WARMING = 0.02
TEMPERATURE_COLD = 18.0
TEMPERATURE_HOT = 32.0
TEMPERATURE_NOISE_DEVIATION = 0.03
aircondition_state
get_new_temperature()[source]

Calculate a new temperature.

Returns the new temperature in deg C.

class vehiclesimulationutilities.VehicleSpeedSimulator[source]

Bases: object

Simulate the speed of a vehicle.

The step size in the vehicle speed is calculated with a normalized distribution using the values:

  • SPEED_STEPSIZE (Should be >0)
  • SPEED_STEPDEVIATION (Should be >0)

When the speed reaches SPEED_MAX, the speed will start to decrease instead. Similarly it starts to increase again at SPEED_MIN.

This class holds no timer or timing information, so the average rate of speed change is dependent on how frequently you call getNewRandomizedSpeed().

currentspeed

float

Vehicle speed in km/h

SPEED_MAX = 110.0
SPEED_MIN = 3.0
SPEED_STEPDEVIATION = 0.9
SPEED_STEPSIZE = 0.3
get_new_randomized_speed()[source]

Calculate a new vehicle speed.

Returns the new value of currentspeed in km/h.

vehiclesimulationutilities.calculate_engine_speed(vehiclespeed)[source]

Calculate the simulated enginespeed.

Parameters:vehiclespeed (float) – Speed in km/h

Returns: Engine speed (float) in RPM (revolutions per minute)