43 std::vector<std::string>
44 VehicleType::getIDList() {
45 std::vector<std::string> ids;
52 VehicleType::getIDCount() {
53 return (
int)getIDList().size();
58 VehicleType::getLength(
const std::string& typeID) {
59 return getVType(typeID)->getLength();
64 VehicleType::getMaxSpeed(
const std::string& typeID) {
65 return getVType(typeID)->getMaxSpeed();
70 VehicleType::getActionStepLength(
const std::string& typeID) {
71 return getVType(typeID)->getActionStepLengthSecs();
76 VehicleType::getSpeedFactor(
const std::string& typeID) {
77 return getVType(typeID)->getSpeedFactor().getParameter()[0];
82 VehicleType::getSpeedDeviation(
const std::string& typeID) {
83 return getVType(typeID)->getSpeedFactor().getParameter()[1];
88 VehicleType::getAccel(
const std::string& typeID) {
89 return getVType(typeID)->getCarFollowModel().getMaxAccel();
94 VehicleType::getDecel(
const std::string& typeID) {
95 return getVType(typeID)->getCarFollowModel().getMaxDecel();
100 VehicleType::getEmergencyDecel(
const std::string& typeID) {
101 return getVType(typeID)->getCarFollowModel().getEmergencyDecel();
106 VehicleType::getApparentDecel(
const std::string& typeID) {
107 return getVType(typeID)->getCarFollowModel().getApparentDecel();
112 VehicleType::getImperfection(
const std::string& typeID) {
113 return getVType(typeID)->getCarFollowModel().getImperfection();
118 VehicleType::getTau(
const std::string& typeID) {
119 return getVType(typeID)->getCarFollowModel().getHeadwayTime();
124 VehicleType::getVehicleClass(
const std::string& typeID) {
125 return toString(getVType(typeID)->getVehicleClass());
130 VehicleType::getEmissionClass(
const std::string& typeID) {
136 VehicleType::getShapeClass(
const std::string& typeID) {
142 VehicleType::getMinGap(
const std::string& typeID) {
143 return getVType(typeID)->getMinGap();
148 VehicleType::getWidth(
const std::string& typeID) {
149 return getVType(typeID)->getWidth();
154 VehicleType::getHeight(
const std::string& typeID) {
155 return getVType(typeID)->getHeight();
160 VehicleType::getColor(
const std::string& typeID) {
166 VehicleType::getMinGapLat(
const std::string& typeID) {
167 return getVType(typeID)->getMinGapLat();
172 VehicleType::getMaxSpeedLat(
const std::string& typeID) {
173 return getVType(typeID)->getMaxSpeedLat();
178 VehicleType::getLateralAlignment(
const std::string& typeID) {
180 return toString(getVType(typeID)->getPreferredLateralAlignment());
182 return toString(getVType(typeID)->getPreferredLateralAlignmentOffset());
188 VehicleType::getParameter(
const std::string& typeID,
const std::string& key) {
190 const std::string attrName =
key.substr(14);
192 throw TraCIException(
"Invalid junctionModel parameter '" + key +
"' for type '" + typeID +
"'");
196 throw TraCIException(
"Invalid junctionModel parameter '" + key +
"' for type '" + typeID +
"'");
198 if (getVType(typeID)->getParameter().jmParameter.count(attr) != 0) {
199 return getVType(typeID)->getParameter().jmParameter.find(attr)->second;
204 return getVType(typeID)->getParameter().getParameter(key,
"");
211 VehicleType::getPersonCapacity(
const std::string& typeID) {
212 return getVType(typeID)->getPersonCapacity();
216 VehicleType::getScale(
const std::string& typeID) {
217 return getVType(typeID)->getParameter().scale;
221 VehicleType::getBoardingDuration(
const std::string& typeID) {
222 return STEPS2TIME(getVType(typeID)->getBoardingDuration(
true));
226 VehicleType::getImpatience(
const std::string& typeID) {
227 return getVType(typeID)->getImpatience();
231 VehicleType::setLength(
const std::string& typeID,
double length) {
232 getVType(typeID)->setLength(length);
237 VehicleType::setMaxSpeed(
const std::string& typeID,
double speed) {
238 getVType(typeID)->setMaxSpeed(speed);
243 VehicleType::setActionStepLength(
const std::string& typeID,
double actionStepLength,
bool resetActionOffset) {
249 VehicleType::setBoardingDuration(
const std::string& typeID,
double boardingDuration) {
250 getVType(typeID)->setBoardingDuration(
TIME2STEPS(boardingDuration),
true);
255 VehicleType::setImpatience(
const std::string& typeID,
double impatience) {
256 getVType(typeID)->setImpatience(impatience);
261 VehicleType::setVehicleClass(
const std::string& typeID,
const std::string& clazz) {
267 VehicleType::setSpeedFactor(
const std::string& typeID,
double factor) {
268 getVType(typeID)->setSpeedFactor(factor);
273 VehicleType::setSpeedDeviation(
const std::string& typeID,
double deviation) {
274 getVType(typeID)->setSpeedDeviation(deviation);
279 VehicleType::setEmissionClass(
const std::string& typeID,
const std::string& clazz) {
285 VehicleType::setShapeClass(
const std::string& typeID,
const std::string& shapeClass) {
291 VehicleType::setWidth(
const std::string& typeID,
double width) {
292 getVType(typeID)->setWidth(width);
297 VehicleType::setHeight(
const std::string& typeID,
double height) {
298 getVType(typeID)->setHeight(height);
303 VehicleType::setMinGap(
const std::string& typeID,
double minGap) {
304 getVType(typeID)->setMinGap(minGap);
309 VehicleType::setAccel(
const std::string& typeID,
double accel) {
310 getVType(typeID)->setAccel(accel);
315 VehicleType::setDecel(
const std::string& typeID,
double decel) {
322 WRITE_WARNINGF(
TL(
"Automatically setting emergencyDecel to % for vType '%' to match decel."),
toString(decel), typeID);
330 VehicleType::setEmergencyDecel(
const std::string& typeID,
double decel) {
333 if (decel < v->getCarFollowModel().getMaxDecel()) {
340 VehicleType::setApparentDecel(
const std::string& typeID,
double decel) {
341 getVType(typeID)->setApparentDecel(decel);
346 VehicleType::setImperfection(
const std::string& typeID,
double imperfection) {
347 getVType(typeID)->setImperfection(imperfection);
352 VehicleType::setTau(
const std::string& typeID,
double tau) {
353 getVType(typeID)->setTau(tau);
358 VehicleType::setColor(
const std::string& typeID,
const TraCIColor& c) {
364 VehicleType::setMinGapLat(
const std::string& typeID,
double minGapLat) {
365 getVType(typeID)->setMinGapLat(minGapLat);
370 VehicleType::setMaxSpeedLat(
const std::string& typeID,
double speed) {
371 getVType(typeID)->setMaxSpeedLat(speed);
376 VehicleType::setLateralAlignment(
const std::string& typeID,
const std::string& latAlignment) {
380 getVType(typeID)->setPreferredLateralAlignment(lad, lao);
382 throw TraCIException(
"Unknown value '" + latAlignment +
"' when setting latAlignment for vType '" + typeID +
"';\n must be one of (\"right\", \"center\", \"arbitrary\", \"nice\", \"compact\", \"left\" or a float)");
387 VehicleType::setScale(
const std::string& typeID,
double value) {
388 getVType(typeID)->setScale(value);
392 VehicleType::copy(
const std::string& origTypeID,
const std::string& newTypeID) {
393 getVType(origTypeID)->duplicateType(newTypeID,
true);
398 VehicleType::setParameter(
const std::string& typeID,
const std::string& name,
const std::string& value) {
400 const std::string attrName = name.substr(14);
402 throw TraCIException(
"Invalid junctionModel parameter '" + name +
"' for type '" + typeID +
"'");
406 throw TraCIException(
"Invalid junctionModel parameter '" + name +
"' for type '" + typeID +
"'");
412 throw TraCIException(
"Invalid junctionModel parameter value '" + value +
"' for type '" + typeID +
" (should be numeric)'");
424 VehicleType::getVType(std::string
id) {
427 throw TraCIException(
"Vehicle type '" +
id +
"' is not known");
433 std::shared_ptr<VariableWrapper>
434 VehicleType::makeWrapper() {
435 return std::make_shared<Helper::SubscriptionWrapper>(handleVariable, mySubscriptionResults, myContextSubscriptionResults);
440 VehicleType::handleVariable(
const std::string& objID,
const int variable, VariableWrapper* wrapper,
tcpip::Storage* paramData) {
441 return handleVariableWithID(objID, objID, variable, wrapper, paramData);
446 VehicleType::handleVariableWithID(
const std::string& objID,
const std::string& typeID,
const int variable, VariableWrapper* wrapper,
tcpip::Storage* paramData) {
449 return wrapper->wrapStringList(objID, variable, getIDList());
451 return wrapper->wrapInt(objID, variable, getIDCount());
453 return wrapper->wrapDouble(objID, variable, getLength(typeID));
455 return wrapper->wrapDouble(objID, variable, getHeight(typeID));
457 return wrapper->wrapDouble(objID, variable, getMinGap(typeID));
459 return wrapper->wrapDouble(objID, variable, getMaxSpeed(typeID));
461 return wrapper->wrapDouble(objID, variable, getAccel(typeID));
463 return wrapper->wrapDouble(objID, variable, getDecel(typeID));
465 return wrapper->wrapDouble(objID, variable, getEmergencyDecel(typeID));
467 return wrapper->wrapDouble(objID, variable, getApparentDecel(typeID));
469 return wrapper->wrapDouble(objID, variable, getActionStepLength(typeID));
471 return wrapper->wrapDouble(objID, variable, getImperfection(typeID));
473 return wrapper->wrapDouble(objID, variable, getTau(typeID));
475 return wrapper->wrapDouble(objID, variable, getSpeedFactor(typeID));
477 return wrapper->wrapDouble(objID, variable, getSpeedDeviation(typeID));
479 return wrapper->wrapString(objID, variable, getVehicleClass(typeID));
481 return wrapper->wrapString(objID, variable, getEmissionClass(typeID));
483 return wrapper->wrapString(objID, variable, getShapeClass(typeID));
485 return wrapper->wrapDouble(objID, variable, getWidth(typeID));
487 return wrapper->wrapColor(objID, variable, getColor(typeID));
489 return wrapper->wrapDouble(objID, variable, getMinGapLat(typeID));
491 return wrapper->wrapDouble(objID, variable, getMaxSpeedLat(typeID));
493 return wrapper->wrapString(objID, variable, getLateralAlignment(typeID));
495 return wrapper->wrapInt(objID, variable, getPersonCapacity(typeID));
497 return wrapper->wrapDouble(objID, variable, getBoardingDuration(typeID));
499 return wrapper->wrapDouble(objID, variable, getImpatience(typeID));
501 return wrapper->wrapDouble(objID, variable, getScale(typeID));
504 return wrapper->wrapString(objID, variable, getParameter(objID, paramData->
readString()));
507 return wrapper->wrapStringPair(objID, variable, getParameterWithKey(objID, paramData->
readString()));
#define WRITE_WARNINGF(...)
LatAlignmentDefinition
Possible ways to choose the lateral alignment, i.e., how vehicles align themselves within their lane.
@ GIVEN
The alignment as offset is given.
SUMOVehicleClass getVehicleClassID(const std::string &name)
Returns the class id of the abstract class given by its name.
SUMOVehicleShape getVehicleShapeID(const std::string &name)
Returns the class id of the shape class given by its name.
std::string getVehicleShapeName(SUMOVehicleShape id)
Returns the class name of the shape class given by its id.
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
@ SUMO_ATTR_EMERGENCYDECEL
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
#define LIBSUMO_SUBSCRIPTION_IMPLEMENTATION(CLASS, DOM)
#define LIBSUMO_GET_PARAMETER_WITH_KEY_IMPLEMENTATION(CLASS)
double getEmergencyDecel() const
Get the vehicle type's maximal phisically possible deceleration [m/s^2].
double getMaxDecel() const
Get the vehicle type's maximal comfortable deceleration [m/s^2].
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
MSVehicleType * getVType(const std::string &id=DEFAULT_VTYPE_ID, SumoRNG *rng=nullptr, bool readOnly=false)
Returns the named vehicle type or a sample from the named distribution.
void insertVTypeIDs(std::vector< std::string > &into) const
Inserts ids of all known vehicle types and vehicle type distributions to the given vector.
The car-following model and parameter.
void setEmergencyDecel(double emergencyDecel)
Set a new value for this type's emergency deceleration.
void setDecel(double decel)
Set a new value for this type's deceleration.
const MSCFModel & getCarFollowModel() const
Returns the vehicle type's car following model definition (const version)
const SUMOVTypeParameter & getParameter() const
static std::string getName(const SUMOEmissionClass c)
Checks whether the string describes a known vehicle class.
static SUMOEmissionClass getClassByName(const std::string &eClass, const SUMOVehicleClass vc=SVC_IGNORING)
Checks whether the string describes a known vehicle class.
Structure representing possible vehicle parameter.
SubParams cfParameter
Car-following parameter.
static std::set< SumoXMLAttr > AllowedJMAttrs
allowed attrs for the junction model
static bool parseLatAlignment(const std::string &val, double &lao, LatAlignmentDefinition &lad)
Parses and validates a given latAlignment value.
static SUMOTime processActionStepLength(double given)
Checks and converts given value for the action step length from seconds to miliseconds assuring it be...
static StringBijection< int > Attrs
The names of SUMO-XML attributes for use in netbuild.
static double toDouble(const std::string &sData)
converts a string into the double value described by it by calling the char-type converter
static bool startsWith(const std::string &str, const std::string prefix)
Checks whether a given string starts with the prefix.
C++ TraCI client API implementation.
static TraCIColor makeTraCIColor(const RGBColor &color)
static RGBColor makeRGBColor(const TraCIColor &color)
virtual std::string readString()
virtual int readUnsignedByte()
TRACI_CONST int VAR_VEHICLECLASS
TRACI_CONST int TRACI_ID_LIST
TRACI_CONST int VAR_IMPATIENCE
TRACI_CONST int VAR_LATALIGNMENT
TRACI_CONST int VAR_SCALE
TRACI_CONST int VAR_MINGAP
TRACI_CONST int VAR_SHAPECLASS
std::map< std::string, libsumo::SubscriptionResults > ContextSubscriptionResults
TRACI_CONST int VAR_ACTIONSTEPLENGTH
TRACI_CONST int VAR_SPEED_FACTOR
TRACI_CONST int VAR_BOARDING_DURATION
TRACI_CONST int VAR_COLOR
TRACI_CONST int VAR_WIDTH
TRACI_CONST int VAR_PERSON_CAPACITY
TRACI_CONST int VAR_MAXSPEED
std::map< std::string, libsumo::TraCIResults > SubscriptionResults
{object->{variable->value}}
TRACI_CONST int VAR_LENGTH
TRACI_CONST int VAR_MAXSPEED_LAT
TRACI_CONST int VAR_PARAMETER
TRACI_CONST int VAR_IMPERFECTION
TRACI_CONST int VAR_HEIGHT
TRACI_CONST int VAR_APPARENT_DECEL
TRACI_CONST int VAR_DECEL
TRACI_CONST int VAR_PARAMETER_WITH_KEY
TRACI_CONST int VAR_MINGAP_LAT
TRACI_CONST int VAR_EMERGENCY_DECEL
TRACI_CONST int VAR_EMISSIONCLASS
TRACI_CONST int VAR_ACCEL
TRACI_CONST int VAR_SPEED_DEVIATION
@ key
the parser read a key of a value in an object
auto get(const nlohmann::detail::iteration_proxy_value< IteratorType > &i) -> decltype(i.key())