![]() |
Eclipse SUMO - Simulation of Urban MObility
|
#include <RealisticEngineModel.h>
Public Types | |
typedef std::map< std::string, std::string > | ParMap |
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) |
virtual void | loadParameters (const ParMap ¶meters) |
void | loadParameters () |
RealisticEngineModel () | |
void | setMaximumAcceleration (double maxAcceleration_mpsps) |
double | setMaximumAcceleration () |
void | setMaximumDeceleration (double maxAcceleration_mpsps) |
double | setMaximumDeceleration () |
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 cAir, double a_m2, double rho_kgpm3) |
double | airDrag_N (double speed_mps) |
double | getEngineTimeConstant_s (double rpm) |
double | getRealBrakingAcceleration (double speed_mps, double accel_mps2, double reqAccel_mps2, SUMOTime t) |
double | gravityForce_N (double mass_kg, double slope) |
double | gravityForce_N () |
double | maxEngineAcceleration_mps2 (double speed_mps) |
double | maxNoSlipAcceleration_mps2 (double slope, double frictionCoefficient) |
double | maxNoSlipAcceleration_mps2 () |
double | opposingForce_N (double speed_mps, double mass_kg, double slope, double cAir, double a_m2, double rho_kgpm3, double cr1, double cr2) |
double | opposingForce_N (double speed_mps) |
void | parseParameter (const ParMap ¶meters, std::string parameter, double &value) |
void | parseParameter (const ParMap ¶meters, std::string parameter, int &value) |
void | parseParameter (const ParMap ¶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 mass_kg, double cr1, double cr2) |
double | rollingResistance_N (double speed_mps) |
double | rpmToPower_hp (double rpm, const struct EngineParameters::PolynomialEngineModelRpmToHp *engineMapping) |
double | rpmToPower_hp (double rpm) |
double | rpmToSpeed_mps (double rpm, double wheelDiameter_m, double differentialRatio, double gearRatio) |
double | rpmToSpeed_mps (double rpm) |
double | speed_mpsToPower_hp (double speed_mps, const struct EngineParameters::PolynomialEngineModelRpmToHp *engineMapping, double wheelDiameter_m, double differentialRatio, double gearRatio) |
double | speed_mpsToPower_hp (double speed_mps) |
double | speed_mpsToRpm (double speed_mps, double wheelDiameter_m, double differentialRatio, double gearRatio) |
double | speed_mpsToRpm (double speed_mps) |
double | speed_mpsToRpm (double speed_mps, double gearRatio) |
double | speed_mpsToThrust_N (double speed_mps, const struct EngineParameters::PolynomialEngineModelRpmToHp *engineMapping, double wheelDiameter_m, double differentialRatio, double gearRatio, double engineEfficiency) |
double | speed_mpsToThrust_N (double speed_mps) |
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 44 of file RealisticEngineModel.h.
|
inherited |
Definition at line 34 of file GenericEngineModel.h.
RealisticEngineModel::RealisticEngineModel | ( | ) |
Definition at line 36 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 43 of file RealisticEngineModel.cpp.
|
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 111 of file RealisticEngineModel.cpp.
Referenced by opposingForce_N().
|
protected |
Computes air drag resistance using stored values
[in] | speed_mps | vehicle speed in meters per second |
Definition at line 114 of file RealisticEngineModel.cpp.
References EngineParameters::__airFrictionCoefficient, and ep.
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 221 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 176 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 192 of file RealisticEngineModel.cpp.
References EngineParameters::dt, ep, getEngineTimeConstant_s(), getRealBrakingAcceleration(), maxEngineAcceleration_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 226 of file RealisticEngineModel.cpp.
References EngineParameters::__brakesAlpha, EngineParameters::__brakesOneMinusAlpha, EngineParameters::__maxNoSlipAcceleration, ep, opposingForce_N(), thrust_NToAcceleration_mps2(), and UNUSED_PARAMETER.
Referenced by getRealAcceleration().
|
protected |
Computes gravitational force due to slope
[in] | mass_kg | vehicle mass in kg |
[in] | slope | road slope in degrees |
Definition at line 125 of file RealisticEngineModel.cpp.
References GRAVITY_MPS2, and M_PI.
|
protected |
Computes gravitational force using stored values
Definition at line 129 of file RealisticEngineModel.cpp.
References EngineParameters::__gravity, and ep.
Referenced by opposingForce_N().
|
virtual |
Load model parameters. This method requires a map of strings to be as flexible as possible, independently from the actual model implementation
[in] | parameters | a map of strings (from parameter name to parameter value) including configuration parameters |
Implements GenericEngineModel.
Definition at line 242 of file RealisticEngineModel.cpp.
References ENGINE_PAR_VEHICLE, ENGINE_PAR_XMLFILE, loadParameters(), GenericEngineModel::parseParameter(), vehicleType, and xmlFile.
void RealisticEngineModel::loadParameters | ( | ) |
Load parameters from xml file
Definition at line 253 of file RealisticEngineModel.cpp.
References EngineParameters::computeCoefficients(), EngineParameters::differentialRatio, EngineParameters::dt, dt_s, ep, EngineParameters::gearRatios, VehicleEngineHandler::getEngineParameters(), EngineParameters::minRpm, minSpeed_mps, rpmToSpeed_mps(), vehicleType, EngineParameters::wheelDiameter_m, and xmlFile.
Referenced by loadParameters(), and 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 171 of file RealisticEngineModel.cpp.
References EngineParameters::__maxAccelerationCoefficient, ep, maxNoSlipAcceleration_mps2(), and speed_mpsToThrust_N().
Referenced by getRealAcceleration().
|
protected |
Computes maximum acceleration without slipping tires
[in] | slope | road slope in degrees |
[in] | frictionCoefficient | tires friction coefficient |
Definition at line 144 of file RealisticEngineModel.cpp.
References GRAVITY_MPS2, and M_PI.
|
protected |
Computes maximum acceleration without slipping tires using stored values
Definition at line 148 of file RealisticEngineModel.cpp.
References EngineParameters::__maxNoSlipAcceleration, and ep.
Referenced by maxEngineAcceleration_mps2().
|
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 133 of file RealisticEngineModel.cpp.
References airDrag_N(), gravityForce_N(), and rollingResistance_N().
Referenced by getRealAcceleration(), and getRealBrakingAcceleration().
|
protected |
Computes total opposing force, using stored values
[in] | speed_mps | speed in meters per second |
Definition at line 140 of file RealisticEngineModel.cpp.
References airDrag_N(), gravityForce_N(), and rollingResistance_N().
|
protectedinherited |
Parses a value from the parameter map
Definition at line 29 of file GenericEngineModel.cpp.
References GenericEngineModel::printParameterError(), and StringUtils::toDouble().
Referenced by FirstOrderLagModel::loadParameters(), and loadParameters().
|
protectedinherited |
Definition at line 39 of file GenericEngineModel.cpp.
References GenericEngineModel::printParameterError(), and StringUtils::toInt().
|
protectedinherited |
Definition at line 49 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 156 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 25 of file GenericEngineModel.cpp.
References GenericEngineModel::className.
Referenced by GenericEngineModel::parseParameter().
|
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 118 of file RealisticEngineModel.cpp.
References GRAVITY_MPS2.
Referenced by opposingForce_N().
|
protected |
Computes rolling resistance using stored values
[in] | speed_mps | vehicle speed in meters per second |
Definition at line 121 of file RealisticEngineModel.cpp.
References EngineParameters::__cr1, EngineParameters::__cr2, and ep.
|
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 67 of file RealisticEngineModel.cpp.
References EngineParameters::PolynomialEngineModelRpmToHp::degree, and EngineParameters::PolynomialEngineModelRpmToHp::x.
Referenced by speed_mpsToPower_hp().
|
protected |
Computes the available power (hp) using stored values
[in] | rpm | engine speed in rpm |
Definition at line 75 of file RealisticEngineModel.cpp.
References EngineParameters::PolynomialEngineModelRpmToHp::degree, EngineParameters::engineMapping, ep, EngineParameters::maxRpm, and EngineParameters::PolynomialEngineModelRpmToHp::x.
|
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 45 of file RealisticEngineModel.cpp.
References M_PI.
Referenced by loadParameters(), and RealisticEngineModel().
|
protected |
Computes vehicle speed in mps using stored values
[in] | rpm | engine rotation speed in rpm |
Definition at line 50 of file RealisticEngineModel.cpp.
References EngineParameters::__rpmToSpeedCoefficient, currentGear, ep, and EngineParameters::gearRatios.
|
inherited |
Sets maximum acceleration value
[in] | maximum | acceleration in meters per second squared |
Definition at line 55 of file GenericEngineModel.cpp.
References GenericEngineModel::maxAcceleration_mpsps.
Referenced by MSCFModel_CC::createVehicleVariables(), and MSCFModel_CC::setParameter().
|
inherited |
Returns the maximum acceleration value
Definition at line 61 of file GenericEngineModel.cpp.
References GenericEngineModel::maxAcceleration_mpsps.
Referenced by GenericEngineModel::~GenericEngineModel().
|
inherited |
Sets maximum deceleration value
[in] | maximum | deceleration (positive value) in meters per second squared |
Definition at line 58 of file GenericEngineModel.cpp.
References GenericEngineModel::maxDeceleration_mpsps.
Referenced by MSCFModel_CC::createVehicleVariables(), and MSCFModel_CC::setParameter().
|
inherited |
Returns the maximum deceleration value
Definition at line 64 of file GenericEngineModel.cpp.
References GenericEngineModel::maxDeceleration_mpsps.
Referenced by GenericEngineModel::~GenericEngineModel().
|
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 287 of file RealisticEngineModel.cpp.
References ENGINE_PAR_VEHICLE, ENGINE_PAR_XMLFILE, loadParameters(), vehicleType, and xmlFile.
|
virtual |
Implements GenericEngineModel.
Definition at line 298 of file RealisticEngineModel.cpp.
References dt_s, and ENGINE_PAR_DT.
|
virtual |
Implements GenericEngineModel.
Definition at line 303 of file RealisticEngineModel.cpp.
References UNUSED_PARAMETER.
|
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 86 of file RealisticEngineModel.cpp.
References rpmToPower_hp(), and speed_mpsToRpm().
Referenced by speed_mpsToThrust_N().
|
protected |
Computes the available power at the current speed using stored values
[in] | speed_mps | vehicle speed in meters per second |
Definition at line 94 of file RealisticEngineModel.cpp.
References rpmToPower_hp(), and speed_mpsToRpm().
|
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 54 of file RealisticEngineModel.cpp.
References M_PI.
Referenced by getEngineData(), getRealAcceleration(), performGearShifting(), and speed_mpsToPower_hp().
|
protected |
Computes engine rotation speed in rpm using stored values
[in] | speed_mps | vehicle speed in meters per second |
Definition at line 59 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 63 of file RealisticEngineModel.cpp.
References EngineParameters::__speedToRpmCoefficient, and ep.
|
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 98 of file RealisticEngineModel.cpp.
References HP_TO_W, and speed_mpsToPower_hp().
Referenced by maxEngineAcceleration_mps2().
|
protected |
Computes the available maximum thrust at current speed using stored values
[in] | speed_mps | vehicle speed in meters per second |
Definition at line 106 of file RealisticEngineModel.cpp.
References EngineParameters::__speedToThrustCoefficient, ep, and speed_mpsToPower_hp().
|
protected |
Computes the acceleration for a certain thrust, using stored values of mass
[in] | thrust_N | thrust in N |
Definition at line 152 of file RealisticEngineModel.cpp.
References EngineParameters::__maxAccelerationCoefficient, and ep.
Referenced by getRealAcceleration(), and getRealBrakingAcceleration().
|
protectedinherited |
Definition at line 39 of file GenericEngineModel.h.
Referenced by FirstOrderLagModel::FirstOrderLagModel(), GenericEngineModel::printParameterError(), and RealisticEngineModel().
|
protected |
Definition at line 50 of file RealisticEngineModel.h.
Referenced by getEngineData(), performGearShifting(), rpmToSpeed_mps(), and speed_mpsToRpm().
|
protected |
Definition at line 54 of file RealisticEngineModel.h.
Referenced by loadParameters(), RealisticEngineModel(), and setParameter().
|
protected |
Definition at line 48 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_mpsToThrust_N(), and thrust_NToAcceleration_mps2().
|
protectedinherited |
Definition at line 41 of file GenericEngineModel.h.
Referenced by FirstOrderLagModel::getRealAcceleration(), and GenericEngineModel::setMaximumAcceleration().
|
protectedinherited |
Definition at line 41 of file GenericEngineModel.h.
Referenced by FirstOrderLagModel::getRealAcceleration(), and GenericEngineModel::setMaximumDeceleration().
|
protected |
Definition at line 52 of file RealisticEngineModel.h.
Referenced by getRealAcceleration(), loadParameters(), and RealisticEngineModel().
|
protected |
Definition at line 58 of file RealisticEngineModel.h.
Referenced by loadParameters(), and setParameter().
|
protected |
Definition at line 56 of file RealisticEngineModel.h.
Referenced by loadParameters(), RealisticEngineModel(), and setParameter().