#include <MSVehicle.h>

Definition at line 79 of file MSVehicle.h.
Move reminder structures | |
| MoveReminderCont | myMoveReminders |
| Current lane's move reminder. | |
| OffsetVector | myOldLaneMoveReminderOffsets |
| Offsets for prior move reminder. | |
| MoveReminderCont | myOldLaneMoveReminders |
| Prior lanes' move reminder. | |
| typedef std::vector < MSMoveReminder * > | MoveReminderCont |
| Definition of a move reminder container. | |
| typedef std::vector< SUMOReal > | OffsetVector |
| Definition of a vector of offset to prior move reminder. | |
Public Member Functions | |
| SUMOReal | adaptMaxSpeed (SUMOReal referenceSpeed) |
| Adapt the vehicle's maximum speed depending on the reference speed. | |
| void | adaptSpeed () |
| void | addPerson (MSPerson *person) throw () |
| bool | addTraciStop (MSLane *lane, SUMOReal pos, SUMOReal radius, SUMOTime duration) |
| void | checkForLaneChanges () |
| void | checkLaneChangeConstraint (SUMOTime time) |
| bool | congested () const |
| void | enterLaneAtEmit (MSLane *enteredLane, SUMOReal pos, SUMOReal speed) |
| Update when the vehicle enters a new lane in the emit step. | |
| void | enterLaneAtLaneChange (MSLane *enteredLane) |
| Update when the vehicle enters a new lane in the laneChange step. | |
| void | enterLaneAtMove (MSLane *enteredLane, SUMOReal driven) |
| Update when the vehicle enters a new lane in the move step. | |
| SUMOReal | gap2pred (const MSVehicle &pred) const throw () |
| Returns the gap between pred and this vehicle. | |
| const MSCFModel & | getCarFollowModel () const throw () |
| Returns the vehicle's car following model definition. | |
| const std::vector< MSDevice * > & | getDevices () const |
| Returns this vehicle's devices. | |
| SUMOReal | getDistanceToPosition (SUMOReal destPos, const MSEdge *destEdge) |
| const MSEdge *const | getEdge () const |
| const std::string & | getID () const throw () |
| Returns the name of the vehicle. | |
| const MSLane & | getLane () const |
| Returns the lane the vehicle is on. | |
| const MSAbstractLaneChangeModel & | getLaneChangeModel () const |
| MSAbstractLaneChangeModel & | getLaneChangeModel () |
| SUMOReal | getMaxSpeed () const |
| Returns the vehicle's maximum speed. | |
| Position2D | getPosition () const |
| Return current Position. | |
| SUMOReal | getSpeedWithoutTraciInfluence () const throw () |
| MSLane * | getTargetLane () const |
| const MSVehicleType & | getVehicleType () const throw () |
| Returns the vehicle's type definition. | |
| SUMOReal | getWaitingSeconds () const throw () |
| Returns the number of seconds waited (speed was lesser than 0.1m/s). | |
| SUMOTime | getWaitingTime () const throw () |
| Returns the SUMOTime waited (speed was lesser than 0.1m/s). | |
| bool | isOnRoad () const throw () |
| Returns the information whether the vehicle is on a road (is simulated). | |
| bool | knowsEdgeTest (MSEdge &edge) const |
| void | leaveLane (bool isArrival) |
| Update of members if vehicle leaves a new lane in the lane change step or at arrival. | |
| void | leaveLaneAtMove (SUMOReal driven) |
| Update when the vehicle leaves a new lane in the move step. | |
| void | moveFirstChecked () |
| moves the vehicles after their responds (right-of-way rules) are known | |
| bool | moveRegardingCritical (SUMOTime t, const MSLane *const lane, const MSVehicle *const pred, const MSVehicle *const neigh, SUMOReal lengthsInFront) throw () |
| Moves vehicles which may run out of the lane. | |
| SUMOReal | processNextStop (SUMOReal currentVelocity) throw () |
| Processes stops, returns the velocity needed to reach the stop. | |
| void | processTraCICommands (SUMOTime time) |
| void | quitRemindedEntered (MSVehicleQuitReminded *r) |
| void | quitRemindedLeft (MSVehicleQuitReminded *r) |
| void | removeOnTripEnd (MSVehicle *veh) throw () |
| Called when the observed vehicle leaves the simulation. | |
| void | setIndividualMaxSpeed (SUMOReal individualMaxSpeed) |
| void | setPreDawdleAcceleration (SUMOReal accel) |
| void | setWasVaporized (bool onDepart) |
| void | startLaneChange (unsigned lane, SUMOTime stickyTime) |
| bool | startSpeedAdaption (float newSpeed, SUMOTime duration, SUMOTime currentTime) |
| void | unsetIndividualMaxSpeed (void) |
| void | vsafeCriticalCont (SUMOTime t, SUMOReal minVSafe, SUMOReal lengthsInFront) |
| void | writeXMLRoute (OutputDevice &os, int index=-1) const |
| virtual | ~MSVehicle () throw () |
| Destructor. | |
vehicle stops definitions and i/o | |
| bool | addStop (const SUMOVehicleParameter::Stop &stopPar, SUMOTime untilOffset=0) throw () |
| Adds a stop. | |
| bool | hasStops () |
| Returns whether the vehicle has to stop somewhere. | |
| bool | isStopped () |
| Returns whether the vehicle is at a stop. | |
interaction with the route | |
| bool | ends () const throw () |
| Returns the information whether the vehicle should end now. | |
| const MSRoute & | getRoute (int index) const throw () |
| Returns the current or a previously used route. | |
| const MSRoute & | getRoute () const throw () |
| Returns the current route. | |
| MSEdgeWeightsStorage & | getWeightsStorage () throw () |
| Returns the vehicle's internal edge travel times/efforts container. | |
| bool | hasSuccEdge (unsigned int nSuccs) const throw () |
| Returns whether the vehicle has still to pass nSuccs edges. | |
| bool | hasValidRoute (std::string &msg) const throw () |
| Validates the current route. | |
| bool | moveRoutePointer (const MSEdge *targetEdge) throw () |
| Moves the vehicle's route pointer to given edge. | |
| bool | replaceRoute (const MSEdgeVector &edges, SUMOTime simTime, bool onInit=false) throw () |
| Replaces the current route by the given edges. | |
| void | reroute (SUMOTime t, SUMOAbstractRouter< MSEdge, SUMOVehicle > &router, bool withTaz=false) throw () |
| Performs a rerouting using the given router. | |
| const MSEdge * | succEdge (unsigned int nSuccs) const throw () |
| Returns the nSuccs'th successor of edge the vehicle is currently at. | |
| bool | willPass (const MSEdge *const edge) const throw () |
| Returns whether the vehicle wil pass the given edge. | |
stretegical/tactical lane choosing methods | |
| virtual const std::vector < LaneQ > & | getBestLanes (bool forceRebuild=false, MSLane *startLane=0) const throw () |
| Returns the description of best lanes to use in order to continue the route. | |
| const std::vector< MSLane * > & | getBestLanesContinuation (const MSLane *const l) const throw () |
| Returns the subpart of best lanes that describes the given lane and their successors. | |
| const std::vector< MSLane * > & | getBestLanesContinuation () const throw () |
| Returns the subpart of best lanes that describes the vehicle's current lane and their successors. | |
Retrieval of CORN values | |
| int | getCORNIntValue (MSCORN::Function f) const throw () |
| Returns the named CORN integer value. | |
| void * | getCORNPointerValue (MSCORN::Pointer p) const throw () |
| Returns the named CORN pointer value. | |
| bool | hasCORNIntValue (MSCORN::Function f) const throw () |
| bool | hasCORNPointerValue (MSCORN::Pointer p) const throw () |
emission handling | |
| const MSEdge & | getDepartEdge () const |
| Returns the edge the vehicle starts from. | |
| SUMOTime | getDesiredDepart () const throw () |
| Returns the desired departure time. | |
| const SUMOVehicleParameter & | getParameter () const throw () |
| Returns the vehicle's parameter (including departure definition). | |
Emission retrieval | |
| SUMOReal | getHarmonoise_NoiseEmissions () const throw () |
| Returns noise emissions of the current state. | |
| SUMOReal | getHBEFA_CO2Emissions () const throw () |
| Returns CO2 emission of the current state. | |
| SUMOReal | getHBEFA_COEmissions () const throw () |
| Returns CO emission of the current state. | |
| SUMOReal | getHBEFA_FuelConsumption () const throw () |
| Returns fuel consumption of the current state. | |
| SUMOReal | getHBEFA_HCEmissions () const throw () |
| Returns HC emission of the current state. | |
| SUMOReal | getHBEFA_NOxEmissions () const throw () |
| Returns NOx emission of the current state. | |
| SUMOReal | getHBEFA_PMxEmissions () const throw () |
| Returns PMx emission of the current state. | |
Interaction with move reminders | |
| SUMOReal | getPositionOnActiveMoveReminderLane (const MSLane *const searchedLane) const throw () |
| Returns the vehicle's position in relation to a passed move reminder lane. | |
| void | workOnMoveReminders (SUMOReal oldPos, SUMOReal newPos, SUMOReal newSpeed) throw () |
| Processes active move reminder. | |
state setter/getter | |
| SUMOReal | getPositionOnLane () const throw () |
| Get the vehicle's position along the lane. | |
| SUMOReal | getPreDawdleAcceleration () const throw () |
| Returns the vehicle's acceleration before dawdling. | |
| SUMOReal | getSpeed () const throw () |
| Returns the vehicle's current speed. | |
| const State & | getState () const throw () |
| Returns the vehicle state. | |
insertion/removal | |
| void | onDepart () throw () |
| Called when the vehicle is inserted into the network. | |
| void | onRemovalFromNet (bool forTeleporting) throw () |
| Called when the vehicle is removed the network. | |
| void | onTryEmit () throw () |
| Called when the vehicle tries to get into the network. | |
state io | |
| void | saveState (std::ostream &os) |
| Saves the states of a vehicle. | |
Static Public Member Functions | |
| static SUMOReal | gap (SUMOReal predPos, SUMOReal predLength, SUMOReal pos) throw () |
| Uses the given values to compute the brutto-gap. | |
| static bool | overlap (const MSVehicle *veh1, const MSVehicle *veh2) |
Protected Member Functions | |
| void | checkRewindLinkLanes (SUMOReal lengthsInFront) throw () |
| MSVehicle (SUMOVehicleParameter *pars, const MSRoute *route, const MSVehicleType *type, int vehicleIndex) throw (ProcessError) | |
| Use this constructor only. | |
| void | rebuildContinuationsFor (LaneQ &q, MSLane *l, MSRouteIterator ce, int seen) const |
| virtual void | setBlinkerInformation () |
Interaction with move reminders | |
| void | activateReminders (bool isEmit, bool isLaneChange) throw () |
| "Activates" all current move reminder | |
| void | adaptLaneEntering2MoveReminder (const MSLane &enteredLane) throw () |
| Adapts the vehicle's entering of a new lane. | |
Protected Attributes | |
| SUMOReal | myArrivalPos |
| the position on the destination lane where the vehicle stops | |
| std::vector< std::vector< LaneQ > > | myBestLanes |
| std::vector< LaneQ >::iterator | myCurrentLaneInBestLanes |
| std::vector< MSLane * > | myFurtherLanes |
| The information into which lanes the vehicle laps into. | |
| bool | myHasIndividualMaxSpeed |
| is true if there has an individual speed been set | |
| SUMOReal | myIndividualMaxSpeed |
| std::map< MSCORN::Function, int > | myIntCORNMap |
| MSLane * | myLane |
| The lane the vehicle is on. | |
| MSAbstractLaneChangeModel * | myLaneChangeModel |
| const MSEdge * | myLastBestLanesEdge |
| SUMOReal | myLastLaneChangeOffset |
| information how long ago the vehicle has performed a lane-change | |
| const SUMOVehicleParameter * | myParameter |
| This Vehicle's parameter. | |
| std::map< MSCORN::Pointer, void * > | myPointerCORNMap |
| SUMOReal | myPreDawdleAcceleration |
| The current acceleration before dawdling. | |
| SUMOReal | myReferenceSpeed |
| the speed which served as reference when calculating the individual maxspeed | |
| const MSRoute * | myRoute |
| This Vehicle's route. | |
| State | myState |
| This Vehicles driving state (pos and speed). | |
| std::list< Stop > | myStops |
| The vehicle's list of stops. | |
| MSLane * | myTarget |
| the lane, the vehicle will be within the next time step (0 if the vehicle stays on the same it was before) | |
| const MSVehicleType *const | myType |
| SUMOTime | myWaitingTime |
| The time the vehicle waits (is not faster than 0.1m/s) in seconds. | |
Static Protected Attributes | |
| static std::vector< MSLane * > | myEmptyLaneVector |
Private Types | |
| typedef std::vector < DriveProcessItem > | DriveItemVector |
| typedef std::vector < MSVehicleQuitReminded * > | QuitRemindedVector |
| typedef std::vector < RouteReplaceInfo > | ReplacedRoutesVector |
| Definition of the vector which stores information about replaced routes. | |
Private Member Functions | |
| MSVehicle (const MSVehicle &) | |
| invalidated copy constructor | |
| MSVehicle () | |
| invalidated efault constructor | |
| MSVehicle & | operator= (const MSVehicle &) |
| invalidated assignment operator | |
Private Attributes | |
| SUMOTime | adaptDuration |
| bool | adaptingSpeed |
| bool | isLastAdaption |
| bool | laneChangeConstraintActive |
| SUMOTime | laneChangeStickyTime |
| MSRouteIterator | myCurrEdge |
| Iterator to current route-edge. | |
| unsigned | myDestinationLane |
| std::vector< MSDevice * > | myDevices |
| The devices this vehicle has. | |
| MSEdgeWeightsStorage * | myEdgeWeights |
| The vehicle's knowledge about edge efforts/travel times;. | |
| DriveItemVector | myLFLinkLanes |
| Container for used Links/visited Lanes during lookForward. | |
| QuitRemindedVector | myQuitReminded |
| SUMOReal | speedBeforeAdaption |
| SUMOReal | speedReduction |
| SUMOReal | speedWithoutTraciInfluence |
| SUMOTime | timeBeforeAdaption |
| SUMOTime | timeBeforeLaneChange |
Friends | |
| class | MSLaneChanger |
| the lane changer sets myLastLaneChangeOffset | |
| class | MSVehicleControl |
Data Structures | |
| struct | DepartArrivalInformation |
| struct | DriveProcessItem |
| struct | LaneQ |
| A structure representing the best lanes for continuing the route. More... | |
| class | RouteReplaceInfo |
| Information about a replaced route. More... | |
| class | State |
| Container that holds the vehicles driving state (position+speed). More... | |
| struct | Stop |
| Definition of vehicle stop (position and duration). More... | |
typedef std::vector< DriveProcessItem > MSVehicle::DriveItemVector [private] |
Definition at line 1017 of file MSVehicle.h.
typedef std::vector< MSMoveReminder* > MSVehicle::MoveReminderCont [private] |
typedef std::vector<SUMOReal> MSVehicle::OffsetVector [private] |
Definition of a vector of offset to prior move reminder.
Definition at line 1036 of file MSVehicle.h.
typedef std::vector<MSVehicleQuitReminded*> MSVehicle::QuitRemindedVector [private] |
Definition at line 1042 of file MSVehicle.h.
typedef std::vector<RouteReplaceInfo> MSVehicle::ReplacedRoutesVector [private] |
Definition of the vector which stores information about replaced routes.
Definition at line 1077 of file MSVehicle.h.
| MSVehicle::~MSVehicle | ( | ) | throw () [virtual] |
Destructor.
Definition at line 134 of file MSVehicle.cpp.
References MSCORN::CORN_P_VEH_ARRIVAL_INFO, MSCORN::CORN_P_VEH_DEPART_INFO, MSCORN::CORN_P_VEH_OLDROUTE, MSCORN::CORN_P_VEH_PASSENGER, MSRoute::erase(), Named::getID(), MSNet::getInstance(), hasCORNPointerValue(), MSRoute::inFurtherUse(), myDevices, myEdgeWeights, myFurtherLanes, myLaneChangeModel, myLFLinkLanes, myParameter, myPointerCORNMap, myQuitReminded, and myRoute.
00134 { 00135 // remove move reminder 00136 for (QuitRemindedVector::iterator i=myQuitReminded.begin(); i!=myQuitReminded.end(); ++i) { 00137 (*i)->removeOnTripEnd(this); 00138 } 00139 // delete the route 00140 if (!myRoute->inFurtherUse()) { 00141 MSRoute::erase(myRoute->getID()); 00142 } 00143 // delete values in CORN 00144 if (myPointerCORNMap.find(MSCORN::CORN_P_VEH_OLDROUTE)!=myPointerCORNMap.end()) { 00145 ReplacedRoutesVector *v = (ReplacedRoutesVector*) myPointerCORNMap[MSCORN::CORN_P_VEH_OLDROUTE]; 00146 for (ReplacedRoutesVector::iterator i=v->begin(); i!=v->end(); ++i) { 00147 delete(*i).route; 00148 } 00149 delete v; 00150 } 00151 if (myPointerCORNMap.find(MSCORN::CORN_P_VEH_DEPART_INFO)!=myPointerCORNMap.end()) { 00152 DepartArrivalInformation *i = (DepartArrivalInformation*) myPointerCORNMap[MSCORN::CORN_P_VEH_DEPART_INFO]; 00153 delete i; 00154 } 00155 if (myPointerCORNMap.find(MSCORN::CORN_P_VEH_ARRIVAL_INFO)!=myPointerCORNMap.end()) { 00156 DepartArrivalInformation *i = (DepartArrivalInformation*) myPointerCORNMap[MSCORN::CORN_P_VEH_ARRIVAL_INFO]; 00157 delete i; 00158 } 00159 // 00160 delete myParameter; 00161 delete myLaneChangeModel; 00162 for (std::vector< MSDevice* >::iterator dev=myDevices.begin(); dev != myDevices.end(); ++dev) { 00163 delete(*dev); 00164 } 00165 myDevices.clear(); 00166 // persons 00167 if (hasCORNPointerValue(MSCORN::CORN_P_VEH_PASSENGER)) { 00168 std::vector<MSPerson*> *persons = (std::vector<MSPerson*>*) myPointerCORNMap[MSCORN::CORN_P_VEH_PASSENGER]; 00169 for (std::vector<MSPerson*>::iterator i=persons->begin(); i!=persons->end(); ++i) { 00170 (*i)->proceed(MSNet::getInstance(), MSNet::getInstance()->getCurrentTimeStep()); 00171 } 00172 delete persons; 00173 } 00174 // other 00175 delete myEdgeWeights; 00176 for (std::vector<MSLane*>::iterator i=myFurtherLanes.begin(); i!=myFurtherLanes.end(); ++i) { 00177 (*i)->resetPartialOccupation(this); 00178 } 00179 for (DriveItemVector::iterator i=myLFLinkLanes.begin(); i!=myLFLinkLanes.end(); ++i) { 00180 if ((*i).myLink!=0) { 00181 (*i).myLink->removeApproaching(this); 00182 } 00183 } 00184 myFurtherLanes.clear(); 00185 }
| MSVehicle::MSVehicle | ( | SUMOVehicleParameter * | pars, | |
| const MSRoute * | route, | |||
| const MSVehicleType * | type, | |||
| int | vehicleIndex | |||
| ) | throw (ProcessError) [protected] |
Use this constructor only.
Definition at line 188 of file MSVehicle.cpp.
References addStop(), MSDevice_HBEFA::buildVehicleDevices(), MSDevice_Routing::buildVehicleDevices(), MSCORN::CORN_VEH_WAITINGTIME, MSNet::getInstance(), MSEdge::getLanes(), MSRoute::getLastEdge(), myArrivalPos, myDevices, myIntCORNMap, myLaneChangeModel, myRoute, SUMOReal, and MSCORN::wished().
00191 : 00192 myLastLaneChangeOffset(0), 00193 myTarget(0), 00194 myWaitingTime(0), 00195 myParameter(pars), 00196 myRoute(route), 00197 myState(0, 0), // 00198 myIndividualMaxSpeed(0.0), 00199 myHasIndividualMaxSpeed(false), 00200 myReferenceSpeed(-1.0), 00201 myLane(0), 00202 myType(type), 00203 myLastBestLanesEdge(0), 00204 myCurrEdge(myRoute->begin()), 00205 myMoveReminders(0), 00206 myOldLaneMoveReminders(0), 00207 myOldLaneMoveReminderOffsets(0), 00208 myArrivalPos(pars->arrivalPos), 00209 myPreDawdleAcceleration(0), 00210 myEdgeWeights(0) 00211 #ifndef NO_TRACI 00212 ,adaptingSpeed(false), 00213 isLastAdaption(false), 00214 speedBeforeAdaption(0), 00215 speedWithoutTraciInfluence(0), 00216 timeBeforeAdaption(0), 00217 speedReduction(0), 00218 adaptDuration(0), 00219 timeBeforeLaneChange(0), 00220 laneChangeStickyTime(0), 00221 laneChangeConstraintActive(false), 00222 myDestinationLane(0) 00223 #endif 00224 { 00225 for (std::vector<SUMOVehicleParameter::Stop>::iterator i=pars->stops.begin(); i!=pars->stops.end(); ++i) { 00226 if (!addStop(*i)) { 00227 throw ProcessError("Stop for vehicle '" + pars->id + 00228 "' on lane '" + i->lane + "' is not downstream the current route."); 00229 } 00230 } 00231 for (std::vector<SUMOVehicleParameter::Stop>::const_iterator i=route->getStops().begin(); i!=route->getStops().end(); ++i) { 00232 if (!addStop(*i)) { 00233 throw ProcessError("Stop for vehicle '" + pars->id + 00234 "' on lane '" + i->lane + "' is not downstream the current route."); 00235 } 00236 } 00237 #ifdef _MESSAGES 00238 myLCMsgEmitter = MSNet::getInstance()->getMsgEmitter("lanechange"); 00239 myBMsgEmitter = MSNet::getInstance()->getMsgEmitter("break"); 00240 myHBMsgEmitter = MSNet::getInstance()->getMsgEmitter("heartbeat"); 00241 #endif 00242 // build arrival definition 00243 SUMOReal lastLaneLength = (myRoute->getLastEdge()->getLanes())[0]->getLength(); 00244 if (myArrivalPos < 0) { 00245 myArrivalPos += lastLaneLength; // !!! validate! 00246 } 00247 if (myArrivalPos<0) { 00248 myArrivalPos = 0; 00249 } 00250 if (myArrivalPos>lastLaneLength) { 00251 myArrivalPos = lastLaneLength; 00252 } 00253 MSDevice_Routing::buildVehicleDevices(*this, myDevices); 00254 myLaneChangeModel = new MSLCM_DK2004(*this); 00255 // init devices 00256 MSDevice_HBEFA::buildVehicleDevices(*this, myDevices); 00257 // init CORN containers 00258 if (MSCORN::wished(MSCORN::CORN_VEH_WAITINGTIME)) { 00259 myIntCORNMap[MSCORN::CORN_VEH_WAITINGTIME] = 0; 00260 } 00261 if ((*myCurrEdge)->getDepartLane(*this) == 0) { 00262 throw ProcessError("Invalid departlane definition for vehicle '" + pars->id + "'"); 00263 } 00264 }
| MSVehicle::MSVehicle | ( | ) | [private] |
invalidated efault constructor
| MSVehicle::MSVehicle | ( | const MSVehicle & | ) | [private] |
invalidated copy constructor
"Activates" all current move reminder
For all move reminder stored in "myMoveReminders", their method "MSMoveReminder::notifyEnter" is called.
| [in] | isEmit | true means the vehicle was emitted |
| [in] | isLaneChange | true means the vehicle entered via lane change |
Definition at line 637 of file MSVehicle.cpp.
References myMoveReminders.
Referenced by enterLaneAtEmit(), enterLaneAtLaneChange(), and enterLaneAtMove().
00637 { 00638 // This erasure-idiom works for all stl-sequence-containers 00639 // See Meyers: Effective STL, Item 9 00640 for (std::vector< MSMoveReminder* >::iterator rem=myMoveReminders.begin(); rem!=myMoveReminders.end();) { 00641 if (!(*rem)->notifyEnter(*this, isEmit, isLaneChange)) { 00642 rem = myMoveReminders.erase(rem); 00643 } else { 00644 ++rem; 00645 } 00646 } 00647 }
| void MSVehicle::adaptLaneEntering2MoveReminder | ( | const MSLane & | enteredLane | ) | throw () [protected] |
Adapts the vehicle's entering of a new lane.
All offsets already stored in "myOldLaneMoveReminderOffsets" are increased by the length that has been left. All still active move reminders from "myMoveReminders" are put into "myOldLaneMoveReminders" and the offset to the last lane is added to "myOldLaneMoveReminderOffsets" for each of these.
Move reminder from the given lane are set into "myMoveReminders".
"myLane" must still be the left lane!
| [in] | enteredLane |
MSLane::getMoveReminder
Definition at line 618 of file MSVehicle.cpp.
References MSLane::getLength(), myLane, myMoveReminders, myOldLaneMoveReminderOffsets, myOldLaneMoveReminders, and SUMOReal.
Referenced by enterLaneAtMove().
00618 { 00619 // save the old work reminders, patching the position information 00620 // add the information about the new offset to the old lane reminders 00621 SUMOReal oldLaneLength = myLane->getLength(); 00622 OffsetVector::iterator i; 00623 for (i=myOldLaneMoveReminderOffsets.begin(); i!=myOldLaneMoveReminderOffsets.end(); ++i) { 00624 (*i) += oldLaneLength; 00625 } 00626 for (size_t j=0; j<myMoveReminders.size(); j++) { 00627 myOldLaneMoveReminderOffsets.push_back(oldLaneLength); 00628 } 00629 copy(myMoveReminders.begin(), myMoveReminders.end(), back_inserter(myOldLaneMoveReminders)); 00630 assert(myOldLaneMoveReminders.size()==myOldLaneMoveReminderOffsets.size()); 00631 // get new move reminder 00632 myMoveReminders = enteredLane.getMoveReminders(); 00633 }
| SUMOReal MSVehicle::adaptMaxSpeed | ( | SUMOReal | referenceSpeed | ) | [inline, virtual] |
Adapt the vehicle's maximum speed depending on the reference speed.
| [in] | the | maximum speed on the edge |
Implements SUMOVehicle.
Definition at line 474 of file MSVehicle.h.
References MSVehicleType::getMaxSpeed(), MSVehicleType::getMaxSpeedWithDeviation(), MSVehicleType::hasSpeedDeviation(), MIN2(), myHasIndividualMaxSpeed, myIndividualMaxSpeed, myReferenceSpeed, and myType.
00474 { 00475 if (myType->hasSpeedDeviation() && referenceSpeed != myReferenceSpeed) { 00476 myHasIndividualMaxSpeed = true; 00477 myIndividualMaxSpeed = myType->getMaxSpeedWithDeviation(referenceSpeed); 00478 myReferenceSpeed = referenceSpeed; 00479 } 00480 if (myHasIndividualMaxSpeed) 00481 return myIndividualMaxSpeed; 00482 return MIN2(myType->getMaxSpeed(), referenceSpeed); 00483 }
| void MSVehicle::adaptSpeed | ( | ) |
called each simulation step to slow down if necessary (see above)
Definition at line 1946 of file MSVehicle.cpp.
References adaptDuration, adaptingSpeed, MSNet::getCurrentTimeStep(), MSNet::getInstance(), isLastAdaption, setIndividualMaxSpeed(), speedBeforeAdaption, speedReduction, SUMOReal, timeBeforeAdaption, and unsetIndividualMaxSpeed().
Referenced by processTraCICommands().
01946 { 01947 SUMOReal maxSpeed = 0; 01948 SUMOTime currentTime = MSNet::getInstance()->getCurrentTimeStep(); 01949 if (!adaptingSpeed) { 01950 return; 01951 } 01952 if (isLastAdaption) { 01953 unsetIndividualMaxSpeed(); 01954 adaptingSpeed = false; 01955 isLastAdaption = false; 01956 return; 01957 } 01958 if (currentTime <= timeBeforeAdaption + adaptDuration) { 01959 maxSpeed = speedBeforeAdaption - (speedReduction / adaptDuration) 01960 * (currentTime - timeBeforeAdaption); 01961 } else { 01962 maxSpeed = speedBeforeAdaption - speedReduction; 01963 isLastAdaption = true; 01964 } 01965 setIndividualMaxSpeed(maxSpeed); 01966 }
| void MSVehicle::addPerson | ( | MSPerson * | person | ) | throw () |
Definition at line 1921 of file MSVehicle.cpp.
References MSCORN::CORN_P_VEH_PASSENGER, hasCORNPointerValue(), and myPointerCORNMap.
Referenced by MSPerson::MSPersonStage_Driving::proceed().
01921 { 01922 if (!hasCORNPointerValue(MSCORN::CORN_P_VEH_PASSENGER)) { 01923 myPointerCORNMap[MSCORN::CORN_P_VEH_PASSENGER] = new std::vector<MSPerson*>(); 01924 } 01925 ((std::vector<MSPerson*>*) myPointerCORNMap[MSCORN::CORN_P_VEH_PASSENGER])->push_back(person); 01926 }
| bool MSVehicle::addStop | ( | const SUMOVehicleParameter::Stop & | stopPar, | |
| SUMOTime | untilOffset = 0 | |||
| ) | throw () |
Adds a stop.
The stop is put into the sorted list.
| [in] | stop | The stop to add |
Definition at line 652 of file MSVehicle.cpp.
References MSRoute::begin(), MSVehicle::Stop::busstop, MSLane::dictionary(), MSVehicle::Stop::duration, MSRoute::end(), MSRoute::find(), MSNet::getBusStop(), getCarFollowModel(), MSLane::getEdge(), MSNet::getInstance(), MSVehicle::Stop::lane, myCurrEdge, MSVehicle::State::myPos, myRoute, MSVehicle::State::mySpeed, myState, myStops, MSVehicle::Stop::pos, MSVehicle::Stop::reached, and MSVehicle::Stop::until.
Referenced by addTraciStop(), and MSVehicle().
00652 { 00653 Stop stop; 00654 stop.lane = MSLane::dictionary(stopPar.lane); 00655 stop.busstop = MSNet::getInstance()->getBusStop(stopPar.busstop); 00656 stop.pos = stopPar.pos; 00657 stop.duration = stopPar.duration; 00658 stop.until = stopPar.until; 00659 if (stop.until != -1) { 00660 stop.until += untilOffset; 00661 } 00662 stop.reached = false; 00663 MSRouteIterator stopEdge = myRoute->find(&stop.lane->getEdge(), myCurrEdge); 00664 if (myCurrEdge > stopEdge || (myCurrEdge == stopEdge && myState.myPos > stop.pos - getCarFollowModel().brakeGap(myState.mySpeed))) { 00665 // do not add the stop if the vehicle is already behind it or cannot break 00666 return false; 00667 } 00668 // check whether the stop lies at the end of a route 00669 std::list<Stop>::iterator iter = myStops.begin(); 00670 MSRouteIterator last = myRoute->begin(); 00671 if (myStops.size()>0) { 00672 last = myRoute->find(&myStops.back().lane->getEdge()); 00673 last = myRoute->find(&stop.lane->getEdge(), last); 00674 if (last!=myRoute->end()) { 00675 iter = myStops.end(); 00676 stopEdge = last; 00677 } 00678 } 00679 while ((iter != myStops.end()) && (myRoute->find(&iter->lane->getEdge()) <= stopEdge)) { 00680 iter++; 00681 } 00682 while ((iter != myStops.end()) 00683 && (stop.pos > iter->pos) 00684 && (myRoute->find(&iter->lane->getEdge()) == stopEdge)) { 00685 iter++; 00686 } 00687 myStops.insert(iter, stop); 00688 return true; 00689 }
schedule a new stop for the vehicle; each time a stop is reached, the vehicle will wait for the given duration before continuing on its route
| lane | lane on wich to stop | |
| pos | position on the given lane at wich to stop | |
| radius | the vehicle will stop if it is within the range [pos-radius, pos+radius] after waiting for the time period duration, the vehicle will continue until the stop is reached again |
Definition at line 2029 of file MSVehicle.cpp.
References addStop(), SUMOVehicleParameter::Stop::busstop, SUMOVehicleParameter::Stop::duration, MSNet::getBusStopID(), MSLane::getID(), MSNet::getInstance(), SUMOVehicleParameter::Stop::lane, myStops, SUMOVehicleParameter::Stop::pos, POSITION_EPS, and SUMOVehicleParameter::Stop::until.
Referenced by traci::TraCIServer::commandStopNode(), and TraCIServerAPI_Vehicle::processSet().
02029 { 02030 //if the stop exists update the duration 02031 for (std::list<Stop>::iterator iter = myStops.begin(); iter != myStops.end(); iter++) { 02032 if (iter->lane == lane && fabs(iter->pos - pos) < POSITION_EPS) { 02033 if (duration == 0 && !iter->reached) { 02034 myStops.erase(iter); 02035 } else { 02036 iter->duration = duration; 02037 } 02038 return true; 02039 } 02040 } 02041 02042 SUMOVehicleParameter::Stop newStop; 02043 newStop.lane = lane->getID(); 02044 newStop.pos = pos; 02045 newStop.duration = duration; 02046 newStop.until = -1; 02047 newStop.busstop = MSNet::getInstance()->getBusStopID(lane, pos); 02048 return addStop(newStop); 02049 }
| void MSVehicle::checkForLaneChanges | ( | ) |
After each changed lane, check if the lane requested by TraCI command "changeLane" is reached and request for more changes if necessary.
Definition at line 1994 of file MSVehicle.cpp.
References MSLane::getRightLane(), laneChangeConstraintActive, myDestinationLane, myLane, myLaneChangeModel, REQUEST_HOLD, REQUEST_LEFT, REQUEST_NONE, REQUEST_RIGHT, and MSAbstractLaneChangeModel::requestLaneChange().
Referenced by enterLaneAtLaneChange(), enterLaneAtMove(), and startLaneChange().
01994 { 01995 MSLane* tmpLane; 01996 unsigned currentLaneIndex = 0; 01997 if (!laneChangeConstraintActive) { 01998 myLaneChangeModel->requestLaneChange(REQUEST_NONE); 01999 return; 02000 } 02001 if ((unsigned int)(*myCurrEdge)->getLanes().size() <= myDestinationLane) { 02002 laneChangeConstraintActive = false; 02003 return; 02004 } 02005 tmpLane = myLane; 02006 while ((tmpLane =tmpLane->getRightLane()) != NULL) { 02007 currentLaneIndex++; 02008 } 02009 if (currentLaneIndex > myDestinationLane) { 02010 myLaneChangeModel->requestLaneChange(REQUEST_RIGHT); 02011 } else if (currentLaneIndex < myDestinationLane) { 02012 myLaneChangeModel->requestLaneChange(REQUEST_LEFT); 02013 } else { 02014 myLaneChangeModel->requestLaneChange(REQUEST_HOLD); 02015 } 02016 }
| void MSVehicle::checkLaneChangeConstraint | ( | SUMOTime | time | ) |
Checks if the sticky time for a "changelane" command has passed already
| time | current simulation time |
Definition at line 1970 of file MSVehicle.cpp.
References laneChangeConstraintActive, laneChangeStickyTime, and timeBeforeLaneChange.
Referenced by processTraCICommands().
01970 { 01971 if (!laneChangeConstraintActive) { 01972 return; 01973 } 01974 if ((time - timeBeforeLaneChange) >= laneChangeStickyTime) { 01975 laneChangeConstraintActive = false; 01976 } 01977 }
| void MSVehicle::checkRewindLinkLanes | ( | SUMOReal | lengthsInFront | ) | throw () [protected] |
Definition at line 1028 of file MSVehicle.cpp.
References bla, MSCFModel::brakeGap(), MSEdge::EDGEFUNCTION_INTERNAL, MSVehicleType::getCarFollowModel(), getCarFollowModel(), MSLane::getEdge(), MSLink::getLane(), MSLane::getLastVehicle(), MSLane::getLength(), MSVehicleType::getLength(), getPositionOnLane(), MSEdge::getPurpose(), getSpeed(), MSLane::getVehicleNumber(), getVehicleType(), MSLane::getVehLenSum(), GLO_VEHICLE, gSelected, MSGlobals::gUsingInternalLanes, MSLink::isCrossing(), GUISelectedStorage::isSelected(), MAX2(), myLane, myLFLinkLanes, MSVehicle::DriveProcessItem::myLink, myWaitingTime, and SUMOReal.
Referenced by moveRegardingCritical().
01028 { 01029 #ifdef DEBUG_VEHICLE_GUI_SELECTION 01030 if (gSelected.isSelected(GLO_VEHICLE, static_cast<const GUIVehicle*>(this)->getGlID())) { 01031 int bla = 0; 01032 } 01033 #endif 01034 #ifdef HAVE_INTERNAL_LANES 01035 if (MSGlobals::gUsingInternalLanes) { 01036 int removalBegin = -1; 01037 bool hadVehicle = false; 01038 SUMOReal seenLanes = 0; 01039 SUMOReal seenSpace = -lengthsInFront; 01040 MSLane *nextSeenNonInternal = 0; 01041 MSLane *approachedLane = myLane; 01042 int lastLinkToInternal = -1; 01043 MSVehicle *leader = 0; 01044 01045 for (unsigned int i=0; i<myLFLinkLanes.size()&&removalBegin<0; ++i) { 01046 // skip unset links 01047 DriveProcessItem &item = myLFLinkLanes[i]; 01048 if (item.myLink==0) { 01049 continue; 01050 } 01051 if (approachedLane->getEdge().getPurpose()!=MSEdge::EDGEFUNCTION_INTERNAL) { 01052 lastLinkToInternal = i; 01053 } 01054 01055 // 01056 01057 // get the next lane, determine whether it is an internal lane 01058 approachedLane = item.myLink->getViaLane(); 01059 bool nextIsInternal = true; 01060 if (approachedLane==0) { 01061 approachedLane = item.myLink->getLane(); 01062 nextIsInternal = false; 01063 } 01064 MSEdge::EdgeBasicFunction ef = approachedLane->getEdge().getPurpose(); 01065 hadVehicle |= approachedLane->getVehicleNumber()!=0; 01066 nextIsInternal &= item.myLink->isCrossing(); 01067 // 01068 if (nextIsInternal) { 01069 // the free place on internal lanes is not counted - vehicles must keep them free 01070 seenSpace = seenSpace - approachedLane->getVehLenSum(); 01071 if (leader==0&&approachedLane->getLastVehicle()!=0) { 01072 leader = approachedLane->getLastVehicle(); 01073 seenSpace += leader->getCarFollowModel().brakeGap(leader->getSpeed()); 01074 } 01075 } else { 01076 MSVehicle *pred = approachedLane->getLastVehicle(); 01077 bool nextDisallows1 = /*myState.mySpeed<.1 &&*/ pred!=0 && seenSpace<.1; 01078 if (nextDisallows1) { 01079 SUMOReal brakeGap = pred->getVehicleType().getCarFollowModel().brakeGap(pred->getSpeed()); 01080 nextDisallows1 &= pred->getPositionOnLane()+brakeGap < pred->getVehicleType().getLength(); 01081 } 01082 // the free space on plain lanes is counted 01083 // !!!: on longer lanes, only the place some meters in front... (next extension) 01084 seenSpace = seenSpace + approachedLane->getLength() - approachedLane->getVehLenSum(); 01085 if (leader==0&&approachedLane->getLastVehicle()!=0) { 01086 leader = approachedLane->getLastVehicle(); 01087 seenSpace += leader->getCarFollowModel().brakeGap(leader->getSpeed()); 01088 } 01089 seenLanes += approachedLane->getLength(); 01090 // we also do not want the vehicle continue if there is not enough place 01091 // behind the last vehicle on the approached lane (and we are currently standing) 01092 bool nextDisallows2 = /*myState.mySpeed<.1 &&*/ approachedLane->getLastVehicle()!=0 && approachedLane->getLastVehicle()->getSpeed()<.1; 01093 if (nextDisallows2) { 01094 nextDisallows2 &= approachedLane->getLastVehicle()->getPositionOnLane() < approachedLane->getLastVehicle()->getVehicleType().getLength(); 01095 } 01096 if ((nextDisallows1||nextDisallows2)&&lastLinkToInternal>=0) { 01097 removalBegin = lastLinkToInternal; 01098 } 01099 nextSeenNonInternal = approachedLane; 01100 } 01101 // now we check whether the vehicle should not continue because 01102 // there is no space on approached lanes 01103 // - we must have seen at least one vehicle 01104 // - we must have seen at least as much place as the vehicle would need 01105 // - the seen space must be enough for our vehicle 01106 // - we should have seen at least one non-internal lane before 01107 SUMOReal impatienceCorrection = MAX2(0, myWaitingTime); 01108 if (hadVehicle&&seenLanes>getVehicleType().getLength()&&seenSpace<getVehicleType().getLength()-impatienceCorrection/10.&&nextSeenNonInternal!=0) { 01109 removalBegin = lastLinkToInternal; 01110 } 01111 } 01112 if (removalBegin!=-1) { 01113 myLFLinkLanes[removalBegin].myVLinkPass = myLFLinkLanes[removalBegin].myVLinkWait; 01114 myLFLinkLanes[removalBegin].mySetRequest = false; 01115 if (removalBegin+1<(int)myLFLinkLanes.size()) { 01116 myLFLinkLanes.erase(myLFLinkLanes.begin()+removalBegin+1, myLFLinkLanes.end()); 01117 } 01118 } 01119 } 01120 #endif 01121 for (DriveItemVector::iterator i=myLFLinkLanes.begin(); i!=myLFLinkLanes.end(); ++i) { 01122 if ((*i).myLink!=0&&(*i).mySetRequest/*&&(*i).myArrivalTime+20<MSNet::getInstance()->getCurrentTimeStep()*/) { 01123 (*i).myLink->setApproaching(this, (*i).myArrivalTime, (*i).myArrivalSpeed); 01124 } 01125 } 01126 }
| bool MSVehicle::congested | ( | ) | const [inline] |
Returns true if vehicle's speed is below 60km/h. This is only relevant on highways. Overtaking on the right is allowed then.
Definition at line 513 of file MSVehicle.h.
References MSVehicle::State::mySpeed, myState, and SUMOReal.
Referenced by MSAbstractLaneChangeModel::congested().
| bool MSVehicle::ends | ( | ) | const throw () |
Returns the information whether the vehicle should end now.
Definition at line 382 of file MSVehicle.cpp.
References MSRoute::end(), myArrivalPos, myCurrEdge, MSVehicle::State::myPos, myRoute, myState, and POSITION_EPS.
Referenced by MSLane::setCritical().
00382 { 00383 return myCurrEdge==myRoute->end()-1 && myState.myPos > myArrivalPos - POSITION_EPS; 00384 }
| void MSVehicle::enterLaneAtEmit | ( | MSLane * | enteredLane, | |
| SUMOReal | pos, | |||
| SUMOReal | speed | |||
| ) |
Update when the vehicle enters a new lane in the emit step.
| [in] | enteredLane | The lane the vehicle enters |
| [in] | pos | The position the vehicle was inserted into the lane |
| [in] | speed | The speed with which the vehicle was inserted into the lane |
Definition at line 1394 of file MSVehicle.cpp.
References activateReminders(), getID(), MSLane::getIncomingLanes(), MSVehicleType::getLength(), MSLane::getMoveReminders(), hasValidRoute(), myDevices, myFurtherLanes, myLane, myMoveReminders, MSVehicle::State::myPos, MSVehicle::State::mySpeed, myState, myType, myWaitingTime, and SUMOReal.
01394 { 01395 myState = State(pos, speed); 01396 assert(myState.myPos >= 0); 01397 assert(myState.mySpeed >= 0); 01398 myWaitingTime = 0; 01399 myLane = enteredLane; 01400 // set and activate the new lane's reminders 01401 for (std::vector< MSDevice* >::iterator dev=myDevices.begin(); dev != myDevices.end(); ++dev) { 01402 (*dev)->enterLaneAtEmit(enteredLane, myState); 01403 } 01404 std::string msg; 01405 if (!hasValidRoute(msg)) { 01406 throw ProcessError("Vehicle '" + getID() + "' has no valid route. " + msg); 01407 } 01408 myMoveReminders = enteredLane->getMoveReminders(); 01409 activateReminders(true, false); 01410 // build the list of lanes the vehicle is lapping into 01411 SUMOReal leftLength = myType->getLength() - pos; 01412 MSLane *clane = enteredLane; 01413 while (leftLength>0) { 01414 const std::vector<MSLane::IncomingLaneInfo> &incoming = clane->getIncomingLanes(); 01415 if (incoming.size()==0) { 01416 break; 01417 } 01418 clane = incoming[0].lane; // !!! just an approximation 01419 myFurtherLanes.push_back(clane); 01420 leftLength -= (clane)->setPartialOccupation(this, leftLength); 01421 } 01422 }
| void MSVehicle::enterLaneAtLaneChange | ( | MSLane * | enteredLane | ) |
Update when the vehicle enters a new lane in the laneChange step.
| [in] | enteredLane | The lane the vehicle enters |
Definition at line 1347 of file MSVehicle.cpp.
References activateReminders(), MSRoute::begin(), checkForLaneChanges(), MSNet::getCurrentTimeStep(), MSLane::getIncomingLanes(), MSNet::getInstance(), MSVehicleType::getLength(), MSLane::getMoveReminders(), getPosition(), getRoute(), getVehicleType(), SUMOVehicleParameter::id, myCurrEdge, myDevices, myLane, myMoveReminders, myParameter, MSVehicle::State::myPos, myState, MSVehicle::State::pos(), MSVehicle::State::speed(), SUMOReal, Position2D::x(), and Position2D::y().
Referenced by MSLaneChanger::change().
01347 { 01348 #ifdef _MESSAGES 01349 if (myLCMsgEmitter!=0) { 01350 SUMOReal timeStep = MSNet::getInstance()->getCurrentTimeStep(); 01351 myLCMsgEmitter->writeLaneChangeEvent(myParameter->id, timeStep, myLane, myState.pos(), myState.speed(), enteredLane, getPosition().x(), getPosition().y()); 01352 } 01353 #endif 01354 MSLane *myPriorLane = myLane; 01355 myLane = enteredLane; 01356 // switch to and activate the new lane's reminders 01357 // keep OldLaneReminders 01358 myMoveReminders = enteredLane->getMoveReminders(); 01359 activateReminders(false, true); 01360 for (std::vector< MSDevice* >::iterator dev=myDevices.begin(); dev != myDevices.end(); ++dev) { 01361 (*dev)->enterLaneAtLaneChange(enteredLane); 01362 } 01363 SUMOReal leftLength = myState.myPos-getVehicleType().getLength(); 01364 if (leftLength<0) { 01365 // we have to rebuild "further lanes" 01366 const MSRoute &route = getRoute(); 01367 MSRouteIterator i = myCurrEdge; 01368 MSLane *lane = myLane; 01369 while (i!=route.begin()&&leftLength>0) { 01370 const MSEdge * const prev = *(--i); 01371 const std::vector<MSLane::IncomingLaneInfo> &incomingLanes = lane->getIncomingLanes(); 01372 for (std::vector<MSLane::IncomingLaneInfo>::const_iterator j=incomingLanes.begin(); j!=incomingLanes.end(); ++j) { 01373 if (&(*j).lane->getEdge()==prev) { 01374 #ifdef HAVE_INTERNAL_LANES 01375 (*j).lane->setPartialOccupation(this, leftLength); 01376 #else 01377 leftLength -= (*j).length; 01378 (*j).lane->setPartialOccupation(this, leftLength); 01379 #endif 01380 leftLength -= (*j).lane->getLength(); 01381 break; 01382 } 01383 } 01384 } 01385 } 01386 #ifndef NO_TRACI 01387 // check if further changes are necessary 01388 checkForLaneChanges(); 01389 #endif 01390 }
| void MSVehicle::enterLaneAtMove | ( | MSLane * | enteredLane, | |
| SUMOReal | driven | |||
| ) |
Update when the vehicle enters a new lane in the move step.
| [in] | enteredLane | The lane the vehicle enters |
| [in] | driven | The distance driven by the vehicle within this time step |
Definition at line 1308 of file MSVehicle.cpp.
References activateReminders(), adaptLaneEntering2MoveReminder(), checkForLaneChanges(), MSEdge::EDGEFUNCTION_INTERNAL, MSRoute::end(), getBestLanes(), MSLane::getEdge(), MSEdge::getPurpose(), myCurrEdge, myDevices, myLane, myRoute, and myStops.
Referenced by moveFirstChecked(), and MSLane::push().
01308 { 01309 #ifndef NO_TRACI 01310 // remove all Stops that were added by Traci and were not reached for any reason 01311 while (!myStops.empty()&&myStops.begin()->lane==myLane) { 01312 myStops.pop_front(); 01313 } 01314 #endif 01315 // move mover reminder one lane further 01316 adaptLaneEntering2MoveReminder(*enteredLane); 01317 // set the entered lane as the current lane 01318 myLane = enteredLane; 01319 // proceed in route 01320 MSEdge &enteredEdge = enteredLane->getEdge(); 01321 // internal edges are not a part of the route... 01322 if (enteredEdge.getPurpose()!=MSEdge::EDGEFUNCTION_INTERNAL) { 01323 // we may have to skip edges, as the vehicle may have past them in one step 01324 // (and, of course, at least one edge is passed) 01325 MSRouteIterator edgeIt = myCurrEdge; 01326 while (*edgeIt != &enteredEdge) { 01327 ++edgeIt; 01328 assert(edgeIt != myRoute->end()); 01329 } 01330 myCurrEdge = edgeIt; 01331 } 01332 01333 // may be optimized: compute only, if the current or the next have more than one lane...!!! 01334 getBestLanes(true); 01335 activateReminders(false, false); 01336 for (std::vector< MSDevice* >::iterator dev=myDevices.begin(); dev != myDevices.end(); ++dev) { 01337 (*dev)->enterLaneAtMove(enteredLane, driven); 01338 } 01339 01340 #ifndef NO_TRACI 01341 checkForLaneChanges(); 01342 #endif 01343 }
| static SUMOReal MSVehicle::gap | ( | SUMOReal | predPos, | |
| SUMOReal | predLength, | |||
| SUMOReal | pos | |||
| ) | throw () [inline, static] |
Uses the given values to compute the brutto-gap.
| [in] | predPos | Position of the leader |
| [in] | predLength | Length of the leader |
| [in] | pos | Position of the follower |
Definition at line 335 of file MSVehicle.h.
Referenced by gap2pred(), MSLane::isEmissionSuccess(), and moveRegardingCritical().
| SUMOReal MSVehicle::gap2pred | ( | const MSVehicle & | pred | ) | const throw () [inline] |
Returns the gap between pred and this vehicle.
Assumes both vehicles are on the same or on are on parallel lanes.
| [in] | pred | The leader |
Definition at line 319 of file MSVehicle.h.
References gap(), getPositionOnLane(), and SUMOReal.
Referenced by moveRegardingCritical().
00319 { 00320 SUMOReal gap = pred.getPositionOnLane() - pred.getVehicleType().getLength() - getPositionOnLane(); 00321 if (gap<0&&gap>-1.0e-12) { 00322 gap = 0; 00323 } 00324 return gap; 00325 }
| const std::vector< MSVehicle::LaneQ > & MSVehicle::getBestLanes | ( | bool | forceRebuild = false, |
|
| MSLane * | startLane = 0 | |||
| ) | const throw () [virtual] |
Returns the description of best lanes to use in order to continue the route.
The information is rebuilt if the vehicle is on a different edge than the one stored in "myLastBestLanesEdge" or "forceRebuild" is true.
Otherwise, only the density changes on the stored lanes are adapted to the container only.
A rebuild must be done if the vehicle leaves a stop; then, another lane may get the best one.
If no starting lane ("startLane") is given, the vehicle's current lane ("myLane") is used as start of bect lanes building.
| [in] | forceRebuild | Whether the best lanes container shall be rebuilt even if the vehicle's edge has not changed |
| [in] | startLane | The lane the process shall start at ("myLane" will be used if ==0) |
Definition at line 1659 of file MSVehicle.cpp.
References MSVehicle::LaneQ::allowsContinuation, MSVehicle::Stop::busstop, MSRoute::end(), MSLane::getEdge(), MSBusStop::getLastFreePos(), MSLane::getLength(), MSVehicleType::getVehicleClass(), MSLane::getVehLenSum(), MSVehicle::LaneQ::lane, MSVehicle::LaneQ::length, myBestLanes, myCurrEdge, myCurrentLaneInBestLanes, myLane, myLastBestLanesEdge, myRoute, myStops, myType, MSVehicle::LaneQ::occupied, MSVehicle::Stop::pos, rebuildContinuationsFor(), and SUMOReal.
Referenced by MSLaneChanger::change(), enterLaneAtMove(), GUIVehicle::getBestLanes(), and processNextStop().
01659 { 01660 if (startLane==0) { 01661 startLane = myLane; 01662 } 01663 if (myLastBestLanesEdge==&startLane->getEdge()&&!forceRebuild) { 01664 std::vector<LaneQ> &lanes = *myBestLanes.begin(); 01665 std::vector<LaneQ>::iterator i; 01666 for (i=lanes.begin(); i!=lanes.end(); ++i) { 01667 SUMOReal v = 0; 01668 for (std::vector<MSLane*>::const_iterator j=(*i).joined.begin(); j!=(*i).joined.end(); ++j) { 01669 v += (*j)->getVehLenSum(); 01670 } 01671 (*i).v = v; 01672 if ((*i).lane==startLane) { 01673 myCurrentLaneInBestLanes = i; 01674 } 01675 } 01676 return *myBestLanes.begin(); 01677 } 01678 myLastBestLanesEdge = &startLane->getEdge(); 01679 myBestLanes.clear(); 01680 myBestLanes.push_back(std::vector<LaneQ>()); 01681 const std::vector<MSLane*> &lanes = (*myCurrEdge)->getLanes(); 01682 MSRouteIterator ce = myCurrEdge; 01683 int seen = 0; 01684 const std::vector<MSLane*> *allowed = 0; 01685 if (ce!=myRoute->end()&&ce+1!=myRoute->end()) { 01686 allowed = (*ce)->allowedLanes(**(ce+1), myType->getVehicleClass()); 01687 } 01688 for (std::vector<MSLane*>::const_iterator i=lanes.begin(); i!=lanes.end(); ++i) { 01689 LaneQ q; 01690 q.lane = *i; 01691 q.length = 0;//q.lane->getLength(); 01692 q.occupied = 0;//q.lane->getVehLenSum(); 01693 if (!myStops.empty()&& &myStops.front().lane->getEdge()==&q.lane->getEdge()) { 01694 if (myStops.front().lane==q.lane) { 01695 q.allowsContinuation = allowed==0||find(allowed->begin(), allowed->end(), q.lane)!=allowed->end(); 01696 q.length += q.lane->getLength(); 01697 q.occupied += q.lane->getVehLenSum(); 01698 } else { 01699 q.allowsContinuation = false; 01700 q.occupied = q.lane->getVehLenSum(); 01701 const Stop &s = myStops.front(); 01702 SUMOReal endPos = s.pos; 01703 if (s.busstop!=0) { 01704 // on bus stops, we have to wait for free place if they are in use... 01705 endPos = s.busstop->getLastFreePos(); 01706 } 01707 q.length = endPos; 01708 } 01709 } else { 01710 q.allowsContinuation = allowed==0||find(allowed->begin(), allowed->end(), q.lane)!=allowed->end(); 01711 } 01712 myBestLanes[0].push_back(q); 01713 } 01714 if (ce!=myRoute->end()) { 01715 for (std::vector<MSVehicle::LaneQ>::iterator i=myBestLanes.begin()->begin(); i!=myBestLanes.begin()->end(); ++i) { 01716 if ((*i).allowsContinuation) { 01717 rebuildContinuationsFor((*i), (*i).lane, ce, seen); 01718 (*i).length += (*i).lane->getLength(); 01719 (*i).occupied += (*i).lane->getVehLenSum(); 01720 } 01721 } 01722 } 01723 SUMOReal best = 0; 01724 int index = 0; 01725 int run = 0; 01726 for (std::vector<MSVehicle::LaneQ>::iterator i=myBestLanes.begin()->begin(); i!=myBestLanes.begin()->end(); ++i, ++run) { 01727 if (best<(*i).length) { 01728 best = (*i).length; 01729 index = run; 01730 } 01731 if ((*i).lane==startLane) { 01732 myCurrentLaneInBestLanes = i; 01733 } 01734 } 01735 run = 0; 01736 for (std::vector<MSVehicle::LaneQ>::iterator i=myBestLanes.begin()->begin(); i!=myBestLanes.begin()->end(); ++i, ++run) { 01737 (*i).bestLaneOffset = index - run; 01738 } 01739 01740 return *myBestLanes.begin(); 01741 }
| const std::vector< MSLane * > & MSVehicle::getBestLanesContinuation | ( | const MSLane *const | l | ) | const throw () |
Returns the subpart of best lanes that describes the given lane and their successors.
Definition at line 1839 of file MSVehicle.cpp.
References myBestLanes, and myEmptyLaneVector.
01839 { 01840 for (std::vector<std::vector<LaneQ> >::const_iterator i=myBestLanes.begin(); i!=myBestLanes.end(); ++i) { 01841 if ((*i).size()!=0&&(*i)[0].lane==l) { 01842 return (*i)[0].joined; 01843 } 01844 } 01845 return myEmptyLaneVector; 01846 }
| const std::vector< MSLane * > & MSVehicle::getBestLanesContinuation | ( | ) | const throw () |
Returns the subpart of best lanes that describes the vehicle's current lane and their successors.
Definition at line 1830 of file MSVehicle.cpp.
References MSEdge::EDGEFUNCTION_INTERNAL, MSLane::getEdge(), MSEdge::getPurpose(), myBestLanes, myEmptyLaneVector, and myLane.
Referenced by MSLane::appropriate(), MSLaneChanger::getRealLeader(), MSLaneChanger::getRealThisLeader(), GUIVehicle::setBlinkerInformation(), and vsafeCriticalCont().
01830 { 01831 if (myBestLanes.empty()||myBestLanes[0].empty()||myLane->getEdge().getPurpose()==MSEdge::EDGEFUNCTION_INTERNAL) { 01832 return myEmptyLaneVector; 01833 } 01834 return (*myCurrentLaneInBestLanes).joined; 01835 }
| const MSCFModel& MSVehicle::getCarFollowModel | ( | ) | const throw () [inline] |
Returns the vehicle's car following model definition.
This is simply a wrapper around the vehicle type's car-following model retrieval for a shorter access.
Definition at line 687 of file MSVehicle.h.
References MSVehicleType::getCarFollowModel(), and myType.
Referenced by addStop(), checkRewindLinkLanes(), MSLane::freeEmit(), MSLane::getFollowerOnConsecutive(), MSLane::getLeaderOnConsecutive(), getMaxSpeedRegardingNextLanes(), MSLaneChanger::getRealLeader(), MSLCM_DK2004::informBlocker(), MSLane::isEmissionSuccess(), moveFirstChecked(), moveRegardingCritical(), MSLCM_DK2004::patchSpeed(), processNextStop(), MSLaneChanger::setIsSafeChange(), vsafeCriticalCont(), MSLCM_DK2004::wantsChangeToLeft(), and MSLCM_DK2004::wantsChangeToRight().
00687 { 00688 return myType->getCarFollowModel(); 00689 }
| int MSVehicle::getCORNIntValue | ( | MSCORN::Function | f | ) | const throw () |
Returns the named CORN integer value.
The behaviour is undefined for not stored values.
Definition at line 550 of file MSVehicle.cpp.
References myIntCORNMap.
Referenced by GUIViewTraffic::doPaintGL(), drawAction_drawVehicleBlinker(), GUIVehicle::Colorer::getColorValue(), saveState(), and writeXMLRoute().
00550 { 00551 return myIntCORNMap.find(f)->second; 00552 }
| void * MSVehicle::getCORNPointerValue | ( | MSCORN::Pointer | p | ) | const throw () |
Returns the named CORN pointer value.
The behaviour is undefined for not stored values.
Definition at line 556 of file MSVehicle.cpp.
References myPointerCORNMap.
Referenced by writeXMLRoute().
00556 { 00557 return myPointerCORNMap.find(p)->second; 00558 }
| const MSEdge& MSVehicle::getDepartEdge | ( | ) | const [inline] |
Returns the edge the vehicle starts from.
Definition at line 151 of file MSVehicle.h.
References myCurrEdge.
00151 { 00152 return **myCurrEdge; 00153 }
| SUMOTime MSVehicle::getDesiredDepart | ( | ) | const throw () [inline] |
Returns the desired departure time.
Definition at line 157 of file MSVehicle.h.
References SUMOVehicleParameter::depart, and myParameter.
Referenced by MSVehicleContainer::add(), MSEmitter::childCheckEmit(), GUIVehicle::getParameterWindow(), and MSPerson::MSPersonStage_Driving::proceed().
00157 { 00158 return myParameter->depart; 00159 }
| const std::vector<MSDevice*>& MSVehicle::getDevices | ( | ) | const [inline] |
Returns this vehicle's devices.
Definition at line 745 of file MSVehicle.h.
References myDevices.
00745 { 00746 return myDevices; 00747 }
| SUMOReal MSVehicle::getDistanceToPosition | ( | SUMOReal | destPos, | |
| const MSEdge * | destEdge | |||
| ) |
Compute distance that will be covered, if the vehicle moves to a given position on its route, starting at its current position.
| destPos,: | position on the destination edge that shall be reached | |
| destEdge,: | destination edge that shall be reached |
Definition at line 1851 of file MSVehicle.cpp.
References MSRoute::getDistanceBetween(), MSLane::getEdge(), MSLane::getLength(), getPositionOnLane(), isOnRoad(), max, myCurrEdge, myLane, myRoute, and SUMOReal.
Referenced by traci::TraCIServer::handleVehicleDomain().
01851 { 01852 #ifdef DEBUG_VEHICLE_GUI_SELECTION 01853 SUMOReal distance = 1000000.; 01854 #else 01855 SUMOReal distance = std::numeric_limits<SUMOReal>::max(); 01856 #endif 01857 if (isOnRoad() && destEdge != NULL) { 01858 if (&myLane->getEdge() == *myCurrEdge) { 01859 // vehicle is on a normal edge 01860 distance = myRoute->getDistanceBetween(getPositionOnLane(), destPos, *myCurrEdge, destEdge); 01861 } else { 01862 // vehicle is on inner junction edge 01863 distance = myLane->getLength() - getPositionOnLane(); 01864 distance += myRoute->getDistanceBetween(0, destPos, *(myCurrEdge+1), destEdge); 01865 } 01866 } 01867 return distance; 01868 }
| const MSEdge *const MSVehicle::getEdge | ( | ) | const |
Definition at line 1466 of file MSVehicle.cpp.
References myCurrEdge.
Referenced by MSVehicleTransfer::checkEmissions(), traci::TraCIServer::commandChangeLane(), traci::TraCIServer::commandChangeTarget(), traci::TraCIServer::handleVehicleDomain(), traci::TraCIServer::postProcessSimulationStep(), and TraCIServerAPI_Vehicle::processSet().
01466 { 01467 return *myCurrEdge; 01468 }
| SUMOReal MSVehicle::getHarmonoise_NoiseEmissions | ( | ) | const throw () |
Returns noise emissions of the current state.
Definition at line 1915 of file MSVehicle.cpp.
References HelpersHarmonoise::computeNoise(), MSVehicleType::getEmissionClass(), myPreDawdleAcceleration, myState, myType, and MSVehicle::State::speed().
Referenced by GUIVehicle::Colorer::getColorValue(), and GUIVehicle::getParameterWindow().
01915 { 01916 return HelpersHarmonoise::computeNoise(myType->getEmissionClass(), myState.speed(), myPreDawdleAcceleration); 01917 }
| SUMOReal MSVehicle::getHBEFA_CO2Emissions | ( | ) | const throw () |
Returns CO2 emission of the current state.
Definition at line 1879 of file MSVehicle.cpp.
References HelpersHBEFA::computeCO2(), MSVehicleType::getEmissionClass(), myPreDawdleAcceleration, myState, myType, and MSVehicle::State::speed().
Referenced by GUIVehicle::Colorer::getColorValue(), and GUIVehicle::getParameterWindow().
01879 { 01880 return HelpersHBEFA::computeCO2(myType->getEmissionClass(), myState.speed(), myPreDawdleAcceleration); 01881 }
| SUMOReal MSVehicle::getHBEFA_COEmissions | ( | ) | const throw () |
Returns CO emission of the current state.
Definition at line 1885 of file MSVehicle.cpp.
References HelpersHBEFA::computeCO(), MSVehicleType::getEmissionClass(), myPreDawdleAcceleration, myState, myType, and MSVehicle::State::speed().
Referenced by GUIVehicle::Colorer::getColorValue(), and GUIVehicle::getParameterWindow().
01885 { 01886 return HelpersHBEFA::computeCO(myType->getEmissionClass(), myState.speed(), myPreDawdleAcceleration); 01887 }
| SUMOReal MSVehicle::getHBEFA_FuelConsumption | ( | ) | const throw () |
Returns fuel consumption of the current state.
Definition at line 1909 of file MSVehicle.cpp.
References HelpersHBEFA::computeFuel(), MSVehicleType::getEmissionClass(), myPreDawdleAcceleration, myState, myType, and MSVehicle::State::speed().
Referenced by GUIVehicle::Colorer::getColorValue(), and GUIVehicle::getParameterWindow().
01909 { 01910 return HelpersHBEFA::computeFuel(myType->getEmissionClass(), myState.speed(), myPreDawdleAcceleration); 01911 }
| SUMOReal MSVehicle::getHBEFA_HCEmissions | ( | ) | const throw () |
Returns HC emission of the current state.
Definition at line 1891 of file MSVehicle.cpp.
References HelpersHBEFA::computeHC(), MSVehicleType::getEmissionClass(), myPreDawdleAcceleration, myState, myType, and MSVehicle::State::speed().
Referenced by GUIVehicle::Colorer::getColorValue(), and GUIVehicle::getParameterWindow().
01891 { 01892 return HelpersHBEFA::computeHC(myType->getEmissionClass(), myState.speed(), myPreDawdleAcceleration); 01893 }
| SUMOReal MSVehicle::getHBEFA_NOxEmissions | ( | ) | const throw () |
Returns NOx emission of the current state.
Definition at line 1897 of file MSVehicle.cpp.
References HelpersHBEFA::computeNOx(), MSVehicleType::getEmissionClass(), myPreDawdleAcceleration, myState, myType, and MSVehicle::State::speed().
Referenced by GUIVehicle::Colorer::getColorValue(), and GUIVehicle::getParameterWindow().
01897 { 01898 return HelpersHBEFA::computeNOx(myType->getEmissionClass(), myState.speed(), myPreDawdleAcceleration); 01899 }
| SUMOReal MSVehicle::getHBEFA_PMxEmissions | ( | ) | const throw () |
Returns PMx emission of the current state.
Definition at line 1903 of file MSVehicle.cpp.
References HelpersHBEFA::computePMx(), MSVehicleType::getEmissionClass(), myPreDawdleAcceleration, myState, myType, and MSVehicle::State::speed().
Referenced by GUIVehicle::Colorer::getColorValue(), and GUIVehicle::getParameterWindow().
01903 { 01904 return HelpersHBEFA::computePMx(myType->getEmissionClass(), myState.speed(), myPreDawdleAcceleration); 01905 }
| const std::string & MSVehicle::getID | ( | ) | const throw () [virtual] |
Returns the name of the vehicle.
Implements SUMOVehicle.
Definition at line 1302 of file MSVehicle.cpp.
References SUMOVehicleParameter::id, and myParameter.
Referenced by MSVehicleTransfer::checkEmissions(), MSEmitter::childCheckEmit(), MSCalibrator::childCheckEmit(), MSInductLoop::collectVehiclesOnDet(), traci::TraCIServer::commandAddVehicle(), traci::TraCIServer::commandChangeTarget(), MSLane::detectCollisions(), MSInductLoop::enterDetectorByMove(), enterLaneAtEmit(), MSVTypeProbe::execute(), GUIVehicle::getMicrosimID(), traci::TraCIServer::handleVehicleDomain(), TraCIServerAPI_Vehicle::processSet(), MSLane::removeVehicle(), replaceRoute(), reroute(), and MSLane::setCritical().
01302 { 01303 return myParameter->id; 01304 }
| const MSLane & MSVehicle::getLane | ( | ) | const |
Returns the lane the vehicle is on.
Definition at line 1478 of file MSVehicle.cpp.
References myLane.
Referenced by MSAbstractLaneChangeModel::congested(), MSCFModel_IDM::desiredSpeed(), MSVTypeProbe::execute(), MSLane::getFollowerOnConsecutive(), traci::TraCIServer::handleVehicleDomain(), MSLCM_DK2004::informBlocker(), MSLCM_DK2004::patchSpeed(), traci::TraCIServer::postProcessSimulationStep(), TraCIServerAPI_Vehicle::processGet(), GUIVehicle::setBlinkerInformation(), MSE2Collector::update(), MSLCM_DK2004::wantsChangeToLeft(), and MSLCM_DK2004::wantsChangeToRight().
01478 { 01479 return *myLane; 01480 }
| const MSAbstractLaneChangeModel & MSVehicle::getLaneChangeModel | ( | ) | const |
Definition at line 1490 of file MSVehicle.cpp.
References myLaneChangeModel.
01490 { 01491 return *myLaneChangeModel; 01492 }
| MSAbstractLaneChangeModel & MSVehicle::getLaneChangeModel | ( | ) |
Definition at line 1484 of file MSVehicle.cpp.
References myLaneChangeModel.
Referenced by MSLaneChanger::advan2left(), MSLaneChanger::advan2right(), MSLaneChanger::change(), MSAbstractLaneChangeModel::MSLCMessager::informLeader(), MSAbstractLaneChangeModel::MSLCMessager::informNeighFollower(), MSAbstractLaneChangeModel::MSLCMessager::informNeighLeader(), and GUIVehicle::setBlinkerInformation().
01484 { 01485 return *myLaneChangeModel; 01486 }
| SUMOReal MSVehicle::getMaxSpeed | ( | ) | const [inline, virtual] |
Returns the vehicle's maximum speed.
Implements SUMOVehicle.
Definition at line 468 of file MSVehicle.h.
References MSVehicleType::getMaxSpeed(), myHasIndividualMaxSpeed, myIndividualMaxSpeed, and myType.
Referenced by MSVehicleTransfer::checkEmissions(), MSEmitter::childCheckEmit(), MSCalibrator::childCheckEmit(), traci::TraCIServer::commandAddVehicle(), GUIVehicle::Colorer::getColorValue(), and moveFirstChecked().
00468 { 00469 if (myHasIndividualMaxSpeed) 00470 return myIndividualMaxSpeed; 00471 return myType->getMaxSpeed(); 00472 }
| const SUMOVehicleParameter& MSVehicle::getParameter | ( | ) | const throw () [inline] |
Returns the vehicle's parameter (including departure definition).
Definition at line 143 of file MSVehicle.h.
References myParameter.
Referenced by MSRouteHandler::closeVehicle(), GUIVehicle::getParameterWindow(), MSVehicleControl::getWaitingVehicle(), TraCIServerAPI_Vehicle::processGet(), and MSRouteHandler::retrieveLastReadVehicle().
00143 { 00144 return *myParameter; 00145 }
| Position2D MSVehicle::getPosition | ( | ) | const |
Return current Position.
Definition at line 1293 of file MSVehicle.cpp.
References MSLane::getShape(), myLane, myState, MSVehicle::State::pos(), and Position2DVector::positionAtLengthPosition().
Referenced by traci::TraCIServer::commandSimulationParameter(), enterLaneAtLaneChange(), MSVTypeProbe::execute(), GUIVehicle::getCenteringBoundary(), traci::TraCIServer::handleVehicleDomain(), moveFirstChecked(), moveRegardingCritical(), traci::TraCIServer::postProcessSimulationStep(), and TraCIServerAPI_Vehicle::processGet().
01293 { 01294 if (myLane==0) { 01295 return Position2D(-1000, -1000); 01296 } 01297 return myLane->getShape().positionAtLengthPosition(myState.pos()); 01298 }
| SUMOReal MSVehicle::getPositionOnActiveMoveReminderLane | ( | const MSLane *const | searchedLane | ) | const throw () |
Returns the vehicle's position in relation to a passed move reminder lane.
| [in] | searchedLane | The lane to search for within move reminder |
Definition at line 577 of file MSVehicle.cpp.
References myLane, myOldLaneMoveReminderOffsets, myOldLaneMoveReminders, MSVehicle::State::myPos, and myState.
Referenced by MSE2Collector::update().
00577 { 00578 if (searchedLane==myLane) { 00579 return myState.myPos; 00580 } 00581 std::vector< MSMoveReminder* >::const_iterator rem = myOldLaneMoveReminders.begin(); 00582 std::vector<SUMOReal>::const_iterator off = myOldLaneMoveReminderOffsets.begin(); 00583 for (; rem!=myOldLaneMoveReminders.end()&&off!=myOldLaneMoveReminderOffsets.end(); ++rem, ++off) { 00584 if ((*rem)->getLane()==searchedLane) { 00585 return (*off) + myState.myPos; 00586 } 00587 } 00588 return -1; 00589 }
| SUMOReal MSVehicle::getPositionOnLane | ( | ) | const throw () [inline, virtual] |
Get the vehicle's position along the lane.
Implements SUMOVehicle.
Definition at line 436 of file MSVehicle.h.
References MSVehicle::State::myPos, and myState.
Referenced by MSLaneChanger::change(), MSLaneChanger::change2left(), MSLaneChanger::change2right(), checkRewindLinkLanes(), MSVTypeProbe::execute(), MSLane::freeEmit(), gap2pred(), getDistanceToPosition(), MSLane::getFollowerOnConsecutive(), MSLane::getLastVehicleInformation(), MSLane::getLeaderOnConsecutive(), GUIVehicle::getParameterWindow(), MSLaneChanger::getRealFollower(), MSLaneChanger::getRealLeader(), MSLaneChanger::getRealThisLeader(), traci::TraCIServer::handleVehicleDomain(), MSLane::isEmissionSuccess(), moveRoutePointer(), MSInductLoop::notifyEnter(), MSE3Collector::MSE3LeaveReminder::notifyEnter(), MSE3Collector::MSE3EntryReminder::notifyEnter(), MSE2Collector::notifyEnter(), MSLane::vehicle_position_sorter::operator()(), MSLane::VehPosition::operator()(), traci::TraCIServer::postProcessSimulationStep(), MSAbstractLaneChangeModel::predInteraction(), TraCIServerAPI_Vehicle::processGet(), MSLane::push(), GUIVehicle::setBlinkerInformation(), MSLane::setCritical(), MSE2Collector::update(), MSLCM_DK2004::wantsChangeToLeft(), and MSLCM_DK2004::wantsChangeToRight().
00436 { 00437 #ifdef HAVE_MESOSIM 00438 if (MSGlobals::gUseMesoSim) { 00439 return MEVehicle::getPositionOnLane(); 00440 } 00441 #endif 00442 return myState.myPos; 00443 }
| SUMOReal MSVehicle::getPreDawdleAcceleration | ( | ) | const throw () [inline] |
Returns the vehicle's acceleration before dawdling.
Definition at line 461 of file MSVehicle.h.
References myPreDawdleAcceleration.
Referenced by traci::TraCIServer::handleVehicleDomain(), TraCIServerAPI_Vehicle::processGet(), and MSDevice_HBEFA::wrappedComputeCommandExecute().
00461 { 00462 return myPreDawdleAcceleration; 00463 }
| const MSRoute & MSVehicle::getRoute | ( | int | index | ) | const throw () |
Returns the current or a previously used route.
| [in] | index | The route to return (0 is the current route; other have an index>0) |
Definition at line 388 of file MSVehicle.cpp.
References MSCORN::CORN_P_VEH_OLDROUTE, myPointerCORNMap, and myRoute.
00388 { 00389 if (index==0) { 00390 return *myRoute; 00391 } 00392 --index; // only prior routes are stored 00393 std::map<MSCORN::Pointer, void*>::const_iterator i = myPointerCORNMap.find(MSCORN::CORN_P_VEH_OLDROUTE); 00394 assert(i!=myPointerCORNMap.end()); 00395 const ReplacedRoutesVector * const v = (const ReplacedRoutesVector * const)(*i).second; 00396 assert((int) v->size()>index); 00397 return *((*v)[index].route); 00398 }
| const MSRoute& MSVehicle::getRoute | ( | ) | const throw () [inline, virtual] |
Returns the current route.
Implements SUMOVehicle.
Definition at line 242 of file MSVehicle.h.
References myRoute.
Referenced by GUIViewTraffic::drawRoute(), enterLaneAtLaneChange(), getMaxSpeedRegardingNextLanes(), traci::TraCIServer::handleVehicleDomain(), TraCIServerAPI_Vehicle::processGet(), and GUIVehicle::Colorer::setFunctionalColor().
00242 { 00243 return *myRoute; 00244 }
| SUMOReal MSVehicle::getSpeed | ( | ) | const throw () [inline, virtual] |
Returns the vehicle's current speed.
Implements SUMOVehicle.
Definition at line 449 of file MSVehicle.h.
References MSVehicle::State::mySpeed, and myState.
Referenced by MSLaneChanger::change(), checkRewindLinkLanes(), MSInductLoop::collectVehiclesOnDet(), MSVTypeProbe::execute(), MSLane::freeEmit(), GUIVehicle::Colorer::getColorValue(), MSLane::getFollowerOnConsecutive(), GUIVehicle::getParameterWindow(), MSLaneChanger::getRealFollower(), MSLaneChanger::getRealLeader(), traci::TraCIServer::handleVehicleDomain(), MSLCM_DK2004::informBlocker(), MSLane::isEmissionSuccess(), moveRegardingCritical(), MSLCM_DK2004::patchSpeed(), MSAbstractLaneChangeModel::predInteraction(), TraCIServerAPI_Vehicle::processGet(), MSLane::push(), MSLaneChanger::setIsSafeChange(), startSpeedAdaption(), MSE3Collector::update(), MSE2Collector::update(), MSLCM_DK2004::wantsChangeToLeft(), MSLCM_DK2004::wantsChangeToRight(), and MSDevice_HBEFA::wrappedComputeCommandExecute().
00449 { 00450 #ifdef HAVE_MESOSIM 00451 if (MSGlobals::gUseMesoSim) { 00452 return MEVehicle::getSpeed(); 00453 } 00454 #endif 00455 return myState.mySpeed; 00456 }
| SUMOReal MSVehicle::getSpeedWithoutTraciInfluence | ( | ) | const throw () [inline] |
Get speed before influence of TraCI settings takes place.
Definition at line 823 of file MSVehicle.h.
References speedWithoutTraciInfluence.
Referenced by TraCIServerAPI_Vehicle::processGet().
00823 { 00824 return speedWithoutTraciInfluence; 00825 }
| const State& MSVehicle::getState | ( | ) | const throw () [inline] |
Returns the vehicle state.
Definition at line 429 of file MSVehicle.h.
References myState.
00429 { 00430 return myState; 00431 }
| MSLane * MSVehicle::getTargetLane | ( | ) | const |
Definition at line 1472 of file MSVehicle.cpp.
References myTarget.
Referenced by MSLane::setCritical().
01472 { 01473 return myTarget; 01474 }
| const MSVehicleType& MSVehicle::getVehicleType | ( | ) | const throw () [inline, virtual] |
Returns the vehicle's type definition.
Implements SUMOVehicle.
Definition at line 675 of file MSVehicle.h.
References myType.
Referenced by MSLaneChanger::change(), MSVehicleTransfer::checkEmissions(), checkRewindLinkLanes(), MSInductLoop::collectVehiclesOnDet(), drawAction_drawVehicleAsBoxPlus(), drawAction_drawVehicleAsPoly(), drawAction_drawVehicleAsTrianglePlus(), drawAction_drawVehicleBlinker(), drawAction_drawVehicleName(), MSLane::enteredByLaneChange(), enterLaneAtLaneChange(), MSVTypeProbe::execute(), MSCalibrator::execute(), MSLane::freeEmit(), MSLane::getLastVehicleInformation(), MSLaneChanger::getRealFollower(), MSLaneChanger::getRealThisLeader(), traci::TraCIServer::handleVehicleDomain(), MSLane::integrateNewVehicle(), MSLane::isEmissionSuccess(), MSE2Collector::isStillActive(), MSLane::leftByLaneChange(), moveFirstChecked(), MSInductLoop::notifyEnter(), MSE3Collector::MSE3LeaveReminder::notifyEnter(), MSE2Collector::notifyEnter(), MSAbstractLaneChangeModel::predInteraction(), TraCIServerAPI_Vehicle::processGet(), MSLane::removeFirstVehicle(), MSLane::removeVehicle(), MSLane::setCritical(), MSE2Collector::update(), MSLCM_DK2004::wantsChangeToLeft(), MSLCM_DK2004::wantsChangeToRight(), and MSDevice_HBEFA::wrappedComputeCommandExecute().
00675 { 00676 return *myType; 00677 }
| SUMOReal MSVehicle::getWaitingSeconds | ( | ) | const throw () [inline] |
Returns the number of seconds waited (speed was lesser than 0.1m/s).
The value is reset if the vehicle moves faster than 0.1m/s
Definition at line 606 of file MSVehicle.h.
References myWaitingTime, and STEPS2TIME.
Referenced by GUIVehicle::Colorer::getColorValue(), and GUIVehicle::getParameterWindow().
00606 { 00607 return STEPS2TIME(myWaitingTime); 00608 }
| SUMOTime MSVehicle::getWaitingTime | ( | ) | const throw () [inline] |
Returns the SUMOTime waited (speed was lesser than 0.1m/s).
The value is reset if the vehicle moves faster than 0.1m/s
Definition at line 596 of file MSVehicle.h.
References myWaitingTime.
00596 { 00597 return myWaitingTime; 00598 }
| MSEdgeWeightsStorage & MSVehicle::getWeightsStorage | ( | ) | throw () |
Returns the vehicle's internal edge travel times/efforts container.
If the vehicle does not have such a container, it is built.
Definition at line 518 of file MSVehicle.cpp.
References myEdgeWeights.
Referenced by traci::TraCIServer::commandChangeRoute(), traci::TraCIServer::commandChangeTarget(), traci::TraCIServer::postProcessSimulationStep(), TraCIServerAPI_Vehicle::processGet(), and TraCIServerAPI_Vehicle::processSet().
00518 { 00519 if (myEdgeWeights==0) { 00520 myEdgeWeights = new MSEdgeWeightsStorage(); 00521 } 00522 return *myEdgeWeights; 00523 }
| bool MSVehicle::hasCORNIntValue | ( | MSCORN::Function | f | ) | const throw () |
Returns whether this vehicle has the named integer value stored
Definition at line 562 of file MSVehicle.cpp.
References myIntCORNMap.
Referenced by GUIViewTraffic::doPaintGL(), GUIVehicle::Colorer::getColorValue(), moveRegardingCritical(), saveState(), GUIVehicle::setBlinkerInformation(), and writeXMLRoute().
00562 { 00563 return myIntCORNMap.find(f)!=myIntCORNMap.end(); 00564 }
| bool MSVehicle::hasCORNPointerValue | ( | MSCORN::Pointer | p | ) | const throw () |
Returns whether this vehicle has the named pointer value stored
Definition at line 568 of file MSVehicle.cpp.
References myPointerCORNMap.
Referenced by addPerson(), onDepart(), processNextStop(), writeXMLRoute(), and ~MSVehicle().
00568 { 00569 return myPointerCORNMap.find(p)!=myPointerCORNMap.end(); 00570 }
| bool MSVehicle::hasStops | ( | ) | [inline] |
Returns whether the vehicle has to stop somewhere.
Definition at line 729 of file MSVehicle.h.
References myStops.
Referenced by traci::TraCIServer::postProcessSimulationStep().
00729 { 00730 return !myStops.empty(); 00731 }
| bool MSVehicle::hasSuccEdge | ( | unsigned int | nSuccs | ) | const throw () [inline] |
Returns whether the vehicle has still to pass nSuccs edges.
| [in] | nSuccs | The number of edge to look forward |
Definition at line 209 of file MSVehicle.h.
References MSRoute::end(), myCurrEdge, and myRoute.
Referenced by succEdge().
00209 { 00210 return myCurrEdge + nSuccs < myRoute->end(); 00211 }
| bool MSVehicle::hasValidRoute | ( | std::string & | msg | ) | const throw () |
Validates the current route.
| [out] | msg | Description why the route is not valid (if it is the case) |
Definition at line 527 of file MSVehicle.cpp.
References MSRoute::end(), MSVehicleType::getVehicleClass(), myCurrEdge, myRoute, and myType.
Referenced by enterLaneAtEmit(), and TraCIServerAPI_Vehicle::processGet().
00527 { 00528 MSRouteIterator last = myRoute->end() - 1; 00529 // check connectivity, first 00530 for (MSRouteIterator e=myCurrEdge; e!=last; ++e) { 00531 if ((*e)->allowedLanes(**(e+1), myType->getVehicleClass())==0) { 00532 msg = "No connection between '" + (*e)->getID() + "' and '" + (*(e+1))->getID() + "'."; 00533 return false; 00534 } 00535 } 00536 last = myRoute->end(); 00537 // check usable lanes, then 00538 for (MSRouteIterator e=myCurrEdge; e!=last; ++e) { 00539 if ((*e)->prohibits(this)) { 00540 msg = "Edge '" + (*e)->getID() + "' prohibits."; 00541 return false; 00542 } 00543 } 00544 return true; 00545 }
| bool MSVehicle::isOnRoad | ( | ) | const throw () [inline] |
Returns the information whether the vehicle is on a road (is simulated).
Definition at line 580 of file MSVehicle.h.
References myLane.
Referenced by GUIVehicle::active(), MSVTypeProbe::execute(), getDistanceToPosition(), traci::TraCIServer::handleVehicleDomain(), GUIVehicleControl::insertVehicleIDs(), moveFirstChecked(), moveRegardingCritical(), traci::TraCIServer::postProcessSimulationStep(), and MSLane::setCritical().
00580 { 00581 #ifdef HAVE_MESOSIM 00582 if (MSGlobals::gUseMesoSim) { 00583 return MEVehicle::getSegment() != 0; 00584 } 00585 #endif 00586 return myLane!=0; 00587 }
| bool MSVehicle::isStopped | ( | ) |
| void MSVehicle::leaveLane | ( | bool | isArrival | ) |
Update of members if vehicle leaves a new lane in the lane change step or at arrival.
Definition at line 1438 of file MSVehicle.cpp.
References myDevices, myFurtherLanes, myMoveReminders, myOldLaneMoveReminderOffsets, myOldLaneMoveReminders, MSVehicle::State::myPos, myState, and SUMOReal.
Referenced by MSLaneChanger::change(), onRemovalFromNet(), and MSLane::removeVehicle().
01438 { 01439 for (std::vector< MSDevice* >::iterator dev=myDevices.begin(); dev != myDevices.end(); ++dev) { 01440 (*dev)->leaveLane(); 01441 } 01442 // dismiss the old lane's reminders 01443 SUMOReal savePos = myState.myPos; // have to do this due to SUMOReal-precision errors 01444 std::vector< MSMoveReminder* >::iterator rem; 01445 for (rem=myMoveReminders.begin(); rem != myMoveReminders.end(); ++rem) { 01446 (*rem)->notifyLeave(*this, isArrival, !isArrival); 01447 } 01448 std::vector<SUMOReal>::iterator off = myOldLaneMoveReminderOffsets.begin(); 01449 for (rem=myOldLaneMoveReminders.begin(); rem!=myOldLaneMoveReminders.end(); ++rem, ++off) { 01450 myState.myPos += (*off); 01451 (*rem)->notifyLeave(*this, isArrival, !isArrival); 01452 myState.myPos -= (*off); 01453 } 01454 myState.myPos = savePos; // have to do this due to SUMOReal-precision errors 01455 myMoveReminders.clear(); 01456 myOldLaneMoveReminders.clear(); 01457 myOldLaneMoveReminderOffsets.clear(); 01458 for (std::vector<MSLane*>::iterator i=myFurtherLanes.begin(); i!=myFurtherLanes.end(); ++i) { 01459 (*i)->resetPartialOccupation(this); 01460 } 01461 myFurtherLanes.clear(); 01462 }
| void MSVehicle::leaveLaneAtMove | ( | SUMOReal | driven | ) |
Update when the vehicle leaves a new lane in the move step.
| [in] | driven | The distance driven by the vehicle within this time step |
Definition at line 1426 of file MSVehicle.cpp.
References myDevices, and myMoveReminders.
Referenced by moveFirstChecked(), and MSLane::removeFirstVehicle().
01426 { 01427 std::vector< MSMoveReminder* >::iterator rem; 01428 for (rem=myMoveReminders.begin(); rem != myMoveReminders.end(); ++rem) { 01429 (*rem)->notifyLeave(*this, false, false); 01430 } 01431 for (std::vector< MSDevice* >::iterator dev=myDevices.begin(); dev != myDevices.end(); ++dev) { 01432 (*dev)->leaveLaneAtMove(driven); 01433 } 01434 }
| void MSVehicle::moveFirstChecked | ( | ) |
moves the vehicles after their responds (right-of-way rules) are known
Definition at line 885 of file MSVehicle.cpp.
References bla, MSCORN::CORN_VEH_WAITINGTIME, DELTA_T, enterLaneAtMove(), getCarFollowModel(), MSNet::getCurrentTimeStep(), MSNet::getInstance(), MSLink::getLane(), MSVehicleType::getLength(), MSLane::getLength(), getMaxSpeed(), MSVehicleType::getMaxSpeed(), getPosition(), MSLink::getState(), getVehicleType(), GLO_VEHICLE, gSelected, SUMOVehicleParameter::id, isOnRoad(), GUISelectedStorage::isSelected(), leaveLaneAtMove(), MSLink::LINKSTATE_TL_YELLOW_MAJOR, MSLink::LINKSTATE_TL_YELLOW_MINOR, MAX2(), MIN2(), MSCFModel::moveHelper(), myFurtherLanes, myIntCORNMap, myLane, myLFLinkLanes, myParameter, MSVehicle::State::myPos, MSVehicle::State::mySpeed, myState, myTarget, myType, myWaitingTime, MSLink::opened(), MSVehicle::State::pos(), MSLane::resetPartialOccupation(), setBlinkerInformation(), MSVehicle::State::speed(), SPEED2DIST, speedWithoutTraciInfluence, SUMOReal, MSCORN::wished(), workOnMoveReminders(), Position2D::x(), and Position2D::y().
00885 { 00886 #ifdef DEBUG_VEHICLE_GUI_SELECTION 00887 if (gSelected.isSelected(GLO_VEHICLE, static_cast<const GUIVehicle*>(this)->getGlID())) { 00888 int bla = 0; 00889 } 00890 #endif 00891 myTarget = 0; 00892 // save old v for optional acceleration computation 00893 SUMOReal oldV = myState.mySpeed; 00894 // get vsafe 00895 SUMOReal vSafe = 0; 00896 00897 assert(myLFLinkLanes.size()!=0); 00898 DriveItemVector::iterator i; 00899 bool cont = true; 00900 SUMOTime t = MSNet::getInstance()->getCurrentTimeStep(); 00901 for (i=myLFLinkLanes.begin(); i!=myLFLinkLanes.end()&&cont; ++i) { 00902 MSLink *link = (*i).myLink; 00903 bool onLinkEnd = link==0; 00904 // the vehicle must change the lane on one of the next lanes 00905 if (!onLinkEnd) { 00906 if (link->opened((*i).myArrivalTime, (*i).myArrivalSpeed)) { 00907 vSafe = (*i).myVLinkPass; 00908 } else { 00909 bool yellow = link->getState()==MSLink::LINKSTATE_TL_YELLOW_MAJOR||link->getState()==MSLink::LINKSTATE_TL_YELLOW_MINOR; 00910 if (vSafe<getCarFollowModel().getSpeedAfterMaxDecel(myState.mySpeed)&&yellow) { 00911 vSafe = (*i).myVLinkPass; 00912 } else { 00913 vSafe = (*i).myVLinkWait; 00914 cont = false; 00915 } 00916 } 00917 } else { 00918 vSafe = (*i).myVLinkWait; 00919 cont = false; 00920 break; 00921 } 00922 } 00923 00924 SUMOReal vNext = getCarFollowModel().moveHelper(this, myLane, vSafe); 00925 vNext = MAX2(vNext, (SUMOReal) 0.); 00926 // visit waiting time 00927 if (vNext<=0.1) { 00928 myWaitingTime += DELTA_T; 00929 if (MSCORN::wished(MSCORN::CORN_VEH_WAITINGTIME)) { 00930 myIntCORNMap[MSCORN::CORN_VEH_WAITINGTIME]++; 00931 } 00932 } else { 00933 myWaitingTime = 0; 00934 } 00935 // call reminders after vNext is set 00936 SUMOReal pos = myState.myPos; 00937 #ifndef NO_TRACI 00938 speedWithoutTraciInfluence = MIN2(vNext, myType->getMaxSpeed()); 00939 #endif 00940 vNext = MIN2(vNext, getMaxSpeed()); 00941 00942 #ifdef _MESSAGES 00943 if (myHBMsgEmitter != 0) { 00944 if (isOnRoad()) { 00945 SUMOReal timeStep = MSNet::getInstance()->getCurrentTimeStep(); 00946 myHBMsgEmitter->writeHeartBeatEvent(myParameter->id, timeStep, myLane, myState.pos(), myState.speed(), getPosition().x(), getPosition().y()); 00947 } 00948 } 00949 if (myBMsgEmitter!=0) { 00950 if (vNext < oldV) { 00951 SUMOReal timeStep = MSNet::getInstance()->getCurrentTimeStep(); 00952 myBMsgEmitter->writeBreakEvent(myParameter->id, timeStep, myLane, myState.pos(), myState.speed(), getPosition().x(), getPosition().y()); 00953 } 00954 } 00955 #endif 00956 // update position and speed 00957 myState.myPos += SPEED2DIST(vNext); 00958 myState.mySpeed = vNext; 00959 myTarget = 0; 00960 std::vector<MSLane*> passedLanes; 00961 for (std::vector<MSLane*>::reverse_iterator i=myFurtherLanes.rbegin(); i!=myFurtherLanes.rend(); ++i) { 00962 passedLanes.push_back(*i); 00963 } 00964 if (passedLanes.size()==0||passedLanes.back()!=myLane) { 00965 passedLanes.push_back(myLane); 00966 } 00967 // move on lane(s) 00968 if (myState.myPos<=myLane->getLength()) { 00969 // we are staying at our lane 00970 // there is no need to go over succeeding lanes 00971 workOnMoveReminders(pos, pos + SPEED2DIST(vNext), vNext); 00972 } else { 00973 // we are moving at least to the next lane (maybe pass even more than one) 00974 MSLane *approachedLane = myLane; 00975 // move the vehicle forward 00976 SUMOReal driven = myState.myPos>approachedLane->getLength() 00977 ? approachedLane->getLength() - pos 00978 : myState.myPos - pos; 00979 for (i=myLFLinkLanes.begin(); i!=myLFLinkLanes.end() && myState.myPos>approachedLane->getLength(); ++i) { 00980 if (approachedLane!=myLane) { 00981 leaveLaneAtMove(driven); 00982 } 00983 MSLink *link = (*i).myLink; 00984 // check whether the vehicle was allowed to enter lane 00985 // otherwise it is decelareted and we do not need to test for it's 00986 // approach on the following lanes when a lane changing is performed 00987 assert(approachedLane!=0); 00988 myState.myPos -= approachedLane->getLength(); 00989 assert(myState.myPos>0); 00990 if (approachedLane!=myLane) { 00991 enterLaneAtMove(approachedLane, driven); 00992 driven += approachedLane->getLength(); 00993 } 00994 // proceed to the next lane 00995 if (link!=0) { 00996 #ifdef HAVE_INTERNAL_LANES 00997 approachedLane = link->getViaLane(); 00998 if (approachedLane==0) { 00999 approachedLane = link->getLane(); 01000 } 01001 #else 01002 approachedLane = link->getLane(); 01003 #endif 01004 } 01005 passedLanes.push_back(approachedLane); 01006 } 01007 myTarget = approachedLane; 01008 } 01009 // clear previously set information 01010 for (std::vector<MSLane*>::iterator i=myFurtherLanes.begin(); i!=myFurtherLanes.end(); ++i) { 01011 (*i)->resetPartialOccupation(this); 01012 } 01013 myFurtherLanes.clear(); 01014 if (myState.myPos-getVehicleType().getLength()<0&&passedLanes.size()>0) { 01015 SUMOReal leftLength = getVehicleType().getLength()-myState.myPos; 01016 std::vector<MSLane*>::reverse_iterator i=passedLanes.rbegin() + 1; 01017 while (leftLength>0&&i!=passedLanes.rend()) { 01018 myFurtherLanes.push_back(*i); 01019 leftLength -= (*i)->setPartialOccupation(this, leftLength); 01020 ++i; 01021 } 01022 } 01023 assert(myTarget==0||myTarget->getLength()>=myState.myPos); 01024 setBlinkerInformation(); 01025 }
| bool MSVehicle::moveRegardingCritical | ( | SUMOTime | t, | |
| const MSLane *const | lane, | |||
| const MSVehicle *const | pred, | |||
| const MSVehicle *const | neigh, | |||
| SUMOReal | lengthsInFront | |||
| ) | throw () |
Moves vehicles which may run out of the lane.
| [in] | lane | The lane the vehicle is on |
| [in] | pred | The leader (may be 0) |
| [in] | neigh | The neighbor vehicle (may be 0) |
| [in] | lengthsInFront | Sum of vehicle lengths in front of the vehicle |
Definition at line 785 of file MSVehicle.cpp.
References MSLane::appropriate(), bla, checkRewindLinkLanes(), MSCORN::CORN_VEH_LASTREROUTEOFFSET, MSCFModel::ffeS(), MSCFModel::ffeV(), gap(), gap2pred(), MSGlobals::gCheck4Accidents, getCarFollowModel(), MSNet::getCurrentTimeStep(), MSNet::getInstance(), MSLane::getLength(), MSLane::getMaxSpeed(), MSLane::getPartialOccupator(), MSLane::getPartialOccupatorEnd(), getPosition(), getSpeed(), GLO_VEHICLE, gSelected, hasCORNIntValue(), SUMOVehicleParameter::id, isOnRoad(), GUISelectedStorage::isSelected(), MSCFModel::leftVehicleVsafe(), MAX2(), MSCFModel::maxNextSpeed(), MIN2(), myIntCORNMap, myLane, myLFLinkLanes, myParameter, MSVehicle::State::myPos, MSVehicle::State::mySpeed, myState, myStops, myTarget, MSVehicle::State::pos(), MSVehicle::State::speed(), SUMOReal, vsafeCriticalCont(), Position2D::x(), and Position2D::y().
00788 { 00789 #ifdef _MESSAGES 00790 if (myHBMsgEmitter != 0) { 00791 if (isOnRoad()) { 00792 SUMOReal timeStep = MSNet::getInstance()->getCurrentTimeStep(); 00793 myHBMsgEmitter->writeHeartBeatEvent(myParameter->id, timeStep, myLane, myState.pos(), myState.speed(), getPosition().x(), getPosition().y()); 00794 } 00795 } 00796 #endif 00797 #ifdef DEBUG_VEHICLE_GUI_SELECTION 00798 if (gSelected.isSelected(GLO_VEHICLE, static_cast<const GUIVehicle*>(this)->getGlID())) { 00799 int bla = 0; 00800 } 00801 #endif 00802 myTarget = 0; 00803 for (DriveItemVector::iterator i=myLFLinkLanes.begin(); i!=myLFLinkLanes.end(); ++i) { 00804 if ((*i).myLink!=0) { 00805 (*i).myLink->removeApproaching(this); 00806 } 00807 } 00808 myLFLinkLanes.clear(); 00809 const MSCFModel &cfModel = getCarFollowModel(); 00810 // check whether the vehicle is not on an appropriate lane 00811 if (!myLane->appropriate(this)) { 00812 // decelerate to lane end when yes 00813 SUMOReal vWish = MIN2(cfModel.ffeS(this, myLane->getLength()-myState.myPos), myLane->getMaxSpeed()); 00814 if (pred!=0) { 00815 // interaction with leader if one exists on same lane 00816 SUMOReal gap = gap2pred(*pred); 00817 if (MSGlobals::gCheck4Accidents && gap<0) { 00818 // collision occured! 00819 return true; 00820 } 00821 vWish = MIN2(vWish, cfModel.ffeV(this, pred)); 00822 } else { 00823 // (potential) interaction with a vehicle extending partially into this lane 00824 MSVehicle *predP = myLane->getPartialOccupator(); 00825 if (predP!=0) { 00826 SUMOReal gap = myLane->getPartialOccupatorEnd() - myState.myPos; 00827 if (MSGlobals::gCheck4Accidents && gap<0) { 00828 // collision occured! 00829 return true; 00830 } 00831 vWish = MIN2(vWish, cfModel.ffeV(this, gap, predP->getSpeed())); 00832 } 00833 } 00834 // interaction with left-lane leader (do not overtake right) 00835 cfModel.leftVehicleVsafe(this, neigh, vWish); 00836 // check whether the vehicle wants to stop somewhere 00837 if (!myStops.empty()&& &myStops.begin()->lane->getEdge()==&lane->getEdge()) { 00838 SUMOReal seen = lane->getLength() - myState.pos(); 00839 SUMOReal vsafeStop = cfModel.ffeS(this, seen-(lane->getLength()-myStops.begin()->pos)); 00840 vWish = MIN2(vWish, vsafeStop); 00841 } 00842 vWish = MAX2((SUMOReal) 0, vWish); 00843 myLFLinkLanes.push_back(DriveProcessItem(0, vWish, vWish, false, 0, 0)); 00844 } else { 00845 // compute other values as in move 00846 SUMOReal vBeg = MIN2(cfModel.maxNextSpeed(myState.mySpeed), lane->getMaxSpeed());//vaccel( myState.mySpeed, lane->maxSpeed() ); 00847 if (pred!=0) { 00848 SUMOReal gap = gap2pred(*pred); 00849 if (MSGlobals::gCheck4Accidents && gap<0) { 00850 // collision occured! 00851 return true; 00852 } 00853 SUMOReal vSafe = cfModel.ffeV(this, gap, pred->getSpeed()); 00854 // the vehicle is bound by the lane speed and must not drive faster 00855 // than vsafe to the next vehicle 00856 vBeg = MIN2(vBeg, vSafe); 00857 } else { 00858 // (potential) interaction with a vehicle extending partially into this lane 00859 MSVehicle *predP = myLane->getPartialOccupator(); 00860 if (predP!=0) { 00861 SUMOReal gap = myLane->getPartialOccupatorEnd() - myState.myPos; 00862 if (MSGlobals::gCheck4Accidents && gap<0) { 00863 // collision occured! 00864 return true; 00865 } 00866 vBeg = MIN2(vBeg, cfModel.ffeV(this, gap, predP->getSpeed())); 00867 } 00868 } 00869 cfModel.leftVehicleVsafe(this, neigh, vBeg); // from left-lane leader (do not overtake right) 00870 // check whether the driver wants to let someone in 00871 // set next links, computing possible speeds 00872 vsafeCriticalCont(t, vBeg, lengthsInFront); 00873 } 00874 //@ to be optimized (move to somewhere else) 00875 if (hasCORNIntValue(MSCORN::CORN_VEH_LASTREROUTEOFFSET)) { 00876 myIntCORNMap[MSCORN::CORN_VEH_LASTREROUTEOFFSET] = myIntCORNMap[MSCORN::CORN_VEH_LASTREROUTEOFFSET] + 1; 00877 } 00878 //@ to be optimized (move to somewhere else) 00879 checkRewindLinkLanes(lengthsInFront); 00880 return false; 00881 }
Moves the vehicle's route pointer to given edge.
Returns true if vehicle is going to enter it's destination edge, false otherwise. Adjusts in both cases the route iterator and the allowedLanes-container.
| [in] | targetEdge | The edge the vehicle enters |
Definition at line 347 of file MSVehicle.cpp.
References MSCORN::CORN_P_VEH_EXIT_TIMES, MSCORN::CORN_VEH_SAVE_EDGE_EXIT, MSEdge::EDGEFUNCTION_INTERNAL, MSRoute::end(), MSNet::getInstance(), getPositionOnLane(), myArrivalPos, myCurrEdge, myPointerCORNMap, myRoute, POSITION_EPS, setWasVaporized(), and MSCORN::wished().
Referenced by MSLane::push().
00347 { 00348 // vaporizing edge? 00349 if (targetEdge->isVaporizing()) { 00350 // yep, let's do the vaporization... 00351 setWasVaporized(false); 00352 return true; 00353 } 00354 // internal edge? 00355 if (targetEdge->getPurpose()==MSEdge::EDGEFUNCTION_INTERNAL) { 00356 // yep, let's continue driving 00357 return false; 00358 } 00359 if (MSCORN::wished(MSCORN::CORN_VEH_SAVE_EDGE_EXIT)) { 00360 if (myPointerCORNMap.find(MSCORN::CORN_P_VEH_EXIT_TIMES)==myPointerCORNMap.end()) { 00361 myPointerCORNMap[MSCORN::CORN_P_VEH_EXIT_TIMES] = new std::vector<SUMOTime>(); 00362 } 00363 ((std::vector<SUMOTime>*) myPointerCORNMap[MSCORN::CORN_P_VEH_EXIT_TIMES])->push_back(MSNet::getInstance()->getCurrentTimeStep()); 00364 } 00365 // search for the target in the vehicle's route. Usually there is 00366 // only one iteration. Only for very short edges a vehicle can 00367 // "jump" over one ore more edges in one timestep. 00368 MSRouteIterator edgeIt = myCurrEdge; 00369 while (*edgeIt != targetEdge) { 00370 ++edgeIt; 00371 assert(edgeIt != myRoute->end()); 00372 } 00373 myCurrEdge = edgeIt; 00374 // Check if destination-edge is reached. Update allowedLanes makes 00375 // only sense if destination isn't reached. 00376 MSRouteIterator destination = myRoute->end() - 1; 00377 return myCurrEdge == destination && getPositionOnLane() > myArrivalPos - POSITION_EPS; 00378 }
| void MSVehicle::onDepart | ( | ) | throw () |
Called when the vehicle is inserted into the network.
Sets optional information about departure time, informs the vehicle control about a further running vehicle.
Definition at line 277 of file MSVehicle.cpp.
References MSCORN::CORN_P_VEH_DEPART_INFO, MSCORN::CORN_P_VEH_PASSENGER, MSCORN::CORN_VEH_DEPART_INFO, MSCORN::CORN_VEH_DEPART_TIME, MSNet::getCurrentTimeStep(), MSNet::getInstance(), MSNet::getVehicleControl(), hasCORNPointerValue(), MSVehicle::DepartArrivalInformation::lane, myIntCORNMap, myLane, myPointerCORNMap, myState, MSVehicle::State::pos(), MSVehicle::DepartArrivalInformation::pos, MSVehicle::State::speed(), MSVehicle::DepartArrivalInformation::speed, MSVehicle::DepartArrivalInformation::time, MSVehicleControl::vehicleEmitted(), and MSCORN::wished().
Referenced by MSEmitter::childCheckEmit(), MSCalibrator::childCheckEmit(), and traci::TraCIServer::commandAddVehicle().
00277 { 00278 // check whether the vehicle's departure time shall be saved 00279 if (MSCORN::wished(MSCORN::CORN_VEH_DEPART_TIME)) { 00280 myIntCORNMap[MSCORN::CORN_VEH_DEPART_TIME] = (int) MSNet::getInstance()->getCurrentTimeStep(); 00281 } 00282 // check whether the vehicle's verbose departure information shall be saved 00283 if (MSCORN::wished(MSCORN::CORN_VEH_DEPART_INFO)) { 00284 DepartArrivalInformation *i = new DepartArrivalInformation(); 00285 i->time = MSNet::getInstance()->getCurrentTimeStep(); 00286 i->lane = myLane; 00287 i->pos = myState.pos(); 00288 i->speed = myState.speed(); 00289 myPointerCORNMap[MSCORN::CORN_P_VEH_DEPART_INFO] = (void*) i; 00290 } 00291 if (hasCORNPointerValue(MSCORN::CORN_P_VEH_PASSENGER)) { 00292 std::vector<MSPerson*> *persons = (std::vector<MSPerson*>*) myPointerCORNMap[MSCORN::CORN_P_VEH_PASSENGER]; 00293 for (std::vector<MSPerson*>::iterator i=persons->begin(); i!=persons->end(); ++i) { 00294 (*i)->setDeparted(MSNet::getInstance()->getCurrentTimeStep()); 00295 } 00296 } 00297 // inform the vehicle control 00298 MSNet::getInstance()->getVehicleControl().vehicleEmitted(*this); 00299 }
| void MSVehicle::onRemovalFromNet | ( | bool | forTeleporting | ) | throw () |
Called when the vehicle is removed the network.
Sets the optional information about arival if forTeleporting is false (the vehicle has arrived). Moves along work reminders and informs all devices and assigned MSVehicleQuitReminded instances about quitting. Calls "leaveLane" then.
| [in] | forTeleporting | true if the vehicle shall be teleported (otherwise it has reached its destination) |
Definition at line 303 of file MSVehicle.cpp.
References MSCORN::CORN_P_VEH_ARRIVAL_INFO, MSCORN::CORN_VEH_ARRIVAL_INFO, MSNet::getCurrentTimeStep(), MSNet::getInstance(), MSVehicle::DepartArrivalInformation::lane, leaveLane(), myDevices, myLane, myLFLinkLanes, myPointerCORNMap, MSVehicle::State::myPos, myQuitReminded, MSVehicle::State::mySpeed, myState, MSVehicle::State::pos(), MSVehicle::DepartArrivalInformation::pos, MSVehicle::State::speed(), MSVehicle::DepartArrivalInformation::speed, SPEED2DIST, SUMOReal, MSVehicle::DepartArrivalInformation::time, MSCORN::wished(), and workOnMoveReminders().
Referenced by MSCalibrator::execute(), MSLane::push(), and MSLane::setCritical().
00303 { 00304 // check whether the vehicle's verbose arrival information shall be saved 00305 if (!forTeleporting && MSCORN::wished(MSCORN::CORN_VEH_ARRIVAL_INFO)) { 00306 DepartArrivalInformation *i = new DepartArrivalInformation(); 00307 i->time = MSNet::getInstance()->getCurrentTimeStep(); 00308 i->lane = myLane; 00309 i->pos = myState.pos(); 00310 i->speed = myState.speed(); 00311 myPointerCORNMap[MSCORN::CORN_P_VEH_ARRIVAL_INFO] = (void*) i; 00312 } 00313 SUMOReal pspeed = myState.mySpeed; 00314 SUMOReal pos = myState.myPos; 00315 SUMOReal oldPos = pos - SPEED2DIST(pspeed); 00316 // process reminder 00317 workOnMoveReminders(oldPos, pos, pspeed); 00318 // remove from structures to be informed about it 00319 for (QuitRemindedVector::iterator i=myQuitReminded.begin(); i!=myQuitReminded.end(); ++i) { 00320 (*i)->removeOnTripEnd(this); 00321 } 00322 myQuitReminded.clear(); 00323 for (std::vector< MSDevice* >::iterator dev=myDevices.begin(); dev != myDevices.end(); ++dev) { 00324 (*dev)->onRemovalFromNet(); 00325 } 00326 for (DriveItemVector::iterator i=myLFLinkLanes.begin(); i!=myLFLinkLanes.end(); ++i) { 00327 if ((*i).myLink!=0) { 00328 (*i).myLink->removeApproaching(this); 00329 } 00330 } 00331 leaveLane(true); 00332 }
| void MSVehicle::onTryEmit | ( | ) | throw () |
Called when the vehicle tries to get into the network.
Calls the appropriate device function, needed for rerouting.
Definition at line 269 of file MSVehicle.cpp.
References myDevices.
Referenced by MSEmitter::schedule().
00269 { 00270 for (std::vector< MSDevice* >::iterator dev=myDevices.begin(); dev != myDevices.end(); ++dev) { 00271 (*dev)->onTryEmit(); 00272 } 00273 }
Returns true if the two vehicles overlap.
Definition at line 503 of file MSVehicle.h.
Referenced by MSLaneChanger::overlapWithHopped().
00503 { 00504 if (veh1->myState.myPos < veh2->myState.myPos) { 00505 return veh2->myState.myPos - veh2->getVehicleType().getLength() < veh1->myState.myPos; 00506 } 00507 return veh1->myState.myPos - veh1->getVehicleType().getLength() < veh2->myState.myPos; 00508 }
| SUMOReal MSVehicle::processNextStop | ( | SUMOReal | currentVelocity | ) | throw () |
Processes stops, returns the velocity needed to reach the stop.
Definition at line 699 of file MSVehicle.cpp.
References MSVehicleControl::addWaiting(), BUS_STOP_OFFSET, MSVehicle::Stop::busstop, MSPersonControl::checkWaiting(), MSCORN::CORN_P_VEH_PASSENGER, DELTA_T, MSVehicle::Stop::duration, MSBusStop::enter(), MSCFModel::ffeS(), MSBusStop::getBeginLanePosition(), getBestLanes(), getCarFollowModel(), MSNet::getCurrentTimeStep(), MSLane::getEdge(), MSNet::getInstance(), MSBusStop::getLastFreePos(), MSVehicleType::getLength(), MSNet::getPersonControl(), MSNet::getVehicleControl(), hasCORNPointerValue(), MAX2(), myLane, myPointerCORNMap, myState, myStops, myType, MSVehicle::State::pos(), MSVehicle::Stop::pos, MSVehicle::Stop::reached, MSVehicleControl::removeWaiting(), SUMOReal, and MSVehicle::Stop::until.
00699 { 00700 if (myStops.empty()) { 00701 // no stops; pass 00702 return currentVelocity; 00703 } 00704 if (myStops.begin()->reached) { 00705 // ok, we have already reached the next stop 00706 if (myStops.begin()->duration==0) { 00707 // ... and have waited as long as needed 00708 if (myStops.begin()->busstop!=0) { 00709 // inform bus stop about leaving it 00710 myStops.begin()->busstop->leaveFrom(this); 00711 } 00712 // the current stop is no longer valid 00713 MSNet::getInstance()->getVehicleControl().removeWaiting(&myLane->getEdge(), this); 00714 if (hasCORNPointerValue(MSCORN::CORN_P_VEH_PASSENGER)) { 00715 std::vector<MSPerson*> *persons = (std::vector<MSPerson*>*) myPointerCORNMap[MSCORN::CORN_P_VEH_PASSENGER]; 00716 for (std::vector<MSPerson*>::iterator i=persons->begin(); i!=persons->end(); ++i) { 00717 (*i)->setDeparted(MSNet::getInstance()->getCurrentTimeStep()); 00718 } 00719 } 00720 myStops.pop_front(); 00721 // maybe the next stop is on the same edge; let's rebuild best lanes 00722 getBestLanes(true); 00723 // continue as wished... 00724 } else { 00725 // we have to wait some more time 00726 myStops.begin()->duration -= DELTA_T; 00727 return 0; 00728 } 00729 } else { 00730 // is the next stop on the current lane? 00731 if (myStops.begin()->lane==myLane) { 00732 Stop &bstop = *myStops.begin(); 00733 // get the stopping position 00734 SUMOReal endPos = bstop.pos; 00735 // SUMOReal offset = 0.1; 00736 bool busStopsMustHaveSpace = true; 00737 if (bstop.busstop!=0) { 00738 // on bus stops, we have to wait for free place if they are in use... 00739 // offset = BUS_STOP_OFFSET; 00740 endPos = bstop.busstop->getLastFreePos(); 00741 if (endPos-5.<bstop.busstop->getBeginLanePosition()) { // !!! explicite offset 00742 busStopsMustHaveSpace = false; 00743 } 00744 } 00745 // if (myState.pos()>=endPos-offset&&busStopsMustHaveSpace) { 00746 if (myState.pos()>=endPos-BUS_STOP_OFFSET&&busStopsMustHaveSpace) { 00747 // ok, we may stop (have reached the stop) 00748 MSNet::getInstance()->getPersonControl().checkWaiting(&myLane->getEdge(), this); 00749 MSNet::getInstance()->getVehicleControl().addWaiting(&myLane->getEdge(), this); 00750 if (hasCORNPointerValue(MSCORN::CORN_P_VEH_PASSENGER)) { 00751 std::vector<MSPerson*> *persons = (std::vector<MSPerson*>*) myPointerCORNMap[MSCORN::CORN_P_VEH_PASSENGER]; 00752 for (std::vector<MSPerson*>::iterator i=persons->begin(); i!=persons->end();) { 00753 if (&(*i)->getDestination() == &myLane->getEdge()) { 00754 (*i)->proceed(MSNet::getInstance(), MSNet::getInstance()->getCurrentTimeStep()); 00755 i = persons->erase(i); 00756 } else { 00757 ++i; 00758 } 00759 } 00760 } 00761 bstop.reached = true; 00762 // compute stopping time 00763 if (bstop.until>=0) { 00764 if (bstop.duration==-1) { 00765 bstop.duration = bstop.until - MSNet::getInstance()->getCurrentTimeStep(); 00766 } else { 00767 bstop.duration = MAX2(bstop.duration, bstop.until - MSNet::getInstance()->getCurrentTimeStep()); 00768 } 00769 } 00770 if (bstop.busstop!=0) { 00771 // let the bus stop know the vehicle 00772 bstop.busstop->enter(this, myState.pos(), myState.pos()-myType->getLength()); 00773 } 00774 } 00775 // decelerate 00776 // !!! should not v be 0 when we have reached the stop? 00777 return getCarFollowModel().ffeS(this, endPos-myState.pos()); 00778 } 00779 } 00780 return currentVelocity; 00781 }
| void MSVehicle::processTraCICommands | ( | SUMOTime | time | ) |
takes all action necessary during a simulation step to process any active command sent by TraCI
| time | the current simulation time |
Definition at line 2020 of file MSVehicle.cpp.
References adaptSpeed(), and checkLaneChangeConstraint().
Referenced by traci::TraCIServer::postProcessSimulationStep().
02020 { 02021 // check for applied lane changing constraints 02022 checkLaneChangeConstraint(time); 02023 // change speed in case of previous "slowDown" command 02024 adaptSpeed(); 02025 }
| void MSVehicle::quitRemindedEntered | ( | MSVehicleQuitReminded * | r | ) |
Definition at line 1496 of file MSVehicle.cpp.
References myQuitReminded.
Referenced by MSE2Collector::isStillActive(), and MSE2Collector::notifyEnter().
01496 { 01497 myQuitReminded.push_back(r); 01498 }
| void MSVehicle::quitRemindedLeft | ( | MSVehicleQuitReminded * | r | ) |
Definition at line 1502 of file MSVehicle.cpp.
References myQuitReminded.
Referenced by MSE2Collector::isStillActive(), MSInductLoop::leaveDetectorByLaneChange(), MSInductLoop::leaveDetectorByMove(), removeOnTripEnd(), and MSInductLoop::~MSInductLoop().
01502 { 01503 QuitRemindedVector::iterator i = find(myQuitReminded.begin(), myQuitReminded.end(), r); 01504 if (i!=myQuitReminded.end()) { 01505 myQuitReminded.erase(i); 01506 } 01507 }
| void MSVehicle::rebuildContinuationsFor | ( | LaneQ & | q, | |
| MSLane * | l, | |||
| MSRouteIterator | ce, | |||
| int | seen | |||
| ) | const [protected] |
Definition at line 1511 of file MSVehicle.cpp.
References abs, MSVehicle::Stop::busstop, MSRoute::end(), MSLane::getEdge(), MSEdge::getLanes(), MSBusStop::getLastFreePos(), MSLane::getLength(), MSLane::getLinkCont(), MSVehicleType::getVehicleClass(), MSLane::getVehLenSum(), MSVehicle::LaneQ::joined, MSVehicle::LaneQ::length, myRoute, myStops, myType, MSVehicle::LaneQ::occupied, MSVehicle::Stop::pos, and SUMOReal.
Referenced by getBestLanes().
01511 { 01512 // check whether the end of iteration was reached 01513 ++ce; 01514 // we end if one of the following cases is true: 01515 // a) we have examined the next edges for 3000m (foresight distance) 01516 // but only if we have at least examined the next edge 01517 // b) if we have examined 8 edges in front (!!! this may be shorted) 01518 // c) if the route does not continue after the seen edges 01519 if ((seen>4 && oq.length+l->getLength()>3000) || seen>8 || ce==myRoute->end()) { 01520 // ok, we have rebuilt this so far... do not have to go any further 01521 return; 01522 } 01523 // we must go further... 01524 // get the list of allowed lanes 01525 const std::vector<MSLane*> *allowed = 0; 01526 if (ce!=myRoute->end()&&ce+1!=myRoute->end()) { 01527 allowed = (*ce)->allowedLanes(**(ce+1), myType->getVehicleClass()); 01528 } 01529 // determined recursively what the best lane is 01530 // save the best lane for later usage 01531 LaneQ best; 01532 best.length = 0; 01533 const std::vector<MSLane*> &lanes = (*ce)->getLanes(); 01534 const MSLinkCont &lc = l->getLinkCont(); 01535 bool gotOne = false; 01536 // we go through all connections of the lane to examine 01537 for (MSLinkCont::const_iterator k=lc.begin(); k!=lc.end(); ++k) { 01538 // prese values 01539 LaneQ q; 01540 MSLane *qqq = (*k)->getLane(); 01541 if (qqq==0) { 01542 q.occupied = 0; 01543 q.length = 0; 01544 continue; 01545 } 01546 q.occupied = qqq->getVehLenSum(); 01547 q.length = qqq->getLength(); 01548 q.joined.push_back(qqq); 01549 01550 01551 if (!myStops.empty()&& &(myStops.front().lane->getEdge())==&qqq->getEdge()) { 01552 if (myStops.front().lane==qqq) { 01553 gotOne = true; 01554 if (allowed==0||find(allowed->begin(), allowed->end(), (*k)->getLane())!=allowed->end()) { 01555 rebuildContinuationsFor(q, qqq, ce, seen+1); 01556 } 01557 } else { 01558 q.occupied = qqq->getVehLenSum(); 01559 const Stop &s = myStops.front(); 01560 SUMOReal endPos = s.pos; 01561 if (s.busstop!=0) { 01562 // on bus stops, we have to wait for free place if they are in use... 01563 endPos = s.busstop->getLastFreePos(); 01564 } 01565 q.length = endPos; 01566 } 01567 } else { 01568 // check whether the lane is allowed for route continuation (has a link to the next 01569 // edge in route) 01570 if (allowed==0||find(allowed->begin(), allowed->end(), (*k)->getLane())!=allowed->end()) { 01571 // yes -> compute the best lane combination for consecutive lanes 01572 gotOne = true; 01573 rebuildContinuationsFor(q, qqq, ce, seen+1); 01574 } else { 01575 // no -> if the lane belongs to an edge not in our route, 01576 // reset values to zero (otherwise the lane but not its continuations) 01577 // will still be regarded 01578 if (&(*k)->getLane()->getEdge()!=*ce) { 01579 q.occupied = 0; 01580 q.length = 0; 01581 } 01582 } 01583 } 01584 // set best lane information 01585 if (q.length>best.length) { 01586 best = q; 01587 } 01588 } 01589 // check whether we need to change the lane on this edge in any case 01590 if (!gotOne) { 01591 // yes, that's the case - we are on an edge on which we have to change 01592 // the lane no matter which lanes we are using so far. 01593 // we have to tell the vehicle the best lane so far... 01594 // the assumption is that we only have to find the first one 01595 // - because the vehicle has to change lanes, it will do this into 01596 // the proper direction as the lanes moving the the proper edge are 01597 // lying side by side 01598 const std::vector<MSLane*> &lanes = (*ce)->getLanes(); 01599 bool oneFound = false; 01600 int bestPos = 0; 01601 MSLane *next = 0; 01602 // we go over the next edge's lanes and determine the first that may be used 01603 for (std::vector<MSLane*>::const_iterator i=lanes.begin(); !oneFound&&i!=lanes.end();) { 01604 if (allowed!=0 && find(allowed->begin(), allowed->end(), *i)!=allowed->end()) { 01605 oneFound = true; 01606 next = *i; 01607 } else { 01608 ++i; 01609 ++bestPos; 01610 } 01611 } 01612 // ... it is now stored in next and its position in bestPos 01613 if (oneFound) { 01614 // ok, we have found a best lane 01615 // (in fact, this should be the case if the route is valid, nonetheless...) 01616 // now let's say that the best lane is the nearest one to the found 01617 int bestDistance = -100; 01618 MSLane *bestL = 0; 01619 // go over all lanes of current edge 01620 const std::vector<MSLane*> &clanes = l->getEdge().getLanes(); 01621 for (std::vector<MSLane*>::const_iterator i=clanes.begin(); i!=clanes.end(); ++i) { 01622 // go over all connected lanes 01623 for (MSLinkCont::const_iterator k=lc.begin(); k!=lc.end(); ++k) { 01624 if ((*k)->getLane()==0) { 01625 continue; 01626 } 01627 // the best lane must be on the proper edge 01628 if (&(*k)->getLane()->getEdge()==*ce) { 01629 std::vector<MSLane*>::const_iterator l=find(lanes.begin(), lanes.end(), (*k)->getLane()); 01630 if (l!=lanes.end()) { 01631 int pos = (int)distance(lanes.begin(), l); 01632 int cdist = abs(pos-bestPos); 01633 if (bestDistance==-100||bestDistance>cdist) { 01634 bestDistance = cdist; 01635 bestL = *i; 01636 } 01637 } 01638 } 01639 } 01640 } 01641 if (bestL==l) { 01642 best.occupied = next->getVehLenSum(); 01643 best.length = next->getLength(); 01644 } else { 01645 best.occupied = 0; 01646 best.length = 0; 01647 best.joined.clear(); 01648 } 01649 } 01650 } 01651 oq.length += best.length; 01652 oq.occupied += best.occupied; 01653 copy(best.joined.begin(), best.joined.end(), back_inserter(oq.joined)); 01654 }
| void MSVehicle::removeOnTripEnd | ( | MSVehicle * | veh | ) | throw () [virtual] |
Called when the observed vehicle leaves the simulation.
| [in] | veh | The vehicle that quits the simulation |
Implements MSVehicleQuitReminded.
Definition at line 1823 of file MSVehicle.cpp.
References quitRemindedLeft().
01823 { 01824 quitRemindedLeft(veh); 01825 }
| bool MSVehicle::replaceRoute | ( | const MSEdgeVector & | edges, | |
| SUMOTime | simTime, | |||
| bool | onInit = false | |||
| ) | throw () [virtual] |
Replaces the current route by the given edges.
It is possible that the new route is not accepted, if a) it does not contain the vehicle's current edge, or b) something fails on insertion into the routes container (see in-line comments).
| [in] | edges | The new list of edges to pass |
| [in] | simTime | The time at which the route was replaced |
Implements SUMOVehicle.
Definition at line 402 of file MSVehicle.cpp.
References SUMOVehicleParameter::arrivalPos, MSRoute::begin(), MSCORN::CORN_P_VEH_OLDROUTE, MSCORN::CORN_VEH_LASTREROUTEOFFSET, MSCORN::CORN_VEH_NUMBERROUTE, MSCORN::CORN_VEH_SAVEREROUTING, MSRoute::dictionary(), MSRoute::erase(), MSRoute::find(), MSRoute::getColor(), Named::getID(), getID(), MSEdge::getLanes(), MSRoute::getLastEdge(), MSRoute::getStops(), MSRoute::inFurtherUse(), myArrivalPos, myCurrEdge, myIntCORNMap, myLastBestLanesEdge, myParameter, myPointerCORNMap, myRoute, myStops, SUMOReal, toString(), and MSCORN::wished().
Referenced by traci::TraCIServer::commandChangeTarget(), TraCIServerAPI_Vehicle::processSet(), and reroute().
00402 { 00403 // assert the vehicle may continue (must not be "teleported" or whatever to another position) 00404 if (!onInit && find(edges.begin(), edges.end(), *myCurrEdge)==edges.end()) { 00405 return false; 00406 } 00407 00408 // build a new one 00409 // build a new id, first 00410 std::string id = getID(); 00411 if (id[0]!='!') { 00412 id = "!" + id; 00413 } 00414 if (myRoute->getID().find("!var#")!=std::string::npos) { 00415 id = myRoute->getID().substr(0, myRoute->getID().rfind("!var#")+4) + toString(myIntCORNMap[MSCORN::CORN_VEH_NUMBERROUTE] + 1); 00416 } else { 00417 id = id + "!var#1"; 00418 } 00419 // build the route 00420 MSRoute *newRoute = new MSRoute(id, edges, false, myRoute->getColor(), myRoute->getStops()); 00421 // and add it to the container (!!!what for? It will never be used again!?) 00422 if (!MSRoute::dictionary(id, newRoute)) { 00423 delete newRoute; 00424 return false; 00425 } 00426 00427 // save information about the current edge 00428 const MSEdge *currentEdge = *myCurrEdge; 00429 00430 // ... maybe the route information shall be saved for output? 00431 if (MSCORN::wished(MSCORN::CORN_VEH_SAVEREROUTING)) { 00432 RouteReplaceInfo rri(*myCurrEdge, simTime, new MSRoute(*myRoute));//new MSRoute("!", myRoute->getEdges(), false)); 00433 if (myPointerCORNMap.find(MSCORN::CORN_P_VEH_OLDROUTE)==myPointerCORNMap.end()) { 00434 myPointerCORNMap[MSCORN::CORN_P_VEH_OLDROUTE] = new ReplacedRoutesVector(); 00435 } 00436 ((ReplacedRoutesVector*) myPointerCORNMap[MSCORN::CORN_P_VEH_OLDROUTE])->push_back(rri); 00437 } 00438 00439 // check whether the old route may be deleted (is not used by anyone else) 00440 if (!myRoute->inFurtherUse()) { 00441 MSRoute::erase(myRoute->getID()); 00442 } 00443 00444 // assign new route 00445 myRoute = newRoute; 00446 // rebuild in-vehicle route information 00447 if (onInit) { 00448 myCurrEdge = myRoute->begin(); 00449 } else { 00450 myCurrEdge = myRoute->find(currentEdge); 00451 } 00452 myLastBestLanesEdge = 0; 00453 // update arrival definition 00454 myArrivalPos = myParameter->arrivalPos; 00455 SUMOReal lastLaneLength = (myRoute->getLastEdge()->getLanes())[0]->getLength(); 00456 if (myArrivalPos < 0) { 00457 myArrivalPos += lastLaneLength; // !!! validate! 00458 } 00459 if (myArrivalPos<0) { 00460 myArrivalPos = 0; 00461 } 00462 if (myArrivalPos>lastLaneLength) { 00463 myArrivalPos = lastLaneLength; 00464 } 00465 // save information that the vehicle was rerouted 00466 // !!! refactor the CORN-stuff 00467 myIntCORNMap[MSCORN::CORN_VEH_LASTREROUTEOFFSET] = 0; 00468 myIntCORNMap[MSCORN::CORN_VEH_NUMBERROUTE] = myIntCORNMap[MSCORN::CORN_VEH_NUMBERROUTE] + 1; 00469 // recheck stops 00470 for (std::list<Stop>::iterator iter = myStops.begin(); iter != myStops.end();) { 00471 if (find(edges.begin(), edges.end(), &iter->lane->getEdge())==edges.end()) { 00472 iter = myStops.erase(iter); 00473 } else { 00474 ++iter; 00475 } 00476 } 00477 return true; 00478 }
| void MSVehicle::reroute | ( | SUMOTime | t, | |
| SUMOAbstractRouter< MSEdge, SUMOVehicle > & | router, | |||
| bool | withTaz = false | |||
| ) | throw () |
Performs a rerouting using the given router.
Tries to find a new route between the current edge and the destination edge, first. Tries to replace the current route by the new one using replaceRoute.
| [in] | t | The time for which the route is computed |
| [in] | router | The router to use |
Definition at line 488 of file MSVehicle.cpp.
References MSEdge::dictionary(), MSRoute::end(), SUMOVehicleParameter::fromTaz, getID(), MSNet::getInstance(), MSRoute::getLastEdge(), myCurrEdge, myParameter, myRoute, replaceRoute(), SUMOVehicleParameter::toTaz, and WRITE_WARNING.
Referenced by MSDevice_Routing::enterLaneAtEmit(), MSDevice_Routing::onTryEmit(), traci::TraCIServer::postProcessSimulationStep(), TraCIServerAPI_Vehicle::processSet(), and MSDevice_Routing::wrappedRerouteCommandExecute().
00488 { 00489 // check whether to reroute 00490 std::vector<const MSEdge*> edges; 00491 if (withTaz && MSEdge::dictionary(myParameter->fromTaz+"-source") && MSEdge::dictionary(myParameter->toTaz)) { 00492 router.compute(MSEdge::dictionary(myParameter->fromTaz+"-source"), MSEdge::dictionary(myParameter->toTaz), (const MSVehicle * const) this, t, edges); 00493 if (edges.size() >= 2) { 00494 edges.erase(edges.begin()); 00495 edges.pop_back(); 00496 } 00497 } else { 00498 router.compute(*myCurrEdge, myRoute->getLastEdge(), (const MSVehicle * const) this, t, edges); 00499 } 00500 if (edges.empty()) { 00501 WRITE_WARNING("No route for vehicle '" + getID() + "' found."); 00502 return; 00503 } 00504 // check whether the new route is the same as the prior 00505 MSRouteIterator ri = myCurrEdge; 00506 std::vector<const MSEdge*>::iterator ri2 = edges.begin(); 00507 while (ri!=myRoute->end()&&ri2!=edges.end()&&*ri==*ri2) { 00508 ++ri; 00509 ++ri2; 00510 } 00511 if (ri!=myRoute->end()||ri2!=edges.end()) { 00512 replaceRoute(edges, MSNet::getInstance()->getCurrentTimeStep(), withTaz); 00513 } 00514 }
| void MSVehicle::saveState | ( | std::ostream & | os | ) |
Saves the states of a vehicle.
Definition at line 1791 of file MSVehicle.cpp.
References MSCORN::CORN_VEH_DEPART_TIME, SUMOVehicleParameter::depart, getCORNIntValue(), MSVehicleType::getID(), Named::getID(), hasCORNIntValue(), SUMOVehicleParameter::id, myCurrEdge, myLastLaneChangeOffset, myParameter, myRoute, myType, myWaitingTime, MSRoute::posInRoute(), SUMOVehicleParameter::repetitionNumber, SUMOVehicleParameter::repetitionOffset, FileHelpers::writeFloat(), FileHelpers::writeInt(), FileHelpers::writeString(), FileHelpers::writeTime(), and FileHelpers::writeUInt().
01791 { 01792 FileHelpers::writeString(os, myParameter->id); 01793 FileHelpers::writeFloat(os, myLastLaneChangeOffset); 01794 FileHelpers::writeFloat(os, myWaitingTime); 01795 FileHelpers::writeInt(os, myParameter->repetitionNumber); 01796 FileHelpers::writeFloat(os, myParameter->repetitionOffset); 01797 FileHelpers::writeString(os, myRoute->getID()); 01798 FileHelpers::writeTime(os, myParameter->depart); 01799 FileHelpers::writeString(os, myType->getID()); 01800 FileHelpers::writeUInt(os, myRoute->posInRoute(myCurrEdge)); 01801 if (hasCORNIntValue(MSCORN::CORN_VEH_DEPART_TIME)) { 01802 FileHelpers::writeInt(os, getCORNIntValue(MSCORN::CORN_VEH_DEPART_TIME)); 01803 } else { 01804 FileHelpers::writeInt(os, -1); 01805 } 01806 #ifdef HAVE_MESOSIM 01807 // !!! several things may be missing 01808 if (mySegment==0) { 01809 FileHelpers::writeUInt(os, 0); 01810 } else { 01811 FileHelpers::writeUInt(os, mySegment->getIndex()); 01812 } 01813 FileHelpers::writeUInt(os, getQueIndex()); 01814 FileHelpers::writeTime(os, myEventTime); 01815 FileHelpers::writeTime(os, myLastEntryTime); 01816 #endif 01817 }
| virtual void MSVehicle::setBlinkerInformation | ( | ) | [inline, protected, virtual] |
Reimplemented in GUIVehicle.
Definition at line 924 of file MSVehicle.h.
Referenced by moveFirstChecked().
| void MSVehicle::setIndividualMaxSpeed | ( | SUMOReal | individualMaxSpeed | ) | [inline] |
Definition at line 485 of file MSVehicle.h.
References myHasIndividualMaxSpeed, and myIndividualMaxSpeed.
Referenced by adaptSpeed(), traci::TraCIServer::commandSetMaximumSpeed(), and TraCIServerAPI_Vehicle::processSet().
00485 { 00486 myHasIndividualMaxSpeed = true; 00487 myIndividualMaxSpeed = individualMaxSpeed; 00488 }
| void MSVehicle::setPreDawdleAcceleration | ( | SUMOReal | accel | ) | [inline] |
Definition at line 494 of file MSVehicle.h.
References myPreDawdleAcceleration.
00494 { 00495 myPreDawdleAcceleration = accel; 00496 }
| void MSVehicle::setWasVaporized | ( | bool | onDepart | ) |
Definition at line 1871 of file MSVehicle.cpp.
References MSCORN::CORN_VEH_VAPORIZED, myIntCORNMap, and MSCORN::wished().
Referenced by moveRoutePointer().
01871 { 01872 if (MSCORN::wished(MSCORN::CORN_VEH_VAPORIZED)) { 01873 myIntCORNMap[MSCORN::CORN_VEH_VAPORIZED] = onDepart ? 1 : 0; 01874 } 01875 }
| void MSVehicle::startLaneChange | ( | unsigned | lane, | |
| SUMOTime | stickyTime | |||
| ) |
Initiate a lane change requested by TraCI command "changeLane".
| lane | the lane index within the current edge, that is the destination of the change | |
| stickyTime | duration for wich the constraint takes effect |
Definition at line 1981 of file MSVehicle.cpp.
References checkForLaneChanges(), MSNet::getCurrentTimeStep(), MSNet::getInstance(), laneChangeConstraintActive, laneChangeStickyTime, myDestinationLane, and timeBeforeLaneChange.
Referenced by traci::TraCIServer::commandChangeLane(), and TraCIServerAPI_Vehicle::processSet().
01981 { 01982 if (lane < 0) { 01983 return; 01984 } 01985 timeBeforeLaneChange = MSNet::getInstance()->getCurrentTimeStep(); 01986 laneChangeStickyTime = stickyTime; 01987 myDestinationLane = lane; 01988 laneChangeConstraintActive = true; 01989 checkForLaneChanges(); 01990 }
The vehicle will slow down to newSpeed within the time interval duration. This is done by limiting the maximum speed every time a simulation step is performed by TraCI. Speed reduction is linear.
| newSpeed | speed to reduce to | |
| duration | time intervall for the speed adaption | |
| currentTime | current simulation time |
Definition at line 1932 of file MSVehicle.cpp.
References adaptDuration, adaptingSpeed, getSpeed(), MAX2(), speedBeforeAdaption, speedReduction, SUMOReal, and timeBeforeAdaption.
Referenced by traci::TraCIServer::commandSlowDown(), and TraCIServerAPI_Vehicle::processSet().
01932 { 01933 if (newSpeed < 0 || duration <= 0/* || newSpeed >= getSpeed()*/) { 01934 return false; 01935 } 01936 speedBeforeAdaption = getSpeed(); 01937 timeBeforeAdaption = currentTime; 01938 adaptDuration = duration; 01939 speedReduction = MAX2((SUMOReal) 0.0f, (SUMOReal)(speedBeforeAdaption - newSpeed)); 01940 adaptingSpeed = true; 01941 return true; 01942 }
| const MSEdge * MSVehicle::succEdge | ( | unsigned int | nSuccs | ) | const throw () [virtual] |
Returns the nSuccs'th successor of edge the vehicle is currently at.
If the rest of the route (counted from the current edge) than nSuccs, 0 is returned.
| [in] | nSuccs | The number of edge to look forward |
Implements SUMOVehicle.
Definition at line 337 of file MSVehicle.cpp.
References hasSuccEdge(), and myCurrEdge.
Referenced by MSVehicleTransfer::checkEmissions().
00337 { 00338 if (hasSuccEdge(nSuccs)) { 00339 return *(myCurrEdge + nSuccs); 00340 } else { 00341 return 0; 00342 } 00343 }
| void MSVehicle::unsetIndividualMaxSpeed | ( | void | ) | [inline] |
Definition at line 490 of file MSVehicle.h.
References myHasIndividualMaxSpeed.
Referenced by adaptSpeed(), traci::TraCIServer::commandSetMaximumSpeed(), and TraCIServerAPI_Vehicle::processSet().
00490 { 00491 myHasIndividualMaxSpeed = false; 00492 }
| void MSVehicle::vsafeCriticalCont | ( | SUMOTime | t, | |
| SUMOReal | minVSafe, | |||
| SUMOReal | lengthsInFront | |||
| ) |
Definition at line 1131 of file MSVehicle.cpp.
References bla, MSCFModel::brakeGap(), MSEdge::EDGEFUNCTION_INTERNAL, MSCFModel::ffeS(), MSCFModel::ffeV(), getBestLanesContinuation(), getCarFollowModel(), MSLane::getEdge(), MSLane::getFirstVehicle(), MSLane::getLastVehicleInformation(), MSLane::getLength(), MSLane::getLinkCont(), MSCFModel::getMaxDecel(), MSLane::getMaxSpeed(), MSEdge::getPurpose(), GLO_VEHICLE, gSelected, MSLane::isLinkEnd(), GUISelectedStorage::isSelected(), MSLink::LINKSTATE_TL_RED, MSLink::LINKSTATE_TL_YELLOW_MAJOR, MSLink::LINKSTATE_TL_YELLOW_MINOR, MAX2(), MSCFModel::maxNextSpeed(), MIN2(), MIN3(), myLane, myLFLinkLanes, MSVehicle::State::myPos, MSVehicle::State::mySpeed, myState, myStops, SPEED2DIST, MSLane::succLinkSec(), SUMOReal, and TIME2STEPS.
Referenced by moveRegardingCritical().
01131 { 01132 #ifdef DEBUG_VEHICLE_GUI_SELECTION 01133 if (gSelected.isSelected(GLO_VEHICLE, static_cast<const GUIVehicle*>(this)->getGlID())) { 01134 int bla = 0; 01135 } 01136 #endif 01137 const MSCFModel &cfModel = getCarFollowModel(); 01138 // the vehicle may have just to look into the next lane 01139 // compute this information and use it only once in the next loop 01140 SUMOReal seen = myLane->getLength() - myState.myPos; 01141 // !!! Why is the brake gap accounted? !!! 01142 if (this!=myLane->getFirstVehicle() && seen - cfModel.brakeGap(myState.mySpeed) > 0) { 01143 // not "reaching critical" 01144 myLFLinkLanes.push_back(DriveProcessItem(0, boundVSafe, boundVSafe, false, 0, 0)); 01145 return; 01146 } 01147 01148 MSLane *nextLane = myLane; 01149 // compute the way the vehicle would drive if it would use the current speed and then 01150 // decelerate 01151 SUMOReal maxV = cfModel.maxNextSpeed(myState.mySpeed); 01152 SUMOReal dist = SPEED2DIST(maxV) + cfModel.brakeGap(maxV);//myState.mySpeed); 01153 SUMOReal vLinkPass = boundVSafe; 01154 SUMOReal vLinkWait = vLinkPass; 01155 const std::vector<MSLane*> &bestLaneConts = getBestLanesContinuation(); 01156 #ifdef HAVE_INTERNAL_LANES 01157 bool hadNonInternal = false; 01158 bool lastInnerHadPriority = false; 01159 bool passingInner = false; 01160 #endif 01161 01162 unsigned int view = 1; 01163 // loop over following lanes 01164 while (true) { 01165 // process stops 01166 if (!myStops.empty()&& &myStops.begin()->lane->getEdge()==&nextLane->getEdge()) { 01167 SUMOReal vsafeStop = cfModel.ffeS(this, seen-(nextLane->getLength()-myStops.begin()->pos)); 01168 vLinkPass = MIN2(vLinkPass, vsafeStop); 01169 vLinkWait = MIN2(vLinkWait, vsafeStop); 01170 } 01171 01172 // get the next link used 01173 MSLinkCont::const_iterator link = myLane->succLinkSec(*this, view, *nextLane, bestLaneConts); 01174 // and the length of the currently investigated lane 01175 SUMOReal laneLength = nextLane->getLength(); 01176 01177 // check whether the lane is a dead end 01178 // (should be valid only on further loop iterations 01179 if (nextLane->isLinkEnd(link)) { 01180 // the vehicle will not drive further 01181 SUMOReal laneEndVSafe = cfModel.ffeS(this, seen); 01182 myLFLinkLanes.push_back(DriveProcessItem(0, MIN2(vLinkPass, laneEndVSafe), MIN2(vLinkPass, laneEndVSafe), false, 0, 0)); 01183 return; 01184 } 01185 // the link was passed 01186 vLinkWait = vLinkPass; 01187 01188 01189 // needed to let vehicles wait for all overlapping vehicles in front 01190 const MSLinkCont &lc = nextLane->getLinkCont(); 01191 01192 // get the following lane 01193 #ifdef HAVE_INTERNAL_LANES 01194 passingInner = nextLane->getEdge().getPurpose()==MSEdge::EDGEFUNCTION_INTERNAL; 01195 bool nextInternal = false; 01196 nextLane = (*link)->getViaLane(); 01197 if (nextLane==0) { 01198 nextLane = (*link)->getLane(); 01199 hadNonInternal = true; 01200 passingInner = false; 01201 } else { 01202 nextInternal = true; 01203 passingInner &= nextLane->getEdge().getPurpose()==MSEdge::EDGEFUNCTION_INTERNAL; 01204 } 01205 #else 01206 nextLane = (*link)->getLane(); 01207 #endif 01208 01209 // compute the velocity to use when the link is not blocked by oter vehicles 01210 // the vehicle shall be not faster when reaching the next lane than allowed 01211 SUMOReal vmaxNextLane = MAX2(cfModel.ffeV(this, seen, nextLane->getMaxSpeed()), nextLane->getMaxSpeed()); 01212 01213 // the vehicle shall keep a secure distance to its predecessor 01214 // (or approach the lane end if the predeccessor is too near) 01215 SUMOReal vsafePredNextLane = 100000; 01216 std::pair<MSVehicle*, SUMOReal> lastOnNext = nextLane->getLastVehicleInformation(); 01217 if (lastOnNext.first!=0) { 01218 if (seen+lastOnNext.second>0) { 01219 vsafePredNextLane = cfModel.ffeV(this, seen+lastOnNext.second, lastOnNext.first->getSpeed()); 01220 } 01221 } 01222 #ifdef DEBUG_VEHICLE_GUI_SELECTION 01223 if (gSelected.isSelected(GLO_VEHICLE, static_cast<const GUIVehicle*>(this)->getGlID())) { 01224 int bla = 0; 01225 } 01226 #endif 01227 // compute the velocity to use when the link may be used 01228 vLinkPass = MIN3(vLinkPass, vmaxNextLane, vsafePredNextLane); 01229 01230 // if the link may not be used (is blocked by another vehicle) then let the 01231 // vehicle decelerate until the end of the street 01232 vLinkWait = MIN3(vLinkPass, vLinkWait, cfModel.ffeS(this, seen)); 01233 01234 bool yellow = (*link)->getState()==MSLink::LINKSTATE_TL_YELLOW_MAJOR||(*link)->getState()==MSLink::LINKSTATE_TL_YELLOW_MINOR; 01235 if (yellow&&SPEED2DIST(vLinkWait)+myState.myPos<laneLength) { 01236 myLFLinkLanes.push_back(DriveProcessItem(*link, vLinkWait, vLinkWait, false, 0, 0)); 01237 return; 01238 } 01239 // behaviour in front of not priorised intersections (waiting for priorised foe vehicles) 01240 bool setRequest = false; 01241 bool mayPass = (*link)->havePriority() || (passingInner&&lastInnerHadPriority); 01242 if (!mayPass) { 01243 // The vehicle will not pass a red light 01244 if ((*link)->getState()==MSLink::LINKSTATE_TL_RED) { 01245 vLinkPass = vLinkWait; 01246 } 01247 // The vehicle may pass if it already has passed the decision point which is at 01248 // Also, after reaching this point, the speed should not be reduced 01249 // Up to this time it is decelearating in order to watch out for foe traffic 01250 if (seen>cfModel.getMaxDecel()) { 01251 vLinkPass = vLinkWait; 01252 // SUMOReal vDecel2Brake = cfModel.ffeV(this, seen-cfModel.getMaxDecel(), cfModel.getMaxDecel()); 01253 // vLinkPass = MIN2(vLinkPass, MAX2(vDecel2Brake, cfModel.getMaxDecel())); 01254 // vLinkWait = MIN2(vLinkWait, MAX2(vDecel2Brake, cfModel.getMaxDecel())); 01255 } 01256 } 01257 lastInnerHadPriority = (*link)->havePriority(); 01258 // process stops 01259 if (!myStops.empty()&& &myStops.begin()->lane->getEdge()==&nextLane->getEdge()) { 01260 SUMOReal vsafeStop = cfModel.ffeS(this, seen+myStops.begin()->pos); 01261 vLinkPass = MIN2(vLinkPass, vsafeStop); 01262 vLinkWait = MIN2(vLinkWait, vsafeStop); 01263 setRequest = false; 01264 } else { 01265 setRequest |= ((*link)->getState()!=MSLink::LINKSTATE_TL_RED&&(vLinkPass>0&&dist-seen>0)); 01266 } 01267 // the next condition matches the previously one used for determining the difference 01268 // between critical/non-critical vehicles. Though, one should assume that a vehicle 01269 // should want to move over an intersection even though it could brake before it!? 01270 setRequest &= dist-seen>0; 01271 SUMOTime arrivalTime = 0; 01272 SUMOTime leaveTime = 0; 01273 if (setRequest) { 01274 arrivalTime = t + TIME2STEPS(seen / vLinkPass); 01275 } 01276 myLFLinkLanes.push_back(DriveProcessItem(*link, vLinkPass, vLinkWait, setRequest, arrivalTime, vLinkPass)); 01277 seen += nextLane->getLength(); 01278 if ((vLinkPass<=0||seen>dist)&&hadNonInternal) { 01279 return; 01280 } 01281 #ifdef HAVE_INTERNAL_LANES 01282 if (!nextInternal) { 01283 view++; 01284 } 01285 #else 01286 view++; 01287 #endif 01288 } 01289 }
Returns whether the vehicle wil pass the given edge.
| [in] | The | edge to find in the vehicle's current route |
Definition at line 482 of file MSVehicle.cpp.
References MSRoute::end(), myCurrEdge, and myRoute.
Referenced by traci::TraCIServer::commandChangeRoute().
00482 { 00483 return find(myCurrEdge, myRoute->end(), edge)!=myRoute->end(); 00484 }
| void MSVehicle::workOnMoveReminders | ( | SUMOReal | oldPos, | |
| SUMOReal | newPos, | |||
| SUMOReal | newSpeed | |||
| ) | throw () |
Processes active move reminder.
This method goes through all active move reminder, both those for the current lane, stored in "myMoveReminders" and those of prior lanes stored in "myOldLaneMoveReminders" calling "MSMoveReminder::isStillActive".
When processing move reminder from "myOldLaneMoveReminders", the offsets (prior lane lengths) are used, which are stored in "myOldLaneMoveReminderOffsets".
Each move reminder which is no longer active is removed from the container.
| [in] | oldPos | The position the vehicle had before it has moved |
| [in] | newPos | The position the vehicle has after it has moved |
| [in] | newSpeed | The vehicle's speed within this move |
Definition at line 593 of file MSVehicle.cpp.
References myMoveReminders, myOldLaneMoveReminderOffsets, myOldLaneMoveReminders, and SUMOReal.
Referenced by moveFirstChecked(), onRemovalFromNet(), and MSLane::push().
00593 { 00594 // This erasure-idiom works for all stl-sequence-containers 00595 // See Meyers: Effective STL, Item 9 00596 for (std::vector< MSMoveReminder* >::iterator rem=myMoveReminders.begin(); rem!=myMoveReminders.end();) { 00597 if (!(*rem)->isStillActive(*this, oldPos, newPos, newSpeed)) { 00598 rem = myMoveReminders.erase(rem); 00599 } else { 00600 ++rem; 00601 } 00602 } 00603 OffsetVector::iterator off=myOldLaneMoveReminderOffsets.begin(); 00604 for (std::vector< MSMoveReminder* >::iterator rem=myOldLaneMoveReminders.begin(); rem!=myOldLaneMoveReminders.end();) { 00605 SUMOReal oldLaneLength = *off; 00606 if (!(*rem)->isStillActive(*this, oldLaneLength+oldPos, oldLaneLength+newPos, newSpeed)) { 00607 rem = myOldLaneMoveReminders.erase(rem); 00608 off = myOldLaneMoveReminderOffsets.erase(off); 00609 } else { 00610 ++rem; 00611 ++off; 00612 } 00613 } 00614 }
| void MSVehicle::writeXMLRoute | ( | OutputDevice & | os, | |
| int | index = -1 | |||
| ) | const |
Definition at line 1745 of file MSVehicle.cpp.
References MSCORN::CORN_P_VEH_EXIT_TIMES, MSCORN::CORN_P_VEH_OLDROUTE, MSCORN::CORN_VEH_NUMBERROUTE, getCORNIntValue(), getCORNPointerValue(), hasCORNIntValue(), hasCORNPointerValue(), myPointerCORNMap, myRoute, OutputDevice::openTag(), time2string(), and MSRoute::writeEdgeIDs().
01745 { 01746 // check if a previous route shall be written 01747 os.openTag("route"); 01748 if (index>=0) { 01749 std::map<MSCORN::Pointer, void*>::const_iterator i = myPointerCORNMap.find(MSCORN::CORN_P_VEH_OLDROUTE); 01750 assert(i!=myPointerCORNMap.end()); 01751 const ReplacedRoutesVector *v = (const ReplacedRoutesVector *)(*i).second; 01752 assert((int) v->size()>index); 01753 // write edge on which the vehicle was when the route was valid 01754 os << " replacedOnEdge=\"" << (*v)[index].edge->getID(); 01755 // write the time at which the route was replaced 01756 os << "\" replacedAtTime=\"" << time2string((*v)[index].time) << "\" probability=\"0\" edges=\""; 01757 // get the route 01758 for (int i=0; i<index; ++i) { 01759 (*v)[i].route->writeEdgeIDs(os, (*v)[i].edge); 01760 } 01761 (*v)[index].route->writeEdgeIDs(os); 01762 } else { 01763 os << " edges=\""; 01764 if (hasCORNIntValue(MSCORN::CORN_VEH_NUMBERROUTE)) { 01765 int noReroutes = getCORNIntValue(MSCORN::CORN_VEH_NUMBERROUTE); 01766 std::map<MSCORN::Pointer, void*>::const_iterator it = myPointerCORNMap.find(MSCORN::CORN_P_VEH_OLDROUTE); 01767 assert(it!=myPointerCORNMap.end()); 01768 const ReplacedRoutesVector *v = (const ReplacedRoutesVector *)(*it).second; 01769 assert((int) v->size()==noReroutes); 01770 for (int i=0; i<noReroutes; ++i) { 01771 (*v)[i].route->writeEdgeIDs(os, (*v)[i].edge); 01772 } 01773 } 01774 myRoute->writeEdgeIDs(os); 01775 if (hasCORNPointerValue(MSCORN::CORN_P_VEH_EXIT_TIMES)) { 01776 os << "\" exitTimes=\""; 01777 const std::vector<SUMOTime> *exits = (const std::vector<SUMOTime> *)getCORNPointerValue(MSCORN::CORN_P_VEH_EXIT_TIMES); 01778 for (std::vector<SUMOTime>::const_iterator it = exits->begin(); it != exits->end(); ++it) { 01779 if (it != exits->begin()) { 01780 os << " "; 01781 } 01782 os << time2string(*it); 01783 } 01784 } 01785 } 01786 (os << "\"").closeTag(true); 01787 }
friend class MSLaneChanger [friend] |
friend class MSVehicleControl [friend] |
Definition at line 568 of file MSVehicle.h.
SUMOTime MSVehicle::adaptDuration [private] |
bool MSVehicle::adaptingSpeed [private] |
bool MSVehicle::isLastAdaption [private] |
bool MSVehicle::laneChangeConstraintActive [private] |
Definition at line 1122 of file MSVehicle.h.
Referenced by checkForLaneChanges(), checkLaneChangeConstraint(), and startLaneChange().
SUMOTime MSVehicle::laneChangeStickyTime [private] |
Definition at line 1116 of file MSVehicle.h.
Referenced by checkLaneChangeConstraint(), and startLaneChange().
SUMOReal MSVehicle::myArrivalPos [protected] |
the position on the destination lane where the vehicle stops
Definition at line 987 of file MSVehicle.h.
Referenced by ends(), moveRoutePointer(), MSVehicle(), and replaceRoute().
std::vector<std::vector<LaneQ> > MSVehicle::myBestLanes [mutable, protected] |
Definition at line 976 of file MSVehicle.h.
Referenced by getBestLanes(), and getBestLanesContinuation().
MSRouteIterator MSVehicle::myCurrEdge [private] |
Iterator to current route-edge.
Definition at line 1001 of file MSVehicle.h.
Referenced by addStop(), ends(), enterLaneAtLaneChange(), enterLaneAtMove(), getBestLanes(), getDepartEdge(), getDistanceToPosition(), getEdge(), hasSuccEdge(), hasValidRoute(), moveRoutePointer(), replaceRoute(), reroute(), saveState(), succEdge(), and willPass().
std::vector<LaneQ>::iterator MSVehicle::myCurrentLaneInBestLanes [mutable, protected] |
unsigned MSVehicle::myDestinationLane [private] |
Definition at line 1119 of file MSVehicle.h.
Referenced by checkForLaneChanges(), and startLaneChange().
std::vector<MSDevice*> MSVehicle::myDevices [private] |
The devices this vehicle has.
Definition at line 998 of file MSVehicle.h.
Referenced by enterLaneAtEmit(), enterLaneAtLaneChange(), enterLaneAtMove(), getDevices(), leaveLane(), leaveLaneAtMove(), MSVehicle(), onRemovalFromNet(), onTryEmit(), and ~MSVehicle().
MSEdgeWeightsStorage* MSVehicle::myEdgeWeights [private] |
The vehicle's knowledge about edge efforts/travel times;.
Definition at line 1089 of file MSVehicle.h.
Referenced by getWeightsStorage(), and ~MSVehicle().
std::vector< MSLane * > MSVehicle::myEmptyLaneVector [static, protected] |
std::vector<MSLane*> MSVehicle::myFurtherLanes [protected] |
The information into which lanes the vehicle laps into.
Definition at line 993 of file MSVehicle.h.
Referenced by GUIVehicle::drawGL(), enterLaneAtEmit(), leaveLane(), moveFirstChecked(), and ~MSVehicle().
bool MSVehicle::myHasIndividualMaxSpeed [protected] |
is true if there has an individual speed been set
Definition at line 963 of file MSVehicle.h.
Referenced by adaptMaxSpeed(), getMaxSpeed(), setIndividualMaxSpeed(), and unsetIndividualMaxSpeed().
SUMOReal MSVehicle::myIndividualMaxSpeed [protected] |
An individual speed for an vehicle that is used (iff set) instead of the maximal speed of the vehicle class. NOTE: This is just a little workaround for allowing an external influence on the actual speed
Definition at line 960 of file MSVehicle.h.
Referenced by adaptMaxSpeed(), getMaxSpeed(), and setIndividualMaxSpeed().
std::map<MSCORN::Function, int> MSVehicle::myIntCORNMap [protected] |
Definition at line 981 of file MSVehicle.h.
Referenced by getCORNIntValue(), GUIVehicle::GUIVehicle(), hasCORNIntValue(), moveFirstChecked(), moveRegardingCritical(), MSVehicle(), onDepart(), replaceRoute(), GUIVehicle::setBlinkerInformation(), and setWasVaporized().
MSLane* MSVehicle::myLane [protected] |
The lane the vehicle is on.
Definition at line 969 of file MSVehicle.h.
Referenced by adaptLaneEntering2MoveReminder(), checkForLaneChanges(), checkRewindLinkLanes(), GUIVehicle::drawGL(), enterLaneAtEmit(), enterLaneAtLaneChange(), enterLaneAtMove(), getBestLanes(), getBestLanesContinuation(), getDistanceToPosition(), getLane(), getPosition(), getPositionOnActiveMoveReminderLane(), isOnRoad(), moveFirstChecked(), moveRegardingCritical(), onDepart(), onRemovalFromNet(), processNextStop(), GUIVehicle::setRemoved(), and vsafeCriticalCont().
MSAbstractLaneChangeModel* MSVehicle::myLaneChangeModel [protected] |
Definition at line 971 of file MSVehicle.h.
Referenced by checkForLaneChanges(), getLaneChangeModel(), MSVehicle(), and ~MSVehicle().
const MSEdge* MSVehicle::myLastBestLanesEdge [mutable, protected] |
SUMOReal MSVehicle::myLastLaneChangeOffset [protected] |
information how long ago the vehicle has performed a lane-change
Definition at line 935 of file MSVehicle.h.
Referenced by MSLaneChanger::change(), GUIVehicle::getLastLaneChangeOffset(), and saveState().
DriveItemVector MSVehicle::myLFLinkLanes [private] |
Container for used Links/visited Lanes during lookForward.
Definition at line 1020 of file MSVehicle.h.
Referenced by checkRewindLinkLanes(), moveFirstChecked(), moveRegardingCritical(), onRemovalFromNet(), vsafeCriticalCont(), and ~MSVehicle().
MoveReminderCont MSVehicle::myMoveReminders [private] |
Current lane's move reminder.
Definition at line 1030 of file MSVehicle.h.
Referenced by activateReminders(), adaptLaneEntering2MoveReminder(), enterLaneAtEmit(), enterLaneAtLaneChange(), leaveLane(), leaveLaneAtMove(), and workOnMoveReminders().
Offsets for prior move reminder.
Definition at line 1039 of file MSVehicle.h.
Referenced by adaptLaneEntering2MoveReminder(), getPositionOnActiveMoveReminderLane(), leaveLane(), and workOnMoveReminders().
Prior lanes' move reminder.
Definition at line 1033 of file MSVehicle.h.
Referenced by adaptLaneEntering2MoveReminder(), getPositionOnActiveMoveReminderLane(), leaveLane(), and workOnMoveReminders().
const SUMOVehicleParameter* MSVehicle::myParameter [protected] |
This Vehicle's parameter.
Definition at line 948 of file MSVehicle.h.
Referenced by enterLaneAtLaneChange(), getDesiredDepart(), getID(), getParameter(), moveFirstChecked(), moveRegardingCritical(), replaceRoute(), reroute(), saveState(), GUIVehicle::setOwnDefinedColor(), and ~MSVehicle().
std::map<MSCORN::Pointer, void*> MSVehicle::myPointerCORNMap [protected] |
Definition at line 980 of file MSVehicle.h.
Referenced by addPerson(), getCORNPointerValue(), getRoute(), hasCORNPointerValue(), moveRoutePointer(), onDepart(), onRemovalFromNet(), processNextStop(), replaceRoute(), writeXMLRoute(), and ~MSVehicle().
SUMOReal MSVehicle::myPreDawdleAcceleration [protected] |
The current acceleration before dawdling.
Definition at line 990 of file MSVehicle.h.
Referenced by getHarmonoise_NoiseEmissions(), getHBEFA_CO2Emissions(), getHBEFA_COEmissions(), getHBEFA_FuelConsumption(), getHBEFA_HCEmissions(), getHBEFA_NOxEmissions(), getHBEFA_PMxEmissions(), getPreDawdleAcceleration(), and setPreDawdleAcceleration().
QuitRemindedVector MSVehicle::myQuitReminded [private] |
Definition at line 1043 of file MSVehicle.h.
Referenced by onRemovalFromNet(), quitRemindedEntered(), quitRemindedLeft(), and ~MSVehicle().
SUMOReal MSVehicle::myReferenceSpeed [protected] |
the speed which served as reference when calculating the individual maxspeed
Definition at line 966 of file MSVehicle.h.
Referenced by adaptMaxSpeed().
const MSRoute* MSVehicle::myRoute [protected] |
This Vehicle's route.
Definition at line 951 of file MSVehicle.h.
Referenced by addStop(), ends(), enterLaneAtMove(), getBestLanes(), getDistanceToPosition(), getRoute(), hasSuccEdge(), hasValidRoute(), moveRoutePointer(), MSVehicle(), rebuildContinuationsFor(), replaceRoute(), reroute(), saveState(), GUIVehicle::setOwnRouteColor(), willPass(), writeXMLRoute(), and ~MSVehicle().
State MSVehicle::myState [protected] |
This Vehicles driving state (pos and speed).
Definition at line 954 of file MSVehicle.h.
Referenced by addStop(), MSLaneChanger::change(), congested(), GUIVehicle::drawGL(), ends(), enterLaneAtEmit(), enterLaneAtLaneChange(), getHarmonoise_NoiseEmissions(), getHBEFA_CO2Emissions(), getHBEFA_COEmissions(), getHBEFA_FuelConsumption(), getHBEFA_HCEmissions(), getHBEFA_NOxEmissions(), getHBEFA_PMxEmissions(), getPosition(), getPositionOnActiveMoveReminderLane(), getPositionOnLane(), getSpeed(), getState(), leaveLane(), moveFirstChecked(), moveRegardingCritical(), onDepart(), onRemovalFromNet(), processNextStop(), and vsafeCriticalCont().
std::list<Stop> MSVehicle::myStops [protected] |
The vehicle's list of stops.
Definition at line 984 of file MSVehicle.h.
Referenced by addStop(), addTraciStop(), enterLaneAtMove(), getBestLanes(), hasStops(), isStopped(), moveRegardingCritical(), processNextStop(), rebuildContinuationsFor(), replaceRoute(), and vsafeCriticalCont().
MSLane* MSVehicle::myTarget [protected] |
the lane, the vehicle will be within the next time step (0 if the vehicle stays on the same it was before)
Definition at line 932 of file MSVehicle.h.
Referenced by getTargetLane(), moveFirstChecked(), and moveRegardingCritical().
const MSVehicleType* const MSVehicle::myType [protected] |
Definition at line 973 of file MSVehicle.h.
Referenced by adaptMaxSpeed(), GUIVehicle::drawGL(), enterLaneAtEmit(), getBestLanes(), getCarFollowModel(), getHarmonoise_NoiseEmissions(), getHBEFA_CO2Emissions(), getHBEFA_COEmissions(), getHBEFA_FuelConsumption(), getHBEFA_HCEmissions(), getHBEFA_NOxEmissions(), getHBEFA_PMxEmissions(), getMaxSpeed(), GUIVehicle::getParameterWindow(), getVehicleType(), hasValidRoute(), moveFirstChecked(), processNextStop(), rebuildContinuationsFor(), saveState(), and GUIVehicle::setOwnTypeColor().
SUMOTime MSVehicle::myWaitingTime [protected] |
The time the vehicle waits (is not faster than 0.1m/s) in seconds.
Definition at line 938 of file MSVehicle.h.
Referenced by checkRewindLinkLanes(), enterLaneAtEmit(), getWaitingSeconds(), getWaitingTime(), moveFirstChecked(), and saveState().
SUMOReal MSVehicle::speedBeforeAdaption [private] |
SUMOReal MSVehicle::speedReduction [private] |
SUMOReal MSVehicle::speedWithoutTraciInfluence [private] |
Definition at line 1101 of file MSVehicle.h.
Referenced by getSpeedWithoutTraciInfluence(), and moveFirstChecked().
SUMOTime MSVehicle::timeBeforeAdaption [private] |
SUMOTime MSVehicle::timeBeforeLaneChange [private] |
Definition at line 1113 of file MSVehicle.h.
Referenced by checkLaneChangeConstraint(), and startLaneChange().
1.5.6