58 #ifdef CHECK_MEMORY_LEAKS 60 #endif // CHECK_MEMORY_LEAKS 120 std::vector<std::string> ids;
123 if ((*i).second->isOnRoad() || (*i).second->isParking()) {
124 ids.push_back((*i).first);
136 if (sumoVehicle == 0) {
144 const bool visible = onRoad || v->
isParking();
185 tempMsg.
writeInt((
int)std::distance(lanes.begin(), std::find(lanes.begin(), lanes.end(), v->
getLane())));
258 std::pair<const MSVehicle* const, SUMOReal> leaderInfo = v->
getLeader(dist);
262 tempMsg.
writeString(leaderInfo.first != 0 ? leaderInfo.first->getID() :
"");
275 if (inputStorage.
readInt() != 2) {
307 if (inputStorage.
readInt() != 2) {
359 const std::vector<MSVehicle::LaneQ>& bestLanes = onRoad ? v->
getBestLanes() : std::vector<MSVehicle::LaneQ>();
360 tempContent.
writeInt((
int) bestLanes.size());
362 for (std::vector<MSVehicle::LaneQ>::const_iterator i = bestLanes.begin(); i != bestLanes.end(); ++i) {
379 std::vector<std::string> bestContIDs;
382 bestContIDs.push_back((*j)->getID());
405 if ((*link)->isTLSControlled()) {
408 tempContent.
writeString((*link)->getTLLogic()->getID());
411 tempContent.
writeInt((*link)->getTLIndex());
417 tempContent.
writeByte((*link)->getState());
421 lane = (*link)->getViaLaneOrLane();
441 b = 1 + (stop.
parking ? 2 : 0) +
486 std::string paramName =
"";
508 std::string warning =
"";
534 std::cout <<
SIMTIME <<
" processSet veh=" <<
id <<
"\n";
536 const bool shouldExist = variable !=
ADD && variable !=
ADD_FULL;
538 if (sumoVehicle == 0) {
544 if (v == 0 && shouldExist) {
547 const bool onInit = v == 0 || v->
getLane() == 0;
553 int compoundSize = inputStorage.
readInt();
554 if (compoundSize < 4 || compoundSize > 7) {
576 bool parking =
false;
577 bool triggered =
false;
578 bool containerTriggered =
false;
579 bool isBusStop =
false;
580 bool isContainerStop =
false;
581 if (compoundSize >= 5) {
586 parking = ((stopFlags & 1) != 0);
587 triggered = ((stopFlags & 2) != 0);
588 containerTriggered = ((stopFlags & 4) != 0);
589 isBusStop = ((stopFlags & 8) != 0);
590 isContainerStop = ((stopFlags & 16) != 0);
593 if (compoundSize >= 6) {
603 if (compoundSize >= 7) {
609 if (isBusStop || isContainerStop) {
611 if (!v->
addTraciBusOrContainerStop(roadId, waitTime, until, parking, triggered, containerTriggered, isContainerStop, error)) {
619 if (pos < startPos) {
627 const std::vector<MSLane*>& allLanes = road->
getLanes();
628 if ((laneIndex < 0) || laneIndex >= (
int)(allLanes.size())) {
632 if (!v->
addTraciStop(allLanes[laneIndex], startPos, pos, waitTime, until, parking, triggered, containerTriggered, error)) {
643 if (inputStorage.
readInt() != 0) {
647 if (!static_cast<MSVehicle*>(v)->hasStops()) {
651 if (!static_cast<MSVehicle*>(v)->resumeFromStopping()) {
653 std::ostringstream strs;
654 strs <<
"reached: " << sto.
reached;
655 strs <<
", duration:" << sto.
duration;
656 strs <<
", edge:" << (*sto.
edge)->getID();
657 strs <<
", startPos: " << sto.
startPos;
658 std::string posStr = strs.str();
668 if (inputStorage.
readInt() != 2) {
681 if ((laneIndex < 0) || (laneIndex >= (
int)(v->
getEdge()->
getLanes().size()))) {
685 std::vector<std::pair<SUMOTime, int> > laneTimeLine;
686 laneTimeLine.push_back(std::make_pair(
MSNet::getInstance()->getCurrentTimeStep(), laneIndex));
687 laneTimeLine.push_back(std::make_pair(
MSNet::getInstance()->getCurrentTimeStep() + stickyTime, laneIndex));
727 if (inputStorage.
readInt() != 2) {
744 std::vector<std::pair<SUMOTime, SUMOReal> > speedTimeLine;
746 speedTimeLine.push_back(std::make_pair(
MSNet::getInstance()->getCurrentTimeStep() + duration, newSpeed));
782 if (vehicleType == 0) {
811 std::vector<std::string> edgeIDs;
826 int parameterCount = inputStorage.
readInt();
827 if (parameterCount == 4) {
829 int begTime = 0, endTime = 0;
853 }
else if (parameterCount == 2) {
873 }
else if (parameterCount == 1) {
896 int parameterCount = inputStorage.
readInt();
897 if (parameterCount == 4) {
899 int begTime = 0, endTime = 0;
923 }
else if (parameterCount == 2) {
943 }
else if (parameterCount == 1) {
966 if (inputStorage.
readInt() != 0) {
976 if (inputStorage.
readInt() != 0) {
1001 if (inputStorage.
readInt() != 2) {
1010 double position = 0;
1020 if (!v->
willPass(&destinationEdge)) {
1029 while (v->
getEdge() != &destinationEdge) {
1049 std::vector<std::pair<SUMOTime, SUMOReal> > speedTimeLine;
1051 speedTimeLine.push_back(std::make_pair(
MSNet::getInstance()->getCurrentTimeStep(), speed));
1066 int laneChangeMode = 0;
1089 if (inputStorage.
readInt() != 6) {
1093 vehicleParams.
id = id;
1095 std::string vTypeID;
1104 std::string routeID;
1117 const int proc = -depart;
1125 WRITE_WARNING(
"Departure time for vehicle '" +
id +
"' is in the past; using current time instead.");
1127 vehicleParams.
depart = depart;
1136 const int proc =
static_cast<int>(-vehicleParams.
departPos);
1151 const int proc =
static_cast<int>(-vehicleParams.
departSpeed);
1165 const int proc =
static_cast<int>(-vehicleParams.
departLane);
1191 if (inputStorage.
readInt() != 14) {
1195 vehicleParams.
id = id;
1197 std::string routeID;
1206 std::string vTypeID;
1339 const int numArgs = inputStorage.
readInt();
1340 if (numArgs != 5 && numArgs != 6) {
1356 double origAngle = 0;
1368 bool keepRoute = v->
getID() !=
"VTD_EGO";
1369 bool mayLeaveNetwork =
false;
1375 keepRoute = (keepRouteFlag == 1);
1376 mayLeaveNetwork = (keepRouteFlag == 2);
1379 const std::string origID = edgeID +
"_" +
toString(laneNum);
1384 while (angle >= 360.) {
1387 while (angle < 0.) {
1394 std::cout <<
" want pos:" << pos <<
" origID:" << origID <<
" laneNum:" << laneNum <<
" origAngle:" << origAngle <<
" angle:" << angle <<
" keepRoute:" << keepRoute << std::endl;
1402 int routeOffset = 0;
1413 found =
vtdMap(pos, maxRouteDistance, origID, angle, *v, server, bestDistance, &lane, lanePos, routeOffset, edges);
1415 if ((found && bestDistance <= maxRouteDistance) || mayLeaveNetwork) {
1420 lanePosLat = perpDist;
1421 if (!mayLeaveNetwork) {
1429 lanePosLat = -lanePosLat;
1433 assert((found && lane != 0) || (!found && lane == 0));
1466 std::vector<std::string> edgeIDs;
1517 std::set<std::string> into;
1519 shape.push_back(pos);
1522 std::map<MSLane*, LaneUtility> lane2utility;
1524 for (std::set<std::string>::const_iterator j = into.begin(); j != into.end(); ++j) {
1526 const MSEdge* prevEdge = 0;
1527 const MSEdge* nextEdge = 0;
1529 bool onRoute =
false;
1533 #ifdef DEBUG_MOVEXY_ANGLE 1534 std::cout <<
"Ego on normal" << std::endl;
1545 ConstMSEdgeVector::const_iterator edgePos = std::find(ev.begin() + routePosition, ev.end(), e);
1546 onRoute = edgePos != ev.end();
1547 if (edgePos == ev.end() - 1 && v.
getEdge() == e) {
1553 nextEdge = !onRoute || edgePos == ev.end() - 1 ? 0 : *(edgePos + 1);
1554 #ifdef DEBUG_MOVEXY_ANGLE 1555 std::cout <<
"normal:" << e->
getID() <<
" prev:" << prevEdge->
getID() <<
" next:";
1556 if (nextEdge != 0) {
1557 std::cout << nextEdge->
getID();
1559 std::cout << std::endl;
1562 #ifdef DEBUG_MOVEXY_ANGLE 1563 std::cout <<
"Ego on internal" << std::endl;
1571 prevEdge = l == 0 ? 0 : &l->
getEdge();
1575 ConstMSEdgeVector::const_iterator prevEdgePos = std::find(ev.begin() + v.
getRoutePosition(), ev.end(), prevEdge);
1580 if (prevEdgePos != ev.end() && (prevEdgePos + 1) != ev.end()) {
1581 onRoute = *(prevEdgePos + 1) == nextEdge;
1583 #ifdef DEBUG_MOVEXY_ANGLE 1584 std::cout <<
"internal:" << e->
getID() <<
" prev:" << prevEdge->
getID() <<
" next:" << nextEdge->getID() << std::endl;
1590 const std::vector<MSLane*>& lanes = e->
getLanes();
1591 const bool perpendicular =
true;
1592 for (std::vector<MSLane*>::const_iterator k = lanes.begin(); k != lanes.end(); ++k) {
1614 #ifdef DEBUG_MOVEXY_ANGLE 1616 std::cout << lane->
getID() <<
" param=" << lane->
getParameter(
"origId", lane->
getID()) <<
" origID='" << origID <<
"\n";
1621 onRoute, sameEdge, prevEdge, nextEdge);
1631 for (std::map<MSLane*, LaneUtility>::iterator i = lane2utility.begin(); i != lane2utility.end(); ++i) {
1645 std::cout <<
" x; l:" << l->
getID() <<
" d:" << u.
dist <<
" dN:" << distN <<
" aD:" << angleDiffN <<
1646 " ID:" << idN <<
" oRN:" << onRouteN <<
" sEN:" << sameEdgeN <<
" value:" << value << std::endl;
1648 if (value > bestValue || bestLane == 0) {
1654 if (bestLane == 0) {
1657 const LaneUtility& u = lane2utility.find(bestLane)->second;
1658 bestDistance = u.
dist;
1664 ConstMSEdgeVector::const_iterator prevEdgePos = std::find(ev.begin(), ev.end(), prevEdge);
1665 routeOffset = (int)std::distance(ev.begin(), prevEdgePos);
1678 #ifdef DEBUG_MOVEXY_ANGLE 1679 std::cout <<
"internal2:" <<
" prev:";
1683 std::cout <<
" next:";
1687 std::cout << std::endl;
1699 const std::vector<MSLane*>& lanes = edge->
getLanes();
1700 bool newBest =
false;
1701 for (std::vector<MSLane*>::const_iterator k = lanes.begin(); k != lanes.end() && bestDistance >
POSITION_EPS; ++k) {
1702 MSLane* candidateLane = *k;
1705 std::cout <<
" b at lane " << candidateLane->
getID() <<
" dist:" << dist <<
" best:" << bestDistance << std::endl;
1707 if (dist < bestDistance) {
1709 bestDistance = dist;
1710 *lane = candidateLane;
1729 for (ConstMSEdgeVector::const_iterator i = v.
getCurrentRouteEdge(); i != edges.end(); ++i) {
1730 #ifdef HAVE_INTERNAL_LANES 1733 const MSEdge* internalCand = prev->getInternalFollowingEdge(*i);
1735 prev = internalCand;
1739 routeOffset = (int)std::distance(edges.begin(), i);
1746 for (ConstMSEdgeVector::const_iterator i = v.
getCurrentRouteEdge(); i != edges.begin(); --i) {
1748 #ifdef HAVE_INTERNAL_LANES 1751 const MSEdge* internalCand = prev->getInternalFollowingEdge(next);
1753 prev = internalCand;
1757 routeOffset = (int)std::distance(edges.begin(), i);
1766 std::cout <<
" b failed - no best route lane" << std::endl;
1775 const std::vector<MSLane*>& lanes = (*lane)->getEdge().getLanes();
1776 for (std::vector<MSLane*>::const_iterator i = lanes.begin(); i != lanes.end(); ++i) {
1777 if ((*i)->getParameter(
"origId", (*i)->getID()) == origID) {
1785 (*lane)->interpolateGeometryPosToLanePos(
1786 (*lane)->getShape().nearest_offset_to_point2D(pos,
false))));
1789 std::cout <<
" b ok lane " << (*lane)->getID() <<
" lanePos:" << lanePos << std::endl;
1801 if (inputStorage.
readInt() != 2) {
1806 std::pair<const MSLane*, SUMOReal> roadPos;
1813 std::string roadID = inputStorage.
readString();
1816 pos = roadPos.first->getShape().positionAtOffset(roadPos.second);
1823 const double p1x = inputStorage.
readDouble();
1824 const double p1y = inputStorage.
readDouble();
1843 v->
getEdge(), &roadPos.first->getEdge());
1874 std::string newID = oType.
getID().find(
'@') == std::string::npos ? oType.
getID() +
"@" + veh->
getID() : oType.
getID();
1876 static_cast<MSVehicle*
>(veh)->replaceVehicleType(type);
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.
void replaceVehicleType(MSVehicleType *type)
Replaces the current vehicle type by the one given.
bool enterLaneAtMove(MSLane *enteredLane, bool onTeleporting=false)
Update when the vehicle enters a new lane in the move step.
MSEdge & getEdge() const
Returns the lane's edge.
RGBColor color
The vehicle's color, TraCI may change this.
static bool commandDistanceRequest(TraCIServer &server, tcpip::Storage &inputStorage, tcpip::Storage &outputStorage, const MSVehicle *v)
Representation of a vehicle in the micro simulation.
bool isLinkEnd(MSLinkCont::const_iterator &i) const
#define VAR_EMISSIONCLASS
virtual void deleteVehicle(SUMOVehicle *v, bool discard=false)
Deletes the vehicle.
static MSLinkCont::const_iterator succLinkSec(const SUMOVehicle &veh, int nRouteSuccs, const MSLane &succLinkSource, const std::vector< MSLane * > &conts)
#define REQUEST_DRIVINGDIST
SUMOReal rotationAtOffset(SUMOReal pos) const
Returns the rotation at the given length.
void collectObjectsInRange(int domain, const PositionVector &shape, SUMOReal range, std::set< std::string > &into)
const SUMOReal SUMO_const_laneWidth
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.
#define RESPONSE_GET_VEHICLE_VARIABLE
SUMOReal nearest_offset_to_point2D(const Position &p, bool perpendicular=true) const
return the nearest offest to point 2D
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.
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)
SUMOReal getDepartPos() const
Returns this vehicle's real departure position.
void setVTDControlled(MSVehicle *v, Position xyPos, MSLane *l, SUMOReal pos, SUMOReal posLat, SUMOReal angle, int edgeOffset, ConstMSEdgeVector route, SUMOTime t)
const std::vector< MSLane * > & getLanes() const
Returns this edge's lanes.
static const MSLane * getLaneChecking(std::string roadID, int laneIndex, SUMOReal pos)
ArrivalLaneDefinition arrivalLaneProcedure
Information how the vehicle shall choose the lane to arrive on.
int bestLaneOffset
The (signed) number of lanes to be crossed to get to the lane which allows to continue the drive...
const MSRouteIterator & getCurrentRouteEdge() const
Returns an iterator pointing to the current edge in this vehicles route.
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.
constVehIt loadedVehBegin() const
Returns the begin of the internal vehicle map.
SUMOReal getSpeedWithoutTraciInfluence() const
Returns the uninfluenced velocity.
DepartLaneDefinition departLaneProcedure
Information how the vehicle shall choose the lane to depart from.
SUMOReal getLength() const
Returns the lane's length.
Position getPosition(const SUMOReal offset=0) const
Return current position (x/y, cartesian)
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.
virtual double readDouble()
SUMOReal arrivalSpeed
(optional) The final speed of the vehicle (not used yet)
Notification
Definition of a vehicle state.
virtual MSVehicle * removeVehicle(MSVehicle *remVehicle, MSMoveReminder::Notification notification, bool notify=true)
SUMOReal getHCEmissions() const
Returns HC emission of the current state.
static bool getPosition(const std::string &id, Position &p)
Returns the named vehicle's position.
SUMOReal getWidth() const
Returns the lane's width.
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
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
bool replaceRoute(const MSRoute *route, bool onInit=false, int offset=0, bool addStops=true)
Replaces the current route by the given one.
const MSRoute & getRoute() const
Returns the current route.
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 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.
static std::string getIDSecure(const T *obj, const std::string &fallBack="NULL")
get an identifier for Named-like object which may be Null
bool hasDeparted() const
Returns whether this vehicle has already departed.
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...
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)
SUMOReal getCO2Emissions() const
Returns CO2 emission of the current state.
std::vector< const MSEdge * > ConstMSEdgeVector
std::pair< const MSVehicle *const, SUMOReal > getLeader(SUMOReal dist=0) const
Returns the leader of the vehicle looking for a fixed distance.
SUMOReal distanceTo(const Position &p2) const
returns the euclidean distance in 3 dimension
ArrivalSpeedDefinition arrivalSpeedProcedure
Information how the vehicle's end speed shall be chosen.
SUMOReal getPositionOnLane() const
Get the vehicle's position along the lane.
virtual void writeUnsignedByte(int)
const std::string & getParameter(const std::string &key, const std::string &defaultValue) const
Returns the value for a given key.
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
EdgeBasicFunction
Defines possible edge types.
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 x() const
Returns the x-position.
bool hasValidRoute(std::string &msg, const MSRoute *route=0) const
Validates the current or given route.
#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 replaceRouteEdges(ConstMSEdgeVector &edges, bool onInit=false, bool check=false, bool addStops=true)
Replaces the current route by the given edges.
The car-following model and parameter.
bool triggered
whether an arriving person lets the vehicle continue
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) ...
virtual int readUnsignedByte()
std::string toTaz
The vehicle's destination zone (district)
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 getElectricityConsumption() const
Returns electricity consumption of the current state.
unsigned char blue() const
Returns the blue-amount of the color.
const std::string & getID() const
Returns the id.
A road/street connecting two junctions.
MSLane * lane
The described lane.
void setSpeedMode(int speedMode)
Sets speed-constraining behaviors.
#define VAR_PERSON_NUMBER
SUMOReal getLength() const
return the length of the edge
MSLane * getLogicalPredecessorLane() const
get the most likely precedecessor lane (sorted using by_connections_to_sorter). The result is cached ...
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.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
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 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...
#define REMOVE_TELEPORT_ARRIVED
const std::vector< MSLane * > & getBestLanesContinuation() const
Returns the best sequence of lanes to continue the route starting at myLane.
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
bool willPass(const MSEdge *const edge) const
Returns whether the vehicle wil pass the given edge.
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
int size() const
Returns the number of edges to pass.
unsigned char alpha() const
Returns the alpha-amount of the color.
virtual void writeByte(int)
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.
SUMOReal z() const
Returns the z-position.
The vehicle arrived at its destination (is deleted)
bool isStopped() const
Returns whether the vehicle is at a stop.
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.
const ConstMSEdgeVector & getEdges() const
DepartDefinition departProcedure
Information how the vehicle shall choose the depart time.
SUMOTime duration
The stopping duration.
#define CMD_SET_VEHICLE_VARIABLE
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 current route starting at 'lane'...
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.
#define CMD_REROUTE_EFFORT
virtual const MSVehicleType & getVehicleType() const =0
Returns the vehicle's type.
TraCI server used to control sumo by a remote TraCI client.
const int VEHPARS_COLOR_SET
bool isInternal() const
return whether this edge is an internal edge
virtual void writeStorage(tcpip::Storage &store)
int personNumber
The static number of persons in the vehicle when it departs (not including boarding persons) ...
bool isParking() const
Returns whether the vehicle is parking.
const std::vector< LaneQ > & getBestLanes() const
Returns the description of best lanes to use in order to continue the route.
int getRoutePosition() const
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.
int getPersonNumber() const
Returns the number of persons.
bool allowsContinuation
Whether this lane allows to continue the drive.
SUMOReal getHarmonoise_NoiseEmissions() const
Returns noise emissions of the current state.
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.
SUMOReal getNOxEmissions() const
Returns NOx emission of the current state.
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)
SUMOAbstractRouter< MSEdge, SUMOVehicle > & getRouterTT(const MSEdgeVector &prohibited=MSEdgeVector()) const
std::vector< std::string > via
List of the via-edges the vehicle must visit.
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.
SUMOReal getPMxEmissions() const
Returns PMx emission of the current state.
SUMOReal getCOEmissions() const
Returns CO emission of the current state.
#define VAR_EDGE_TRAVELTIME
SUMOReal getWidth() const
Get the width which vehicles of this class shall have when being drawn.
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.
EdgeBasicFunction getPurpose() const
Returns the edge type (EdgeBasicFunction)
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
const MSEdge * succEdge(int nSuccs) const
Returns the nSuccs'th successor of edge the vehicle is currently at.
MSRouteIterator end() const
Returns the end of the list of edges to pass.
SUMOReal getSlope() const
Returns the slope of the road at vehicle's position.
std::string toHex(const T i, std::streamsize numDigits=0)
bool containerTriggered
whether an arriving container lets the vehicle continue
MSInsertionControl & getInsertionControl()
Returns the insertion control.
int setParameter
Information for the router which parameter were set, TraCI may modify this (whe changing color) ...
#define CMD_REROUTE_TRAVELTIME
std::vector< MSLane * > bestContinuations
#define VAR_ELECTRICITYCONSUMPTION
SUMOReal y() const
Returns the y-position.
SUMOReal getFuelConsumption() const
Returns fuel consumption of the current state.
static SUMOReal getMinAngleDiff(SUMOReal angle1, SUMOReal angle2)
Returns the minimum distance (clockwise/counter-clockwise) between both angles.
const MSVehicleType & getVehicleType() const
Returns the vehicle's type definition.
static SUMOReal gLateralResolution
void set(SUMOReal x, SUMOReal y)
set positions x and y
MSRouteIterator edge
The edge in the route to stop at.
SUMOReal getChosenSpeedFactor() const
Returns the precomputed factor by which the driver wants to be faster than the speed limit...
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 std::string & getID() const
Returns the name of the vehicle type.
virtual const std::string & getID() const =0
Get the vehicle's ID.
SUMOReal getSpeed() const
Returns the vehicle's current speed.
const SUMOVehicleParameter & getParameter() const
Returns the vehicle's parameter (including departure definition)
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
SUMOVehicle * getVehicle(const std::string &id) const
Returns the vehicle with the given id.
void setLaneChangeMode(int value)
Sets lane changing behavior.
SUMOReal getWaitingSeconds() const
Returns the number of seconds waited (speed was lesser than 0.1m/s)
virtual void writeDouble(double)
void setSignals(int signals)
const PositionVector & getShape() const
Returns this lane's shape.
SUMOReal distanceTo2D(const Position &p2) const
returns the euclidean distance in the x-y-plane
void move2side(SUMOReal amount)
move position vector to side using certain ammount
const MSEdge * getRerouteOrigin() const
Returns the starting point for reroutes (usually the current edge)
bool knowsEffort(const MSEdge *const e) const
Returns the information whether any effort is known for the given edge.
int getSignals() const
Returns the signals.
unsigned char green() const
Returns the green-amount of the color.
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.
const MSEdgeVector & getSuccessors() const
Returns the following edges.
#define VAR_SPEED_WITHOUT_TRACI
constVehIt loadedVehEnd() const
Returns the end of the internal vehicle map.
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
int getSpeedMode() const
return the current speed mode
bool retrieveExistingEffort(const MSEdge *const e, const SUMOReal t, SUMOReal &value) const
Returns an effort for an edge and time if stored.
void setLaneTimeLine(const std::vector< std::pair< SUMOTime, int > > &laneTimeLine)
Sets a new lane timeline.
const MSEdge * getEdge() const
Returns the edge the vehicle is currently at.
The vehicle was teleported out of the net.
The class responsible for building and deletion of vehicles.
bool knowsTravelTime(const MSEdge *const e) const
Returns the information whether any travel time is known for the given edge.
SUMOReal getVehicleMaxSpeed(const SUMOVehicle *const veh) const
Returns the lane's maximum speed, given a vehicle's speed limit adaptation.
bool isOnRoad() const
Returns the information whether the vehicle is on a road (is simulated)
MSLane * getLane() const
Returns the lane the vehicle is on.
The edge is an internal edge.
Tag for the last element in the enum for safe int casting.
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.
unsigned char red() const
Returns the red-amount of the color.
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.
const MSEdgeWeightsStorage & getWeightsStorage() const
Returns the vehicle's internal edge travel times/efforts container.
bool retrieveExistingTravelTime(const MSEdge *const e, const SUMOReal t, SUMOReal &value) const
Returns a travel time for an edge and time if stored.
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.
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.
static const SUMOReal INVALID_OFFSET
a value to signify offsets outside the range of [0, Line.length()]
MSRouteIterator begin() const
Returns the begin of the list of edges to pass.
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.
SUMOReal getAngle() const
Returns the vehicle's direction in radians.
const std::string & getID() const
Returns the name of the vehicle.
static bool vtdMap_matchingRoutePosition(const Position &pos, const std::string &origID, MSVehicle &v, SUMOReal &bestDistance, MSLane **lane, SUMOReal &lanePos, int &routeOffset, ConstMSEdgeVector &edges)
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.