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) {
179 return toString(getVType(typeID)->getPreferredLateralAlignment());
184 VehicleType::getParameter(
const std::string& typeID,
const std::string& key) {
185 return getVType(typeID)->getParameter().getParameter(key,
"");
191 VehicleType::getPersonCapacity(
const std::string& typeID) {
192 return getVType(typeID)->getPersonCapacity();
196 VehicleType::setLength(
const std::string& typeID,
double length) {
197 getVType(typeID)->setLength(length);
202 VehicleType::setMaxSpeed(
const std::string& typeID,
double speed) {
203 getVType(typeID)->setMaxSpeed(speed);
208 VehicleType::setActionStepLength(
const std::string& typeID,
double actionStepLength,
bool resetActionOffset) {
214 VehicleType::setVehicleClass(
const std::string& typeID,
const std::string& clazz) {
220 VehicleType::setSpeedFactor(
const std::string& typeID,
double factor) {
221 getVType(typeID)->setSpeedFactor(factor);
226 VehicleType::setSpeedDeviation(
const std::string& typeID,
double deviation) {
227 getVType(typeID)->setSpeedDeviation(deviation);
232 VehicleType::setEmissionClass(
const std::string& typeID,
const std::string& clazz) {
238 VehicleType::setShapeClass(
const std::string& typeID,
const std::string& shapeClass) {
244 VehicleType::setWidth(
const std::string& typeID,
double width) {
245 getVType(typeID)->setWidth(width);
250 VehicleType::setHeight(
const std::string& typeID,
double height) {
251 getVType(typeID)->setHeight(height);
256 VehicleType::setMinGap(
const std::string& typeID,
double minGap) {
257 getVType(typeID)->setMinGap(minGap);
262 VehicleType::setAccel(
const std::string& typeID,
double accel) {
263 getVType(typeID)->setAccel(accel);
268 VehicleType::setDecel(
const std::string& typeID,
double decel) {
275 WRITE_WARNING(
"Automatically setting emergencyDecel to " +
toString(decel) +
" for vType '" + typeID +
"' to match decel.");
283 VehicleType::setEmergencyDecel(
const std::string& typeID,
double decel) {
286 if (decel < v->getCarFollowModel().getMaxDecel()) {
293 VehicleType::setApparentDecel(
const std::string& typeID,
double decel) {
294 getVType(typeID)->setApparentDecel(decel);
299 VehicleType::setImperfection(
const std::string& typeID,
double imperfection) {
300 getVType(typeID)->setImperfection(imperfection);
305 VehicleType::setTau(
const std::string& typeID,
double tau) {
306 getVType(typeID)->setTau(tau);
311 VehicleType::setColor(
const std::string& typeID,
const TraCIColor& c) {
317 VehicleType::setMinGapLat(
const std::string& typeID,
double minGapLat) {
318 getVType(typeID)->setMinGapLat(minGapLat);
323 VehicleType::setMaxSpeedLat(
const std::string& typeID,
double speed) {
324 getVType(typeID)->setMaxSpeedLat(speed);
329 VehicleType::setLateralAlignment(
const std::string& typeID,
const std::string& latAlignment) {
335 VehicleType::copy(
const std::string& origTypeID,
const std::string& newTypeID) {
336 getVType(origTypeID)->duplicateType(newTypeID,
true);
341 VehicleType::setParameter(
const std::string& typeID,
const std::string& name,
const std::string& value) {
350 VehicleType::getVType(std::string
id) {
353 throw TraCIException(
"Vehicle type '" +
id +
"' is not known");
359 std::shared_ptr<VariableWrapper>
360 VehicleType::makeWrapper() {
361 return std::make_shared<Helper::SubscriptionWrapper>(handleVariable, mySubscriptionResults, myContextSubscriptionResults);
366 VehicleType::handleVariable(
const std::string& objID,
const int variable, VariableWrapper* wrapper) {
367 return handleVariableWithID(objID, objID, variable, wrapper);
372 VehicleType::handleVariableWithID(
const std::string& objID,
const std::string& typeID,
const int variable, VariableWrapper* wrapper) {
375 return wrapper->wrapStringList(objID, variable, getIDList());
377 return wrapper->wrapInt(objID, variable, getIDCount());
379 return wrapper->wrapDouble(objID, variable, getLength(typeID));
381 return wrapper->wrapDouble(objID, variable, getHeight(typeID));
383 return wrapper->wrapDouble(objID, variable, getMinGap(typeID));
385 return wrapper->wrapDouble(objID, variable, getMaxSpeed(typeID));
387 return wrapper->wrapDouble(objID, variable, getAccel(typeID));
389 return wrapper->wrapDouble(objID, variable, getDecel(typeID));
391 return wrapper->wrapDouble(objID, variable, getEmergencyDecel(typeID));
393 return wrapper->wrapDouble(objID, variable, getApparentDecel(typeID));
395 return wrapper->wrapDouble(objID, variable, getActionStepLength(typeID));
397 return wrapper->wrapDouble(objID, variable, getImperfection(typeID));
399 return wrapper->wrapDouble(objID, variable, getTau(typeID));
401 return wrapper->wrapDouble(objID, variable, getSpeedFactor(typeID));
403 return wrapper->wrapDouble(objID, variable, getSpeedDeviation(typeID));
405 return wrapper->wrapString(objID, variable, getVehicleClass(typeID));
407 return wrapper->wrapString(objID, variable, getEmissionClass(typeID));
409 return wrapper->wrapString(objID, variable, getShapeClass(typeID));
411 return wrapper->wrapDouble(objID, variable, getWidth(typeID));
413 return wrapper->wrapColor(objID, variable, getColor(typeID));
415 return wrapper->wrapDouble(objID, variable, getMinGapLat(typeID));
417 return wrapper->wrapDouble(objID, variable, getMaxSpeedLat(typeID));
419 return wrapper->wrapString(objID, variable, getLateralAlignment(typeID));
421 return wrapper->wrapInt(objID, variable, getPersonCapacity(typeID));
TRACI_CONST int VAR_APPARENT_DECEL
SUMOVehicleClass getVehicleClassID(const std::string &name)
Returns the class id of the abstract class given by its name.
std::map< std::string, TraCIResults > SubscriptionResults
{object->{variable->value}}
TRACI_CONST int VAR_EMISSIONCLASS
TRACI_CONST int VAR_MINGAP
TRACI_CONST int VAR_MAXSPEED_LAT
TRACI_CONST int VAR_ACTIONSTEPLENGTH
static TraCIColor makeTraCIColor(const RGBColor &color)
#define LIBSUMO_GET_PARAMETER_WITH_KEY_IMPLEMENTATION(CLASS)
TRACI_CONST int VAR_COLOR
TRACI_CONST int VAR_WIDTH
Structure representing possible vehicle parameter.
MSVehicleType * getVType(const std::string &id=DEFAULT_VTYPE_ID, std::mt19937 *rng=nullptr)
Returns the named vehicle type or a sample from the named distribution.
void setDecel(double decel)
Set a new value for this type's deceleration.
TRACI_CONST int VAR_MINGAP_LAT
TRACI_CONST int VAR_VEHICLECLASS
static SUMOTime processActionStepLength(double given)
Checks and converts given value for the action step length from seconds to miliseconds assuring it be...
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
std::map< std::string, SubscriptionResults > ContextSubscriptionResults
TRACI_CONST int VAR_MAXSPEED
#define WRITE_WARNING(msg)
The car-following model and parameter.
std::string getVehicleShapeName(SUMOVehicleShape id)
Returns the class name of the shape class given by its id.
TRACI_CONST int VAR_LATALIGNMENT
TRACI_CONST int VAR_ACCEL
static RGBColor makeRGBColor(const TraCIColor &color)
TRACI_CONST int TRACI_ID_LIST
C++ TraCI client API implementation.
const MSCFModel & getCarFollowModel() const
Returns the vehicle type's car following model definition (const version)
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
double getEmergencyDecel() const
Get the vehicle type's maximal phisically possible deceleration [m/s^2].
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
TRACI_CONST int VAR_LENGTH
static std::string getName(const SUMOEmissionClass c)
Checks whether the string describes a known vehicle class.
double getMaxDecel() const
Get the vehicle type's maximal comfortable deceleration [m/s^2].
#define LIBSUMO_SUBSCRIPTION_IMPLEMENTATION(CLASS, DOMAIN)
const SUMOVTypeParameter & getParameter() const
void insertVTypeIDs(std::vector< std::string > &into) const
Inserts ids of all known vehicle types and vehicle type distributions to the given vector...
TRACI_CONST int VAR_SPEED_DEVIATION
TRACI_CONST int VAR_EMERGENCY_DECEL
static StringBijection< LateralAlignment > LateralAlignments
lateral alignments
TRACI_CONST int VAR_SPEED_FACTOR
void setEmergencyDecel(double emergencyDecel)
Set a new value for this type's emergency deceleration.
static SUMOEmissionClass getClassByName(const std::string &eClass, const SUMOVehicleClass vc=SVC_IGNORING)
Checks whether the string describes a known vehicle class.
TRACI_CONST int VAR_PERSON_CAPACITY
SubParams cfParameter
Car-following parameter.
TRACI_CONST int VAR_SHAPECLASS
SUMOVehicleShape getVehicleShapeID(const std::string &name)
Returns the class id of the shape class given by its name.
TRACI_CONST int VAR_HEIGHT
TRACI_CONST int VAR_IMPERFECTION
TRACI_CONST int VAR_DECEL