Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
MSDevice_Bluelight.cpp
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2013-2023 German Aerospace Center (DLR) and others.
4// This program and the accompanying materials are made available under the
5// terms of the Eclipse Public License 2.0 which is available at
6// https://www.eclipse.org/legal/epl-2.0/
7// This Source Code may also be made available under the following Secondary
8// Licenses when the conditions for such availability set forth in the Eclipse
9// Public License 2.0 are satisfied: GNU General Public License, version 2
10// or later which is available at
11// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13/****************************************************************************/
21// A device for emergency vehicle. The behaviour of other traffic participants will be triggered with this device.
22// For example building a rescue lane.
23/****************************************************************************/
24#include <config.h>
25
31#include <microsim/MSNet.h>
32#include <microsim/MSLane.h>
33#include <microsim/MSEdge.h>
34#include <microsim/MSLink.h>
35#include <microsim/MSVehicle.h>
39#include "MSDevice_Tripinfo.h"
40#include "MSDevice_Bluelight.h"
41
42//#define DEBUG_BLUELIGHT
43//#define DEBUG_BLUELIGHT_RESCUELANE
44
45#define INFLUENCED_BY "rescueLane"
46
47// ===========================================================================
48// method definitions
49// ===========================================================================
50// ---------------------------------------------------------------------------
51// static initialisation methods
52// ---------------------------------------------------------------------------
53void
55 oc.addOptionSubTopic("Bluelight Device");
56 insertDefaultAssignmentOptions("bluelight", "Bluelight Device", oc);
57
58 oc.doRegister("device.bluelight.reactiondist", new Option_Float(25.0));
59 oc.addDescription("device.bluelight.reactiondist", "Bluelight Device", TL("Set the distance at which other drivers react to the blue light and siren sound"));
60}
61
62
63void
64MSDevice_Bluelight::buildVehicleDevices(SUMOVehicle& v, std::vector<MSVehicleDevice*>& into) {
66 if (equippedByDefaultAssignmentOptions(oc, "bluelight", v, false)) {
68 WRITE_WARNINGF(TL("bluelight device is not compatible with mesosim (ignored for vehicle '%')"), v.getID());
69 } else {
70 MSDevice_Bluelight* device = new MSDevice_Bluelight(v, "bluelight_" + v.getID(),
71 getFloatParam(v, oc, "bluelight.reactiondist", oc.getFloat("device.bluelight.reactiondist"), false));
72 into.push_back(device);
73 }
74 }
75}
76
77
78// ---------------------------------------------------------------------------
79// MSDevice_Bluelight-methods
80// ---------------------------------------------------------------------------
82 double reactionDist) :
83 MSVehicleDevice(holder, id),
84 myReactionDist(reactionDist) {
85#ifdef DEBUG_BLUELIGHT
86 std::cout << SIMTIME << " initialized device '" << id << "' with myReactionDist=" << myReactionDist << "\n";
87#endif
88}
89
90
93
94
95bool
97 double /* newPos */, double newSpeed) {
98#ifdef DEBUG_BLUELIGHT
99 std::cout << SIMTIME << " device '" << getID() << "' notifyMove: newSpeed=" << newSpeed << "\n";
100#else
101 UNUSED_PARAMETER(newSpeed);
102#endif
103 //violate red lights this only need to be done once so shift it todo
104 MSVehicle& ego = dynamic_cast<MSVehicle&>(veh);
105 MSVehicle::Influencer& redLight = ego.getInfluencer();
106 const double vMax = ego.getLane()->getVehicleMaxSpeed(&ego);
107 redLight.setSpeedMode(7);
108 if (ego.getSpeed() < 0.5 * vMax) {
109 // advance as far as possible (assume vehicles will keep moving out of the way)
112 try {
114 } catch (InvalidArgument&) {
115 // not supported by the current laneChangeModel
116 }
117 } else {
118 // restore defaults
123 try {
126 } catch (InvalidArgument&) {
127 // not supported by the current laneChangeModel
128 }
129 }
130 // build a rescue lane for all vehicles on the route of the emergency vehicle within the range of the siren
134 // use edges on the way of the emergency vehicle
135 std::vector<const MSEdge*> upcomingEdges;
136 std::set<MSVehicle*, ComparatorIdLess> upcomingVehicles;
137 std::set<std::string> lastStepInfluencedVehicles = myInfluencedVehicles;
138 std::vector<MSLink*> upcomingLinks;
139 double affectedJunctionDist = ego.getPositionOnLane() + myReactionDist;
140 for (const MSLane* const l : ego.getUpcomingLanesUntil(myReactionDist)) {
141 upcomingEdges.push_back(&l->getEdge());
142
143 affectedJunctionDist -= l->getLength();
144 if (affectedJunctionDist > 0 && l->isInternal()) {
145 upcomingLinks.push_back(l->getIncomingLanes()[0].viaLink);
146 }
147 }
148
149 for (const MSEdge* const e : upcomingEdges) {
150 //inform all vehicles on upcomingEdges
151 for (const SUMOVehicle* v : e->getVehicles()) {
152 upcomingVehicles.insert(dynamic_cast<MSVehicle*>(const_cast<SUMOVehicle*>(v)));
153 if (lastStepInfluencedVehicles.count(v->getID()) > 0) {
154 lastStepInfluencedVehicles.erase(v->getID());
155 }
156 }
157 }
158 // reset all vehicles that were in myInfluencedVehicles in the previous step but not in the current step todo refactor
159 for (std::string vehID : lastStepInfluencedVehicles) {
160 myInfluencedVehicles.erase(vehID);
161 Parameterised::Map::iterator it = myInfluencedTypes.find(vehID);
162 MSVehicle* veh2 = dynamic_cast<MSVehicle*>(vc.getVehicle(vehID));
163 if (veh2 != nullptr && it != myInfluencedTypes.end()) {
164 // The vehicle gets back its old VehicleType after the emergency vehicle have passed them
165 resetVehicle(veh2, it->second);
166 }
167 }
168
169 for (MSVehicle* veh2 : upcomingVehicles) {
170 assert(veh2 != nullptr);
171 if (veh2->getLane() == nullptr) {
172 continue;
173 }
174 if (std::find(upcomingEdges.begin(), upcomingEdges.end(), &veh2->getLane()->getEdge()) != upcomingEdges.end()) {
175 if (veh2->getDevice(typeid(MSDevice_Bluelight)) != nullptr) {
176 // emergency vehicles should not react
177 continue;
178 }
179 const int numLanes = (int)veh2->getLane()->getEdge().getNumLanes();
180 // make sure that vehicle are still building the a rescue lane
181 if (myInfluencedVehicles.count(veh2->getID()) > 0) {
182 // Vehicle gets a new Vehicletype to change the alignment and the lanechange options
183 MSVehicleType& t = veh2->getSingularType();
184 // Setting the lateral alignment to build a rescue lane
186 if (veh2->getLane()->getIndex() == numLanes - 1) {
188 }
190#ifdef DEBUG_BLUELIGHT_RESCUELANE
191 std::cout << "Refresh alignment for vehicle: " << veh2->getID()
192 << " laneIndex=" << veh2->getLane()->getIndex() << " numLanes=" << numLanes
193 << " alignment=" << toString(align) << "\n";
194#endif
195 }
196
197 double distanceDelta = veh.getPosition().distanceTo(veh2->getPosition());
198 //emergency vehicle has to slow down when entering the rescue lane
199 if (distanceDelta <= 10 && veh.getID() != veh2->getID() && myInfluencedVehicles.count(veh2->getID()) > 0 && veh2->getSpeed() < 1) {
200 // set ev speed to 20 km/h 0 5.56 m/s
201 std::vector<std::pair<SUMOTime, double> > speedTimeLine;
202 speedTimeLine.push_back(std::make_pair(MSNet::getInstance()->getCurrentTimeStep(), veh.getSpeed()));
203 speedTimeLine.push_back(std::make_pair(MSNet::getInstance()->getCurrentTimeStep() + TIME2STEPS(2), 5.56));
204 redLight.setSpeedTimeLine(speedTimeLine);
205 }
206
207 // the perception of the sound of the siren should be around 25 meters
208 // todo only vehicles in front of the emergency vehicle should react
209 if (distanceDelta <= myReactionDist && veh.getID() != veh2->getID() && myInfluencedVehicles.count(veh2->getID()) == 0) {
210 // only a percentage of vehicles should react to the emergency vehicle to make the behaviour more realistic
211 double reaction = RandHelper::rand();
212 MSVehicle::Influencer& lanechange = veh2->getInfluencer();
213
214 //other vehicle should not use the rescue lane so they should not make any lane changes
215 lanechange.setLaneChangeMode(1605);//todo change lane back
216 // the vehicles should react according to the distance to the emergency vehicle taken from real world data
217 double reactionProb = (
218 distanceDelta < getFloatParam(myHolder, OptionsCont::getOptions(), "bluelight.near-dist", 12.5, false)
219 ? getFloatParam(myHolder, OptionsCont::getOptions(), "bluelight.reaction-prob-near", 0.577, false)
220 : getFloatParam(myHolder, OptionsCont::getOptions(), "bluelight.reaction-prob-far", 0.189, false));
221 // todo works only for one second steps
222 //std::cout << SIMTIME << " veh2=" << veh2->getID() << " distanceDelta=" << distanceDelta << " reaction=" << reaction << " reactionProb=" << reactionProb << "\n";
223 if (veh2->isActionStep(SIMSTEP) && reaction < reactionProb * veh2->getActionStepLengthSecs()) {
224 myInfluencedVehicles.insert(veh2->getID());
225 myInfluencedTypes.insert(std::make_pair(veh2->getID(), veh2->getVehicleType().getID()));
226
227 // Vehicle gets a new Vehicletype to change the alignment and the lanechange options
228 MSVehicleType& t = veh2->getSingularType();
229 // Setting the lateral alignment to build a rescue lane
231 if (veh2->getLane()->getIndex() == numLanes - 1) {
233 }
235 // disable strategic lane-changing
236#ifdef DEBUG_BLUELIGHT_RESCUELANE
237 std::cout << SIMTIME << " device=" << getID() << " formingRescueLane=" << veh2->getID()
238 << " laneIndex=" << veh2->getLane()->getIndex() << " numLanes=" << numLanes
239 << " alignment=" << toString(align) << "\n";
240#endif
241 std::vector<std::string> influencedBy = StringTokenizer(veh2->getParameter().getParameter(INFLUENCED_BY, "")).getVector();
242 if (std::find(influencedBy.begin(), influencedBy.end(), myHolder.getID()) == influencedBy.end()) {
243 influencedBy.push_back(myHolder.getID());
244 const_cast<SUMOVehicleParameter&>(veh2->getParameter()).setParameter(INFLUENCED_BY, toString(influencedBy));
245 }
246 veh2->getLaneChangeModel().setParameter(toString(SUMO_ATTR_LCA_STRATEGIC_PARAM), "-1");
247 }
248 }
249
250 } else { //if vehicle is passed all vehicles which had to react should get their state back after they leave the communication range
251 if (myInfluencedVehicles.count(veh2->getID()) > 0) {
252 double distanceDelta = veh.getPosition().distanceTo(veh2->getPosition());
253 if (distanceDelta > myReactionDist && veh.getID() != veh2->getID()) {
254 myInfluencedVehicles.erase(veh2->getID());
255 Parameterised::Map::iterator it = myInfluencedTypes.find(veh2->getID());
256 if (it != myInfluencedTypes.end()) {
257 // The vehicle gets back its old VehicleType after the emergency vehicle have passed them
258 resetVehicle(veh2, it->second);
259 }
260 }
261 }
262 }
263 }
264 // make upcoming junction foes slow down
265 for (MSLink* link : upcomingLinks) {
266 auto avi = link->getApproaching(&ego);
267 MSLink::BlockingFoes blockingFoes;
268 link->opened(avi.arrivalTime, avi.arrivalSpeed, avi.arrivalSpeed, ego.getLength(),
269 0, ego.getCarFollowModel().getMaxDecel(), ego.getWaitingTime(), ego.getLateralPositionOnLane(), &blockingFoes, true, &ego);
270 const SUMOTime timeToArrival = avi.arrivalTime - SIMSTEP;
271 for (const SUMOVehicle* foe : blockingFoes) {
272 const double dist = ego.getPosition().distanceTo2D(foe->getPosition());
273 if (dist < myReactionDist) {
274 MSVehicle* microFoe = dynamic_cast<MSVehicle*>(const_cast<SUMOVehicle*>(foe));
275 if (microFoe->getDevice(typeid(MSDevice_Bluelight)) != nullptr) {
276 // emergency vehicles should not react
277 continue;
278 }
279 const double timeToBrake = foe->getSpeed() / 4.5;
280 if (timeToArrival < TIME2STEPS(timeToBrake + 1)) {
281 ;
282 std::vector<std::pair<SUMOTime, double> > speedTimeLine;
283 speedTimeLine.push_back(std::make_pair(SIMSTEP, foe->getSpeed()));
284 speedTimeLine.push_back(std::make_pair(avi.arrivalTime, 0));
285 microFoe->getInfluencer().setSpeedTimeLine(speedTimeLine);
286 //std::cout << SIMTIME << " foe=" << foe->getID() << " dist=" << dist << " timeToBrake= " << timeToBrake << " ttA=" << STEPS2TIME(timeToArrival) << "\n";
287 }
288 }
289 }
290 }
291
292 // ego is at the end of its current lane and cannot continue
293 const double distToEnd = ego.getLane()->getLength() - ego.getPositionOnLane();
294 //std::cout << SIMTIME << " " << getID() << " lane=" << ego.getLane()->getID() << " pos=" << ego.getPositionOnLane() << " distToEnd=" << distToEnd << " conts=" << toString(ego.getBestLanesContinuation()) << " furtherEdges=" << upcomingEdges.size() << "\n";
295 if (ego.getBestLanesContinuation().size() == 1 && distToEnd <= POSITION_EPS
296 // route continues
297 && upcomingEdges.size() > 1) {
298 const MSEdge* currentEdge = &ego.getLane()->getEdge();
299 // move onto the intersection as if there was a connection from the current lane
300 const MSEdge* next = currentEdge->getInternalFollowingEdge(upcomingEdges[1], ego.getVClass());
301 if (next == nullptr) {
302 next = upcomingEdges[1];
303 }
304 // pick the lane that causes the minimizes lateral jump
305 const std::vector<MSLane*>* allowed = next->allowedLanes(ego.getVClass());
306 MSLane* nextLane = next->getLanes().front();
307 double bestJump = std::numeric_limits<double>::max();
308 double newPosLat = 0;
309 if (allowed != nullptr) {
310 for (MSLane* nextCand : *allowed) {
311 for (auto ili : nextCand->getIncomingLanes()) {
312 if (&ili.lane->getEdge() == currentEdge) {
313 double jump = fabs(ego.getLatOffset(ili.lane) + ego.getLateralPositionOnLane());
314 if (jump < bestJump) {
315 //std::cout << SIMTIME << " nextCand=" << nextCand->getID() << " from=" << ili.lane->getID() << " jump=" << jump << "\n";
316 bestJump = jump;
317 nextLane = nextCand;
318 // stay within newLane
319 const double maxVehOffset = MAX2(0.0, nextLane->getWidth() - ego.getVehicleType().getWidth()) * 0.5;
320 newPosLat = ego.getLatOffset(ili.lane) + ego.getLateralPositionOnLane();
321 newPosLat = MAX2(-maxVehOffset, newPosLat);
322 newPosLat = MIN2(maxVehOffset, newPosLat);
323 }
324 }
325 }
326 }
327 }
328 ego.leaveLane(NOTIFICATION_JUNCTION, nextLane);
331 ego.setTentativeLaneAndPosition(nextLane, 0, newPosLat); // update position
332 ego.enterLaneAtMove(nextLane);
333 // sublane model must adapt state to the new lane
335 }
336 return true; // keep the device
337}
338
339
340void
341MSDevice_Bluelight::resetVehicle(MSVehicle* veh2, const std::string& targetTypeID) {
342 MSVehicleType* targetType = MSNet::getInstance()->getVehicleControl().getVType(targetTypeID);
343 //targetType is nullptr if the vehicle type has already changed to its old vehicleType
344 if (targetType != nullptr) {
345#ifdef DEBUG_BLUELIGHT_RESCUELANE
346 std::cout << SIMTIME << " device=" << getID() << " reset " << veh2->getID() << "\n";
347#endif
348
349 std::vector<std::string> influencedBy = StringTokenizer(veh2->getParameter().getParameter(INFLUENCED_BY, "")).getVector();
350 auto it = std::find(influencedBy.begin(), influencedBy.end(), myHolder.getID());
351 if (it != influencedBy.end()) {
352 influencedBy.erase(it);
353 const_cast<SUMOVehicleParameter&>(veh2->getParameter()).setParameter(INFLUENCED_BY, toString(influencedBy));
354 }
355 if (influencedBy.size() == 0) {
356 veh2->replaceVehicleType(targetType);
359 }
360 }
361}
362
363
364
365bool
367 UNUSED_PARAMETER(veh);
368#ifdef DEBUG_BLUELIGHT
369 std::cout << SIMTIME << " device '" << getID() << "' notifyEnter: reason=" << toString(reason) << " enteredLane=" << Named::getIDSecure(enteredLane) << "\n";
370#else
371 UNUSED_PARAMETER(reason);
372 UNUSED_PARAMETER(enteredLane);
373#endif
374 return true; // keep the device
375}
376
377
378bool
379MSDevice_Bluelight::notifyLeave(SUMOTrafficObject& veh, double /*lastPos*/, MSMoveReminder::Notification reason, const MSLane* enteredLane) {
380 UNUSED_PARAMETER(veh);
381#ifdef DEBUG_BLUELIGHT
382 std::cout << SIMTIME << " device '" << getID() << "' notifyLeave: reason=" << toString(reason) << " approachedLane=" << Named::getIDSecure(enteredLane) << "\n";
383#else
384 UNUSED_PARAMETER(reason);
385 UNUSED_PARAMETER(enteredLane);
386#endif
387 return true; // keep the device
388}
389
390
391void
393 if (tripinfoOut != nullptr) {
394 tripinfoOut->openTag("bluelight");
395 tripinfoOut->closeTag();
396 }
397}
398
399std::string
400MSDevice_Bluelight::getParameter(const std::string& key) const {
401 if (key == "reactiondist") {
402 return toString(myReactionDist);
403 }
404 throw InvalidArgument("Parameter '" + key + "' is not supported for device of type '" + deviceName() + "'");
405}
406
407
408void
409MSDevice_Bluelight::setParameter(const std::string& key, const std::string& value) {
410 double doubleValue;
411 try {
412 doubleValue = StringUtils::toDouble(value);
413 } catch (NumberFormatException&) {
414 throw InvalidArgument("Setting parameter '" + key + "' requires a number for device of type '" + deviceName() + "'");
415 }
416 if (key == "reactiondist") {
417 myReactionDist = doubleValue;
418 } else {
419 throw InvalidArgument("Setting parameter '" + key + "' is not supported for device of type '" + deviceName() + "'");
420 }
421}
422
423
424/****************************************************************************/
long long int SUMOTime
Definition GUI.h:36
#define INFLUENCED_BY
#define WRITE_WARNINGF(...)
Definition MsgHandler.h:271
#define TL(string)
Definition MsgHandler.h:287
#define SIMSTEP
Definition SUMOTime.h:61
#define SIMTIME
Definition SUMOTime.h:62
#define TIME2STEPS(x)
Definition SUMOTime.h:57
LatAlignmentDefinition
Possible ways to choose the lateral alignment, i.e., how vehicles align themselves within their lane.
@ RIGHT
drive on the right side
@ LEFT
drive on the left side
@ ARBITRARY
maintain the current alignment
@ SUMO_ATTR_LCA_SPEEDGAIN_LOOKAHEAD
@ SUMO_ATTR_MINGAP_LAT
@ SUMO_ATTR_LCA_STRATEGIC_PARAM
#define UNUSED_PARAMETER(x)
Definition StdDefs.h:30
T MIN2(T a, T b)
Definition StdDefs.h:76
T MAX2(T a, T b)
Definition StdDefs.h:82
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition ToString.h:46
virtual void setParameter(const std::string &key, const std::string &value)
try to set the given parameter for this laneChangeModel. Throw exception for unsupported key
MSVehicleDevice * getDevice(const std::type_info &type) const
Returns a device of the given type if it exists, nullptr otherwise.
const SUMOVehicleParameter & getParameter() const
Returns the vehicle's parameter (including departure definition)
double getLength() const
Returns the vehicle's length.
SUMOVehicleClass getVClass() const
Returns the vehicle's access class.
const MSVehicleType & getVehicleType() const
Returns the vehicle's type definition.
double getMaxDecel() const
Get the vehicle type's maximal comfortable deceleration [m/s^2].
Definition MSCFModel.h:264
A device which collects info on the vehicle trip (mainly on departure and arrival)
bool notifyMove(SUMOTrafficObject &veh, double oldPos, double newPos, double newSpeed)
Checks for waiting steps when the vehicle moves.
void setParameter(const std::string &key, const std::string &value)
try to set the given parameter for this device. Throw exception for unsupported key
std::string getParameter(const std::string &key) const
try to retrieve the given parameter from this device. Throw exception for unsupported key
std::set< std::string > myInfluencedVehicles
static void insertOptions(OptionsCont &oc)
Inserts MSDevice_Bluelight-options.
static void buildVehicleDevices(SUMOVehicle &v, std::vector< MSVehicleDevice * > &into)
Build devices for the given vehicle, if needed.
void resetVehicle(MSVehicle *veh2, const std::string &targetTypeID)
restore type of influenced vehicle
double myReactionDist
reaction distance of other vehicle (i.e. due to different noise levels of the siren)
Parameterised::Map myInfluencedTypes
~MSDevice_Bluelight()
Destructor.
bool notifyEnter(SUMOTrafficObject &veh, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
Saves departure info on insertion.
const std::string deviceName() const
return the name for this type of device
void generateOutput(OutputDevice *tripinfoOut) const
Called on writing tripinfo output.
MSDevice_Bluelight(SUMOVehicle &holder, const std::string &id, double reactionDist)
Constructor.
bool notifyLeave(SUMOTrafficObject &veh, double lastPos, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
Saves arrival info.
static double getFloatParam(const SUMOVehicle &v, const OptionsCont &oc, std::string paramName, double deflt, bool required=false)
Definition MSDevice.cpp:199
static void insertDefaultAssignmentOptions(const std::string &deviceName, const std::string &optionsTopic, OptionsCont &oc, const bool isPerson=false)
Adds common command options that allow to assign devices to vehicles.
Definition MSDevice.cpp:148
static bool equippedByDefaultAssignmentOptions(const OptionsCont &oc, const std::string &deviceName, DEVICEHOLDER &v, bool outputOptionSet, const bool isPerson=false)
Determines whether a vehicle should get a certain device.
Definition MSDevice.h:202
A road/street connecting two junctions.
Definition MSEdge.h:77
const std::vector< MSLane * > & getLanes() const
Returns this edge's lanes.
Definition MSEdge.h:168
const std::vector< MSLane * > * allowedLanes(const MSEdge &destination, SUMOVehicleClass vclass=SVC_IGNORING) const
Get the allowed lanes to reach the destination-edge.
Definition MSEdge.cpp:439
const MSEdge * getInternalFollowingEdge(const MSEdge *followerAfterInternal, SUMOVehicleClass vClass) const
Definition MSEdge.cpp:798
static bool gUseMesoSim
Definition MSGlobals.h:103
Representation of a lane in the micro simulation.
Definition MSLane.h:84
double getLength() const
Returns the lane's length.
Definition MSLane.h:593
double getVehicleMaxSpeed(const SUMOTrafficObject *const veh) const
Returns the lane's maximum speed, given a vehicle's speed limit adaptation.
Definition MSLane.h:565
MSEdge & getEdge() const
Returns the lane's edge.
Definition MSLane.h:745
double getWidth() const
Returns the lane's width.
Definition MSLane.h:622
Notification
Definition of a vehicle state.
@ NOTIFICATION_JUNCTION
The vehicle arrived at a junction.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition MSNet.cpp:183
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
Definition MSNet.h:380
Changes the wished vehicle speed / lanes.
Definition MSVehicle.h:1353
void setLaneChangeMode(int value)
Sets lane changing behavior.
void setSpeedMode(int speedMode)
Sets speed-constraining behaviors.
void setSpeedTimeLine(const std::vector< std::pair< SUMOTime, double > > &speedTimeLine)
Sets a new velocity timeline.
The class responsible for building and deletion of vehicles.
SUMOVehicle * getVehicle(const std::string &id) const
Returns the vehicle with the given id.
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.
Abstract in-vehicle device.
SUMOVehicle & myHolder
The vehicle that stores the device.
Representation of a vehicle in the micro simulation.
Definition MSVehicle.h:77
const std::vector< const MSLane * > getUpcomingLanesUntil(double distance) const
Returns the upcoming (best followed by default 0) sequence of lanes to continue the route starting at...
void setTentativeLaneAndPosition(MSLane *lane, double pos, double posLat=0)
set tentative lane and position during insertion to ensure that all cfmodels work (some of them requi...
SUMOTime getWaitingTime() const
Returns the SUMOTime waited (speed was lesser than 0.1m/s)
Definition MSVehicle.h:672
MSAbstractLaneChangeModel & getLaneChangeModel()
void enterLaneAtMove(MSLane *enteredLane, bool onTeleporting=false)
Update when the vehicle enters a new lane in the move step.
Position getPosition(const double offset=0) const
Return current position (x/y, cartesian)
const std::vector< MSLane * > & getBestLanesContinuation() const
Returns the best sequence of lanes to continue the route starting at myLane.
void leaveLane(const MSMoveReminder::Notification reason, const MSLane *approachedLane=0)
Update of members if vehicle leaves a new lane in the lane change step or at arrival.
void replaceVehicleType(MSVehicleType *type)
Replaces the current vehicle type by the one given.
double getLatOffset(const MSLane *lane) const
Get the offset that that must be added to interpret myState.myPosLat for the given lane.
const MSLane * getLane() const
Returns the lane the vehicle is on.
Definition MSVehicle.h:584
Influencer & getInfluencer()
double getLateralPositionOnLane() const
Get the vehicle's lateral position on the lane.
Definition MSVehicle.h:416
double getSpeed() const
Returns the vehicle's current speed.
Definition MSVehicle.h:493
const MSCFModel & getCarFollowModel() const
Returns the vehicle's car following model definition.
Definition MSVehicle.h:978
double getPositionOnLane() const
Get the vehicle's position along the lane.
Definition MSVehicle.h:377
The car-following model and parameter.
double getMinGapLat() const
Get the minimum lateral gap that vehicles of this type maintain.
double getWidth() const
Get the width which vehicles of this class shall have when being drawn.
const std::string & getID() const
Returns the name of the vehicle type.
void setPreferredLateralAlignment(const LatAlignmentDefinition &latAlignment, double latAlignmentOffset=0.0)
Set vehicle's preferred lateral alignment.
const SUMOVTypeParameter & getParameter() const
static std::string getIDSecure(const T *obj, const std::string &fallBack="NULL")
get an identifier for Named-like object which may be Null
Definition Named.h:67
const std::string & getID() const
Returns the id.
Definition Named.h:74
A storage for options typed value containers)
Definition OptionsCont.h:89
void addDescription(const std::string &name, const std::string &subtopic, const std::string &description)
Adds a description for an option.
double getFloat(const std::string &name) const
Returns the double-value of the named option (only for Option_Float)
void doRegister(const std::string &name, Option *o)
Adds an option under the given name.
void addOptionSubTopic(const std::string &topic)
Adds an option subtopic.
static OptionsCont & getOptions()
Retrieves the options.
Static storage of an output device and its base (abstract) implementation.
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
virtual const std::string getParameter(const std::string &key, const std::string defaultValue="") const
Returns the value for a given key.
virtual void setParameter(const std::string &key, const std::string &value)
Sets a parameter.
double distanceTo2D(const Position &p2) const
returns the euclidean distance in the x-y-plane
Definition Position.h:254
double distanceTo(const Position &p2) const
returns the euclidean distance in 3 dimension
Definition Position.h:244
static double rand(SumoRNG *rng=nullptr)
Returns a random real number in [0, 1)
Representation of a vehicle, person, or container.
virtual const MSVehicleType & getVehicleType() const =0
Returns the object's "vehicle" type.
virtual double getSpeed() const =0
Returns the object's current speed.
virtual Position getPosition(const double offset=0) const =0
Return current position (x/y, cartesian)
std::string getLCParamString(const SumoXMLAttr attr, const std::string &defaultValue) const
Returns the named value from the map, or the default if it is not contained there.
Representation of a vehicle.
Definition SUMOVehicle.h:62
Structure representing possible vehicle parameter.
std::vector< std::string > getVector()
return vector of strings
static double toDouble(const std::string &sData)
converts a string into the double value described by it by calling the char-type converter