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 #include <microsim/MSNet.h>
23 #include "TraCI_VehicleType.h"
24 #include "TraCI.h"
25 std::vector<std::string> TraCI_VehicleType::getIDList() {
26  std::vector<std::string> ids;
28  return ids;
29 }
30 double TraCI_VehicleType::getLength(const std::string& typeID) {
31  MSVehicleType* v = getVType(typeID);
32  return v->getLength();
33 }
34 double TraCI_VehicleType::getMaxSpeed(const std::string& typeID) {
35  MSVehicleType* v = getVType(typeID);
36  return v->getMaxSpeed();
37 }
38 double TraCI_VehicleType::getSpeedFactor(const std::string& typeID) {
39  MSVehicleType* v = getVType(typeID);
40  return v->getSpeedFactor().getParameter()[0];
41 }
42 double TraCI_VehicleType::getSpeedDeviation(const std::string& typeID) {
43  MSVehicleType* v = getVType(typeID);
44  return v->getSpeedFactor().getParameter()[1];
45 }
46 double TraCI_VehicleType::getAccel(const std::string& typeID) {
47  MSVehicleType* v = getVType(typeID);
48  return v->getCarFollowModel().getMaxAccel();
49 }
50 double TraCI_VehicleType::getDecel(const std::string& typeID) {
51  MSVehicleType* v = getVType(typeID);
52  return v->getCarFollowModel().getMaxDecel();
53 }
54 double TraCI_VehicleType::getImperfection(const std::string& typeID) {
55  MSVehicleType* v = getVType(typeID);
56  return v->getCarFollowModel().getImperfection();
57 }
58 double TraCI_VehicleType::getTau(const std::string& typeID) {
59  MSVehicleType* v = getVType(typeID);
60  return v->getCarFollowModel().getHeadwayTime();
61 }
62 std::string TraCI_VehicleType::getVehicleClass(const std::string& typeID) {
63  MSVehicleType* v = getVType(typeID);
64  return toString(v->getVehicleClass());
65 }
66 std::string TraCI_VehicleType::getEmissionClass(const std::string& typeID) {
67  MSVehicleType* v = getVType(typeID);
69 }
70 std::string TraCI_VehicleType::getShapeClass(const std::string& typeID) {
71  MSVehicleType* v = getVType(typeID);
72  return getVehicleShapeName(v->getGuiShape());
73 }
74 double TraCI_VehicleType::getMinGap(const std::string& typeID) {
75  MSVehicleType* v = getVType(typeID);
76  return v->getMinGap();
77 }
78 double TraCI_VehicleType::getWidth(const std::string& typeID) {
79  MSVehicleType* v = getVType(typeID);
80  return v->getWidth();
81 }
82 double TraCI_VehicleType::getHeight(const std::string& typeID) {
83  MSVehicleType* v = getVType(typeID);
84  return v->getHeight();
85 }
86 TraCIColor TraCI_VehicleType::getColor(const std::string& typeID) {
87  MSVehicleType* v = getVType(typeID);
88  return TraCI::makeTraCIColor(v->getColor());
89 }
90 double TraCI_VehicleType::getMinGapLat(const std::string& typeID) {
91  MSVehicleType* v = getVType(typeID);
92  return v->getMinGapLat();
93 }
94 double TraCI_VehicleType::getMaxSpeedLat(const std::string& typeID) {
95  MSVehicleType* v = getVType(typeID);
96  return v->getMaxSpeedLat();
97 }
98 std::string TraCI_VehicleType::getLateralAlignment(const std::string& typeID) {
99  MSVehicleType* v = getVType(typeID);
101 }
102 
103 
104 std::string
105 TraCI_VehicleType::getParameter(const std::string& typeID, const std::string& key) {
106  MSVehicleType* v = getVType(typeID);
107  return v->getParameter().getParameter(key, "");
108 }
109 
110 
111 void TraCI_VehicleType::setLength(const std::string& typeID, double length) {
112  MSVehicleType* v = getVType(typeID);
113  v->setLength(length);
114 }
115 void TraCI_VehicleType::setMaxSpeed(const std::string& typeID, double speed) {
116  MSVehicleType* v = getVType(typeID);
117  v->setMaxSpeed(speed);
118 }
119 void TraCI_VehicleType::setVehicleClass(const std::string& typeID, const std::string& clazz) {
120  MSVehicleType* v = getVType(typeID);
121  v->setVClass(getVehicleClassID(clazz));
122 }
123 void TraCI_VehicleType::setSpeedFactor(const std::string& typeID, double factor) {
124  MSVehicleType* v = getVType(typeID);
125  v->setSpeedFactor(factor);
126 }
127 void TraCI_VehicleType::setSpeedDeviation(const std::string& typeID, double deviation) {
128  MSVehicleType* v = getVType(typeID);
129  v->setSpeedDeviation(deviation);
130 }
131 void TraCI_VehicleType::setEmissionClass(const std::string& typeID, const std::string& clazz) {
132  MSVehicleType* v = getVType(typeID);
134 }
135 void TraCI_VehicleType::setShapeClass(const std::string& typeID, const std::string& shapeClass) {
136  MSVehicleType* v = getVType(typeID);
137  v->setShape(getVehicleShapeID(shapeClass));
138 }
139 void TraCI_VehicleType::setWidth(const std::string& typeID, double width) {
140  MSVehicleType* v = getVType(typeID);
141  v->setWidth(width);
142 }
143 void TraCI_VehicleType::setHeight(const std::string& typeID, double height) {
144  MSVehicleType* v = getVType(typeID);
145  v->setHeight(height);
146 }
147 void TraCI_VehicleType::setMinGap(const std::string& typeID, double minGap) {
148  MSVehicleType* v = getVType(typeID);
149  v->setMinGap(minGap);
150 }
151 void TraCI_VehicleType::setAccel(const std::string& typeID, double accel) {
152  MSVehicleType* v = getVType(typeID);
153  v->getCarFollowModel().setMaxAccel(accel);
154 }
155 void TraCI_VehicleType::setDecel(const std::string& typeID, double decel) {
156  MSVehicleType* v = getVType(typeID);
157  v->getCarFollowModel().setMaxDecel(decel);
158 }
159 void TraCI_VehicleType::setImperfection(const std::string& typeID, double imperfection) {
160  MSVehicleType* v = getVType(typeID);
161  v->getCarFollowModel().setImperfection(imperfection);
162 }
163 void TraCI_VehicleType::setTau(const std::string& typeID, double tau) {
164  MSVehicleType* v = getVType(typeID);
166 }
167 void TraCI_VehicleType::setColor(const std::string& typeID, const TraCIColor& c) {
168  MSVehicleType* v = getVType(typeID);
170 
171 }
172 void TraCI_VehicleType::setMinGapLat(const std::string& typeID, double minGapLat) {
173  MSVehicleType* v = getVType(typeID);
174  v->setMinGapLat(minGapLat);
175 }
176 void TraCI_VehicleType::setMaxSpeedLat(const std::string& typeID, double speed) {
177  MSVehicleType* v = getVType(typeID);
178  v->setMaxSpeedLat(speed);
179 }
180 void TraCI_VehicleType::setLateralAlignment(const std::string& typeID, const std::string& latAlignment) {
181  MSVehicleType* v = getVType(typeID);
183 }
184 
185 void TraCI_VehicleType::addParameter(const std::string& typeID, const std::string& name, const std::string& value) {
186  MSVehicleType* v = getVType(typeID);
187  ((SUMOVTypeParameter&) v->getParameter()).addParameter(name, value);
188 }
191  if (t == 0) {
192  throw TraCIException("Vehicle type '" + id + "' is not known");
193  }
194  return t;
195 }
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.
static void setSpeedDeviation(const std::string &typeID, double deviation)
SUMOVehicleShape getGuiShape() const
Get this vehicle type&#39;s shape.
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)
LateralAlignment getPreferredLateralAlignment() const
Get vehicle&#39;s preferred lateral alignment.
static TraCIColor makeTraCIColor(const RGBColor &color)
Definition: TraCI.cpp:128
virtual double getImperfection() const
Get the driver&#39;s imperfection.
Definition: MSCFModel.h:212
std::vector< double > & getParameter()
Returns the parameters of this distribution.
static std::string getEmissionClass(const std::string &typeID)
static std::vector< std::string > getIDList()
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition: MSNet.cpp:158
double getMinGapLat() const
Get the minimum lateral gap that vehicles of this type maintain.
void setLength(const double &length)
Set a new value for this type&#39;s length.
static double getMaxSpeedLat(const std::string &typeID)
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)
The car-following model and parameter.
Definition: MSVehicleType.h:74
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)
double getMaxAccel() const
Get the vehicle type&#39;s maximum acceleration [m/s^2].
Definition: MSCFModel.h:193
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 MSCFModel & getCarFollowModel() const
Returns the vehicle type&#39;s car following model definition (const version)
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:56
static void setMaxSpeedLat(const std::string &typeID, double speed)
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:310
virtual void setHeadwayTime(double headwayTime)
Sets a new value for driver reaction time [s].
Definition: MSCFModel.h:415
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)
double getMaxSpeed() const
Get vehicle&#39;s maximum speed [m/s].
static void setMaxSpeed(const std::string &typeID, double speed)
void setEmissionClass(SUMOEmissionClass eclass)
Set a new value for this type&#39;s emission class.
double getMinGap() const
Get the free space in front of vehicles of this class.
static std::string getName(const SUMOEmissionClass c)
Checks whether the string describes a known vehicle class.
double getMaxDecel() const
Get the vehicle type&#39;s maximum deceleration [m/s^2].
Definition: MSCFModel.h:201
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.
const SUMOVTypeParameter & getParameter() const
static void setWidth(const std::string &typeID, double width)
void insertVTypeIDs(std::vector< std::string > &into) const
Inserts ids of all known vehicle types and vehicle type distributions to the given vector...
const RGBColor & getColor() const
Returns this type&#39;s color.
static double getImperfection(const std::string &typeID)
double getMaxSpeedLat() const
Get vehicle&#39;s maximum lateral speed [m/s].
const std::string & getParameter(const std::string &key, const std::string &defaultValue) const
Returns the value for a given key.
double getWidth() const
Get the width which vehicles of this class shall have when being drawn.
double getHeight() const
Get the height which vehicles of this class shall have when being drawn.
static StringBijection< LateralAlignment > LateralAlignments
lateral alignments
static double getDecel(const std::string &typeID)
virtual void setMaxDecel(double decel)
Sets a new value for maximum deceleration [m/s^2].
Definition: MSCFModel.h:399
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:391
virtual double getHeadwayTime() const
Get the driver&#39;s reaction time [s].
Definition: MSCFModel.h:220
static void setTau(const std::string &typeID, double tau)
virtual void setImperfection(double imperfection)
Sets a new value for driver imperfection.
Definition: MSCFModel.h:407
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.
double getLength() const
Get vehicle&#39;s length [m].
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)
static MSVehicleType * getVType(std::string id)
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.
void setPreferredLateralAlignment(LateralAlignment latAlignment)
Set vehicle&#39;s preferred lateral alignment.
MSVehicleType * getVType(const std::string &id=DEFAULT_VTYPE_ID, MTRand *rng=0)
Returns the named vehicle type or a sample from the named distribution.
static double getSpeedDeviation(const std::string &typeID)
SUMOEmissionClass getEmissionClass() const
Get this vehicle type&#39;s emission class.
const Distribution_Parameterized & getSpeedFactor() const
Returns this type&#39;s speed factor.
static double getWidth(const std::string &typeID)
static void addParameter(const std::string &id, const std::string &name, const std::string &value)
SUMOVehicleClass getVehicleClass() const
Get this vehicle type&#39;s vehicle class.
static double getMaxSpeed(const std::string &typeID)