47 #define DEFAULT_VIEW "View #0" 60 #define SUMOTime_MAX std::numeric_limits<SUMOTime>::max() 82 void connect(
const std::string& host,
int port);
93 void load(
const std::vector<std::string>& args);
155 std::vector<std::string> getIDList()
const;
156 int getIDCount()
const;
157 double getAdaptedTraveltime(
const std::string& edgeID,
double time)
const;
158 double getEffort(
const std::string& edgeID,
SUMOTime time)
const;
159 double getCO2Emission(
const std::string& edgeID)
const;
160 double getCOEmission(
const std::string& edgeID)
const;
161 double getHCEmission(
const std::string& edgeID)
const;
162 double getPMxEmission(
const std::string& edgeID)
const;
163 double getNOxEmission(
const std::string& edgeID)
const;
164 double getFuelConsumption(
const std::string& edgeID)
const;
165 double getNoiseEmission(
const std::string& edgeID)
const;
166 double getElectricityConsumption(
const std::string& edgeID)
const;
167 double getLastStepMeanSpeed(
const std::string& edgeID)
const;
168 double getLastStepOccupancy(
const std::string& edgeID)
const;
169 double getLastStepLength(
const std::string& edgeID)
const;
170 double getTraveltime(
const std::string& edgeID)
const;
171 int getLastStepVehicleNumber(
const std::string& edgeID)
const;
172 double getLastStepHaltingNumber(
const std::string& edgeID)
const;
173 std::vector<std::string> getLastStepVehicleIDs(
const std::string& edgeID)
const;
175 void adaptTraveltime(
const std::string& edgeID,
double time,
double begin = 0,
double end =
SUMOTime_MAX / 1000.0)
const;
177 void setMaxSpeed(
const std::string& edgeID,
double speed)
const;
200 std::vector<std::string> getIDList()
const;
201 double getZoom(
const std::string& viewID =
DEFAULT_VIEW)
const;
203 std::string getSchema(
const std::string& viewID =
DEFAULT_VIEW)
const;
205 void setZoom(
const std::string& viewID,
double zoom)
const;
206 void setOffset(
const std::string& viewID,
double x,
double y)
const;
207 void setSchema(
const std::string& viewID,
const std::string& schemeName)
const;
208 void setBoundary(
const std::string& viewID,
double xmin,
double ymin,
double xmax,
double ymax)
const;
209 void screenshot(
const std::string& viewID,
const std::string& filename)
const;
210 void trackVehicle(
const std::string& viewID,
const std::string& vehID)
const;
233 std::vector<std::string> getIDList()
const;
234 double getPosition(
const std::string& loopID)
const;
235 std::string getLaneID(
const std::string& loopID)
const;
236 int getLastStepVehicleNumber(
const std::string& loopID)
const;
237 double getLastStepMeanSpeed(
const std::string& loopID)
const;
238 std::vector<std::string> getLastStepVehicleIDs(
const std::string& loopID)
const;
239 double getLastStepOccupancy(
const std::string& loopID)
const;
240 double getLastStepMeanLength(
const std::string& loopID)
const;
241 double getTimeSinceDetection(
const std::string& loopID)
const;
242 std::vector<TraCIVehicleData> getVehicleData(
const std::string& loopID)
const;
266 std::vector<std::string> getIDList()
const;
290 std::vector<std::string> getIDList()
const;
291 double getLength(
const std::string& laneID)
const;
292 double getMaxSpeed(
const std::string& laneID)
const;
293 double getWidth(
const std::string& laneID)
const;
294 std::vector<std::string> getAllowed(
const std::string& laneID)
const;
295 std::vector<std::string> getDisallowed(
const std::string& laneID)
const;
296 int getLinkNumber(
const std::string& laneID)
const;
298 std::string getEdgeID(
const std::string& laneID)
const;
299 double getCO2Emission(
const std::string& laneID)
const;
300 double getCOEmission(
const std::string& laneID)
const;
301 double getHCEmission(
const std::string& laneID)
const;
302 double getPMxEmission(
const std::string& laneID)
const;
303 double getNOxEmission(
const std::string& laneID)
const;
304 double getFuelConsumption(
const std::string& laneID)
const;
305 double getNoiseEmission(
const std::string& laneID)
const;
306 double getElectricityConsumption(
const std::string& laneID)
const;
307 double getLastStepMeanSpeed(
const std::string& laneID)
const;
308 double getLastStepOccupancy(
const std::string& laneID)
const;
309 double getLastStepLength(
const std::string& laneID)
const;
310 double getTraveltime(
const std::string& laneID)
const;
311 int getLastStepVehicleNumber(
const std::string& laneID)
const;
312 int getLastStepHaltingNumber(
const std::string& laneID)
const;
313 std::vector<std::string> getLastStepVehicleIDs(
const std::string& laneID)
const;
315 void setAllowed(
const std::string& laneID,
const std::vector<std::string>& allowedClasses)
const;
316 void setDisallowed(
const std::string& laneID,
const std::vector<std::string>& disallowedClasses)
const;
317 void setMaxSpeed(
const std::string& laneID,
double speed)
const;
318 void setLength(
const std::string& laneID,
double length)
const;
338 std::vector<std::string> getIDList()
const;
358 std::vector<std::string> getIDList()
const;
359 int getLastStepVehicleNumber(
const std::string& detID)
const;
360 double getLastStepMeanSpeed(
const std::string& detID)
const;
361 std::vector<std::string> getLastStepVehicleIDs(
const std::string& detID)
const;
362 int getLastStepHaltingNumber(
const std::string& detID)
const;
385 std::vector<std::string> getIDList()
const;
386 std::string getType(
const std::string& poiID)
const;
390 void setType(
const std::string& poiID,
const std::string& setType)
const;
391 void setPosition(
const std::string& poiID,
double x,
double y)
const;
392 void setColor(
const std::string& poiID,
const TraCIColor& c)
const;
393 void add(
const std::string& poiID,
double x,
double y,
const TraCIColor& c,
const std::string& type,
int layer)
const;
394 void remove(
const std::string& poiID,
int layer = 0)
const;
417 std::vector<std::string> getIDList()
const;
418 std::string getType(
const std::string& polygonID)
const;
421 void setType(
const std::string& polygonID,
const std::string& setType)
const;
423 void setColor(
const std::string& polygonID,
const TraCIColor& c)
const;
424 void add(
const std::string& polygonID,
const TraCIPositionVector& shape,
const TraCIColor& c,
bool fill,
const std::string& type,
int layer)
const;
425 void remove(
const std::string& polygonID,
int layer = 0)
const;
448 std::vector<std::string> getIDList()
const;
449 std::vector<std::string> getEdges(
const std::string& routeID)
const;
451 void add(
const std::string& routeID,
const std::vector<std::string>& edges)
const;
479 int getLoadedNumber()
const;
480 std::vector<std::string> getLoadedIDList()
const;
481 int getDepartedNumber()
const;
482 std::vector<std::string> getDepartedIDList()
const;
483 int getArrivedNumber()
const;
484 std::vector<std::string> getArrivedIDList()
const;
485 int getStartingTeleportNumber()
const;
486 std::vector<std::string> getStartingTeleportIDList()
const;
487 int getEndingTeleportNumber()
const;
488 std::vector<std::string> getEndingTeleportIDList()
const;
491 int getMinExpectedNumber()
const;
493 void subscribe(
int domID,
const std::string& objID,
SUMOTime beginTime,
SUMOTime endTime,
const std::vector<int>& vars)
const;
494 void subscribeContext(
int domID,
const std::string& objID,
SUMOTime beginTime,
SUMOTime endTime,
int domain,
double range,
const std::vector<int>& vars)
const;
496 const SubscribedValues& getSubscriptionResults()
const;
497 const TraCIValues& getSubscriptionResults(
const std::string& objID)
const;
499 const SubscribedContextValues& getContextSubscriptionResults()
const;
500 const SubscribedValues& getContextSubscriptionResults(
const std::string& objID)
const;
523 std::vector<std::string> getIDList()
const;
524 std::string getRedYellowGreenState(
const std::string& tlsID)
const;
525 std::vector<TraCILogic> getCompleteRedYellowGreenDefinition(
const std::string& tlsID)
const;
526 std::vector<std::string> getControlledLanes(
const std::string& tlsID)
const;
527 std::vector<TraCILink> getControlledLinks(
const std::string& tlsID)
const;
528 std::string getProgram(
const std::string& tlsID)
const;
529 int getPhase(
const std::string& tlsID)
const;
530 int getNextSwitch(
const std::string& tlsID)
const;
532 void setRedYellowGreenState(
const std::string& tlsID,
const std::string& state)
const;
533 void setPhase(
const std::string& tlsID,
int index)
const;
534 void setProgram(
const std::string& tlsID,
const std::string& programID)
const;
535 void setPhaseDuration(
const std::string& tlsID,
int phaseDuration)
const;
536 void setCompleteRedYellowGreenDefinition(
const std::string& tlsID,
const TraCILogic& logic)
const;
559 std::vector<std::string> getIDList()
const;
560 double getLength(
const std::string& typeID)
const;
561 double getMaxSpeed(
const std::string& typeID)
const;
562 double getSpeedFactor(
const std::string& typeID)
const;
563 double getSpeedDeviation(
const std::string& typeID)
const;
564 double getAccel(
const std::string& typeID)
const;
565 double getDecel(
const std::string& typeID)
const;
566 double getImperfection(
const std::string& typeID)
const;
567 double getTau(
const std::string& typeID)
const;
568 std::string getVehicleClass(
const std::string& typeID)
const;
569 std::string getEmissionClass(
const std::string& typeID)
const;
570 std::string getShapeClass(
const std::string& typeID)
const;
571 double getMinGap(
const std::string& typeID)
const;
572 double getWidth(
const std::string& typeID)
const;
573 double getHeight(
const std::string& typeID)
const;
575 double getMinGapLat(
const std::string& typeID)
const;
576 double getMaxSpeedLat(
const std::string& typeID)
const;
577 std::string getLateralAlignment(
const std::string& typeID)
const;
579 void setLength(
const std::string& typeID,
double length)
const;
580 void setMaxSpeed(
const std::string& typeID,
double speed)
const;
581 void setVehicleClass(
const std::string& typeID,
const std::string& clazz)
const;
582 void setSpeedFactor(
const std::string& typeID,
double factor)
const;
583 void setSpeedDeviation(
const std::string& typeID,
double deviation)
const;
584 void setEmissionClass(
const std::string& typeID,
const std::string& clazz)
const;
585 void setShapeClass(
const std::string& typeID,
const std::string& shapeClass)
const;
586 void setWidth(
const std::string& typeID,
double width)
const;
587 void setHeight(
const std::string& typeID,
double height)
const;
588 void setMinGap(
const std::string& typeID,
double minGap)
const;
589 void setAccel(
const std::string& typeID,
double accel)
const;
590 void setDecel(
const std::string& typeID,
double decel)
const;
591 void setImperfection(
const std::string& typeID,
double imperfection)
const;
592 void setTau(
const std::string& typeID,
double tau)
const;
593 void setColor(
const std::string& typeID,
const TraCIColor& c)
const;
594 void setMinGapLat(
const std::string& typeID,
double minGapLat)
const;
595 void setMaxSpeedLat(
const std::string& typeID,
double speed)
const;
596 void setLateralAlignment(
const std::string& typeID,
const std::string& latAlignment)
const;
634 std::vector<std::string> getIDList()
const;
635 int getIDCount()
const;
636 double getSpeed(
const std::string& vehicleID)
const;
637 double getMaxSpeed(
const std::string& vehicleID)
const;
639 double getAngle(
const std::string& vehicleID)
const;
640 std::string getRoadID(
const std::string& vehicleID)
const;
641 std::string getLaneID(
const std::string& vehicleID)
const;
642 int getLaneIndex(
const std::string& vehicleID)
const;
643 std::string getTypeID(
const std::string& vehicleID)
const;
644 std::string getRouteID(
const std::string& vehicleID)
const;
645 int getRouteIndex(
const std::string& vehicleID)
const;
646 std::vector<std::string> getEdges(
const std::string& vehicleID)
const;
648 double getLanePosition(
const std::string& vehicleID)
const;
649 double getLateralLanePosition(
const std::string& vehicleID)
const;
650 double getCO2Emission(
const std::string& vehicleID)
const;
651 double getCOEmission(
const std::string& vehicleID)
const;
652 double getHCEmission(
const std::string& vehicleID)
const;
653 double getPMxEmission(
const std::string& vehicleID)
const;
654 double getNOxEmission(
const std::string& vehicleID)
const;
655 double getFuelConsumption(
const std::string& vehicleID)
const;
656 double getNoiseEmission(
const std::string& vehicleID)
const;
657 double getElectricityConsumption(
const std::string& vehicleID)
const;
658 int getSignalStates(
const std::string& vehicleID)
const;
659 double getWaitingTime(
const std::string& vehicleID)
const;
660 std::vector<NextTLSData> getNextTLS(
const std::string& vehID)
const;
661 int getSpeedMode(
const std::string& vehicleID)
const;
662 double getSlope(
const std::string& vehicleID)
const;
663 std::string getLine(
const std::string& vehicleID)
const;
664 std::vector<std::string> getVia(
const std::string& vehicleID)
const;
665 std::string getEmissionClass(
const std::string& vehicleID)
const;
666 std::string getShapeClass(
const std::string& vehicleID)
const;
683 void add(
const std::string& vehicleID,
684 const std::string& routeID,
685 const std::string& typeID =
"DEFAULT_VEHTYPE",
686 std::string depart =
"-1",
687 const std::string& departLane =
"first",
688 const std::string& departPos =
"base",
689 const std::string& departSpeed =
"0",
690 const std::string& arrivalLane =
"current",
691 const std::string& arrivalPos =
"max",
692 const std::string& arrivalSpeed =
"current",
693 const std::string& fromTaz =
"",
694 const std::string& toTaz =
"",
695 const std::string& line =
"",
696 int personCapacity = 0,
697 int personNumber = 0)
const;
699 void changeTarget(
const std::string& vehicleID,
const std::string& edgeID)
const;
700 void moveTo(
const std::string& vehicleID,
const std::string& laneID,
double position)
const;
701 void moveToXY(
const std::string& vehicleID,
const std::string& edgeID,
const int lane,
const double x,
const double y,
const double angle,
const int keepRoute)
const;
702 void slowDown(
const std::string& vehicleID,
double speed,
int duration)
const;
703 void setSpeed(
const std::string& vehicleID,
double speed)
const;
704 void setMaxSpeed(
const std::string& vehicleID,
double speed)
const;
705 void remove(
const std::string& vehicleID,
char reason =
REMOVE_VAPORIZED)
const;
706 void setColor(
const std::string& vehicleID,
const TraCIColor& c)
const;
707 void setLine(
const std::string& vehicleID,
const std::string& line)
const;
708 void setVia(
const std::string& vehicleID,
const std::vector<std::string>& via)
const;
709 void setShapeClass(
const std::string& vehicleID,
const std::string& clazz)
const;
710 void setEmissionClass(
const std::string& vehicleID,
const std::string& clazz)
const;
729 std::vector<std::string> getIDList()
const;
730 int getIDCount()
const;
731 double getSpeed(
const std::string& personID)
const;
733 std::string getRoadID(
const std::string& personID)
const;
734 std::string getTypeID(
const std::string& personID)
const;
735 double getWaitingTime(
const std::string& personID)
const;
736 std::string getNextEdge(
const std::string& personID)
const;
737 std::string getVehicle(
const std::string& personID)
const;
738 int getRemainingStages(
const std::string& personID)
const;
739 int getStage(
const std::string& personID,
int nextStageIndex = 0)
const;
740 std::vector<std::string> getEdges(
const std::string& personID,
int nextStageIndex = 0)
const;
742 void removeStages(
const std::string& personID)
const;
743 void add(
const std::string& personID,
const std::string& edgeID,
double pos,
double depart =
DEPARTFLAG_NOW,
const std::string typeID =
"DEFAULT_PEDTYPE");
744 void appendWaitingStage(
const std::string& personID,
double duration,
const std::string& description =
"waiting",
const std::string& stopID =
"");
745 void appendWalkingStage(
const std::string& personID,
const std::vector<std::string>& edges,
double arrivalPos,
double duration = -1,
double speed = -1,
const std::string& stopID =
"");
746 void appendDrivingStage(
const std::string& personID,
const std::string& toEdge,
const std::string& lines,
const std::string& stopID =
"");
747 void removeStage(
const std::string& personID,
int nextStageIndex)
const;
748 void setSpeed(
const std::string& personID,
double speed)
const;
749 void setType(
const std::string& personID,
const std::string& typeID)
const;
750 void setLength(
const std::string& personID,
double length)
const;
751 void setWidth(
const std::string& personID,
double width)
const;
752 void setHeight(
const std::string& personID,
double height)
const;
753 void setMinGap(
const std::string& personID,
double minGap)
const;
754 void setColor(
const std::string& personID,
const TraCIColor& c)
const;
851 int domain,
double range,
const std::vector<int>& vars)
const;
855 void send_commandMoveToXY(
const std::string& vehicleID,
const std::string& edgeID,
const int lane,
856 const double x,
const double y,
const double angle,
const int keepRoute)
const;
884 std::ostringstream oss;
885 oss.setf(std::ios::fixed , std::ios::floatfield);
886 oss << std::setprecision(accuracy);
EdgeScope edge
Scope for interaction with edges.
char state
The current state of the tls.
LaneScope(TraCIAPI &parent)
void send_commandSetValue(int domID, int varID, const std::string &objID, tcpip::Storage &content) const
Sends a SetVariable request.
tcpip::Socket * mySocket
The socket.
C++ TraCI client API implementation.
void close()
ends the simulation and closes the connection
Scope for interaction with edges.
void check_resultState(tcpip::Storage &inMsg, int command, bool ignoreCommandId=false, std::string *acknowledgement=0) const
Validates the result state of a command.
void connect(const std::string &host, int port)
Connects to the specified SUMO server.
MeMeScope(TraCIAPI &parent)
std::map< int, TraCIValue > TraCIValues
{object->{variable->value}}
GUIScope(TraCIAPI &parent)
virtual ~TrafficLightScope()
TraCIScopeWrapper & operator=(const TraCIScopeWrapper &src)
invalidated assignment operator
JunctionScope junction
Scope for interaction with junctions.
PersonScope(TraCIAPI &parent)
void send_commandGetVariable(int domID, int varID, const std::string &objID, tcpip::Storage *add=0) const
Sends a GetVariable request.
LaneScope lane
Scope for interaction with lanes.
PersonScope person
Scope for interaction with persons.
void load(const std::vector< std::string > &args)
Let sumo load a simulation using the given command line like options.
Scope for interaction with vehicles.
Scope for interaction with traffic lights.
SubscribedContextValues mySubscribedContextValues
void closeSocket()
Closes the connection.
void simulationStep(SUMOTime time=0)
Advances by one step (or up to the given time)
Scope for interaction with lane area detectors.
Scope for interaction with the gui.
TrafficLightScope trafficlights
Scope for interaction with traffic lights.
void readVariableSubscription(tcpip::Storage &inMsg)
std::map< std::string, SubscribedValues > SubscribedContextValues
Scope for interaction with routes.
InductionLoopScope inductionloop
Scope for interaction with inductive loops.
TraCIPosition getPosition(int cmd, int var, const std::string &id, tcpip::Storage *add=0)
Scope for interaction with inductive loops.
POIScope(TraCIAPI &parent)
Scope for interaction with POIs.
Scope for interaction with the simulation.
Scope for interaction with multi entry/-exit detectors.
SubscribedValues mySubscribedValues
InductionLoopScope(TraCIAPI &parent)
MeMeScope multientryexit
Scope for interaction with multi-entry/-exit detectors.
std::map< std::string, TraCIValues > SubscribedValues
Scope for interaction with vehicle types.
PolygonScope(TraCIAPI &parent)
double getFloat(int cmd, int var, const std::string &id, tcpip::Storage *add=0)
void send_commandSubscribeObjectVariable(int domID, const std::string &objID, SUMOTime beginTime, SUMOTime endTime, const std::vector< int > &vars) const
Sends a SubscribeVariable request.
RouteScope route
Scope for interaction with routes.
void send_commandSimulationStep(SUMOTime time) const
Sends a SimulationStep command.
virtual ~InductionLoopScope()
Scope for interaction with polygons.
void send_commandMoveToXY(const std::string &vehicleID, const std::string &edgeID, const int lane, const double x, const double y, const double angle, const int keepRoute) const
int getInt(int cmd, int var, const std::string &id, tcpip::Storage *add=0)
int getByte(int cmd, int var, const std::string &id, tcpip::Storage *add=0)
static std::string toString(const T &t, std::streamsize accuracy=PRECISION)
int getUnsignedByte(int cmd, int var, const std::string &id, tcpip::Storage *add=0)
double getDouble(int cmd, int var, const std::string &id, tcpip::Storage *add=0)
Scope for interaction with vehicles.
Scope for interaction with junctions.
TrafficLightScope(TraCIAPI &parent)
void readContextSubscription(tcpip::Storage &inMsg)
TraCIPositionVector getPolygon(int cmd, int var, const std::string &id, tcpip::Storage *add=0)
void readVariables(tcpip::Storage &inMsg, const std::string &objectID, int variableCount, SubscribedValues &into)
virtual ~SimulationScope()
std::vector< std::string > getStringVector(int cmd, int var, const std::string &id, tcpip::Storage *add=0)
EdgeScope(TraCIAPI &parent)
POIScope poi
Scope for interaction with POIs.
SimulationScope simulation
Scope for interaction with the simulation.
Scope for interaction with lanes.
TraCIScopeWrapper(TraCIAPI &parent)
Constructor.
RouteScope(TraCIAPI &parent)
VehicleScope vehicle
Scope for interaction with vehicles.
SUMOTime getSUMOTime(int cmd, int var, const std::string &id, tcpip::Storage *add=0)
void processGET(tcpip::Storage &inMsg, int command, int expectedType, bool ignoreCommandId=false) const
std::string id
The id of the next tls.
PolygonScope polygon
Scope for interaction with polygons.
virtual ~TraCIScopeWrapper()
Destructor.
VehicleTypeScope(TraCIAPI &parent)
void send_commandClose() const
Sends a Close command.
TraCIAPI & myParent
The parent TraCI client which offers the connection.
int check_commandGetResult(tcpip::Storage &inMsg, int command, int expectedType=-1, bool ignoreCommandId=false) const
Validates the result state of a command.
TraCIBoundary getBoundingBox(int cmd, int var, const std::string &id, tcpip::Storage *add=0)
GUIScope gui
Scope for interaction with the gui.
TraCIColor getColor(int cmd, int var, const std::string &id, tcpip::Storage *add=0)
std::string getString(int cmd, int var, const std::string &id, tcpip::Storage *add=0)
VehicleScope(TraCIAPI &parent)
SimulationScope(TraCIAPI &parent)
double dist
The distance to the tls.
An abstract interface for accessing type-dependent values.
LaneAreaScope lanearea
Scope for interaction with lanes.
virtual ~VehicleTypeScope()
int tlIndex
The tls index of the controlled link.
LaneAreaScope(TraCIAPI &parent)
void send_commandSubscribeObjectContext(int domID, const std::string &objID, SUMOTime beginTime, SUMOTime endTime, int domain, double range, const std::vector< int > &vars) const
Sends a SubscribeContext request.
JunctionScope(TraCIAPI &parent)
VehicleTypeScope vehicletype
Scope for interaction with vehicle types.