SUMO - Simulation of Urban MObility
TraCI_VehicleType.cpp
Go to the documentation of this file.
1 /****************************************************************************/
7 // C++ TraCI client API implementation
8 /****************************************************************************/
9 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
10 // Copyright (C) 2017-2017 DLR (http://www.dlr.de/) and contributors
11 /****************************************************************************/
12 //
13 // This file is part of SUMO.
14 // SUMO is free software: you can redistribute it and/or modify
15 // it under the terms of the GNU General Public License as published by
16 // the Free Software Foundation, either version 3 of the License, or
17 // (at your option) any later version.
18 //
19 /****************************************************************************/
20 
21 
22 // ===========================================================================
23 // included modules
24 // ===========================================================================
25 #ifdef _MSC_VER
26 #include <windows_config.h>
27 #else
28 #include <config.h>
29 #endif
30 
31 #include <microsim/MSNet.h>
34 #include "TraCI_VehicleType.h"
35 #include "TraCI.h"
36 
37 
38 // ===========================================================================
39 // method definitions
40 // ===========================================================================
41 std::vector<std::string> TraCI_VehicleType::getIDList() {
42  std::vector<std::string> ids;
44  return ids;
45 }
46 
47 
48 double TraCI_VehicleType::getLength(const std::string& typeID) {
49  MSVehicleType* v = getVType(typeID);
50  return v->getLength();
51 }
52 
53 
54 double TraCI_VehicleType::getMaxSpeed(const std::string& typeID) {
55  MSVehicleType* v = getVType(typeID);
56  return v->getMaxSpeed();
57 }
58 
59 
60 double TraCI_VehicleType::getSpeedFactor(const std::string& typeID) {
61  MSVehicleType* v = getVType(typeID);
62  return v->getSpeedFactor().getParameter()[0];
63 }
64 double TraCI_VehicleType::getSpeedDeviation(const std::string& typeID) {
65  MSVehicleType* v = getVType(typeID);
66  return v->getSpeedFactor().getParameter()[1];
67 }
68 double TraCI_VehicleType::getAccel(const std::string& typeID) {
69  MSVehicleType* v = getVType(typeID);
70  return v->getCarFollowModel().getMaxAccel();
71 }
72 double TraCI_VehicleType::getDecel(const std::string& typeID) {
73  MSVehicleType* v = getVType(typeID);
74  return v->getCarFollowModel().getMaxDecel();
75 }
76 double TraCI_VehicleType::getEmergencyDecel(const std::string& typeID) {
77  MSVehicleType* v = getVType(typeID);
79 }
80 double TraCI_VehicleType::getApparentDecel(const std::string& typeID) {
81  MSVehicleType* v = getVType(typeID);
82  return v->getCarFollowModel().getApparentDecel();
83 }
84 double TraCI_VehicleType::getImperfection(const std::string& typeID) {
85  MSVehicleType* v = getVType(typeID);
86  return v->getCarFollowModel().getImperfection();
87 }
88 double TraCI_VehicleType::getTau(const std::string& typeID) {
89  MSVehicleType* v = getVType(typeID);
90  return v->getCarFollowModel().getHeadwayTime();
91 }
92 std::string TraCI_VehicleType::getVehicleClass(const std::string& typeID) {
93  MSVehicleType* v = getVType(typeID);
94  return toString(v->getVehicleClass());
95 }
96 std::string TraCI_VehicleType::getEmissionClass(const std::string& typeID) {
97  MSVehicleType* v = getVType(typeID);
99 }
100 std::string TraCI_VehicleType::getShapeClass(const std::string& typeID) {
101  MSVehicleType* v = getVType(typeID);
102  return getVehicleShapeName(v->getGuiShape());
103 }
104 double TraCI_VehicleType::getMinGap(const std::string& typeID) {
105  MSVehicleType* v = getVType(typeID);
106  return v->getMinGap();
107 }
108 double TraCI_VehicleType::getWidth(const std::string& typeID) {
109  MSVehicleType* v = getVType(typeID);
110  return v->getWidth();
111 }
112 double TraCI_VehicleType::getHeight(const std::string& typeID) {
113  MSVehicleType* v = getVType(typeID);
114  return v->getHeight();
115 }
116 TraCIColor TraCI_VehicleType::getColor(const std::string& typeID) {
117  MSVehicleType* v = getVType(typeID);
118  return TraCI::makeTraCIColor(v->getColor());
119 }
120 double TraCI_VehicleType::getMinGapLat(const std::string& typeID) {
121  MSVehicleType* v = getVType(typeID);
122  return v->getMinGapLat();
123 }
124 double TraCI_VehicleType::getMaxSpeedLat(const std::string& typeID) {
125  MSVehicleType* v = getVType(typeID);
126  return v->getMaxSpeedLat();
127 }
128 std::string TraCI_VehicleType::getLateralAlignment(const std::string& typeID) {
129  MSVehicleType* v = getVType(typeID);
131 }
132 
133 
134 std::string
135 TraCI_VehicleType::getParameter(const std::string& typeID, const std::string& key) {
136  MSVehicleType* v = getVType(typeID);
137  return v->getParameter().getParameter(key, "");
138 }
139 
140 
141 void TraCI_VehicleType::setLength(const std::string& typeID, double length) {
142  MSVehicleType* v = getVType(typeID);
143  v->setLength(length);
144 }
145 void TraCI_VehicleType::setMaxSpeed(const std::string& typeID, double speed) {
146  MSVehicleType* v = getVType(typeID);
147  v->setMaxSpeed(speed);
148 }
149 void TraCI_VehicleType::setVehicleClass(const std::string& typeID, const std::string& clazz) {
150  MSVehicleType* v = getVType(typeID);
151  v->setVClass(getVehicleClassID(clazz));
152 }
153 void TraCI_VehicleType::setSpeedFactor(const std::string& typeID, double factor) {
154  MSVehicleType* v = getVType(typeID);
155  v->setSpeedFactor(factor);
156 }
157 void TraCI_VehicleType::setSpeedDeviation(const std::string& typeID, double deviation) {
158  MSVehicleType* v = getVType(typeID);
159  v->setSpeedDeviation(deviation);
160 }
161 void TraCI_VehicleType::setEmissionClass(const std::string& typeID, const std::string& clazz) {
162  MSVehicleType* v = getVType(typeID);
164 }
165 void TraCI_VehicleType::setShapeClass(const std::string& typeID, const std::string& shapeClass) {
166  MSVehicleType* v = getVType(typeID);
167  v->setShape(getVehicleShapeID(shapeClass));
168 }
169 void TraCI_VehicleType::setWidth(const std::string& typeID, double width) {
170  MSVehicleType* v = getVType(typeID);
171  v->setWidth(width);
172 }
173 void TraCI_VehicleType::setHeight(const std::string& typeID, double height) {
174  MSVehicleType* v = getVType(typeID);
175  v->setHeight(height);
176 }
177 void TraCI_VehicleType::setMinGap(const std::string& typeID, double minGap) {
178  MSVehicleType* v = getVType(typeID);
179  v->setMinGap(minGap);
180 }
181 void TraCI_VehicleType::setAccel(const std::string& typeID, double accel) {
182  MSVehicleType* v = getVType(typeID);
183  v->getCarFollowModel().setMaxAccel(accel);
184 }
185 void TraCI_VehicleType::setDecel(const std::string& typeID, double decel) {
186  MSVehicleType* v = getVType(typeID);
187  v->getCarFollowModel().setMaxDecel(decel);
188 }
189 void TraCI_VehicleType::setEmergencyDecel(const std::string& typeID, double decel) {
190  MSVehicleType* v = getVType(typeID);
192 }
193 void TraCI_VehicleType::setApparentDecel(const std::string& typeID, double decel) {
194  MSVehicleType* v = getVType(typeID);
196 }
197 void TraCI_VehicleType::setImperfection(const std::string& typeID, double imperfection) {
198  MSVehicleType* v = getVType(typeID);
199  v->getCarFollowModel().setImperfection(imperfection);
200 }
201 void TraCI_VehicleType::setTau(const std::string& typeID, double tau) {
202  MSVehicleType* v = getVType(typeID);
204 }
205 void TraCI_VehicleType::setColor(const std::string& typeID, const TraCIColor& c) {
206  MSVehicleType* v = getVType(typeID);
208 
209 }
210 void TraCI_VehicleType::setMinGapLat(const std::string& typeID, double minGapLat) {
211  MSVehicleType* v = getVType(typeID);
212  v->setMinGapLat(minGapLat);
213 }
214 void TraCI_VehicleType::setMaxSpeedLat(const std::string& typeID, double speed) {
215  MSVehicleType* v = getVType(typeID);
216  v->setMaxSpeedLat(speed);
217 }
218 void TraCI_VehicleType::setLateralAlignment(const std::string& typeID, const std::string& latAlignment) {
219  MSVehicleType* v = getVType(typeID);
221 }
222 void TraCI_VehicleType::copy(const std::string& origTypeID, const std::string& newTypeID) {
223  getVType(origTypeID)->duplicateType(newTypeID, true);
224 }
225 void TraCI_VehicleType::addParameter(const std::string& typeID, const std::string& name, const std::string& value) {
226  MSVehicleType* v = getVType(typeID);
227  ((SUMOVTypeParameter&) v->getParameter()).addParameter(name, value);
228 }
231  if (t == 0) {
232  throw TraCIException("Vehicle type '" + id + "' is not known");
233  }
234  return t;
235 }
static void setAccel(const std::string &typeID, double accel)
SUMOVehicleClass getVehicleClassID(const std::string &name)
Returns the class id of the abstract class given by its name.
void setMinGap(const double &minGap)
Set a new value for this type&#39;s minimum gap.
double getMinGap() const
Get the free space in front of vehicles of this class.
static void setSpeedDeviation(const std::string &typeID, double deviation)
SUMOVehicleClass getVehicleClass() const
Get this vehicle type&#39;s vehicle class.
static void setShapeClass(const std::string &typeID, const std::string &shapeClass)
static std::string getParameter(const std::string &typeID, const std::string &key)
static double getSpeedFactor(const std::string &typeID)
static std::string getShapeClass(const std::string &typeID)
static TraCIColor getColor(const std::string &typeID)
void setShape(SUMOVehicleShape shape)
Set a new value for this type&#39;s shape.
Structure representing possible vehicle parameter.
static void setVehicleClass(const std::string &typeID, const std::string &clazz)
static TraCIColor makeTraCIColor(const RGBColor &color)
Definition: TraCI.cpp:128
std::vector< double > & getParameter()
Returns the parameters of this distribution.
static std::string getEmissionClass(const std::string &typeID)
static double getApparentDecel(const std::string &typeID)
virtual double getHeadwayTime() const
Get the driver&#39;s desired headway [s].
Definition: MSCFModel.h:247
static std::vector< std::string > getIDList()
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition: MSNet.cpp:169
double getMaxSpeed() const
Get vehicle&#39;s maximum speed [m/s].
void setLength(const double &length)
Set a new value for this type&#39;s length.
LateralAlignment getPreferredLateralAlignment() const
Get vehicle&#39;s preferred lateral alignment.
void insertVTypeIDs(std::vector< std::string > &into) const
Inserts ids of all known vehicle types and vehicle type distributions to the given vector...
static void copy(const std::string &origTypeID, const std::string &newTypeID)
static double getMaxSpeedLat(const std::string &typeID)
const std::string & getParameter(const std::string &key, const std::string &defaultValue) const
Returns the value for a given key.
void setMaxSpeed(const double &maxSpeed)
Set a new value for this type&#39;s maximum speed.
static void setMinGapLat(const std::string &typeID, double minGapLat)
virtual void setApparentDecel(double decel)
Sets a new value for the apparent deceleration [m/s^2].
Definition: MSCFModel.h:457
The car-following model and parameter.
Definition: MSVehicleType.h:73
double getEmergencyDecel() const
Get the vehicle type&#39;s maximal phisically possible deceleration [m/s^2].
Definition: MSCFModel.h:220
static void setApparentDecel(const std::string &typeID, double decel)
const MSCFModel & getCarFollowModel() const
Returns the vehicle type&#39;s car following model definition (const version)
std::string getVehicleShapeName(SUMOVehicleShape id)
Returns the class name of the shape class given by its id.
static void setEmissionClass(const std::string &typeID, const std::string &clazz)
void setMinGapLat(const double &minGapLat)
Set a new value for this type&#39;s minimum lataral gap.
static std::string getLateralAlignment(const std::string &typeID)
static double getMinGap(const std::string &typeID)
static double getMinGapLat(const std::string &typeID)
static std::string getVehicleClass(const std::string &typeID)
const SUMOVTypeParameter & getParameter() const
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:56
static void setMaxSpeedLat(const std::string &typeID, double speed)
double getHeight() const
Get the height which vehicles of this class shall have when being drawn.
virtual double getImperfection() const
Get the driver&#39;s imperfection.
Definition: MSCFModel.h:239
double getMaxDecel() const
Get the vehicle type&#39;s maximal comfortable deceleration [m/s^2].
Definition: MSCFModel.h:212
static double getAccel(const std::string &typeID)
static void setHeight(const std::string &typeID, double height)
static void setImperfection(const std::string &typeID, double imperfection)
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
Definition: MSNet.h:305
virtual void setHeadwayTime(double headwayTime)
Sets a new value for desired headway [s].
Definition: MSCFModel.h:473
static void setSpeedFactor(const std::string &typeID, double factor)
void setHeight(const double &height)
Set a new value for this type&#39;s height.
static void setLength(const std::string &typeID, double length)
static double getTau(const std::string &typeID)
static void setMinGap(const std::string &typeID, double minGap)
static void setMaxSpeed(const std::string &typeID, double speed)
void setEmissionClass(SUMOEmissionClass eclass)
Set a new value for this type&#39;s emission class.
static std::string getName(const SUMOEmissionClass c)
Checks whether the string describes a known vehicle class.
double getWidth() const
Get the width which vehicles of this class shall have when being drawn.
void setSpeedDeviation(const double &dev)
Set a new value for this type&#39;s speed deviation.
void setSpeedFactor(const double &factor)
Set a new value for this type&#39;s speed factor.
static void setWidth(const std::string &typeID, double width)
SUMOVehicleShape getGuiShape() const
Get this vehicle type&#39;s shape.
MSVehicleType * getVType(const std::string &id=DEFAULT_VTYPE_ID, std::mt19937 *rng=0)
Returns the named vehicle type or a sample from the named distribution.
static double getImperfection(const std::string &typeID)
static void setEmergencyDecel(const std::string &typeID, double decel)
double getMinGapLat() const
Get the minimum lateral gap that vehicles of this type maintain.
double getLength() const
Get vehicle&#39;s length [m].
static StringBijection< LateralAlignment > LateralAlignments
lateral alignments
const Distribution_Parameterized & getSpeedFactor() const
Returns this type&#39;s speed factor.
static double getDecel(const std::string &typeID)
double getMaxAccel() const
Get the vehicle type&#39;s maximum acceleration [m/s^2].
Definition: MSCFModel.h:204
virtual void setMaxDecel(double decel)
Sets a new value for maximal comfortable deceleration [m/s^2].
Definition: MSCFModel.h:441
static SUMOEmissionClass getClassByName(const std::string &eClass, const SUMOVehicleClass vc=SVC_IGNORING)
Checks whether the string describes a known vehicle class.
virtual void setMaxAccel(double accel)
Sets a new value for maximum acceleration [m/s^2].
Definition: MSCFModel.h:433
static void setTau(const std::string &typeID, double tau)
static double getEmergencyDecel(const std::string &typeID)
virtual void setImperfection(double imperfection)
Sets a new value for driver imperfection.
Definition: MSCFModel.h:465
static double getHeight(const std::string &typeID)
static void setDecel(const std::string &typeID, double decel)
void setWidth(const double &width)
Set a new value for this type&#39;s width.
const RGBColor & getColor() const
Returns this type&#39;s color.
void setVClass(SUMOVehicleClass vclass)
Set a new value for this type&#39;s vehicle class.
static void setColor(const std::string &typeID, const TraCIColor &c)
void setColor(const RGBColor &color)
Set a new value for this type&#39;s color.
SUMOVehicleShape getVehicleShapeID(const std::string &name)
Returns the class id of the shape class given by its name.
static void setLateralAlignment(const std::string &typeID, const std::string &latAlignment)
virtual void setEmergencyDecel(double decel)
Sets a new value for maximal physically possible deceleration [m/s^2].
Definition: MSCFModel.h:449
static MSVehicleType * getVType(std::string id)
double getApparentDecel() const
Get the vehicle type&#39;s apparent deceleration [m/s^2] (the one regarded by its followers.
Definition: MSCFModel.h:228
static double getLength(const std::string &typeID)
static RGBColor makeRGBColor(const TraCIColor &color)
Definition: TraCI.cpp:138
void setMaxSpeedLat(const double &maxSpeedLat)
Set a new value for this type&#39;s maximum lateral speed.
SUMOEmissionClass getEmissionClass() const
Get this vehicle type&#39;s emission class.
void setPreferredLateralAlignment(LateralAlignment latAlignment)
Set vehicle&#39;s preferred lateral alignment.
MSVehicleType * duplicateType(const std::string &id, bool persistent) const
Duplicates the microsim vehicle type giving the newly created type the given id.
static double getSpeedDeviation(const std::string &typeID)
double getMaxSpeedLat() const
Get vehicle&#39;s maximum lateral speed [m/s].
static double getWidth(const std::string &typeID)
static void addParameter(const std::string &id, const std::string &name, const std::string &value)
static double getMaxSpeed(const std::string &typeID)