Eclipse SUMO - Simulation of Urban MObility
|
#include <RealisticEngineModel.h>
Public Member Functions | |
void | getEngineData (double speed_mps, int &gear, double &rpm) |
virtual double | getRealAcceleration (double speed_mps, double accel_mps2, double reqAccel_mps2, SUMOTime timeStep=0) |
void | loadParameters () |
RealisticEngineModel () | |
void | setMaximumAcceleration (double maxAcc) |
void | setMaximumDeceleration (double maxDec) |
virtual void | setParameter (const std::string parameter, const std::string &value) |
virtual void | setParameter (const std::string parameter, double value) |
virtual void | setParameter (const std::string parameter, int value) |
virtual | ~RealisticEngineModel () |
Protected Member Functions | |
double | airDrag_N (double speed_mps) |
double | airDrag_N (double speed_mps, double cAir, double a_m2, double rho_kgpm3) |
double | getEngineTimeConstant_s (double rpm) |
double | getRealBrakingAcceleration (double speed_mps, double accel_mps2, double reqAccel_mps2, SUMOTime t) |
double | gravityForce_N () |
double | gravityForce_N (double mass_kg, double slope) |
double | maxEngineAcceleration_mps2 (double speed_mps) |
double | maxNoSlipAcceleration_mps2 () |
double | maxNoSlipAcceleration_mps2 (double slope, double frictionCoefficient) |
double | opposingForce_N (double speed_mps) |
double | opposingForce_N (double speed_mps, double mass_kg, double slope, double cAir, double a_m2, double rho_kgpm3, double cr1, double cr2) |
void | parseParameter (const Parameterised::Map ¶meters, std::string parameter, double &value) |
void | parseParameter (const Parameterised::Map ¶meters, std::string parameter, int &value) |
void | parseParameter (const Parameterised::Map ¶meters, std::string parameter, std::string &value) |
int | performGearShifting (double speed_mps, double acceleration_mps2) |
void | printParameterError (std::string parameter, std::string value) |
double | rollingResistance_N (double speed_mps) |
double | rollingResistance_N (double speed_mps, double mass_kg, double cr1, double cr2) |
double | rpmToPower_hp (double rpm) |
double | rpmToPower_hp (double rpm, const struct EngineParameters::PolynomialEngineModelRpmToHp *engineMapping) |
double | rpmToSpeed_mps (double rpm) |
double | rpmToSpeed_mps (double rpm, double wheelDiameter_m, double differentialRatio, double gearRatio) |
double | speed_mpsToPower_hp (double speed_mps) |
double | speed_mpsToPower_hp (double speed_mps, const struct EngineParameters::PolynomialEngineModelRpmToHp *engineMapping, double wheelDiameter_m, double differentialRatio, double gearRatio) |
double | speed_mpsToRpm (double speed_mps) |
double | speed_mpsToRpm (double speed_mps, double gearRatio) |
double | speed_mpsToRpm (double speed_mps, double wheelDiameter_m, double differentialRatio, double gearRatio) |
double | speed_mpsToThrust_N (double speed_mps) |
double | speed_mpsToThrust_N (double speed_mps, const struct EngineParameters::PolynomialEngineModelRpmToHp *engineMapping, double wheelDiameter_m, double differentialRatio, double gearRatio, double engineEfficiency) |
double | thrust_NToAcceleration_mps2 (double thrust_N) |
Protected Attributes | |
std::string | className |
int | currentGear |
double | dt_s |
EngineParameters | ep |
double | maxAcceleration_mpsps |
double | maxDeceleration_mpsps |
double | minSpeed_mps |
std::string | vehicleType |
std::string | xmlFile |
This class implements a detailed engine and braking model which takes into account engine characteristics, gear ratios, external forces due to air drag, etc. This class uses a particular notation for variables to take into account both name and unit, to avoid confusion and mistakes. We write the name in camel case, then an underscore, then the unit of measure. For example, engine force in newton (kg * m / s^2) we use
double engineForce_kgmps2
so units which are multiplied are just one next to the other (kgm), "p" denotes "per", while the exponent is just a number attached to the unit (s2). The same notation is used for functions that compute quantities
Definition at line 47 of file RealisticEngineModel.h.
RealisticEngineModel::RealisticEngineModel | ( | ) |
Definition at line 37 of file RealisticEngineModel.cpp.
References GenericEngineModel::className, EngineParameters::differentialRatio, dt_s, ep, EngineParameters::gearRatios, EngineParameters::minRpm, minSpeed_mps, rpmToSpeed_mps(), EngineParameters::wheelDiameter_m, and xmlFile.
|
virtual |
Definition at line 45 of file RealisticEngineModel.cpp.
|
protected |
Computes air drag resistance using stored values
[in] | speed_mps | vehicle speed in meters per second |
Definition at line 130 of file RealisticEngineModel.cpp.
References EngineParameters::__airFrictionCoefficient, and ep.
|
protected |
Computes air drag resistance
[in] | speed_mps | vehicle speed in meters per second |
[in] | cAir | drag coefficient |
[in] | a_m2 | maximum vehicle section in square meters |
[in] | rho_kgpm3 | air density in kilograms per cubic meter |
Definition at line 125 of file RealisticEngineModel.cpp.
Referenced by opposingForce_N(), and opposingForce_N().
void RealisticEngineModel::getEngineData | ( | double | speed_mps, |
int & | gear, | ||
double & | rpm | ||
) |
Returns current engine RPM and gear
[in] | speed_mps | current speed |
[out] | gear | current gear |
[out] | rpm | engine's rpm |
Definition at line 250 of file RealisticEngineModel.cpp.
References currentGear, and speed_mpsToRpm().
Referenced by MSCFModel_CC::getParameter().
|
protected |
Computes the engine actuation time constant as function of the rpm
[in] | rpm | engine rpm |
Definition at line 205 of file RealisticEngineModel.cpp.
References EngineParameters::__engineTau1, EngineParameters::__engineTau2, EngineParameters::__engineTauDe_s, ep, EngineParameters::fixedTauBurn, TAU_MAX, and EngineParameters::tauEx_s.
Referenced by getRealAcceleration().
|
virtual |
Computes real vehicle acceleration given current speed, current acceleration, and requested acceleration. If the requested acceleration is negative, then the braking model is invoked
[in] | speed_mps | current speed in meters per second |
[in] | accel_mps2 | current acceleration in meters per squared second |
[in] | reqAccel_mps2 | requested acceleration in meters per squared second |
[in] | timeStep | current simulation timestep. needed for debugging purposes only |
Implements GenericEngineModel.
Definition at line 222 of file RealisticEngineModel.cpp.
References EngineParameters::dt, ep, getEngineTimeConstant_s(), getRealBrakingAcceleration(), maxEngineAcceleration_mps2(), maxNoSlipAcceleration_mps2(), minSpeed_mps, opposingForce_N(), performGearShifting(), speed_mpsToRpm(), and thrust_NToAcceleration_mps2().
|
protected |
Computes real vehicle deceleration
[in] | speed_mps | current speed in meters per second |
[in] | accel_mps2 | current vehicle acceleration in meters per squared second |
[in] | reqAccel_mps2 | the requested deceleration in meters per squared second. Notice that this value must be negative |
[in] | the | real deceleration in meters per squared second. Notice that the returned value is an acceleration, you should not invert it |
Definition at line 256 of file RealisticEngineModel.cpp.
References EngineParameters::__brakesAlpha, EngineParameters::__brakesOneMinusAlpha, ep, maxNoSlipAcceleration_mps2(), opposingForce_N(), thrust_NToAcceleration_mps2(), and UNUSED_PARAMETER.
Referenced by getRealAcceleration().
|
protected |
Computes gravitational force using stored values
Definition at line 150 of file RealisticEngineModel.cpp.
References EngineParameters::__gravity, and ep.
Referenced by opposingForce_N(), and opposingForce_N().
|
protected |
Computes gravitational force due to slope
[in] | mass_kg | vehicle mass in kg |
[in] | slope | road slope in degrees |
Definition at line 145 of file RealisticEngineModel.cpp.
References GRAVITY_MPS2, and M_PI.
void RealisticEngineModel::loadParameters | ( | ) |
Load parameters from xml file
Definition at line 270 of file RealisticEngineModel.cpp.
References EngineParameters::computeCoefficients(), EngineParameters::differentialRatio, EngineParameters::dt, dt_s, ep, EngineParameters::gearRatios, VehicleEngineHandler::getEngineParameters(), EngineParameters::minRpm, minSpeed_mps, rpmToSpeed_mps(), XMLSubSys::runParser(), vehicleType, EngineParameters::wheelDiameter_m, and xmlFile.
Referenced by setParameter().
|
protected |
Computes maximum vehicle acceleration. This function computes the maximum acceleration at the wheel, considering tires friction but without considering air friction, rolling resistance, and road slope.
[in] | speed_mps | current speed in meters per second |
Definition at line 200 of file RealisticEngineModel.cpp.
References EngineParameters::__maxAccelerationCoefficient, ep, and speed_mpsToThrust_N().
Referenced by getRealAcceleration().
|
protected |
Computes maximum acceleration without slipping tires using stored values
Definition at line 174 of file RealisticEngineModel.cpp.
References EngineParameters::__maxNoSlipAcceleration, and ep.
Referenced by getRealAcceleration(), and getRealBrakingAcceleration().
|
protected |
Computes maximum acceleration without slipping tires
[in] | slope | road slope in degrees |
[in] | frictionCoefficient | tires friction coefficient |
Definition at line 169 of file RealisticEngineModel.cpp.
References GRAVITY_MPS2, and M_PI.
|
protected |
Computes total opposing force, using stored values
[in] | speed_mps | speed in meters per second |
Definition at line 164 of file RealisticEngineModel.cpp.
References airDrag_N(), gravityForce_N(), and rollingResistance_N().
|
protected |
Computes total opposing force, i.e., air drag, rolling resistance, and gravity
[in] | speed_mps | speed in meters per second |
[in] | mass_kg | vehicle mass in kg |
[in] | slope | road slope in degrees |
[in] | cAir | drag coefficient |
[in] | a_m2 | maximum vehicle section in square meters |
[in] | rho_kgpm3 | air density in kilograms per cubic meter |
[in] | cr1 | tires parameter |
[in] | cr2 | tires parameter |
Definition at line 155 of file RealisticEngineModel.cpp.
References airDrag_N(), gravityForce_N(), and rollingResistance_N().
Referenced by getRealAcceleration(), and getRealBrakingAcceleration().
|
protectedinherited |
Parses a value from the parameter map
Definition at line 32 of file GenericEngineModel.cpp.
References GenericEngineModel::printParameterError(), and StringUtils::toDouble().
Referenced by FirstOrderLagModel::loadParameters().
|
protectedinherited |
Definition at line 42 of file GenericEngineModel.cpp.
References GenericEngineModel::printParameterError(), and StringUtils::toInt().
|
protectedinherited |
Definition at line 52 of file GenericEngineModel.cpp.
|
protected |
Computes current gear according to gear shifting rules
[in] | speed_mps | current speed in meters per second |
[in] | acceleration_mps2 | current acceleration in meters per squared second |
Definition at line 184 of file RealisticEngineModel.cpp.
References currentGear, EngineParameters::GearShiftingRules::deltaRpm, ep, EngineParameters::gearRatios, EngineParameters::nGears, EngineParameters::GearShiftingRules::rpm, EngineParameters::shiftingRule, and speed_mpsToRpm().
Referenced by getRealAcceleration().
|
protectedinherited |
Prints a parameter error
Definition at line 28 of file GenericEngineModel.cpp.
References GenericEngineModel::className.
Referenced by GenericEngineModel::parseParameter(), and GenericEngineModel::parseParameter().
|
protected |
Computes rolling resistance using stored values
[in] | speed_mps | vehicle speed in meters per second |
Definition at line 140 of file RealisticEngineModel.cpp.
References EngineParameters::__cr1, EngineParameters::__cr2, and ep.
|
protected |
Computes rolling resistance
[in] | speed_mps | vehicle speed in meters per second |
[in] | mass_kg | mass of the vehicle in kg |
[in] | cr1 | tires parameter |
[in] | cr2 | tires parameter |
Definition at line 135 of file RealisticEngineModel.cpp.
References GRAVITY_MPS2.
Referenced by opposingForce_N(), and opposingForce_N().
|
protected |
Computes the available power (hp) using stored values
[in] | rpm | engine speed in rpm |
Definition at line 84 of file RealisticEngineModel.cpp.
References EngineParameters::PolynomialEngineModelRpmToHp::degree, EngineParameters::engineMapping, ep, EngineParameters::maxRpm, and EngineParameters::PolynomialEngineModelRpmToHp::x.
|
protected |
Given an engine mapping computes the available power (hp) given current engine speed in rpm
[in] | rpm | engine speed in rpm |
[in] | engineMapping | engine mapping from rpm to hp |
Definition at line 75 of file RealisticEngineModel.cpp.
References EngineParameters::PolynomialEngineModelRpmToHp::degree, and EngineParameters::PolynomialEngineModelRpmToHp::x.
Referenced by speed_mpsToPower_hp(), and speed_mpsToPower_hp().
|
protected |
Computes vehicle speed in mps using stored values
[in] | rpm | engine rotation speed in rpm |
Definition at line 54 of file RealisticEngineModel.cpp.
References EngineParameters::__rpmToSpeedCoefficient, currentGear, ep, and EngineParameters::gearRatios.
|
protected |
Given engine rotation in rpm, tracting wheels diameter, differential ratio, and gear ratio, computes vehicle speed in mps
[in] | rpm | engine rotation speed in rpm |
[in] | wheelDiameter_m | tracting wheels diameter in m |
[in] | differentialRatio | differential ratio |
[in] | gearRatio | gear ratio |
Definition at line 48 of file RealisticEngineModel.cpp.
References M_PI.
Referenced by loadParameters(), and RealisticEngineModel().
|
inherited |
Sets maximum acceleration value
[in] | maximum | acceleration in meters per second squared |
Definition at line 58 of file GenericEngineModel.cpp.
References GenericEngineModel::maxAcceleration_mpsps.
Referenced by MSCFModel_CC::createVehicleVariables(), and MSCFModel_CC::setParameter().
|
inherited |
Sets maximum deceleration value
[in] | maximum | deceleration (positive value) in meters per second squared |
Definition at line 61 of file GenericEngineModel.cpp.
References GenericEngineModel::maxDeceleration_mpsps.
Referenced by MSCFModel_CC::createVehicleVariables(), and MSCFModel_CC::setParameter().
|
virtual |
Sets a single parameter value
[in] | parameter | the name of the parameter |
[in] | value | the value for the parameter |
Implements GenericEngineModel.
Definition at line 284 of file RealisticEngineModel.cpp.
References ENGINE_PAR_VEHICLE, ENGINE_PAR_XMLFILE, loadParameters(), vehicleType, and xmlFile.
|
virtual |
Implements GenericEngineModel.
Definition at line 297 of file RealisticEngineModel.cpp.
References dt_s, and ENGINE_PAR_DT.
|
virtual |
Implements GenericEngineModel.
Definition at line 304 of file RealisticEngineModel.cpp.
References UNUSED_PARAMETER.
|
protected |
Computes the available power at the current speed using stored values
[in] | speed_mps | vehicle speed in meters per second |
Definition at line 105 of file RealisticEngineModel.cpp.
References rpmToPower_hp(), and speed_mpsToRpm().
|
protected |
Given vehicle speed in mps, and the rpm to hp mapping, computes the available power at the current speed
[in] | speed_mps | vehicle speed in meters per second |
[in] | engineMapping | engine mapping from rpm to hp |
[in] | wheelDiameter_m | tracting wheels diameter in m |
[in] | differentialRatio | differential ratio |
[in] | gearRatio | gear ratio |
Definition at line 96 of file RealisticEngineModel.cpp.
References rpmToPower_hp(), and speed_mpsToRpm().
Referenced by speed_mpsToThrust_N(), and speed_mpsToThrust_N().
|
protected |
Computes engine rotation speed in rpm using stored values
[in] | speed_mps | vehicle speed in meters per second |
Definition at line 65 of file RealisticEngineModel.cpp.
References EngineParameters::__speedToRpmCoefficient, currentGear, ep, and EngineParameters::gearRatios.
|
protected |
Computes engine rotation speed in rpm using stored values and given gear ratio
[in] | speed_mps | vehicle speed in meters per second |
[in] | gearRatio | gear ratio |
Definition at line 70 of file RealisticEngineModel.cpp.
References EngineParameters::__speedToRpmCoefficient, and ep.
|
protected |
Given vehicle speed in mps, tracting wheels diameter, differential ratio, and gear ratio, computes engine rotation speed in rpm
[in] | speed_mps | vehicle speed in meters per second |
[in] | wheelDiameter_m | tracting wheels diameter in m |
[in] | differentialRatio | differential ratio |
[in] | gearRatio | gear ratio |
Definition at line 59 of file RealisticEngineModel.cpp.
References M_PI.
Referenced by getEngineData(), getRealAcceleration(), performGearShifting(), speed_mpsToPower_hp(), and speed_mpsToPower_hp().
|
protected |
Computes the available maximum thrust at current speed using stored values
[in] | speed_mps | vehicle speed in meters per second |
Definition at line 119 of file RealisticEngineModel.cpp.
References EngineParameters::__speedToThrustCoefficient, ep, and speed_mpsToPower_hp().
|
protected |
Given vehicle speed in mps, and the rpm to hp mapping, computes the available maximum thrust at current speed
[in] | speed_mps | vehicle speed in meters per second |
[in] | engineMapping | engine mapping from rpm to hp |
[in] | wheelDiameter_m | tracting wheels diameter in m |
[in] | differentialRatio | differential ratio |
[in] | gearRatio | gear ratio |
[in] | engineEfficiency | engine efficiency |
Definition at line 110 of file RealisticEngineModel.cpp.
References HP_TO_W, and speed_mpsToPower_hp().
Referenced by maxEngineAcceleration_mps2().
|
protected |
Computes the acceleration for a certain thrust, using stored values of mass
[in] | thrust_N | thrust in N |
Definition at line 179 of file RealisticEngineModel.cpp.
References EngineParameters::__maxAccelerationCoefficient, and ep.
Referenced by getRealAcceleration(), and getRealBrakingAcceleration().
|
protectedinherited |
Definition at line 83 of file GenericEngineModel.h.
Referenced by FirstOrderLagModel::FirstOrderLagModel(), GenericEngineModel::printParameterError(), and RealisticEngineModel().
|
protected |
Definition at line 53 of file RealisticEngineModel.h.
Referenced by getEngineData(), performGearShifting(), rpmToSpeed_mps(), and speed_mpsToRpm().
|
protected |
Definition at line 57 of file RealisticEngineModel.h.
Referenced by loadParameters(), RealisticEngineModel(), and setParameter().
|
protected |
Definition at line 51 of file RealisticEngineModel.h.
Referenced by airDrag_N(), getEngineTimeConstant_s(), getRealAcceleration(), getRealBrakingAcceleration(), gravityForce_N(), loadParameters(), maxEngineAcceleration_mps2(), maxNoSlipAcceleration_mps2(), performGearShifting(), RealisticEngineModel(), rollingResistance_N(), rpmToPower_hp(), rpmToSpeed_mps(), speed_mpsToRpm(), speed_mpsToRpm(), speed_mpsToThrust_N(), and thrust_NToAcceleration_mps2().
|
protectedinherited |
Definition at line 86 of file GenericEngineModel.h.
Referenced by FirstOrderLagModel::getRealAcceleration(), and GenericEngineModel::setMaximumAcceleration().
|
protectedinherited |
Definition at line 86 of file GenericEngineModel.h.
Referenced by FirstOrderLagModel::getRealAcceleration(), and GenericEngineModel::setMaximumDeceleration().
|
protected |
Definition at line 55 of file RealisticEngineModel.h.
Referenced by getRealAcceleration(), loadParameters(), and RealisticEngineModel().
|
protected |
Definition at line 61 of file RealisticEngineModel.h.
Referenced by loadParameters(), and setParameter().
|
protected |
Definition at line 59 of file RealisticEngineModel.h.
Referenced by loadParameters(), RealisticEngineModel(), and setParameter().