50 return MIN2(maxPower / speed, maxTraction);
64 std::ostringstream internals;
65 internals << odometerAngles.size() <<
" ";
66 for (
auto item : odometerAngles) {
67 internals << item.first <<
" " << item.second <<
" ";
77 const std::string cfmID = attrs.
get<std::string>(
SUMO_ATTR_ID,
nullptr, ok);
78 if (cfmID !=
"Rail") {
79 throw ProcessError(
TLF(
"incompatible carFollowModel '%' when loading state for Rail", cfmID));
82 int odometerAnglesSize;
83 bis >> odometerAnglesSize;
84 for (
int i = 0; i < odometerAnglesSize; i++) {
89 odometerAngles.push_back(std::make_pair(o, a));
99 if (odometerAngles.empty() || odometerAngles.back().first != odo) {
100 odometerAngles.push_back(std::make_pair(odo, veh->
getAngle()));
102 while (odometerAngles.size() > 2) {
103 double distCleaned = odometerAngles.back().first - odometerAngles[1].first;
104 if (distCleaned >= curveIntegration) {
105 odometerAngles.erase(odometerAngles.begin());
111 if (odometerAngles.size() > 1) {
112 const double dist = odometerAngles.back().first - odometerAngles.front().first;
113 const double angleDiff =
GeomHelper::angleDiff(odometerAngles.back().second, odometerAngles.front().second);
114 if (dist < curveIntegration) {
117 return angleDiff == 0
118 ? std::numeric_limits<double>::max()
119 : dist / fabs(angleDiff);
135 if (trainType.compare(
"RB425") == 0) {
137 }
else if (trainType.compare(
"RB628") == 0) {
139 }
else if (trainType.compare(
"NGT400") == 0) {
141 }
else if (trainType.compare(
"NGT400_16") == 0) {
143 }
else if (trainType.compare(
"ICE1") == 0) {
145 }
else if (trainType.compare(
"REDosto7") == 0) {
147 }
else if (trainType.compare(
"Freight") == 0) {
149 }
else if (trainType.compare(
"ICE3") == 0) {
151 }
else if (trainType.compare(
"MireoPlusB") == 0) {
153 }
else if (trainType.compare(
"MireoPlusH") == 0) {
155 }
else if (trainType.compare(
"custom") == 0) {
205 WRITE_WARNING(
TLF(
"Ignoring tractionTable because maxPower and maxTraction are set for vType '%'.", vtype->
getID()));
213 if (hasSomeResCoef && !hasAllResCoef) {
214 throw ProcessError(
TLF(
"Some undefined resistance coefficients for vType '%' (requires resCoef_constant, resCoef_linear and resCoef_quadratic)", vtype->
getID()));
217 WRITE_WARNING(
TLF(
"Ignoring resistanceTable because resistance coefficients are set for vType '%'.", vtype->
getID()));
221 throw ProcessError(
TLF(
"Either tractionTable or maxPower must be defined for vType '%' with Rail model type '%'.", vtype->
getID(), trainType));
224 throw ProcessError(
TLF(
"Either resistanceTable or resCoef_constant must be defined for vType '%' with Rail model type '%'.", vtype->
getID(), trainType));
240 if (speed >= 30 / 3.6) {
250 return MIN2(vsafe, vmax);
254 return MAX2(
MIN2(vsafe, vmax), vmin);
285 assert(vars !=
nullptr);
287 if (r == std::numeric_limits<double>::max()) {
294 WRITE_WARNINGF(
"Cannot compute curve resistance for vehicle '%' with radius % at time %",
317 double totalRes = res + gr + cr;
321 if (speed < targetSpeed) {
325 if (totalRes > trac) {
339 const double slope = veh->
getSlope();
343 const double totalRes = res + gr + cr;
347 return MAX2(vMin, 0.);
378 WRITE_ERROR(
"function call not allowed for rail model. Exiting!");
389 const bool onInsertion,
const CalcReason )
const {
409 const double y =
MAX2(0.0, ((sqrt((b + 2.0 * v) * (b + 2.0 * v) + 8.0 * b * dist) - b) * 0.5 - v) / b);
410 const double yFull = floor(y);
411 const double exactGap = (yFull * yFull + yFull) * 0.5 * b + yFull * v + (y > yFull ? v : 0.0);
413 return DIST2SPEED(
MAX2(0.0, dist - exactGap) / (yFull + 1)) + fullSpeedGain + targetSpeed;
415 WRITE_ERROR(
TL(
"Anything else than semi implicit euler update is not yet implemented. Exiting!"));
#define WRITE_WARNINGF(...)
#define WRITE_ERRORF(...)
#define WRITE_WARNING(msg)
std::string time2string(SUMOTime t, bool humanReadable)
convert SUMOTime to string (independently of global format setting)
const long long int VTYPEPARS_MAXSPEED_SET
const long long int VTYPEPARS_MASS_SET
const long long int VTYPEPARS_LENGTH_SET
@ SUMO_ATTR_RESISTANCE_COEFFICIENT_CONSTANT
@ SUMO_ATTR_ROECKL_OFFSET_SHARP
@ SUMO_ATTR_CURVE_INTEGRATION
@ SUMO_ATTR_RESISTANCE_TABLE
@ SUMO_ATTR_ROECKL_NUMERATOR_SHARP
@ SUMO_ATTR_CURVE_RESISTANCE
@ SUMO_ATTR_ROECKL_SHARP_RADIUS
@ SUMO_ATTR_ROECKL_NUMERATOR
@ SUMO_ATTR_RESISTANCE_COEFFICIENT_QUADRATIC
@ SUMO_ATTR_EMERGENCYDECEL
@ SUMO_ATTR_ROECKL_OFFSET
@ SUMO_ATTR_RESISTANCE_COEFFICIENT_LINEAR
@ SUMO_ATTR_TRACTION_TABLE
@ SUMO_ATTR_STATE
The state of a link.
const double INVALID_DOUBLE
invalid double
static double angleDiff(const double angle1, const double angle2)
Returns the difference of the second angle to the first angle in radiants.
static double getInterpolatedValue(const LinearApproxMap &map, double axisValue)
Get interpolated value.
double getOdometer() const
Returns the distance that was already driven by this vehicle.
const MSVehicleType & getVehicleType() const
Returns the vehicle's type definition.
void loadState(const SUMOSAXAttributes &attrs)
Loads the state of the vehicle variables from the given description.
double getIntegratedRadius(const MSVehicle *veh, double curveIntegration)
void saveState(OutputDevice &out, const MSCFModel &cfm) const
Saves the vehicle variables.
TrainParams initICE3Params() const
TrainParams initNGT400_16Params() const
virtual ~MSCFModel_Rail()
TrainParams initREDosto7Params() const
virtual double minNextSpeedEmergency(double speed, const MSVehicle *const veh=0) const
Returns the minimum speed after emergency braking, given the current speed (depends on the numerical ...
TrainParams initCustomParams() const
TrainParams initICE1Params() const
MSCFModel_Rail(const MSVehicleType *vtype)
Constructor.
double getCurveResistance(const MSVehicle *veh) const
TrainParams initMireoPlusB2TParams() const
double freeSpeed(const MSVehicle *const veh, double speed, double seen, double maxSpeed, const bool onInsertion, const CalcReason usage=CalcReason::CURRENT) const
Computes the vehicle's safe speed without a leader.
TrainParams initRB628Params() const
virtual MSCFModel * duplicate(const MSVehicleType *vtype) const
Duplicates the car-following model.
virtual int getModelID() const
Returns the model's ID; the XML-Tag number is used.
double getSpeedAfterMaxDecel(double v) const
Returns the velocity after maximum deceleration.
TrainParams myTrainParams
virtual double minNextSpeed(double speed, const MSVehicle *const veh) const
Returns the minimum speed given the current speed (depends on the numerical update scheme and its ste...
double getWeight(const MSVehicle *const veh) const
double followSpeed(const MSVehicle *const veh, double speed, double gap2pred, double predSpeed, double predMaxDecel, const MSVehicle *const pred=0, const CalcReason usage=CalcReason::CURRENT) const
Computes the vehicle's follow speed (no dawdling)
double getRotWeight(const MSVehicle *const veh) const
TrainParams initRB425Params() const
TrainParams initFreightParams() const
virtual double maxNextSpeed(double speed, const MSVehicle *const veh) const
Returns the maximum speed given the current speed.
TrainParams initNGT400Params() const
TrainParams initMireoPlusH2TParams() const
double finalizeSpeed(MSVehicle *const veh, double vPos) const
Applies interaction with stops and lane changing model influences. Called at most once per simulation...
double stopSpeed(const MSVehicle *const veh, const double speed, double gap, double decel, const CalcReason usage=CalcReason::CURRENT) const
Computes the vehicle's safe speed for approaching a non-moving obstacle (no dawdling)
The car-following model abstraction.
virtual void setEmergencyDecel(double decel)
Sets a new value for maximal physically possible deceleration [m/s^2].
virtual double finalizeSpeed(MSVehicle *const veh, double vPos) const
Applies interaction with stops and lane changing model influences. Called at most once per simulation...
virtual void setMaxDecel(double decel)
Sets a new value for maximal comfortable deceleration [m/s^2].
CalcReason
What the return value of stop/follow/free-Speed is used for.
double myDecel
The vehicle's maximum deceleration [m/s^2].
double maximumSafeStopSpeed(double gap, double decel, double currentSpeed, bool onInsertion=false, double headway=-1, bool relaxEmergency=true) const
Returns the maximum next velocity for stopping within gap.
static bool gSemiImplicitEulerUpdate
Representation of a vehicle in the micro simulation.
double getCurveRadius() const
Returns the vehicle's current curve radius in m.
double getSlope() const
Returns the slope of the road at vehicle's position in degrees.
double getAngle() const
Returns the vehicle's direction in radians.
MSCFModel::VehicleVariables * getCarFollowVariables() const
Returns the vehicle's car following model variables.
The car-following model and parameter.
double getMaxSpeed() const
Get vehicle's (technical) maximum speed [m/s].
const std::string & getID() const
Returns the name of the vehicle type.
double getMinGap() const
Get the free space in front of vehicles of this class.
bool wasSet(long long int what) const
Returns whether the given parameter was set.
double getLength() const
Get vehicle's length [m].
double getMass() const
Get this vehicle type's mass.
const SUMOVTypeParameter & getParameter() const
const std::string & getID() const
Returns the id.
Static storage of an output device and its base (abstract) implementation.
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
OutputDevice & writeAttr(const ATTR_TYPE &attr, const T &val, const bool isNull=false)
writes a named attribute
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
Encapsulated SAX-Attributes.
virtual std::string getString(int id, bool *isPresent=nullptr) const =0
Returns the string-value of the named (by its enum-value) attribute.
T get(int attr, const char *objectid, bool &ok, bool report=true) const
Tries to read given attribute assuming it is an int.
LinearApproxHelpers::LinearApproxMap getCFProfile(const SumoXMLAttr attr, const LinearApproxHelpers::LinearApproxMap &defaultProfile) const
Returns the named value from the map, or the default if it is not contained there.
double getCFParam(const SumoXMLAttr attr, const double defaultValue) const
Returns the named value from the map, or the default if it is not contained there.
std::string getCFParamString(const SumoXMLAttr attr, const std::string defaultValue) const
Returns the named value from the map, or the default if it is not contained there.
LinearApproxHelpers::LinearApproxMap traction
double roeckl_offset_sharp
LinearApproxHelpers::LinearApproxMap resistance
double roeckl_numerator_sharp
double getTraction(double speed) const
double roeckl_sharp_radius
double getResistance(double speed) const