59 #define DEBUG_COND (isSelected())
67 std::set<std::string> MSBaseVehicle::myShallTraceMoveReminders;
81 if (myRoutingMode == 1) {
96 throw ProcessError(
"getPreviousSpeed() is not available for non-MSVehicles.");
122 , myTraceMoveReminders(myShallTraceMoveReminders.count(pars->id) > 0)
170 throw ProcessError(
"Changing a vehicle ID is not permitted");
178 const std::map<int, double>*
181 if (batteryDevice !=
nullptr) {
220 if (source ==
nullptr) {
224 if (sink ==
nullptr) {
231 double firstPos = -1;
234 if (stops.size() > 0) {
237 const bool skipFirst = stops.front() == source && sourcePos <= firstPos;
238 const bool skipLast = stops.back() == sink &&
myArrivalPos >= lastPos;
242 <<
" source=" << source->
getID() <<
" sourcePos=" << sourcePos <<
" firstPos=" << firstPos <<
" arrivalPos=" <<
myArrivalPos <<
" lastPos=" << lastPos
246 if (stops.size() == 1 && (skipFirst || skipLast)) {
250 stops.erase(stops.begin());
253 stops.erase(stops.end() - 1);
262 if (viaEdge == source || viaEdge == sink) {
265 assert(viaEdge != 0);
267 throw ProcessError(
"Vehicle '" +
getID() +
"' is not allowed on any lane of via edge '" + viaEdge->
getID() +
"'.");
269 stops.push_back(viaEdge);
277 if (into.size() > 0) {
279 edges.insert(edges.end(), into.begin(), into.end());
280 if ((*s)->isTazConnector()) {
281 source = into.back();
287 std::string error =
"Vehicle '" +
getID() +
"' has no valid route from edge '" + source->
getID() +
"' to stop edge '" + (*s)->getID() +
"'.";
292 edges.push_back(source);
297 router.
compute(source, sink,
this, t, edges, silent);
298 if (edges.empty() && silent) {
301 if (!edges.empty() && edges.front()->isTazConnector()) {
302 edges.erase(edges.begin());
304 if (!edges.empty() && edges.back()->isTazConnector()) {
308 const double previousCost = onInit ? routeCost : router.
recomputeCosts(oldEdgesRemaining,
this, t);
309 const double savings = previousCost - routeCost;
339 std::string
id =
getID();
343 const std::string idSuffix =
id +
"!var#";
347 id = idSuffix +
toString(++varIndex);
349 int oldSize = (int)edges.size();
352 if (origin != *
myCurrEdge && edges.front() == origin) {
354 oldSize = (int)edges.size();
380 if (!
replaceRoute(newRoute, info, onInit, (
int)edges.
size() - oldSize,
false, removeStops)) {
397 if (newCurrEdge == edges.end()) {
401 (newCurrEdge + 1) == edges.end() || (*(newCurrEdge + 1)) != &(
getLane()->getOutgoingViaLanes().front().first->
getEdge()))) {
419 if (stopsFromScratch) {
430 lastPos += (*myCurrEdge)->getLength();
432 #ifdef DEBUG_REPLACE_ROUTE
434 std::cout <<
" replaceRoute on " << (*myCurrEdge)->getID() <<
" lane=" << myLane->getID() <<
" stopsFromScratch=" << stopsFromScratch <<
"\n";
437 for (std::list<MSStop>::iterator iter =
myStops.begin(); iter !=
myStops.end();) {
438 double endPos = iter->getEndPos(*
this);
439 #ifdef DEBUG_REPLACE_ROUTE
441 std::cout <<
" stopEdge=" << iter->lane->getEdge().getID() <<
" start=" << (searchStart -
myCurrEdge) <<
" endPos=" << endPos <<
" lastPos=" << lastPos <<
"\n";
444 if (*searchStart != &iter->lane->getEdge()
445 || endPos < lastPos) {
446 if (searchStart != edges.end() && !iter->reached) {
452 iter->edge = std::find(searchStart, edges.end(), &iter->lane->getEdge());
453 #ifdef DEBUG_REPLACE_ROUTE
455 std::cout <<
" foundIndex=" << (iter->edge -
myCurrEdge) <<
" end=" << (edges.end() -
myCurrEdge) <<
"\n";
458 if (iter->edge == edges.end()) {
466 searchStart = iter->edge;
472 for (std::vector<SUMOVehicleParameter::Stop>::const_iterator i = newRoute->
getStops().begin(); i != newRoute->
getStops().end(); ++i) {
536 if (taxiDevice !=
nullptr) {
570 if (route ==
nullptr) {
573 start = route->
begin();
579 msg =
"No connection between edge '" + (*e)->getID() +
"' and edge '" + (*(e + 1))->getID() +
"'.";
586 if ((*e)->prohibits(
this)) {
587 msg =
"Edge '" + (*e)->getID() +
"' prohibits.";
597 if (
myRoute->
getEdges().size() > 0 && !(*myCurrEdge)->prohibits(
this)) {
601 msg =
"Vehicle '" +
getID() +
"' is not allowed to depart on its first edge.";
618 }
else if (!silent) {
639 if (myTraceMoveReminders) {
640 traceMoveReminder(
"add", rem, 0,
true);
650 if (r->first == rem) {
652 if (myTraceMoveReminders) {
653 traceMoveReminder(
"remove", rem, 0,
false);
666 if (rem->first->notifyEnter(*
this, reason, enteredLane)) {
668 if (myTraceMoveReminders) {
669 traceMoveReminder(
"notifyEnter", rem->first, rem->second,
true);
675 if (myTraceMoveReminders) {
676 traceMoveReminder(
"notifyEnter", rem->first, rem->second,
false);
691 const double lastLaneLength = lanes[0]->getLength();
695 WRITE_WARNING(
"Vehicle '" +
getID() +
"' will not be able to arrive at the given position!");
720 for (std::vector<MSLane*>::const_iterator l = lanes.begin(); l != lanes.end(); ++l) {
725 WRITE_WARNING(
"Vehicle '" +
getID() +
"' will not be able to arrive with the given speed!");
740 if (
typeid(*dev) == type) {
755 std::ostringstream os;
793 myStops.begin()->parkingarea ==
nullptr || !
myStops.begin()->parkingarea->parkOnRoad());
829 if (stopPar.
lane ==
"") {
833 if (cand->allowsVehicleClass(
getVClass())) {
838 if (stop.
lane ==
nullptr) {
839 errorMsg =
"Vehicle '" +
myParameter->
id +
"' is not allowed to stop on any lane of edge '" + stopPar.
edge +
"'.";
845 errorMsg =
"Vehicle '" +
myParameter->
id +
"' is not allowed to stop on lane '" + stopPar.
lane +
"'.";
852 errorMsg =
"Mesoscopic simulation does not allow stopping on internal edge '" + stopPar.
edge +
"' for vehicle '" +
myParameter->
id +
"'.";
857 if (stopPar.
until != -1) {
865 std::string stopType =
"stop";
866 std::string stopID =
"";
868 stopType =
"busStop";
871 stopType =
"containerStop";
874 stopType =
"chargingStation";
877 stopType =
"overheadWireSegment";
880 stopType =
"parkingArea";
883 const std::string errorMsgStart = stopID ==
"" ? stopType : stopType +
" '" + stopID +
"'";
886 errorMsg = errorMsgStart +
" for vehicle '" +
myParameter->
id +
"' on lane '" + stop.
lane->
getID() +
"' has an invalid position.";
891 errorMsg = errorMsgStart +
" on lane '" + stop.
lane->
getID() +
"' is too short for vehicle '" +
myParameter->
id +
"'.";
895 if (searchStart ==
nullptr) {
903 std::list<MSStop>::iterator iter =
myStops.begin();
907 prevStopEdge =
myStops.back().edge;
908 prevEdge = &
myStops.back().lane->getEdge();
909 prevStopPos =
myStops.back().pars.endPos;
911 if (prevStopEdge == stop.
edge
914 stop.
edge = std::find(prevStopEdge + 1,
myRoute->
end(), stopEdge);
919 while (iter !=
myStops.end() && (iter->edge < stop.
edge ||
920 (iter->pars.endPos < stop.
pars.
endPos && iter->edge == stop.
edge))) {
921 prevStopEdge = iter->edge;
922 prevStopPos = iter->pars.endPos;
926 int index = stopPar.
index;
928 prevStopEdge = iter->edge;
929 prevStopPos = iter->pars.endPos;
936 const bool sameEdgeAsLastStop = prevStopEdge == stop.
edge && prevEdge == &stop.
lane->
getEdge();
938 (sameEdgeAsLastStop && prevStopPos > stop.
pars.
endPos && !collision)
943 return addStop(stopPar, errorMsg, untilOffset, collision, &next);
945 errorMsg = errorMsgStart +
" for vehicle '" +
myParameter->
id +
"' on lane '" + stop.
lane->
getID() +
"' is not downstream the current route.";
961 pos += (*myCurrEdge)->getLength();
971 return addStop(stopPar, errorMsg, untilOffset, collision, &next);
973 errorMsg = errorMsgStart +
" for vehicle '" +
myParameter->
id +
"' on lane '" + stop.
lane->
getID() +
"' is before departPos.";
978 std::list<MSStop>::iterator iter2 = iter;
981 errorMsg = errorMsgStart +
" for vehicle '" +
myParameter->
id +
"' on lane '" + stop.
lane->
getID() +
"' ends earlier than previous stop.";
996 std::string errorMsg;
997 if (!
addStop(stop, errorMsg,
myParameter->
depart, stop.startPos == stop.endPos, searchStart) && !ignoreStopErrors) {
1000 if (errorMsg !=
"") {
1006 std::string errorMsg;
1007 if (!
addStop(stop, errorMsg, untilOffset, stop.
startPos == stop.
endPos, searchStart) && !ignoreStopErrors) {
1010 if (errorMsg !=
"") {
1028 lastPos += (*myCurrEdge)->getLength();
1031 const double endPos = stop.getEndPos(*
this);
1033 const std::string prefix =
"Stop " +
toString(i) +
" on edge '" + stop.lane->getEdge().getID() +
"' ";
1034 if (stop.lane->isInternal()) {
1037 it = std::find(start,
myRoute->
end(), stop.lane->getEdge().getNormalBefore());
1039 it + 1 ==
myRoute->
end() || *(it + 1) != stop.lane->getEdge().getNormalSuccessor())) {
1043 const MSEdge*
const stopEdge = &stop.lane->getEdge();
1044 it = std::find(start,
myRoute->
end(), stopEdge);
1052 if (it2 == stop.edge) {
1057 WRITE_ERROR(prefix +
"used invalid route index " + err);
1059 }
else if (it2 < start) {
1063 if (it != stop.edge && endPos >= lastPos) {
1081 const MSStop* prev =
nullptr;
1082 const MSEdge* internalSuccessor =
nullptr;
1087 const double stopPos = stop.getEndPos(*
this);
1088 if ((prev ==
nullptr
1089 || prev->
edge != stop.edge
1090 || (prev->
lane == stop.lane && prev->
getEndPos(*
this) > stopPos))
1091 && *stop.edge != internalSuccessor) {
1092 result.push_back(*stop.edge);
1093 if (stop.lane->isInternal()) {
1094 internalSuccessor = stop.lane->getNextNormal();
1095 result.push_back(internalSuccessor);
1097 internalSuccessor =
nullptr;
1111 std::vector<std::pair<int, double> >
1113 std::vector<std::pair<int, double> > result;
1114 for (std::list<MSStop>::const_iterator iter =
myStops.begin(); iter !=
myStops.end(); ++iter) {
1115 result.push_back(std::make_pair(
1117 iter->getEndPos(*
this)));
1126 if (nextStopIndex == 0 &&
isStopped()) {
1129 auto stopIt =
myStops.begin();
1130 std::advance(stopIt, nextStopIndex);
1273 std::vector<std::string>
1275 std::vector<std::string> ret;
1276 const std::vector<MSTransportable*>& persons =
getPersons();
1277 for (std::vector<MSTransportable*>::const_iterator it_p = persons.begin(); it_p != persons.end(); ++it_p) {
1278 ret.push_back((*it_p)->getID());
1302 const std::vector<MSTransportable*>&
1312 const std::vector<MSTransportable*>&
1345 if (dev->deviceName() == deviceName) {
1356 if (deviceName ==
"rerouting") {
1362 assert(routingDevice != 0);
1366 throw InvalidArgument(
"Creating device of type '" + deviceName +
"' is not supported");
1375 if (dev->deviceName() == deviceName) {
1376 return dev->getParameter(key);
1379 throw InvalidArgument(
"No device of type '" + deviceName +
"' exists");
1386 if (dev->deviceName() == deviceName) {
1387 dev->setParameter(key, value);
1391 throw InvalidArgument(
"No device of type '" + deviceName +
"' exists");
1397 assert(type !=
nullptr);
1419 if (lane ==
nullptr) {
1430 if (lane ==
nullptr) {
1442 if (tok.
size() < 3) {
1443 error =
"Invalid device parameter '" + key +
"' for vehicle '" +
getID() +
"'.";
1449 error =
"Vehicle '" +
getID() +
"' does not support device parameter '" + key +
"' (" + e.what() +
").";
1453 if (microVeh ==
nullptr) {
1454 error =
"Meso Vehicle '" +
getID() +
"' does not support laneChangeModel parameters.";
1457 const std::string attrName = key.substr(16);
1461 error =
"Vehicle '" +
getID() +
"' does not support laneChangeModel parameter '" + key +
"' (" + e.what() +
").";
1465 if (microVeh ==
nullptr) {
1466 error =
"Meso Vehicle '" +
getID() +
"' does not support carFollowModel parameters.";
1469 const std::string attrName = key.substr(15);
1473 error =
"Vehicle '" +
getID() +
"' does not support carFollowModel parameter '" + key +
"' (" + e.what() +
").";
1478 if (tok.
size() != 3) {
1479 error =
"Invalid check for device. Expected format is 'has.DEVICENAME.device'.";
1490 MSBaseVehicle::initMoveReminderOutput(
const OptionsCont& oc) {
1491 if (oc.
isSet(
"movereminder-output.vehicles")) {
1492 const std::vector<std::string> vehicles = oc.
getStringVector(
"movereminder-output.vehicles");
1493 myShallTraceMoveReminders.insert(vehicles.begin(), vehicles.end());
1499 MSBaseVehicle::traceMoveReminder(
const std::string& type,
MSMoveReminder* rem,
double pos,
bool keep)
const {
std::vector< const MSEdge * > ConstMSEdgeVector
ConstMSEdgeVector::const_iterator MSRouteIterator
#define WRITE_WARNING(msg)
std::string time2string(SUMOTime t)
convert SUMOTime to string
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
DepartLaneDefinition
Possible ways to choose a lane on depart.
@ GIVEN
The speed is given.
@ GIVEN
The position is given.
@ DEFAULT
No information given; use default.
@ BASE
Back-at-zero position.
const int VEHPARS_SPEEDFACTOR_SET
@ GIVEN
The arrival lane is given.
@ RANDOM
The edge is chosen randomly.
@ GIVEN
The edge index is given.
@ DEFAULT
No information given; use default.
const int VEHPARS_FORCE_REROUTE
@ RANDOM
The arrival position is chosen randomly.
@ GIVEN
The arrival position is given.
@ CENTER
Half the road length.
const int VEHPARS_LINE_SET
@ DEPART_CONTAINER_TRIGGERED
The departure is container triggered.
@ DEPART_TRIGGERED
The departure is person triggered.
@ SUMO_TAG_VEHICLE
description of a vehicle
@ SUMO_TAG_PARKING_ZONE_REROUTE
entry for an alternative parking zone
@ SUMO_ATTR_TIME
trigger: the time of the step
#define UNUSED_PARAMETER(x)
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
static double computeNoise(SUMOEmissionClass c, double v, double a)
Returns the noise produced by the a vehicle of the given type at the given speed.
MESegment * getSegmentForEdge(const MSEdge &e, double pos=0)
Get the segment for a given edge at a given position.
virtual std::string getParameter(const std::string &key) const
try to retrieve the given parameter from this laneChangeModel. Throw exception for unsupported key
BaseInfluencer()
Constructor.
SUMOAbstractRouter< MSEdge, SUMOVehicle > & getRouterTT(const int rngIndex, SUMOVehicleClass svc) const
double getMaxSpeed() const
Returns the maximum speed.
MSVehicleDevice * getDevice(const std::type_info &type) const
Returns a device of the given type if it exists or 0.
void addStops(const bool ignoreStopErrors, MSRouteIterator *searchStart=nullptr)
Adds stops to the built vehicle.
std::list< MSStop > myStops
The vehicle's list of stops.
double getImpatience() const
Returns this vehicles impatience.
const std::vector< MSTransportable * > & getPersons() const
retrieve riding persons
virtual void initDevices()
const MSEdge * succEdge(int nSuccs) const
Returns the nSuccs'th successor of edge the vehicle is currently at.
void resetRoutePosition(int index, DepartLaneDefinition departLaneProcedure)
reset index of edge within route
std::string getDeviceParameter(const std::string &deviceName, const std::string &key) const
try to retrieve the given parameter from any of the vehicles devices, raise InvalidArgument if no dev...
MSVehicleType * myType
This vehicle's type.
MoveReminderCont myMoveReminders
Currently relevant move reminders.
bool allowsBoarding(MSTransportable *t) const
whether the given transportable is allowed to board this vehicle
double myDepartPos
The real depart position.
const SUMOVehicleParameter & getParameter() const
Returns the vehicle's parameter (including departure definition)
void addReminder(MSMoveReminder *rem)
Adds a MoveReminder dynamically.
bool replaceRouteEdges(ConstMSEdgeVector &edges, double cost, double savings, const std::string &info, bool onInit=false, bool check=false, bool removeStops=true)
Replaces the current route by the given edges.
double getFuelConsumption() const
Returns fuel consumption of the current state.
void replaceParameter(const SUMOVehicleParameter *newParameter)
replace the vehicle parameter (deleting the old one)
double getCO2Emissions() const
Returns CO2 emission of the current state.
std::vector< MSVehicleDevice * > myDevices
The devices this vehicle has.
virtual bool replaceRoute(const MSRoute *route, const std::string &info, bool onInit=false, int offset=0, bool addStops=true, bool removeStops=true)
Replaces the current route by the given one.
double getPreviousSpeed() const
Returns the vehicle's previous speed.
virtual void addTransportable(MSTransportable *transportable)
Adds a person or container to this vehicle.
double getElectricityConsumption() const
Returns electricity consumption of the current state.
int getRouteValidity(bool update=true, bool silent=false)
check for route validity at first insertion attempt
double getOdometer() const
Returns the distance that was already driven by this vehicle.
virtual bool hasArrived() const
Returns whether this vehicle has already arived (by default this is true if the vehicle has reached i...
const NumericalID myNumericalID
static NumericalID myCurrentNumericalIndex
MSVehicleType & getSingularType()
Replaces the current vehicle type with a new one used by this vehicle only.
void replaceVehicleType(MSVehicleType *type)
Replaces the current vehicle type by the one given.
double getLength() const
Returns the vehicle's length.
bool isParking() const
Returns whether the vehicle is parking.
const MSEdge * getEdge() const
Returns the edge the vehicle is currently at.
double getHarmonoise_NoiseEmissions() const
Returns noise emissions of the current state.
const std::map< int, double > * getEmissionParameters() const
Returns the vehicle's emission model parameter.
bool hasValidRoute(std::string &msg, const MSRoute *route=0) const
Validates the current or given route.
bool isStoppedInRange(const double pos, const double tolerance) const
return whether the given position is within range of the current stop
int getPersonNumber() const
Returns the number of persons.
double getNOxEmissions() const
Returns NOx emission of the current state.
void setID(const std::string &newID)
set the id (inherited from Named but forbidden for vehicles)
std::mt19937 * getRNG() const
double getPMxEmissions() const
Returns PMx emission of the current state.
MSRouteIterator myCurrEdge
Iterator to current route-edge.
static std::vector< MSTransportable * > myEmptyTransportableVector
bool hasDeparted() const
Returns whether this vehicle has already departed.
double getCOEmissions() const
Returns CO emission of the current state.
MSDevice_Transportable * myContainerDevice
The containers this vehicle may have.
MSBaseVehicle(SUMOVehicleParameter *pars, const MSRoute *route, MSVehicleType *type, const double speedFactor)
Constructor.
double getStateOfCharge() const
Returns actual state of charge of battery (Wh) RICE_CHECK: This may be a misnomer,...
MSEdgeWeightsStorage & _getWeightsStorage() const
bool hasDevice(const std::string &deviceName) const
check whether the vehicle is equiped with a device of the given type
virtual const MSEdge * getRerouteOrigin() const
Returns the starting point for reroutes (usually the current edge)
void calculateArrivalParams()
(Re-)Calculates the arrival position and lane from the vehicle parameters
double basePos(const MSEdge *edge) const
departure position where the vehicle fits fully onto the edge (if possible)
void setDeviceParameter(const std::string &deviceName, const std::string &key, const std::string &value)
try to set the given parameter from any of the vehicles devices, raise InvalidArgument if no device p...
MSDevice_Transportable * myPersonDevice
The passengers this vehicle may have.
const MSRoute * myRoute
This vehicle's route.
const MSVehicleType & getVehicleType() const
Returns the vehicle's type definition.
bool hasStops() const
Returns whether the vehicle has to stop somewhere.
virtual void activateReminders(const MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
"Activates" all current move reminder
bool isLineStop(double position) const
returns whether the vehicle serves a public transport line that serves the given stop
double myChosenSpeedFactor
A precomputed factor by which the driver wants to be faster than the speed limit.
@ ROUTE_INVALID
route was checked and is valid
@ ROUTE_START_INVALID_PERMISSIONS
std::string getPrefixedParameter(const std::string &key, std::string &error) const
retrieve parameters of devices, models and the vehicle itself
void removeTransportable(MSTransportable *t)
removes a person or container
SUMOVehicleClass getVClass() const
Returns the vehicle's access class.
int myArrivalLane
The destination lane where the vehicle stops.
virtual ~MSBaseVehicle()
Destructor.
SUMOTime myDeparture
The real departure time.
std::vector< std::string > getPersonIDList() const
Returns the list of persons.
const MSEdgeWeightsStorage & getWeightsStorage() const
Returns the vehicle's internal edge travel times/efforts container.
bool isStoppedTriggered() const
Returns whether the vehicle is on a triggered stop.
bool addStop(const SUMOVehicleParameter::Stop &stopPar, std::string &errorMsg, SUMOTime untilOffset=0, bool collision=false, MSRouteIterator *searchStart=nullptr)
Adds a stop.
double getHCEmissions() const
Returns HC emission of the current state.
virtual bool resumeFromStopping()
void onDepart()
Called when the vehicle is inserted into the network.
void removeReminder(MSMoveReminder *rem)
Removes a MoveReminder dynamically.
bool haveValidStopEdges() const
check whether all stop.edge MSRouteIterators are valid and in order
virtual double getAcceleration() const
Returns the vehicle's acceleration.
virtual bool handleCollisionStop(MSStop &stop, const bool collision, const double distToStop, const std::string &errorMsgStart, std::string &errorMsg)
int getRoutePosition() const
return index of edge within route
static const SUMOTime NOT_YET_DEPARTED
double getElecHybridCurrent() const
Returns actual current (A) of ElecHybrid device RICE_CHECK: Is this the current consumed from the ove...
const SUMOVehicleParameter * myParameter
This vehicle's parameter.
virtual bool hasValidRouteStart(std::string &msg)
checks wether the vehicle can depart on the first edge
int myRouteValidity
status of the current vehicle route
std::vector< std::pair< int, double > > getStopIndices() const
return list of route indices for the remaining stops
const ConstMSEdgeVector getStopEdges(double &firstPos, double &lastPos) const
Returns the list of still pending stop edges also returns the first and last stop position.
SUMOTime myStopUntilOffset
The offset when adding route stops with 'until' on route replacement.
virtual bool isOnRoad() const
Returns the information whether the vehicle is on a road (is simulated)
void reroute(SUMOTime t, const std::string &info, SUMOAbstractRouter< MSEdge, SUMOVehicle > &router, const bool onInit=false, const bool withTaz=false, const bool silent=false)
Performs a rerouting using the given router.
const std::vector< MSTransportable * > & getContainers() const
retrieve riding containers
MSEdgeWeightsStorage * myEdgeWeights
void createDevice(const std::string &deviceName)
create device of the given type
bool isStopped() const
Returns whether the vehicle is at a stop.
bool abortNextStop(int nextStopIndex=0)
deletes the next stop at the given index if it exists
int myNumberReroutes
The number of reroutings.
double myArrivalPos
The position on the destination lane where the vehicle stops.
virtual void saveState(OutputDevice &out)
Saves the (common) state of a vehicle.
double myOdometer
A simple odometer to keep track of the length of the route already driven.
int getContainerNumber() const
Returns the number of containers.
virtual std::string getParameter(const MSVehicle *veh, const std::string &key) const
try to get the given parameter for this carFollowingModel
Battery device for electric vehicles.
double getActualBatteryCapacity() const
Get the actual vehicle's Battery Capacity in kWh.
const std::map< int, double > & getEnergyParams() const
retrieve parameters for the energy consumption model
A device which collects info on the vehicle trip (mainly on departure and arrival)
double getCurrentFromOverheadWire() const
Get actual current in the overhead wire segment.
double getActualBatteryCapacity() const
Get the actual vehicle's Battery Capacity in kWh.
A device that performs vehicle rerouting based on current edge speeds.
bool notifyEnter(SUMOTrafficObject &veh, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
Computes a new route on vehicle insertion.
static void buildVehicleDevices(SUMOVehicle &v, std::vector< MSVehicleDevice * > &into)
Build devices for the given vehicle, if needed.
A device which collects info on the vehicle trip (mainly on departure and arrival)
bool allowsBoarding(MSTransportable *t) const
whether the given person is allowed to board this taxi
const std::vector< MSTransportable * > & getTransportables() const
Returns the list of transportables using this vehicle.
static MSDevice_Transportable * buildVehicleDevices(SUMOVehicle &v, std::vector< MSVehicleDevice * > &into, const bool isContainer)
Build devices for the given vehicle, if needed.
int size() const
Return the number of passengers / containers.
void addTransportable(MSTransportable *transportable)
Add a passenger.
void removeTransportable(MSTransportable *transportable)
Remove a passenger (TraCI)
Abstract in-vehicle / in-person device.
static void buildVehicleDevices(SUMOVehicle &v, std::vector< MSVehicleDevice * > &into)
Build devices for the given vehicle, if needed.
A road/street connecting two junctions.
const std::vector< MSLane * > * allowedLanes(const MSEdge &destination, SUMOVehicleClass vclass=SVC_IGNORING) const
Get the allowed lanes to reach the destination-edge.
const std::vector< MSLane * > & getLanes() const
Returns this edge's lanes.
double getLength() const
return the length of the edge
bool isTazConnector() const
bool isInternal() const
return whether this edge is an internal edge
static bool dictionary(const std::string &id, MSEdge *edge)
Inserts edge into the static dictionary Returns true if the key id isn't already in the dictionary....
const MSEdge * getNormalBefore() const
if this edge is an internal edge, return its first normal predecessor, otherwise the edge itself
A storage for edge travel times and efforts.
static MELoop * gMesoNet
mesoscopic simulation infrastructure
static SUMOTime gTimeToImpatience
void descheduleDeparture(const SUMOVehicle *veh)
stops trying to emit the given vehicle (and delete it)
Representation of a lane in the micro simulation.
int getRNGIndex() const
returns the associated RNG index
const MSEdge * getNextNormal() const
Returns the lane's follower if it is an internal lane, the edge of the lane otherwise.
double getLength() const
Returns the lane's length.
bool allowsVehicleClass(SUMOVehicleClass vclass) const
static bool dictionary(const std::string &id, MSLane *lane)
Static (sic!) container methods {.
MSEdge & getEdge() const
Returns the lane's edge.
std::mt19937 * getRNG() const
return the associated RNG
Something on a lane to be noticed about vehicle movement.
Notification
Definition of a vehicle state.
@ NOTIFICATION_DEPARTED
The vehicle has departed (was inserted into the network)
const std::string & getDescription() const
bool warnOnce(const std::string &typeAndID)
return whether a warning regarding the given object shall be issued
@ VEHICLE_STATE_NEWROUTE
The vehicle got a new route.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
SUMOAbstractRouter< MSEdge, SUMOVehicle > & getRouterTT(const int rngIndex, const MSEdgeVector &prohibited=MSEdgeVector()) const
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
MSInsertionControl & getInsertionControl()
Returns the insertion control.
void informVehicleStateListener(const SUMOVehicle *const vehicle, VehicleState to, const std::string &info="")
Informs all added listeners about a vehicle's state change.
void addReference() const
increments the reference counter for the route
int size() const
Returns the number of edges to pass.
const std::vector< SUMOVehicleParameter::Stop > & getStops() const
Returns the stops.
MSRouteIterator end() const
Returns the end of the list of edges to pass.
static bool dictionary(const std::string &id, const MSRoute *route)
Adds a route to the dictionary.
void setCosts(double costs)
Sets the costs of the route.
static bool hasRoute(const std::string &id)
returns whether a route with the given id exists
void release() const
deletes the route if there are no further references to it
const MSEdge * getLastEdge() const
returns the destination edge
const RGBColor & getColor() const
Returns the color.
MSRouteIterator begin() const
Returns the begin of the list of edges to pass.
static void checkDist(const std::string &id)
Checks the distribution whether it is permanent and deletes it if not.
const ConstMSEdgeVector & getEdges() const
SUMOTime getPeriod() const
returns the period
void setSavings(double savings)
Sets the savings of the route.
static SUMOAbstractRouter< MSEdge, SUMOVehicle > & getRouterTT(const int rngIndex, SUMOVehicleClass svc, const MSEdgeVector &prohibited=MSEdgeVector())
return the router instance
const MSLane * lane
The lane to stop at (microsim only)
MSStoppingPlace * containerstop
(Optional) container stop if one is assigned to the stop
bool collision
Whether this stop was triggered by a collision.
void initPars(const SUMOVehicleParameter::Stop &stopPar)
initialize attributes from the given stop parameters
const MESegment * segment
The segment to stop at (mesosim only)
MSRouteIterator edge
The edge in the route to stop at.
double getEndPos(const SUMOVehicle &veh) const
return halting position for upcoming stop;
MSParkingArea * parkingarea
(Optional) parkingArea if one is assigned to the stop
MSStoppingPlace * chargingStation
(Optional) charging station if one is assigned to the stop
const SUMOVehicleParameter::Stop pars
The stop parameter.
MSStoppingPlace * busstop
(Optional) bus stop if one is assigned to the stop
MSStoppingPlace * overheadWireSegment
(Optional) overhead wire segment if one is assigned to the stop
bool isPerson() const
Whether it is a person.
void vehicleDeparted(const SUMOVehicle &v)
Informs this control about a vehicle's departure.
void removeVType(const MSVehicleType *vehType)
Abstract in-vehicle device.
Representation of a vehicle in the micro simulation.
MSAbstractLaneChangeModel & getLaneChangeModel()
const MSCFModel & getCarFollowModel() const
Returns the vehicle's car following model definition.
The car-following model and parameter.
SUMOVehicleClass getVehicleClass() const
Get this vehicle type's vehicle class.
double getMaxSpeed() const
Get vehicle's maximum speed [m/s].
bool isVehicleSpecific() const
Returns whether this type belongs to a single vehicle only (was modified)
SUMOEmissionClass getEmissionClass() const
Get this vehicle type's emission class.
const std::string & getID() const
Returns the name of the vehicle type.
double getLength() const
Get vehicle's length [m].
MSVehicleType * buildSingularType(const std::string &id) const
Duplicates the microsim vehicle type giving the newly created type the given id, marking it as vehicl...
static std::string getIDSecure(const T *obj, const std::string &fallBack="NULL")
get an identifier for Named-like object which may be Null
const std::string & getID() const
Returns the id.
A storage for options typed value containers)
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.
const StringVector & getStringVector(const std::string &name) const
Returns the list of string-value of the named option (only for Option_StringVector)
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.
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
static OutputDevice & getDeviceByOption(const std::string &name)
Returns the device described by the option.
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
const std::string getParameter(const std::string &key, const std::string defaultValue="") const
Returns the value for a given key.
static double compute(const SUMOEmissionClass c, const EmissionType e, const double v, const double a, const double slope, const std::map< int, double > *param=0)
Returns the amount of the emitted pollutant given the vehicle type and state (in mg/s or ml/s for fue...
static const RGBColor DEFAULT_COLOR
The default color (for vehicle types and vehicles)
static double rand(std::mt19937 *rng=nullptr)
Returns a random real number in [0, 1)
bool computeLooped(const E *from, const E *to, const V *const vehicle, SUMOTime msTime, std::vector< const E * > &into, bool silent=false)
Builds the route between the given edges using the minimum effort at the given time if from == to,...
double recomputeCosts(const std::vector< const E * > &edges, const V *const v, SUMOTime msTime, double *lengthp=nullptr) const
virtual bool compute(const E *from, const E *to, const V *const vehicle, SUMOTime msTime, std::vector< const E * > &into, bool silent=false)=0
Builds the route between the given edges using the minimum effort at the given time The definition of...
virtual SUMOTime getWaitingTime() const =0
virtual double getSlope() const =0
Returns the slope of the road at object's position in degrees.
virtual double getSpeed() const =0
Returns the object's current speed.
virtual const MSLane * getLane() const =0
Returns the lane the object is currently at.
virtual double getPositionOnLane() const =0
Get the object's position along the lane.
Representation of a vehicle.
long long int NumericalID
virtual bool isIdling() const =0
Returns whether the vehicle is idling (waiting to re-enter the net.
Definition of vehicle stop (position and duration)
std::string edge
The edge to stop at (used only in NETEDIT)
std::string lane
The lane to stop at.
double startPos
The stopping position start.
int index
at which position in the stops list
SUMOTime until
The time at which the vehicle may continue its journey.
double endPos
The stopping position end.
SUMOTime arrival
The (expected) time at which the vehicle reaches the stop.
Structure representing possible vehicle parameter.
int parametersSet
Information for the router which parameter were set, TraCI may modify this (when changing color)
ArrivalSpeedDefinition arrivalSpeedProcedure
Information how the vehicle's end speed shall be chosen.
SUMOTime repetitionOffset
The time offset between vehicle reinsertions.
std::vector< std::string > via
List of the via-edges the vehicle must visit.
int repetitionsDone
The number of times the vehicle was already inserted.
ArrivalLaneDefinition arrivalLaneProcedure
Information how the vehicle shall choose the lane to arrive on.
void write(OutputDevice &dev, const OptionsCont &oc, const SumoXMLTag tag=SUMO_TAG_VEHICLE, const std::string &typeID="") const
Writes the parameters as a beginning element.
int personNumber
The static number of persons in the vehicle when it departs (not including boarding persons)
double departPos
(optional) The position the vehicle shall depart from
double arrivalPos
(optional) The position the vehicle shall arrive on
std::string routeid
The vehicle's route id.
std::string id
The vehicle's id.
std::vector< Stop > stops
List of the stops the vehicle will make, TraCI may add entries here.
int departEdge
(optional) The initial edge within the route of the vehicle
bool wasSet(int what) const
Returns whether the given parameter was set.
ArrivalPosDefinition arrivalPosProcedure
Information how the vehicle shall choose the arrival position.
DepartEdgeDefinition departEdgeProcedure
Information how the vehicle's initial edge shall be chosen.
std::string toTaz
The vehicle's destination zone (district)
double arrivalSpeed
(optional) The final speed of the vehicle (not used yet)
DepartDefinition departProcedure
Information how the vehicle shall choose the depart time.
std::string fromTaz
The vehicle's origin zone (district)
DepartPosDefinition departPosProcedure
Information how the vehicle shall choose the departure position.
std::string line
The vehicle's line (mainly for public transport)
int containerNumber
The static number of containers in the vehicle when it departs.
int size() const
returns the number of existing substrings
std::string get(int pos) const
returns the item at the given position
static bool startsWith(const std::string &str, const std::string prefix)
Checks whether a given string starts with the prefix.
static bool endsWith(const std::string &str, const std::string suffix)
Checks whether a given string ends with the suffix.