SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MSBaseVehicle Class Reference

The base class for microscopic and mesoscopic vehicles. More...

#include <MSBaseVehicle.h>

Inheritance diagram for MSBaseVehicle:
SUMOVehicle MSVehicle GUIVehicle

Public Member Functions

virtual void activateReminders (const MSMoveReminder::Notification reason)
 "Activates" all current move reminder
virtual void addPerson (MSPerson *person)
 Adds a person to this vehicle.
void addReminder (MSMoveReminder *rem)
 Adds a MoveReminder dynamically.
virtual bool addStop (const SUMOVehicleParameter::Stop &stopPar, SUMOTime untilOffset=0)=0
 Adds a stop.
virtual SUMOReal getAcceleration () const
 Returns the vehicle's acceleration.
virtual SUMOReal getArrivalPos () const
 Returns this vehicle's desired arrivalPos for its current route (may change on reroute)
SUMOReal getChosenSpeedFactor () const
 Returns the precomputed factor by which the driver wants to be faster than the speed limit.
SUMOTime getDeparture () const
 Returns this vehicle's real departure time.
MSDevicegetDevice (const std::type_info &type) const
 Returns a device of the given type if it exists or 0.
const std::vector< MSDevice * > & getDevices () const
 Returns this vehicle's devices.
const MSEdgegetEdge () const
 Returns the edge the vehicle is currently at.
const std::string & getID () const
 Returns the name of the vehicle.
SUMOReal getImpatience () const
 Returns this vehicles impatience.
SUMOReal getMaxSpeed () const
 Returns the maximum speed.
unsigned int getNumberReroutes () const
 Returns the number of new routes this vehicle got.
const SUMOVehicleParametergetParameter () const
 Returns the vehicle's parameter (including departure definition)
virtual SUMOReal getPositionOnLane () const =0
 Get the vehicle's position along the lane.
virtual const MSEdgegetRerouteOrigin () const
 Returns the starting point for reroutes (usually the current edge)
const MSRoutegetRoute () const
 Returns the current route.
virtual SUMOReal getSlope () const
 Returns the slope of the road at vehicle's position.
virtual SUMOReal getSpeed () const =0
 Returns the vehicle's current speed.
const MSVehicleTypegetVehicleType () const
 Returns the vehicle's type definition.
virtual SUMOTime getWaitingTime () const =0
virtual bool hasArrived () const
 Returns whether this vehicle has already arived (by default this is true if the vehicle has reached its final edge)
bool hasDeparted () const
 Returns whether this vehicle has already departed.
bool hasValidRoute (std::string &msg) const
 Validates the current route.
virtual bool isOnRoad () const
 Returns the information whether the vehicle is on a road (is simulated)
virtual bool isStopped () const =0
 Returns whether the vehicle is at a stop.
 MSBaseVehicle (SUMOVehicleParameter *pars, const MSRoute *route, const MSVehicleType *type, const SUMOReal speedFactor)
 Constructor.
void onDepart ()
 Called when the vehicle is inserted into the network.
void removeReminder (MSMoveReminder *rem)
 Removes a MoveReminder dynamically.
virtual bool replaceRoute (const MSRoute *route, bool onInit=false, int offset=0)=0
 Replaces the current route by the given one.
bool replaceRouteEdges (MSEdgeVector &edges, bool onInit=false)
 Replaces the current route by the given edges.
void reroute (SUMOTime t, SUMOAbstractRouter< MSEdge, SUMOVehicle > &router, bool withTaz=false)
 Performs a rerouting using the given router.
void setChosenSpeedFactor (SUMOReal factor)
 Returns the precomputed factor by which the driver wants to be faster than the speed limit.
const MSEdgesuccEdge (unsigned int nSuccs) const
 Returns the nSuccs'th successor of edge the vehicle is currently at.
virtual ~MSBaseVehicle ()
 Destructor.
state io
virtual void saveState (OutputDevice &out)
 Saves the (common) state of a vehicle.
state io
virtual void loadState (const SUMOSAXAttributes &attrs, const SUMOTime offset)=0
 Loads the state of this vehicle from the given description.

Protected Member Functions

void calculateArrivalPos ()
 (Re-)Calculates the arrival position from the vehicle parameters

Protected Attributes

SUMOReal myArrivalPos
 the position on the destination lane where the vehicle stops
SUMOReal myChosenSpeedFactor
 A precomputed factor by which the driver wants to be faster than the speed limit.
MSRouteIterator myCurrEdge
 Iterator to current route-edge.
SUMOTime myDeparture
 The real departure time.
std::vector< MSDevice * > myDevices
 The devices this vehicle has.
unsigned int myNumberReroutes
 The number of reroutings.
const SUMOVehicleParametermyParameter
 This Vehicle's parameter.
const MSRoutemyRoute
 This Vehicle's route.
const MSVehicleTypemyType
 This Vehicle's type.

Private Member Functions

MSBaseVehicleoperator= (const MSBaseVehicle &s)
 invalidated assignment operator

Static Private Attributes

static const SUMOTime NOT_YET_DEPARTED = SUMOTime_MAX

Move reminder structures

typedef std::vector< std::pair
< MSMoveReminder *, SUMOReal > > 
MoveReminderCont
 Definition of a move reminder container.
MoveReminderCont myMoveReminders
 Current lane's move reminder.

Detailed Description

The base class for microscopic and mesoscopic vehicles.

Definition at line 58 of file MSBaseVehicle.h.

Member Typedef Documentation

typedef std::vector< std::pair<MSMoveReminder*, SUMOReal> > MSBaseVehicle::MoveReminderCont
protected

Definition of a move reminder container.

Definition at line 320 of file MSBaseVehicle.h.

Constructor & Destructor Documentation

MSBaseVehicle::MSBaseVehicle ( SUMOVehicleParameter pars,
const MSRoute route,
const MSVehicleType type,
const SUMOReal  speedFactor 
)

Constructor.

Parameters
[in]parsThe vehicle description
[in]routeThe vehicle's route
[in]typeThe vehicle's type
[in]speedFactorThe factor for driven lane's speed limits
Exceptions
ProcessErrorIf a value is wrong

Definition at line 62 of file MSBaseVehicle.cpp.

References MSRoute::addReference(), MSDevice::buildVehicleDevices(), calculateArrivalPos(), myDevices, myMoveReminders, and myRoute.

MSBaseVehicle::~MSBaseVehicle ( )
virtual

Member Function Documentation

void MSBaseVehicle::activateReminders ( const MSMoveReminder::Notification  reason)
virtual

"Activates" all current move reminder

For all move reminder stored in "myMoveReminders", their method "MSMoveReminder::notifyEnter" is called.

Parameters
[in]reasonThe reason for changing the reminders' states
See Also
MSMoveReminder
MSMoveReminder::notifyEnter
MSMoveReminder::Notification

Reimplemented in MSVehicle.

Definition at line 271 of file MSBaseVehicle.cpp.

References myMoveReminders.

void MSBaseVehicle::addPerson ( MSPerson person)
virtual

Adds a person to this vehicle.

The default implementation does nothing since persons are not supported by default

Parameters
[in]personThe person to add

Implements SUMOVehicle.

Reimplemented in MSVehicle.

Definition at line 217 of file MSBaseVehicle.cpp.

void MSBaseVehicle::addReminder ( MSMoveReminder rem)

Adds a MoveReminder dynamically.

Parameters
[in]remthe reminder to add
See Also
MSMoveReminder

Definition at line 244 of file MSBaseVehicle.cpp.

References myMoveReminders.

Referenced by MSVehicle::adaptLaneEntering2MoveReminder(), MSVehicle::enterLaneAtInsertion(), and MSVehicle::enterLaneAtLaneChange().

virtual bool SUMOVehicle::addStop ( const SUMOVehicleParameter::Stop stopPar,
SUMOTime  untilOffset = 0 
)
pure virtualinherited

Adds a stop.

The stop is put into the sorted list.

Parameters
[in]stopThe stop to add
Returns
Whether the stop could be added

Implemented in MSVehicle.

void MSBaseVehicle::calculateArrivalPos ( )
protected
SUMOReal MSBaseVehicle::getAcceleration ( ) const
virtual

Returns the vehicle's acceleration.

This default implementation returns always 0.

Returns
The acceleration

Implements SUMOVehicle.

Reimplemented in MSVehicle.

Definition at line 187 of file MSBaseVehicle.cpp.

virtual SUMOReal MSBaseVehicle::getArrivalPos ( ) const
inlinevirtual

Returns this vehicle's desired arrivalPos for its current route (may change on reroute)

Returns
This vehicle's real arrivalPos

Implements SUMOVehicle.

Definition at line 197 of file MSBaseVehicle.h.

References myArrivalPos.

SUMOReal MSBaseVehicle::getChosenSpeedFactor ( ) const
inlinevirtual

Returns the precomputed factor by which the driver wants to be faster than the speed limit.

Returns
Speed limit factor

Implements SUMOVehicle.

Definition at line 271 of file MSBaseVehicle.h.

References myChosenSpeedFactor.

Referenced by GUIVehicle::getParameterWindow(), and TraCIServerAPI_Vehicle::processGet().

SUMOTime MSBaseVehicle::getDeparture ( ) const
inlinevirtual

Returns this vehicle's real departure time.

Returns
This vehicle's real departure time

Implements SUMOVehicle.

Definition at line 189 of file MSBaseVehicle.h.

References myDeparture.

MSDevice * MSBaseVehicle::getDevice ( const std::type_info &  type) const
virtual

Returns a device of the given type if it exists or 0.

Implements SUMOVehicle.

Definition at line 324 of file MSBaseVehicle.cpp.

References myDevices.

const std::vector<MSDevice*>& MSBaseVehicle::getDevices ( ) const
inlinevirtual

Returns this vehicle's devices.

Returns
This vehicle's devices

Implements SUMOVehicle.

Definition at line 224 of file MSBaseVehicle.h.

References myDevices.

const MSEdge * MSBaseVehicle::getEdge ( ) const
virtual

Returns the edge the vehicle is currently at.

Returns
The current edge in the vehicle's route

Implements SUMOVehicle.

Definition at line 127 of file MSBaseVehicle.cpp.

References myCurrEdge.

Referenced by MSVehicleTransfer::add(), GUIApplicationWindow::checkGamingEvents(), MSVehicleTransfer::checkInsertions(), TraCIServerAPI_Vehicle::commandDistanceRequest(), and TraCIServerAPI_Vehicle::processSet().

SUMOReal MSBaseVehicle::getMaxSpeed ( ) const
virtual
unsigned int MSBaseVehicle::getNumberReroutes ( ) const
inlinevirtual

Returns the number of new routes this vehicle got.

Returns
the number of new routes this vehicle got

Implements SUMOVehicle.

Definition at line 213 of file MSBaseVehicle.h.

References myNumberReroutes.

Referenced by GUIVehicle::drawGLAdditional(), GUIVehicle::getColorValue(), and replaceRouteEdges().

const SUMOVehicleParameter & MSBaseVehicle::getParameter ( ) const
virtual
virtual SUMOReal SUMOVehicle::getPositionOnLane ( ) const
pure virtualinherited
virtual const MSEdge* MSBaseVehicle::getRerouteOrigin ( ) const
inlinevirtual

Returns the starting point for reroutes (usually the current edge)

This differs from *myCurrEdge only if the vehicle is on an internal edge

Returns
The rerouting start point

Reimplemented in MSVehicle.

Definition at line 135 of file MSBaseVehicle.h.

References myCurrEdge.

Referenced by replaceRouteEdges(), and reroute().

SUMOReal MSBaseVehicle::getSlope ( ) const
virtual

Returns the slope of the road at vehicle's position.

This default implementation returns always 0.

Returns
The acceleration

Implements SUMOVehicle.

Reimplemented in MSVehicle.

Definition at line 193 of file MSBaseVehicle.cpp.

const MSVehicleType& MSBaseVehicle::getVehicleType ( ) const
inlinevirtual

Returns the vehicle's type definition.

Returns
The vehicle's type definition

Implements SUMOVehicle.

Definition at line 95 of file MSBaseVehicle.h.

References myType.

Referenced by MSLCM_JE2013::_patchSpeed(), MSLCM_LC2013::_patchSpeed(), MSLCM_JE2013::_wantsChange(), MSLCM_LC2013::_wantsChange(), MSVehicle::addStop(), MSLaneChanger::change(), MSLane::checkFailure(), GUIApplicationWindow::checkGamingEvents(), MSVehicleTransfer::checkInsertions(), MSVehicle::checkRewindLinkLanes(), MSAbstractLaneChangeModel::continueLaneChangeManeuver(), MSLane::detectCollisions(), MSE2Collector::detectorUpdate(), GUIVehicle::drawAction_drawRailCarriages(), GUIVehicle::drawAction_drawVehicleAsBoxPlus(), GUIVehicle::drawAction_drawVehicleAsImage(), GUIVehicle::drawAction_drawVehicleAsPoly(), GUIVehicle::drawAction_drawVehicleAsTrianglePlus(), drawAction_drawVehicleBlinker(), drawAction_drawVehicleBrakeLight(), GUIVehicle::drawGL(), GUIVehicle::drawGLAdditional(), MSLane::enteredByLaneChange(), MSVehicle::enterLaneAtLaneChange(), MSVehicle::estimateLeaveSpeed(), MSVehicle::estimateSpeedAfterDistance(), MSVTypeProbe::execute(), MSVehicle::executeMove(), MSLane::executeMovements(), MSLane::freeInsertion(), MSLane::getBruttoOccupancy(), MSEdge::getDepartLane(), MSLane::getFollowerOnConsecutive(), getImpatience(), MSLane::getLastVehicleInformation(), MSVehicle::getLeader(), MSLane::getLeaderOnConsecutive(), MSLane::getMissingRearGap(), MSLane::getNettoOccupancy(), MSLaneChanger::getRealFollower(), MSLaneChanger::getRealLeader(), MSLaneChanger::getRealThisLeader(), MSVehicle::getTimeGap(), MSLane::incorporateVehicle(), MSLCM_JE2013::informFollower(), MSLCM_LC2013::informFollower(), MSLCM_JE2013::informLeader(), MSLCM_LC2013::informLeader(), MSLane::insertVehicle(), MSLane::integrateNewVehicle(), MSLane::isInsertionSuccess(), MSLane::leftByLaneChange(), MSLane::maxSpeedGapInsertion(), MSLink::maybeOccupied(), MSVehicle::overlap(), MSLCM_DK2008::patchSpeed(), MSVehicle::planMoveInternal(), MSLane::planMovements(), MSAbstractLaneChangeModel::predInteraction(), TraCIServerAPI_Vehicle::processGet(), MSVehicle::processNextStop(), MSLane::pWagGenericInsertion(), MSLane::pWagSimpleInsertion(), MSLaneChanger::registerUnchanged(), MSLane::removeVehicle(), MSLCM_JE2013::saveBlockerLength(), MSLCM_LC2013::saveBlockerLength(), GUIVehicle::selectBlockingFoes(), GUIVehicle::setFunctionalColor(), MSLCM_JE2013::slowDownForBlocked(), MSLCM_LC2013::slowDownForBlocked(), MSLaneChanger::startChange(), MSLCM_DK2008::wantsChangeToLeft(), MSLCM_DK2008::wantsChangeToRight(), MSEmissionExport::write(), MSFCDExport::write(), MSQueueExport::writeLane(), and MSFullExport::writeVehicles().

virtual SUMOTime SUMOVehicle::getWaitingTime ( ) const
pure virtualinherited

Implemented in MSVehicle.

Referenced by getImpatience().

bool MSBaseVehicle::hasArrived ( ) const
virtual

Returns whether this vehicle has already arived (by default this is true if the vehicle has reached its final edge)

Implements SUMOVehicle.

Reimplemented in MSVehicle.

Definition at line 212 of file MSBaseVehicle.cpp.

References succEdge().

bool MSBaseVehicle::hasDeparted ( ) const
virtual

Returns whether this vehicle has already departed.

Implements SUMOVehicle.

Definition at line 206 of file MSBaseVehicle.cpp.

References myDeparture, and NOT_YET_DEPARTED.

Referenced by MSVehicle::addStop(), MSVehicle::loadState(), and TraCIServerAPI_Vehicle::processSet().

bool MSBaseVehicle::hasValidRoute ( std::string &  msg) const

Validates the current route.

Parameters
[out]msgDescription why the route is not valid (if it is the case)
Returns
Whether the vehicle's current route is valid

Definition at line 222 of file MSBaseVehicle.cpp.

References MSRoute::end(), MSVehicleType::getVehicleClass(), myCurrEdge, myRoute, and myType.

Referenced by MSVehicle::enterLaneAtInsertion(), and TraCIServerAPI_Vehicle::processGet().

virtual bool MSBaseVehicle::isOnRoad ( ) const
inlinevirtual

Returns the information whether the vehicle is on a road (is simulated)

Returns
Whether the vehicle is simulated

Implements SUMOVehicle.

Reimplemented in MSVehicle.

Definition at line 125 of file MSBaseVehicle.h.

Referenced by MSXMLRawOut::writeVehicle().

virtual bool SUMOVehicle::isStopped ( ) const
pure virtualinherited

Returns whether the vehicle is at a stop.

Returns
Whether the has stopped

Implemented in MSVehicle.

Referenced by MSDevice_Person::notifyMove().

virtual void SUMOVehicle::loadState ( const SUMOSAXAttributes attrs,
const SUMOTime  offset 
)
pure virtualinherited

Loads the state of this vehicle from the given description.

Implemented in MSVehicle.

Referenced by MSStateHandler::myStartElement().

void MSBaseVehicle::onDepart ( )
virtual

Called when the vehicle is inserted into the network.

Sets optional information about departure time, informs the vehicle control about a further running vehicle.

Implements SUMOVehicle.

Definition at line 199 of file MSBaseVehicle.cpp.

References MSNet::getCurrentTimeStep(), MSNet::getInstance(), MSNet::getVehicleControl(), myDeparture, and MSVehicleControl::vehicleDeparted().

Referenced by MSCalibrator::execute().

MSBaseVehicle& MSBaseVehicle::operator= ( const MSBaseVehicle s)
private

invalidated assignment operator

void MSBaseVehicle::removeReminder ( MSMoveReminder rem)

Removes a MoveReminder dynamically.

Parameters
[in]remthe reminder to remove
See Also
MSMoveReminder

Definition at line 255 of file MSBaseVehicle.cpp.

References myMoveReminders.

virtual bool SUMOVehicle::replaceRoute ( const MSRoute route,
bool  onInit = false,
int  offset = 0 
)
pure virtualinherited

Replaces the current route by the given one.

Implemented in MSVehicle.

Referenced by MSTriggeredRerouter::notifyEnter(), MSDevice_Routing::preInsertionReroute(), and replaceRouteEdges().

bool MSBaseVehicle::replaceRouteEdges ( MSEdgeVector edges,
bool  onInit = false 
)
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).

Parameters
[in]edgesThe new list of edges to pass
[in]simTimeThe time at which the route was replaced
Returns
Whether the new route was accepted

Implements SUMOVehicle.

Definition at line 154 of file MSBaseVehicle.cpp.

References MSRoute::addReference(), MSRoute::begin(), RGBColor::DEFAULT_COLOR, MSRoute::dictionary(), MSRoute::getColor(), Named::getID(), getID(), getNumberReroutes(), getRerouteOrigin(), MSRoute::getStops(), myCurrEdge, myRoute, MSRoute::release(), SUMOVehicle::replaceRoute(), and toString().

Referenced by MSVehicle::Influencer::postProcessVTD(), TraCIServerAPI_Vehicle::processSet(), and reroute().

void MSBaseVehicle::reroute ( SUMOTime  t,
SUMOAbstractRouter< MSEdge, SUMOVehicle > &  router,
bool  withTaz = false 
)
virtual

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.

Parameters
[in]tThe time for which the route is computed
[in]routerThe router to use
See Also
replaceRoute

Implements SUMOVehicle.

Definition at line 133 of file MSBaseVehicle.cpp.

References SUMOAbstractRouter< E, V >::compute(), MSEdge::dictionary(), SUMOVehicleParameter::fromTaz, getID(), MSRoute::getLastEdge(), getRerouteOrigin(), myParameter, myRoute, replaceRouteEdges(), SUMOVehicleParameter::toTaz, and WRITE_WARNING.

Referenced by TraCIServerAPI_Vehicle::processSet().

void MSBaseVehicle::saveState ( OutputDevice out)
virtual
void MSBaseVehicle::setChosenSpeedFactor ( SUMOReal  factor)
inline

Returns the precomputed factor by which the driver wants to be faster than the speed limit.

Returns
Speed limit factor

Definition at line 278 of file MSBaseVehicle.h.

References myChosenSpeedFactor.

Referenced by TraCIServerAPI_Vehicle::processSet().

const MSEdge * MSBaseVehicle::succEdge ( unsigned int  nSuccs) const
virtual

Returns the nSuccs'th successor of edge the vehicle is currently at.

If the rest of the route (counted from the current edge) has less than nSuccs edges, 0 is returned.

Parameters
[in]nSuccsThe number of edge to look forward
Returns
The nSuccs'th following edge in the vehicle's route

Implements SUMOVehicle.

Definition at line 117 of file MSBaseVehicle.cpp.

References myCurrEdge.

Referenced by MSVehicleTransfer::add(), MSLane::appropriate(), MSVehicleTransfer::checkInsertions(), hasArrived(), and TraCIServerAPI_Vehicle::processSet().

Field Documentation

SUMOReal MSBaseVehicle::myArrivalPos
protected

the position on the destination lane where the vehicle stops

Definition at line 333 of file MSBaseVehicle.h.

Referenced by calculateArrivalPos(), getArrivalPos(), MSVehicle::hasArrived(), MSVehicle::planMoveInternal(), MSVehicle::resetRoutePosition(), and MSVehicle::updateBestLanes().

SUMOReal MSBaseVehicle::myChosenSpeedFactor
protected

A precomputed factor by which the driver wants to be faster than the speed limit.

Definition at line 313 of file MSBaseVehicle.h.

Referenced by getChosenSpeedFactor(), MSVehicle::MSVehicle(), and setChosenSpeedFactor().

SUMOTime MSBaseVehicle::myDeparture
protected

The real departure time.

Definition at line 330 of file MSBaseVehicle.h.

Referenced by getDeparture(), hasDeparted(), MSVehicle::loadState(), onDepart(), and MSVehicle::saveState().

std::vector<MSDevice*> MSBaseVehicle::myDevices
protected

The devices this vehicle has.

Definition at line 327 of file MSBaseVehicle.h.

Referenced by MSVehicle::addPerson(), getDevice(), getDevices(), GUIVehicle::GUIVehicle(), MSBaseVehicle(), and ~MSBaseVehicle().

unsigned int MSBaseVehicle::myNumberReroutes
protected

The number of reroutings.

Definition at line 336 of file MSBaseVehicle.h.

Referenced by getNumberReroutes(), and MSVehicle::replaceRoute().

const SUMOTime MSBaseVehicle::NOT_YET_DEPARTED = SUMOTime_MAX
staticprivate

Definition at line 342 of file MSBaseVehicle.h.

Referenced by hasDeparted().


The documentation for this class was generated from the following files: