58 #ifdef CHECK_MEMORY_LEAKS 60 #endif // CHECK_MEMORY_LEAKS 118 std::vector<std::string> ids;
121 if ((*i).second->isOnRoad() || (*i).second->isParking()) {
122 ids.push_back((*i).first);
134 if (sumoVehicle == 0) {
142 const bool visible = onRoad || v->
isParking();
183 tempMsg.
writeInt((
int)std::distance(lanes.begin(), std::find(lanes.begin(), lanes.end(), v->
getLane())));
256 std::pair<const MSVehicle* const, SUMOReal> leaderInfo = v->
getLeader(dist);
260 tempMsg.
writeString(leaderInfo.first != 0 ? leaderInfo.first->getID() :
"");
273 if (inputStorage.
readInt() != 2) {
305 if (inputStorage.
readInt() != 2) {
357 const std::vector<MSVehicle::LaneQ>& bestLanes = onRoad ? v->
getBestLanes() : std::vector<MSVehicle::LaneQ>();
358 tempContent.
writeInt((
int) bestLanes.size());
360 for (std::vector<MSVehicle::LaneQ>::const_iterator i = bestLanes.begin(); i != bestLanes.end(); ++i) {
377 std::vector<std::string> bestContIDs;
380 bestContIDs.push_back((*j)->getID());
403 if ((*link)->isTLSControlled()) {
406 tempContent.
writeString((*link)->getTLLogic()->getID());
409 tempContent.
writeInt((*link)->getTLIndex());
415 tempContent.
writeByte((*link)->getState());
419 lane = (*link)->getViaLaneOrLane();
439 b = 1 + (stop.
parking ? 2 : 0) +
476 std::string paramName =
"";
498 std::string warning =
"";
524 const bool shouldExist = variable !=
ADD && variable !=
ADD_FULL;
526 if (sumoVehicle == 0) {
532 if (v == 0 && shouldExist) {
540 int compoundSize = inputStorage.
readInt();
541 if (compoundSize < 4 || compoundSize > 7) {
563 bool parking =
false;
564 bool triggered =
false;
565 bool containerTriggered =
false;
566 bool isBusStop =
false;
567 bool isContainerStop =
false;
568 if (compoundSize >= 5) {
573 parking = ((stopFlags & 1) != 0);
574 triggered = ((stopFlags & 2) != 0);
575 containerTriggered = ((stopFlags & 4) != 0);
576 isBusStop = ((stopFlags & 8) != 0);
577 isContainerStop = ((stopFlags & 16) != 0);
580 if (compoundSize >= 6) {
590 if (compoundSize >= 7) {
596 if (isBusStop || isContainerStop) {
598 if (!v->
addTraciBusOrContainerStop(roadId, waitTime, until, parking, triggered, containerTriggered, isContainerStop, error)) {
606 if (pos < startPos) {
614 const std::vector<MSLane*>& allLanes = road->
getLanes();
615 if ((laneIndex < 0) || laneIndex >= (
int)(allLanes.size())) {
619 if (!v->
addTraciStop(allLanes[laneIndex], startPos, pos, waitTime, until, parking, triggered, containerTriggered, error)) {
630 if (inputStorage.
readInt() != 0) {
634 if (!static_cast<MSVehicle*>(v)->hasStops()) {
638 if (!static_cast<MSVehicle*>(v)->resumeFromStopping()) {
640 std::ostringstream strs;
641 strs <<
"reached: " << sto.
reached;
642 strs <<
", duration:" << sto.
duration;
643 strs <<
", edge:" << (*sto.
edge)->getID();
644 strs <<
", startPos: " << sto.
startPos;
645 std::string posStr = strs.str();
655 if (inputStorage.
readInt() != 2) {
668 if ((laneIndex < 0) || (laneIndex >= (
int)(v->
getEdge()->
getLanes().size()))) {
672 std::vector<std::pair<SUMOTime, int> > laneTimeLine;
673 laneTimeLine.push_back(std::make_pair(
MSNet::getInstance()->getCurrentTimeStep(), laneIndex));
674 laneTimeLine.push_back(std::make_pair(
MSNet::getInstance()->getCurrentTimeStep() + stickyTime, laneIndex));
714 if (inputStorage.
readInt() != 2) {
731 std::vector<std::pair<SUMOTime, SUMOReal> > speedTimeLine;
733 speedTimeLine.push_back(std::make_pair(
MSNet::getInstance()->getCurrentTimeStep() + duration, newSpeed));
763 if (vehicleType == 0) {
792 std::vector<std::string> edgeIDs;
807 int parameterCount = inputStorage.
readInt();
808 if (parameterCount == 4) {
810 int begTime = 0, endTime = 0;
834 }
else if (parameterCount == 2) {
854 }
else if (parameterCount == 1) {
877 int parameterCount = inputStorage.
readInt();
878 if (parameterCount == 4) {
880 int begTime = 0, endTime = 0;
904 }
else if (parameterCount == 2) {
924 }
else if (parameterCount == 1) {
947 if (inputStorage.
readInt() != 0) {
957 if (inputStorage.
readInt() != 0) {
976 if (inputStorage.
readInt() != 2) {
995 if (!v->
willPass(&destinationEdge)) {
1004 while (v->
getEdge() != &destinationEdge) {
1024 std::vector<std::pair<SUMOTime, SUMOReal> > speedTimeLine;
1026 speedTimeLine.push_back(std::make_pair(
MSNet::getInstance()->getCurrentTimeStep(), speed));
1045 int laneChangeMode = 0;
1068 if (inputStorage.
readInt() != 6) {
1072 vehicleParams.
id = id;
1074 std::string vTypeID;
1083 std::string routeID;
1096 const int proc = -depart;
1104 WRITE_WARNING(
"Departure time for vehicle '" +
id +
"' is in the past; using current time instead.");
1106 vehicleParams.
depart = depart;
1115 const int proc =
static_cast<int>(-vehicleParams.
departPos);
1130 const int proc =
static_cast<int>(-vehicleParams.
departSpeed);
1144 const int proc =
static_cast<int>(-vehicleParams.
departLane);
1170 if (inputStorage.
readInt() != 14) {
1174 vehicleParams.
id = id;
1176 std::string routeID;
1185 std::string vTypeID;
1315 const int numArgs = inputStorage.
readInt();
1316 if (numArgs != 5 && numArgs != 6) {
1332 double origAngle = 0;
1344 bool keepRoute = v->
getID() !=
"VTD_EGO";
1345 bool mayLeaveNetwork =
false;
1351 keepRoute = (keepRouteFlag == 1);
1352 mayLeaveNetwork = (keepRouteFlag == 2);
1355 std::string origID = edgeID +
" " +
toString(laneNum);
1357 edgeID =
'-' + edgeID;
1362 if (angle >= 180.) {
1363 angle = -360. + angle;
1364 }
else if (angle <= -180.) {
1365 angle = 360. + angle;
1370 std::cout << std::endl <<
"begin vehicle " << v->
getID() <<
" vehPos:" << vehPos <<
" lane:" << v->
getLane()->
getID() << std::endl;
1371 std::cout <<
" want pos:" << pos <<
" edge:" << edgeID <<
" laneNum:" << laneNum <<
" origAngle:" << origAngle <<
" angle:" << angle <<
" keepRoute:" << keepRoute << std::endl;
1379 int routeOffset = 0;
1390 found =
vtdMap(pos, maxRouteDistance, origID, angle, *v, server, bestDistance, &lane, lanePos, routeOffset, edges);
1392 if ((found && bestDistance <= maxRouteDistance) || mayLeaveNetwork) {
1397 lanePosLat = perpDist;
1398 if (!mayLeaveNetwork) {
1406 lanePosLat = -lanePosLat;
1410 assert((found && lane != 0) || (!found && lane == 0));
1471 std::set<std::string> into;
1473 shape.push_back(pos);
1476 std::map<MSLane*, LaneUtility> lane2utility;
1478 for (std::set<std::string>::const_iterator j = into.begin(); j != into.end(); ++j) {
1480 const MSEdge* prevEdge = 0;
1481 const MSEdge* nextEdge = 0;
1483 bool onRoute =
false;
1487 #ifdef DEBUG_VTD_ANGLE 1488 std::cout <<
"Ego on normal" << std::endl;
1499 ConstMSEdgeVector::const_iterator edgePos = std::find(ev.begin() + routePosition, ev.end(), e);
1500 onRoute = edgePos != ev.end();
1501 if (edgePos == ev.end() - 1 && v.
getEdge() == e) {
1507 nextEdge = !onRoute || edgePos == ev.end() - 1 ? 0 : *(edgePos + 1);
1508 #ifdef DEBUG_VTD_ANGLE 1509 std::cout <<
"normal:" << e->
getID() <<
" prev:" << prevEdge->
getID() <<
" next:";
1510 if (nextEdge != 0) {
1511 std::cout << nextEdge->
getID();
1513 std::cout << std::endl;
1516 #ifdef DEBUG_VTD_ANGLE 1517 std::cout <<
"Ego on internal" << std::endl;
1525 prevEdge = l == 0 ? 0 : &l->
getEdge();
1529 ConstMSEdgeVector::const_iterator prevEdgePos = std::find(ev.begin() + v.
getRoutePosition(), ev.end(), prevEdge);
1534 if (prevEdgePos != ev.end() && (prevEdgePos + 1) != ev.end()) {
1535 onRoute = *(prevEdgePos + 1) == nextEdge;
1537 #ifdef DEBUG_VTD_ANGLE 1538 std::cout <<
"internal:" << e->
getID() <<
" prev:" << prevEdge->
getID() <<
" next:" << nextEdge->getID() << std::endl;
1544 const std::vector<MSLane*>& lanes = e->
getLanes();
1545 for (std::vector<MSLane*>::const_iterator k = lanes.begin(); k != lanes.end(); ++k) {
1567 #ifdef DEBUG_VTD_ANGLE 1568 std::cout << lane->
getID() <<
": " << langle <<
" " << off << std::endl;
1573 onRoute, sameEdge, prevEdge, nextEdge);
1576 maxDist =
MAX2(maxDist, dist);
1585 for (std::map<MSLane*, LaneUtility>::iterator i = lane2utility.begin(); i != lane2utility.end(); ++i) {
1599 std::cout <<
" x; l:" << l->
getID() <<
" d:" << u.
dist <<
" dN:" << distN <<
" aD:" << angleDiffN <<
1600 " ID:" << idN <<
" oRN:" << onRouteN <<
" sEN:" << sameEdgeN <<
" value:" << value << std::endl;
1602 if (value > bestValue || bestLane == 0) {
1608 if (bestLane == 0) {
1611 const LaneUtility& u = lane2utility.find(bestLane)->second;
1612 bestDistance = u.
dist;
1618 ConstMSEdgeVector::const_iterator prevEdgePos = std::find(ev.begin(), ev.end(), prevEdge);
1619 routeOffset = (int)std::distance(ev.begin(), prevEdgePos);
1632 #ifdef DEBUG_VTD_ANGLE 1633 std::cout <<
"internal2:" <<
" prev:";
1637 std::cout <<
" next:";
1641 std::cout << std::endl;
1653 const std::vector<MSLane*>& lanes = edge->
getLanes();
1654 bool newBest =
false;
1655 for (std::vector<MSLane*>::const_iterator k = lanes.begin(); k != lanes.end() && bestDistance >
POSITION_EPS; ++k) {
1656 MSLane* candidateLane = *k;
1659 std::cout <<
" b at lane " << candidateLane->
getID() <<
" dist:" << dist <<
" best:" << bestDistance << std::endl;
1661 if (dist < bestDistance) {
1663 bestDistance = dist;
1664 *lane = candidateLane;
1683 for (ConstMSEdgeVector::const_iterator i = v.
getCurrentRouteEdge(); i != edges.end(); ++i) {
1684 #ifdef HAVE_INTERNAL_LANES 1687 const MSEdge* internalCand = prev->getInternalFollowingEdge(*i);
1689 prev = internalCand;
1693 routeOffset = (int)std::distance(edges.begin(), i);
1700 for (ConstMSEdgeVector::const_iterator i = v.
getCurrentRouteEdge(); i != edges.begin(); --i) {
1702 #ifdef HAVE_INTERNAL_LANES 1705 const MSEdge* internalCand = prev->getInternalFollowingEdge(next);
1707 prev = internalCand;
1711 routeOffset = (int)std::distance(edges.begin(), i);
1720 std::cout <<
" b failed - no best route lane" << std::endl;
1730 const std::vector<MSLane*>& lanes = (*lane)->getEdge().getLanes();
1731 for (std::vector<MSLane*>::const_iterator i = lanes.begin(); i != lanes.end(); ++i) {
1732 if ((*i)->getParameter(
"origId",
"") == origID) {
1742 std::cout <<
" b ok lane " << (*lane)->getID() <<
" lanePos:" << lanePos << std::endl;
1754 if (inputStorage.
readInt() != 2) {
1759 std::pair<const MSLane*, SUMOReal> roadPos;
1766 std::string roadID = inputStorage.
readString();
1769 pos = roadPos.first->getShape().positionAtOffset(roadPos.second);
1776 const double p1x = inputStorage.
readDouble();
1777 const double p1y = inputStorage.
readDouble();
1796 v->
getEdge(), &roadPos.first->getEdge());
1827 std::string newID = oType.
getID().find(
'@') == std::string::npos ? oType.
getID() +
"@" + veh->
getID() : oType.
getID();
1829 static_cast<MSVehicle*
>(veh)->replaceVehicleType(type);
1836 const std::map<std::string, std::vector<MSLane*> >&
1840 for (MSEdgeVector::const_iterator i = edges.begin(); i != edges.end(); ++i) {
1841 const std::vector<MSLane*>& lanes = (*i)->getLanes();
1842 for (std::vector<MSLane*>::const_iterator j = lanes.begin(); j != lanes.end(); ++j) {
1843 if ((*j)->knowsParameter(
"origId")) {
1844 std::string origID = (*j)->getParameter(
"origId",
"");
1846 gVTDMap[origID] = std::vector<MSLane*>();
1848 gVTDMap[origID].push_back(*j);
1853 gVTDMap[
"unknown"] = std::vector<MSLane*>();
int getRoutePosition() const
SUMOReal getWidth() const
Returns the lane's width.
static bool setVariable(const int cmd, const int variable, MSVehicleType &v, TraCIServer &server, tcpip::Storage &inputStorage, tcpip::Storage &outputStorage)
Processes a set value for the given type.
MSLane * getLogicalPredecessorLane() const
get the most likely precedecessor lane (sorted using by_connections_to_sorter). The result is cached ...
void replaceVehicleType(MSVehicleType *type)
Replaces the current vehicle type by the one given.
SUMOReal getLength() const
Returns the lane's length.
SUMOReal getHarmonoise_NoiseEmissions() const
Returns noise emissions of the current state.
bool enterLaneAtMove(MSLane *enteredLane, bool onTeleporting=false)
Update when the vehicle enters a new lane in the move step.
RGBColor color
The vehicle's color.
static bool commandDistanceRequest(TraCIServer &server, tcpip::Storage &inputStorage, tcpip::Storage &outputStorage, const MSVehicle *v)
MSEdge & getEdge() const
Returns the lane's edge.
Representation of a vehicle in the micro simulation.
#define VAR_EMISSIONCLASS
bool hasValidRoute(std::string &msg, const MSRoute *route=0) const
Validates the current or given route.
#define REQUEST_DRIVINGDIST
void collectObjectsInRange(int domain, const PositionVector &shape, SUMOReal range, std::set< std::string > &into)
constVehIt loadedVehBegin() const
Returns the begin of the internal vehicle map.
static bool parseDepartSpeed(const std::string &val, const std::string &element, const std::string &id, SUMOReal &speed, DepartSpeedDefinition &dsd, std::string &error)
Validates a given departSpeed value.
const ConstMSEdgeVector & getEdges() const
#define RESPONSE_GET_VEHICLE_VARIABLE
static MSVehicleType & getSingularType(SUMOVehicle *const veh)
#define CMD_GET_VEHICLE_VARIABLE
static std::map< std::string, std::vector< MSLane * > > gVTDMap
static bool parseArrivalPos(const std::string &val, const std::string &element, const std::string &id, SUMOReal &pos, ArrivalPosDefinition &apd, std::string &error)
Validates a given arrivalPos value.
bool hasDeparted() const
Returns whether this vehicle has already departed.
void setTentativeLaneAndPosition(MSLane *lane, SUMOReal pos, SUMOReal posLat=0)
set tentative lane and position during insertion to ensure that all cfmodels work (some of them requi...
static bool processSet(TraCIServer &server, tcpip::Storage &inputStorage, tcpip::Storage &outputStorage)
Processes a set value command (Command 0xc4: Change Vehicle State)
void setVTDControlled(MSVehicle *v, Position xyPos, MSLane *l, SUMOReal pos, SUMOReal posLat, SUMOReal angle, int edgeOffset, ConstMSEdgeVector route, SUMOTime t)
MSLane * getLane() const
Returns the lane the vehicle is on.
SUMOReal distanceTo(const Position &p2) const
returns the euclidean distance in 3 dimension
static const MSLane * getLaneChecking(std::string roadID, int laneIndex, SUMOReal pos)
ArrivalLaneDefinition arrivalLaneProcedure
Information how the vehicle shall choose the lane to arrive on.
bool knowsEffort(const MSEdge *const e) const
Returns the information whether any effort is known for the given edge.
Position getPosition(const SUMOReal offset=0) const
Return current position (x/y, cartesian)
int bestLaneOffset
The (signed) number of lanes to be crossed to get to the lane which allows to continue the drive...
static bool vtdMap(const Position &pos, SUMOReal maxRouteDistance, const std::string &origID, const SUMOReal angle, MSVehicle &v, TraCIServer &server, SUMOReal &bestDistance, MSLane **lane, SUMOReal &lanePos, int &routeOffset, ConstMSEdgeVector &edges)
bool readTypeCheckingColor(tcpip::Storage &inputStorage, RGBColor &into)
Reads the value type and a color, verifying the type.
void setRespectJunctionPriority(bool value)
Sets whether junction priority rules shall be respected.
unsigned char alpha() const
Returns the alpha-amount of the color.
int getPersonNumber() const
Returns the number of persons.
DepartLaneDefinition departLaneProcedure
Information how the vehicle shall choose the lane to depart from.
SUMOReal departSpeed
(optional) The initial speed of the vehicle
#define VAR_ALLOWED_SPEED
Tag for the last element in the enum for safe int casting.
static bool getVariable(const int variable, const MSVehicleType &v, tcpip::Storage &tempMsg)
Processes a value request for the given type.
const SUMOVehicleParameter & getParameter() const
Returns the vehicle's parameter (including departure definition)
virtual double readDouble()
SUMOReal arrivalSpeed
(optional) The final speed of the vehicle (not used yet)
SUMOVehicle * getVehicle(const std::string &id) const
Returns the vehicle with the given id.
Notification
Definition of a vehicle state.
virtual MSVehicle * removeVehicle(MSVehicle *remVehicle, MSMoveReminder::Notification notification, bool notify=true)
bool replaceRoute(const MSRoute *route, bool onInit=false, int offset=0)
Replaces the current route by the given one.
SUMOReal getNOxEmissions() const
Returns NOx emission of the current state.
virtual bool compute(const E *from, const E *to, const V *const vehicle, SUMOTime msTime, std::vector< const E *> &into)=0
Builds the route between the given edges using the minimum effort at the given time The definition of...
bool knowsTravelTime(const MSEdge *const e) const
Returns the information whether any travel time is known for the given edge.
static bool getPosition(const std::string &id, Position &p)
Returns the named vehicle's position.
bool reached
Information whether the stop has been reached.
bool readTypeCheckingInt(tcpip::Storage &inputStorage, int &into)
Reads the value type and an int, verifying the type.
SUMOReal arrivalPos
(optional) The position the vehicle shall arrive on
const std::vector< MSLane * > & getLanes() const
Returns this edge's lanes.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
bool readTypeCheckingString(tcpip::Storage &inputStorage, std::string &into)
Reads the value type and a string, verifying the type.
bool readTypeCheckingDouble(tcpip::Storage &inputStorage, double &into)
Reads the value type and a double, verifying the type.
const PositionVector & getShape() const
Returns this lane's shape.
bool isLinkEnd(MSLinkCont::const_iterator &i) const
const MSRoute & getRoute() const
Returns the current route.
The vehicle got vaporized.
static bool dictionary(const std::string &id, MSEdge *edge)
Inserts edge into the static dictionary Returns true if the key id isn't already in the dictionary...
unsigned char blue() const
Returns the blue-amount of the color.
virtual bool addVehicle(const std::string &id, SUMOVehicle *v)
Tries to insert the vehicle into the internal vehicle container.
static std::pair< MSLane *, SUMOReal > convertCartesianToRoadMap(Position pos)
Definition of vehicle stop (position and duration)
std::vector< const MSEdge * > ConstMSEdgeVector
ArrivalSpeedDefinition arrivalSpeedProcedure
Information how the vehicle's end speed shall be chosen.
int getSignals() const
Returns the signals.
const std::string & getID() const
Returns the id.
virtual void writeUnsignedByte(int)
int getSpeedMode() const
return the current speed mode
EdgeBasicFunction
Defines possible edge types.
int size() const
Returns the number of edges to pass.
bool writeErrorStatusCmd(int commandId, const std::string &description, tcpip::Storage &outputStorage)
Writes a status command to the given storage with status = RTYPE_ERR.
Tag for the last element in the enum for safe int casting.
SUMOReal getCO2Emissions() const
Returns CO2 emission of the current state.
#define VAR_SPEED_DEVIATION
SUMOReal length
The overall length which may be driven when using this lane without a lane change.
#define VAR_NOISEEMISSION
#define VAR_FUELCONSUMPTION
#define UNUSED_PARAMETER(x)
void addEffort(const MSEdge *const e, SUMOReal begin, SUMOReal end, SUMOReal value)
Adds an effort information for an edge and a time span.
static MSVehicleType * build(SUMOVTypeParameter &from)
Builds the microsim vehicle type described by the given parameter.
virtual void writeInt(int)
#define WRITE_WARNING(msg)
bool retrieveExistingEffort(const MSEdge *const e, const SUMOReal t, SUMOReal &value) const
Returns an effort for an edge and time if stored.
The car-following model and parameter.
bool triggered
whether an arriving person lets the vehicle continue
virtual int readUnsignedByte()
std::string toTaz
The vehicle's destination zone (district)
SUMOReal nearest_offset_to_point2D(const Position &p, bool perpendicular=true) const
return the nearest offest to point 2D
void addTravelTime(const MSEdge *const e, SUMOReal begin, SUMOReal end, SUMOReal value)
Adds a travel time information for an edge and a time span.
static bool processGet(TraCIServer &server, tcpip::Storage &inputStorage, tcpip::Storage &outputStorage)
Processes a get value command (Command 0xa4: Get Vehicle Variable)
SUMOReal nextOccupation
As occupation, but without the first lane.
SUMOReal getSpeedWithoutTraciInfluence() const
Returns the uninfluenced velocity.
SUMOReal distanceTo2D(const Position &p2) const
returns the euclidean distance in the x-y-plane
A road/street connecting two junctions.
bool isOnRoad() const
Returns the information whether the vehicle is on a road (is simulated)
SUMOReal getDistanceBetween(SUMOReal fromPos, SUMOReal toPos, const MSEdge *fromEdge, const MSEdge *toEdge, bool includeInternal=true) const
Compute the distance between 2 given edges on this route, including the length of internal lanes...
SUMOReal getWidth() const
Get the width which vehicles of this class shall have when being drawn.
MSLane * lane
The described lane.
#define VAR_PERSON_NUMBER
SUMOReal getCOEmissions() const
Returns CO emission of the current state.
SUMOReal getFuelConsumption() const
Returns fuel consumption of the current state.
void setEmergencyBrakeRedLight(bool value)
Sets whether red lights shall be a reason to brake.
DepartSpeedDefinition departSpeedProcedure
Information how the vehicle's initial speed shall be chosen.
void removeEffort(const MSEdge *const e)
Removes the effort information for an edge.
DepartLaneDefinition
Possible ways to choose a lane on depart.
Representation of a vehicle.
MSStoppingPlace * containerstop
(Optional) container stop if one is assigned to the stop
void setChosenSpeedFactor(const SUMOReal factor)
Returns the precomputed factor by which the driver wants to be faster than the speed limit...
DepartPosDefinition departPosProcedure
Information how the vehicle shall choose the departure position.
SUMOReal z() const
Returns the z-position.
#define REMOVE_TELEPORT_ARRIVED
A point in 2D or 3D with translation and scaling methods.
void set(unsigned char r, unsigned char g, unsigned char b, unsigned char a)
assigns new values
SUMOReal getWaitingSeconds() const
Returns the number of seconds waited (speed was lesser than 0.1m/s)
SUMOReal getDepartPos() const
Returns this vehicle's real departure position.
const std::vector< MSLane * > & getBestLanesContinuation() const
Returns the subpart of best lanes that describes the vehicle's current lane and their successors...
const MSEdge * getEdge() const
Returns the edge the vehicle is currently at.
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
virtual void writeByte(int)
SUMOReal getPMxEmissions() const
Returns PMx emission of the current state.
ConstMSEdgeVector::const_iterator MSRouteIterator
bool readTypeCheckingStringList(tcpip::Storage &inputStorage, std::vector< std::string > &into)
Reads the value type and a string list, verifying the type.
The vehicle arrived at its destination (is deleted)
SUMOReal rotationDegreeAtOffset(SUMOReal pos) const
Returns the rotation at the given length.
virtual SUMOVehicle * buildVehicle(SUMOVehicleParameter *defs, const MSRoute *route, const MSVehicleType *type, const bool ignoreStopErrors, const bool fromRouteFile=true)
Builds a vehicle, increases the number of built vehicles.
int arrivalLane
(optional) The lane the vehicle shall arrive on (not used yet)
virtual void writeStringList(const std::vector< std::string > &s)
SUMOTime depart
The vehicle's departure time.
DepartDefinition departProcedure
Information how the vehicle shall choose the depart time.
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
SUMOTime duration
The stopping duration.
#define CMD_SET_VEHICLE_VARIABLE
SUMOReal getPositionOnLane() const
Get the vehicle's position along the lane.
SUMOReal x() const
Returns the x-position.
std::string fromTaz
The vehicle's origin zone (district)
virtual std::string readString()
#define CMD_GET_EDGE_VARIABLE
Tag for the last element in the enum for safe int casting.
A structure representing the best lanes for continuing the route.
void onRemovalFromNet(const MSMoveReminder::Notification reason)
Called when the vehicle is removed from the network.
static bool parseArrivalLane(const std::string &val, const std::string &element, const std::string &id, int &lane, ArrivalLaneDefinition &ald, std::string &error)
Validates a given arrivalLane value.
SUMOReal distance2D(const Position &p, bool perpendicular=false) const
closest 2D-distance to point p (or -1 if perpendicular is true and the point is beyond this vector) ...
#define CMD_REROUTE_EFFORT
EdgeBasicFunction getPurpose() const
Returns the edge type (EdgeBasicFunction)
SUMOReal getSlope() const
Returns the slope of the road at vehicle's position.
std::string toString(const T &t, std::streamsize accuracy=OUTPUT_ACCURACY)
TraCI server used to control sumo by a remote TraCI client.
bool isInternal() const
return whether this edge is an internal edge
const int VEHPARS_COLOR_SET
SUMOReal getVehicleMaxSpeed(const SUMOVehicle *const veh) const
Returns the lane's maximum speed, given a vehicle's speed limit adaptation.
virtual void writeStorage(tcpip::Storage &store)
int personNumber
The static number of persons in the vehicle when it departs (not including boarding persons) ...
static bool parseDepartPos(const std::string &val, const std::string &element, const std::string &id, SUMOReal &pos, DepartPosDefinition &dpd, std::string &error)
Validates a given departPos value.
static MSLinkCont::const_iterator succLinkSec(const SUMOVehicle &veh, int nRouteSuccs, const MSLane &succLinkSource, const std::vector< MSLane *> &conts)
bool allowsContinuation
Whether this lane allows to continue the drive.
static SUMOReal naviDegree(const SUMOReal angle)
int departLane
(optional) The lane the vehicle shall depart from (index in edge)
std::string line
The vehicle's line (mainly for public transport)
#define INVALID_DOUBLE_VALUE
DepartSpeedDefinition
Possible ways to choose the departure speed.
void writeResponseWithLength(tcpip::Storage &outputStorage, tcpip::Storage &tempMsg)
void alreadyDeparted(SUMOVehicle *veh)
stops trying to emit the given vehicle (because it already departed)
static bool findCloserLane(const MSEdge *edge, const Position &pos, SUMOReal &bestDistance, MSLane **lane)
void forceVehicleInsertion(MSVehicle *veh, SUMOReal pos, MSMoveReminder::Notification notification, SUMOReal posLat=0)
Inserts the given vehicle at the given position.
static bool parseArrivalSpeed(const std::string &val, const std::string &element, const std::string &id, SUMOReal &speed, ArrivalSpeedDefinition &asd, std::string &error)
Validates a given arrivalSpeed value.
const std::string & getParameter(const std::string &key, const std::string &defaultValue) const
Returns the value for a given key.
#define VAR_EDGE_TRAVELTIME
static bool dictionary(const std::string &id, MSLane *lane)
Static (sic!) container methods {.
void setSpeedTimeLine(const std::vector< std::pair< SUMOTime, SUMOReal > > &speedTimeLine)
Sets a new velocity timeline.
virtual void writeString(const std::string &s)
void removeTravelTime(const MSEdge *const e)
Removes the travel time information for an edge.
Influencer & getInfluencer()
Returns the velocity/lane influencer.
void scheduleVehicleRemoval(SUMOVehicle *veh)
Removes a vehicle after it has ended.
Structure representing possible vehicle parameter.
#define INVALID_INT_VALUE
SUMOReal getAngle() const
Returns the vehicle's direction in radians.
const MSVehicleType & getVehicleType() const
Returns the vehicle's type definition.
std::string toHex(const T i, std::streamsize numDigits=0)
bool containerTriggered
whether an arriving container lets the vehicle continue
void setConsiderMaxDeceleration(bool value)
Sets whether the maximum deceleration shall be regarded.
MSInsertionControl & getInsertionControl()
Returns the insertion control.
int setParameter
Information for the router which parameter were set.
unsigned char green() const
Returns the green-amount of the color.
#define CMD_REROUTE_TRAVELTIME
SUMOReal getChosenSpeedFactor() const
Returns the precomputed factor by which the driver wants to be faster than the speed limit...
std::vector< MSLane * > bestContinuations
Consecutive lane that can be followed without a lane change (contribute to length and occupation) ...
#define VAR_ELECTRICITYCONSUMPTION
SUMOReal getLength() const
return the length of the edge
static SUMOReal getMinAngleDiff(SUMOReal angle1, SUMOReal angle2)
Returns the minimum distance (clockwise/counter-clockwise) between both angles.
static SUMOReal gLateralResolution
const MSEdge * getRerouteOrigin() const
Returns the starting point for reroutes (usually the current edge)
const std::string & getID() const
Returns the name of the vehicle type.
void set(SUMOReal x, SUMOReal y)
void setConsiderSafeVelocity(bool value)
Sets whether the safe velocity shall be regarded.
bool replaceRouteEdges(ConstMSEdgeVector &edges, bool onInit=false, bool check=false)
Replaces the current route by the given edges.
MSRouteIterator edge
The edge in the route to stop at.
bool addTraciBusOrContainerStop(const std::string &stopId, const SUMOTime duration, const SUMOTime until, const bool parking, const bool triggered, const bool containerTriggered, const bool isContainerStop, std::string &errorMsg)
const MSEdgeVector & getSuccessors() const
Returns the following edges.
std::map< std::string, SUMOVehicle * >::const_iterator constVehIt
Definition of the internal vehicles map iterator.
SUMOReal departPos
(optional) The position the vehicle shall depart from
void setLaneChangeMode(int value)
Sets lane changing behavior.
const MSEdgeVector & getEdges() const
Returns loaded edges.
virtual void writeDouble(double)
const MSEdge * succEdge(int nSuccs) const
Returns the nSuccs'th successor of edge the vehicle is currently at.
SUMOReal getHCEmissions() const
Returns HC emission of the current state.
const MSEdgeWeightsStorage & getWeightsStorage() const
Returns the vehicle's internal edge travel times/efforts container.
unsigned char red() const
Returns the red-amount of the color.
void move2side(SUMOReal amount)
move position vector to side using certain ammount
void switchOffSignal(int signal)
Switches the given signal off.
void switchOnSignal(int signal)
Switches the given signal on.
void writeStatusCmd(int commandId, int status, const std::string &description, tcpip::Storage &outputStorage)
Writes a status command to the given storage.
#define VAR_SPEED_WITHOUT_TRACI
MSEdgeControl & getEdgeControl()
Returns the edge control.
void reroute(SUMOTime t, SUMOAbstractRouter< MSEdge, SUMOVehicle > &router, const bool onInit=false, const bool withTaz=false)
Performs a rerouting using the given router.
#define VAR_LANECHANGE_MODE
void setLaneTimeLine(const std::vector< std::pair< SUMOTime, int > > &laneTimeLine)
Sets a new lane timeline.
MSRouteIterator begin() const
Returns the begin of the list of edges to pass.
SUMOAbstractRouter< MSEdge, SUMOVehicle > & getRouterTT(const MSEdgeVector &prohibited=MSEdgeVector()) const
The vehicle was teleported out of the net.
bool isStopped() const
Returns whether the vehicle is at a stop.
The class responsible for building and deletion of vehicles.
bool willPass(const MSEdge *const edge) const
Returns whether the vehicle wil pass the given edge.
std::vector< MSEdge * > MSEdgeVector
const std::vector< LaneQ > & getBestLanes() const
Returns the description of best lanes to use in order to continue the route.
bool isParking() const
Returns whether the vehicle is parking.
SUMOReal getElectricityConsumption() const
Returns electricity consumption of the current state.
std::pair< const MSVehicle *const, SUMOReal > getLeader(SUMOReal dist=0) const
Returns the leader of the vehicle looking for a fixed distance.
const MSRouteIterator & getCurrentRouteEdge() const
Returns an iterator pointing to the current edge in this vehicles route.
The edge is an internal edge.
static const std::map< std::string, std::vector< MSLane * > > & getOrBuildVTDMap()
#define WRITE_MESSAGE(msg)
Tag for the last element in the enum for safe int casting.
SUMOReal y() const
Returns the y-position.
MSVehicleType * getVType(const std::string &id=DEFAULT_VTYPE_ID, MTRand *rng=0)
Returns the named vehicle type or a sample from the named distribution.
DepartPosDefinition
Possible ways to choose the departure position.
const std::string & getID() const
Returns the name of the vehicle.
void add(SUMOVehicle *veh)
Adds a single vehicle for departure.
bool addTraciStop(MSLane *const lane, const SUMOReal startPos, const SUMOReal endPos, const SUMOTime duration, const SUMOTime until, const bool parking, const bool triggered, const bool containerTriggered, std::string &errorMsg)
SUMOReal startPos
The stopping position start.
MSStoppingPlace * busstop
(Optional) bus stop if one is assigned to the stop
Representation of a lane in the micro simulation.
SUMOReal getSpeed() const
Returns the vehicle's current speed.
bool retrieveExistingTravelTime(const MSEdge *const e, const SUMOReal t, SUMOReal &value) const
Returns a travel time for an edge and time if stored.
MSRouteIterator end() const
Returns the end of the list of edges to pass.
static void parseEdgesList(const std::string &desc, ConstMSEdgeVector &into, const std::string &rid)
Parses the given string assuming it contains a list of edge ids divided by spaces.
virtual const std::string & getID() const =0
Get the vehicle's ID.
DepartDefinition
Possible ways to depart.
static bool parseDepart(const std::string &val, const std::string &element, const std::string &id, SUMOTime &depart, DepartDefinition &dd, std::string &error)
Validates a given depart value.
bool readTypeCheckingByte(tcpip::Storage &inputStorage, int &into)
Reads the value type and a byte, verifying the type.
constVehIt loadedVehEnd() const
Returns the end of the internal vehicle map.
void setConsiderMaxAcceleration(bool value)
Sets whether the maximum acceleration shall be regarded.
static const SUMOReal INVALID_OFFSET
a value to signify offsets outside the range of [0, Line.length()]
ArrivalPosDefinition arrivalPosProcedure
Information how the vehicle shall choose the arrival position.
std::string id
The vehicle's id.
bool parking
whether the vehicle is removed from the net while stopping
The vehicle is being teleported.
static bool vtdMap_matchingRoutePosition(const Position &pos, const std::string &origID, MSVehicle &v, SUMOReal &bestDistance, MSLane **lane, SUMOReal &lanePos, int &routeOffset, ConstMSEdgeVector &edges)
virtual const MSVehicleType & getVehicleType() const =0
Returns the vehicle's type.
static bool dictionary(const std::string &id, const MSRoute *route)
Adds a route to the dictionary.
static bool parseDepartLane(const std::string &val, const std::string &element, const std::string &id, int &lane, DepartLaneDefinition &dld, std::string &error)
Validates a given departLane value.