28#pragma warning(disable: 4514 4820)
57#define LIBSUMO_NAMESPACE libtraci
59#define LIBSUMO_NAMESPACE libsumo
62#define LIBSUMO_SUBSCRIPTION_API \
63static void subscribe(const std::string& objectID, const std::vector<int>& varIDs = std::vector<int>({-1}), \
64 double begin = libsumo::INVALID_DOUBLE_VALUE, double end = libsumo::INVALID_DOUBLE_VALUE, const libsumo::TraCIResults& parameters = libsumo::TraCIResults()); \
65static void unsubscribe(const std::string& objectID); \
66static void subscribeContext(const std::string& objectID, int domain, double dist, const std::vector<int>& varIDs = std::vector<int>({-1}), \
67 double begin = libsumo::INVALID_DOUBLE_VALUE, double end = libsumo::INVALID_DOUBLE_VALUE, const libsumo::TraCIResults& parameters = libsumo::TraCIResults()); \
68static void unsubscribeContext(const std::string& objectID, int domain, double dist); \
69static const libsumo::SubscriptionResults getAllSubscriptionResults(); \
70static const libsumo::TraCIResults getSubscriptionResults(const std::string& objectID); \
71static const libsumo::ContextSubscriptionResults getAllContextSubscriptionResults(); \
72static const libsumo::SubscriptionResults getContextSubscriptionResults(const std::string& objectID); \
73static void subscribeParameterWithKey(const std::string& objectID, const std::string& key, double beginTime = libsumo::INVALID_DOUBLE_VALUE, double endTime = libsumo::INVALID_DOUBLE_VALUE); \
74static const int DOMAIN_ID; \
75static int domainID() { return DOMAIN_ID; }
77#define LIBSUMO_SUBSCRIPTION_IMPLEMENTATION(CLASS, DOM) \
78const int CLASS::DOMAIN_ID(libsumo::CMD_GET_##DOM##_VARIABLE); \
80CLASS::subscribe(const std::string& objectID, const std::vector<int>& varIDs, double begin, double end, const libsumo::TraCIResults& parameters) { \
81 libsumo::Helper::subscribe(libsumo::CMD_SUBSCRIBE_##DOM##_VARIABLE, objectID, varIDs, begin, end, parameters); \
84CLASS::unsubscribe(const std::string& objectID) { \
85 libsumo::Helper::subscribe(libsumo::CMD_SUBSCRIBE_##DOM##_VARIABLE, objectID, std::vector<int>(), libsumo::INVALID_DOUBLE_VALUE, libsumo::INVALID_DOUBLE_VALUE, libsumo::TraCIResults()); \
88CLASS::subscribeContext(const std::string& objectID, int domain, double dist, const std::vector<int>& varIDs, double begin, double end, const TraCIResults& parameters) { \
89 libsumo::Helper::subscribe(libsumo::CMD_SUBSCRIBE_##DOM##_CONTEXT, objectID, varIDs, begin, end, parameters, domain, dist); \
92CLASS::unsubscribeContext(const std::string& objectID, int domain, double dist) { \
93 libsumo::Helper::subscribe(libsumo::CMD_SUBSCRIBE_##DOM##_CONTEXT, objectID, std::vector<int>(), libsumo::INVALID_DOUBLE_VALUE, libsumo::INVALID_DOUBLE_VALUE, libsumo::TraCIResults(), domain, dist); \
95const libsumo::SubscriptionResults \
96CLASS::getAllSubscriptionResults() { \
97 return mySubscriptionResults; \
99const libsumo::TraCIResults \
100CLASS::getSubscriptionResults(const std::string& objectID) { \
101 return mySubscriptionResults[objectID]; \
103const libsumo::ContextSubscriptionResults \
104CLASS::getAllContextSubscriptionResults() { \
105 return myContextSubscriptionResults; \
107const libsumo::SubscriptionResults \
108CLASS::getContextSubscriptionResults(const std::string& objectID) { \
109 return myContextSubscriptionResults[objectID]; \
112CLASS::subscribeParameterWithKey(const std::string& objectID, const std::string& key, double beginTime, double endTime) { \
113 libsumo::Helper::subscribe(libsumo::CMD_SUBSCRIBE_##DOM##_VARIABLE, objectID, std::vector<int>({libsumo::VAR_PARAMETER_WITH_KEY}), beginTime, endTime, libsumo::TraCIResults {{libsumo::VAR_PARAMETER_WITH_KEY, std::make_shared<libsumo::TraCIString>(key)}}); \
117#define LIBSUMO_ID_PARAMETER_API \
118static std::vector<std::string> getIDList(); \
119static int getIDCount(); \
120static std::string getParameter(const std::string& objectID, const std::string& key); \
121static const std::pair<std::string, std::string> getParameterWithKey(const std::string& objectID, const std::string& key); \
122static void setParameter(const std::string& objectID, const std::string& key, const std::string& value);
124#define LIBSUMO_GET_PARAMETER_WITH_KEY_IMPLEMENTATION(CLASS) \
125const std::pair<std::string, std::string> \
126CLASS::getParameterWithKey(const std::string& objectID, const std::string& key) { \
127 return std::make_pair(key, getParameter(objectID, key)); \
131#define SWIGJAVA_CAST(CLASS) \
132static std::shared_ptr<CLASS> cast(std::shared_ptr<TraCIResult> res) { \
133 return std::dynamic_pointer_cast<CLASS>(res); \
149 :
std::runtime_error(what) {}
160 :
std::runtime_error(what) {}
181 std::ostringstream os;
182 os <<
"TraCIPosition(" <<
x <<
"," <<
y;
204 std::ostringstream os;
226 std::ostringstream os;
227 os <<
"TraCIColor(" <<
r <<
"," <<
g <<
"," <<
b <<
"," <<
a <<
")";
242 std::ostringstream os;
245 os <<
"(" << v.x <<
"," << v.y <<
"," << v.z <<
")";
260 std::ostringstream os;
278 std::ostringstream os;
309 std::ostringstream os;
311 for (std::string v :
value) {
326 std::ostringstream os;
328 for (
double v :
value) {
343 std::ostringstream os;
345 for (
int v :
value) {
360 std::ostringstream os;
362 for (
const auto& v :
value) {
363 os <<
"(" << v.first <<
"," << v.second <<
"),";
368 std::vector<std::pair<std::string, double> >
value;
376typedef std::map<int, std::shared_ptr<libsumo::TraCIResult> >
TraCIResults;
386 const std::vector<int>& _next = std::vector<int>(),
387 const std::string& _name =
"",
388 const std::string& _earlyTarget =
"") :
403%
template(TraCIPhaseVector) std::vector<std::shared_ptr<libsumo::TraCIPhase> >;
410 TraCILogic(
const std::string& _programID,
const int _type,
const int _currentPhaseIndex,
411 const std::vector<std::shared_ptr<libsumo::TraCIPhase> >& _phases = std::vector<std::shared_ptr<libsumo::TraCIPhase> >())
412 : programID(_programID), type(_type), currentPhaseIndex(_currentPhaseIndex), phases(_phases) {}
416 std::ostringstream os;
417 os <<
"TraCILink(" << programID <<
"," << type <<
"," << currentPhaseIndex <<
")";
424 std::vector<std::shared_ptr<libsumo::TraCIPhase> >
phases;
431 std::ostringstream os;
432 os <<
"TraCILogicVectorWrapped[";
434 os << v.getString() <<
",";
446 TraCILink(
const std::string& _from,
const std::string& _via,
const std::string& _to)
447 : fromLane(_from), viaLane(_via), toLane(_to) {}
451 std::ostringstream os;
452 os <<
"TraCILink(" << fromLane <<
"," << viaLane <<
"," << toLane <<
")";
464 std::ostringstream os;
465 os <<
"TraCILinkVectorVectorWrapped[";
466 for (
const std::vector<TraCILink>& v : value) {
469 os << tl.getString() <<
",";
476 std::vector<std::vector<TraCILink> >
value;
482 TraCIConnection(
const std::string& _approachedLane,
const bool _hasPrio,
const bool _isOpen,
const bool _hasFoe,
483 const std::string _approachedInternal,
const std::string _state,
const std::string _direction,
const double _length)
484 : approachedLane(_approachedLane), hasPrio(_hasPrio), isOpen(_isOpen), hasFoe(_hasFoe),
485 approachedInternal(_approachedInternal), state(_state), direction(_direction), length(_length) {}
489 std::ostringstream os;
490 os <<
"TraCIConnection(" << approachedLane <<
"," << hasPrio <<
"," << isOpen
491 <<
"," << hasFoe <<
"," << approachedInternal <<
"," << state <<
"," << direction <<
"," << length <<
")";
508 std::ostringstream os;
509 os <<
"TraCIConnectionVectorWrapped[";
511 os << v.getString() <<
",";
524 std::ostringstream os;
525 os <<
"TraCIVehicleData(" <<
id <<
"," << length <<
"," << entryTime
526 <<
"," << leaveTime <<
"," << typeID <<
")";
545 std::ostringstream os;
546 os <<
"TraCIVehicleDataVectorWrapped[";
548 os << v.getString() <<
",";
554 std::vector<TraCIVehicleData>
value;
560 std::ostringstream os;
561 os <<
"TraCINextTLSData(" <<
id <<
"," << tlIndex <<
"," << dist
562 <<
"," << state <<
")";
579 std::ostringstream os;
580 os <<
"TraCINextTLSDataVectorWrapped[";
582 os << v.getString() <<
",";
588 std::vector<TraCINextTLSData>
value;
595 double startPos = INVALID_DOUBLE_VALUE,
596 double endPos = INVALID_DOUBLE_VALUE,
597 const std::string& stoppingPlaceID =
"",
599 double duration = INVALID_DOUBLE_VALUE,
600 double until = INVALID_DOUBLE_VALUE,
601 double intendedArrival = INVALID_DOUBLE_VALUE,
602 double arrival = INVALID_DOUBLE_VALUE,
603 double depart = INVALID_DOUBLE_VALUE,
604 const std::string&
split =
"",
605 const std::string& join =
"",
606 const std::string& actType =
"",
607 const std::string& tripId =
"",
608 const std::string& line =
"",
613 stoppingPlaceID(stoppingPlaceID),
614 stopFlags(stopFlags),
617 intendedArrival(intendedArrival),
629 std::ostringstream os;
630 os <<
"TraCINextStopData(" << lane <<
"," << endPos <<
"," << stoppingPlaceID
631 <<
"," << stopFlags <<
"," << duration <<
"," << until
632 <<
"," << arrival <<
")";
677 std::ostringstream os;
678 os <<
"TraCINextStopDataVectorWrapped[";
680 os << v.getString() <<
",";
686 std::vector<TraCINextStopData>
value;
692 std::ostringstream os;
693 os <<
"TraCIBestLanesData(" << laneID <<
"," << length <<
"," << occupation
694 <<
"," << bestLaneOffset <<
"," << allowsContinuation <<
",[";
695 for (
const std::string& s : continuationLanes) {
719 std::ostringstream os;
720 os <<
"TraCIBestLanesDataVectorWrapped[";
722 os << v.getString() <<
",";
728 std::vector<TraCIBestLanesData>
value;
734 TraCIStage(
int type = INVALID_INT_VALUE,
const std::string& vType =
"",
const std::string& line =
"",
const std::string& destStop =
"",
735 const std::vector<std::string>& edges = std::vector<std::string>(),
736 double travelTime = INVALID_DOUBLE_VALUE,
double cost = INVALID_DOUBLE_VALUE,
double length = INVALID_DOUBLE_VALUE,
737 const std::string& intended =
"",
double depart = INVALID_DOUBLE_VALUE,
double departPos = INVALID_DOUBLE_VALUE,
738 double arrivalPos = INVALID_DOUBLE_VALUE,
const std::string& description =
"") :
739 type(type), vType(vType), line(line), destStop(destStop), edges(edges), travelTime(travelTime), cost(cost),
740 length(length), intended(intended), depart(depart), departPos(departPos), arrivalPos(arrivalPos), description(description) {}
774 const std::vector<std::string>& persons,
775 const std::string& group,
776 const std::string& fromEdge,
777 const std::string& toEdge,
781 double reservationTime,
783 id(id), persons(persons), group(group), fromEdge(fromEdge), toEdge(toEdge), departPos(departPos), arrivalPos(arrivalPos),
784 depart(depart), reservationTime(reservationTime), state(state) {}
807 std::ostringstream os;
808 os <<
"TraCIReservation(id=" <<
id <<
")";
816 std::ostringstream os;
817 os <<
"TraCIReservationVectorWrapped[";
819 os << v.getString() <<
",";
825 std::vector<TraCIReservation>
value;
845 std::ostringstream os;
846 os <<
"TraCICollision(collider=" << collider <<
", victim=" << victim <<
")";
854 std::ostringstream os;
855 os <<
"TraCICollisionVectorWrapped[";
857 os << v.getString() <<
",";
885 std::map<std::string, std::string>
param;
888 std::ostringstream os;
889 os <<
"TraCISignalConstraint(signalId=" << signalId <<
", tripid=" << tripId <<
", foeSignal=" << foeSignal <<
", foeId=" << foeId <<
")";
897 std::ostringstream os;
898 os <<
"TraCISignalConstraintVectorWrapped[";
900 os << v.getString() <<
",";
906 std::vector<TraCISignalConstraint>
value;
923 std::ostringstream os;
924 os <<
"TraCIJunctionFoe(foeId=" << foeId <<
", egoDist=" << egoDist <<
", foeDist=" << foeDist <<
", foeDist=" << foeDist <<
")";
932 std::ostringstream os;
933 os <<
"TraCIJunctionFoeVectorWrapped[";
935 os << v.getString() <<
",";
941 std::vector<TraCIJunctionFoe>
value;
std::vector< std::string > & split(const std::string &s, char delim, std::vector< std::string > &elems)
#define SWIGJAVA_CAST(CLASS)
An error which is not recoverable.
FatalTraCIError(std::string what)
An error which allows to continue.
TraCIException(std::string what)
TRACI_CONST double INVALID_DOUBLE_VALUE
TRACI_CONST int POSITION_3D
TRACI_CONST int POSITION_ROADMAP
std::map< std::string, libsumo::SubscriptionResults > ContextSubscriptionResults
TRACI_CONST int POSITION_2D
TRACI_CONST int TYPE_INTEGER
std::map< std::string, libsumo::TraCIResults > SubscriptionResults
{object->{variable->value}}
TRACI_CONST int INVALID_INT_VALUE
TRACI_CONST int TYPE_DOUBLE
std::map< int, std::shared_ptr< libsumo::TraCIResult > > TraCIResults
{variable->value}
TRACI_CONST int TYPE_STRING
double length
The length than can be driven from that lane without lane change.
std::string getString() const
double occupation
The traffic density along length.
bool allowsContinuation
Whether this lane allows continuing the route.
int bestLaneOffset
The offset of this lane from the best lane.
std::vector< std::string > continuationLanes
The sequence of lanes that best allows continuing the route without lane change.
std::string laneID
The id of the lane.
std::vector< TraCIBestLanesData > value
std::string getString() const
std::string lane
The lane where the collision happended.
std::string type
The type of collision.
std::string collider
The ids of the participating vehicles and persons.
double pos
The position of the collision along the lane.
std::string getString() const
std::vector< TraCICollision > value
std::string getString() const
std::string getString() const
TraCIColor(int r, int g, int b, int a=255)
std::string getString() const
TraCIConnection(const std::string &_approachedLane, const bool _hasPrio, const bool _isOpen, const bool _hasFoe, const std::string _approachedInternal, const std::string _state, const std::string _direction, const double _length)
std::string approachedLane
std::string approachedInternal
std::vector< TraCIConnection > value
std::string getString() const
std::string getString() const
std::vector< double > value
std::string getString() const
TraCIInt(int v=0, int t=libsumo::TYPE_INTEGER)
std::string getString() const
std::string getString() const
std::string getString() const
std::string foeId
the id of the vehicle with intersecting trajectory
std::vector< TraCIJunctionFoe > value
std::string getString() const
std::string getString() const
TraCILink(const std::string &_from, const std::string &_via, const std::string &_to)
std::vector< std::vector< TraCILink > > value
std::string getString() const
std::map< std::string, std::string > subParameter
std::vector< std::shared_ptr< libsumo::TraCIPhase > > phases
TraCILogic(const std::string &_programID, const int _type, const int _currentPhaseIndex, const std::vector< std::shared_ptr< libsumo::TraCIPhase > > &_phases=std::vector< std::shared_ptr< libsumo::TraCIPhase > >())
std::string getString() const
std::vector< TraCILogic > value
std::string getString() const
std::string stoppingPlaceID
Id assigned to the stop.
std::string lane
The lane to stop at.
std::string actType
additional information for this stop
std::string tripId
id of the trip within a cyclical public transport route
std::string getString() const
double startPos
The stopping position start.
double arrival
The actual arrival time (only for past stops)
TraCINextStopData(const std::string &lane="", double startPos=INVALID_DOUBLE_VALUE, double endPos=INVALID_DOUBLE_VALUE, const std::string &stoppingPlaceID="", int stopFlags=0, double duration=INVALID_DOUBLE_VALUE, double until=INVALID_DOUBLE_VALUE, double intendedArrival=INVALID_DOUBLE_VALUE, double arrival=INVALID_DOUBLE_VALUE, double depart=INVALID_DOUBLE_VALUE, const std::string &split="", const std::string &join="", const std::string &actType="", const std::string &tripId="", const std::string &line="", double speed=0)
double depart
The time at which this stop was ended.
std::string join
the id of the vehicle (train portion) to which this vehicle shall be joined
double speed
the speed at which this stop counts as reached (waypoint mode)
double intendedArrival
The intended arrival time.
double endPos
The stopping position end.
std::string split
the id of the vehicle (train portion) that splits of upon reaching this stop
std::string line
the new line id of the trip within a cyclical public transport route
double duration
The intended (minimum) stopping duration.
double until
The time at which the vehicle may continue its journey.
std::string getString() const
std::vector< TraCINextStopData > value
std::string getString() const
double dist
The distance to the tls.
int tlIndex
The tls index of the controlled link.
std::string id
The id of the next tls.
char state
The current state of the tls.
std::string getString() const
std::vector< TraCINextTLSData > value
TraCIPhase(const double _duration, const std::string &_state, const double _minDur=libsumo::INVALID_DOUBLE_VALUE, const double _maxDur=libsumo::INVALID_DOUBLE_VALUE, const std::vector< int > &_next=std::vector< int >(), const std::string &_name="", const std::string &_earlyTarget="")
A 2D or 3D-position, for 2D positions z == INVALID_DOUBLE_VALUE.
std::string getString() const
std::string getString() const
std::vector< TraCIPosition > value
double departPos
pickup position on the origin edge
double reservationTime
time when the reservation was made
double arrivalPos
drop-off position on the destination edge
std::vector< std::string > persons
The persons ids that are part of this reservation.
int state
the state of this reservation
std::string fromEdge
The origin edge id.
std::string group
The group id of this reservation.
std::string id
The id of the taxi reservation (usable for traci.vehicle.dispatchTaxi)
std::string toEdge
The destination edge id.
TraCIReservation(const std::string &id, const std::vector< std::string > &persons, const std::string &group, const std::string &fromEdge, const std::string &toEdge, double departPos, double arrivalPos, double depart, double reservationTime, int state)
std::string getString() const
std::vector< TraCIReservation > value
std::string getString() const
virtual std::string getString() const
virtual int getType() const
An edgeId, position and laneIndex.
std::string getString() const
TraCIRoadPosition(const std::string e="", const double p=INVALID_DOUBLE_VALUE, const int li=INVALID_INT_VALUE)
std::string foeId
the tripId or vehicle id of the train that must pass first
std::string tripId
the tripId or vehicle id of the train that is constrained
std::string foeSignal
the tlsID of the rail signla that the foe must pass first
std::string signalId
the idea of the rail signal where this constraint is active
std::map< std::string, std::string > param
additional parameters
bool active
whether this constraint is active
std::string getString() const
int type
the type of constraint (predecessor:0, insertionPredecessor:1)
bool mustWait
whether tripId must still wait for foeId to pass foeSignal
int limit
the number of trains that must be recorded at the foeSignal
std::string getString() const
std::vector< TraCISignalConstraint > value
std::string intended
id of the intended vehicle for public transport ride
int type
The type of stage (walking, driving, ...)
std::string destStop
The id of the destination stop.
double travelTime
duration of the stage in seconds
double departPos
position on the lane when starting the stage
std::string description
arbitrary description string
std::string line
The line or the id of the vehicle type.
TraCIStage(int type=INVALID_INT_VALUE, const std::string &vType="", const std::string &line="", const std::string &destStop="", const std::vector< std::string > &edges=std::vector< std::string >(), double travelTime=INVALID_DOUBLE_VALUE, double cost=INVALID_DOUBLE_VALUE, double length=INVALID_DOUBLE_VALUE, const std::string &intended="", double depart=INVALID_DOUBLE_VALUE, double departPos=INVALID_DOUBLE_VALUE, double arrivalPos=INVALID_DOUBLE_VALUE, const std::string &description="")
double depart
intended depart time for public transport ride or INVALID_DOUBLE_VALUE
std::vector< std::string > edges
The sequence of edges to travel.
double arrivalPos
position on the lane when ending the stage
std::string vType
The vehicle type when using a private car or bike.
std::string getString() const
std::vector< std::pair< std::string, double > > value
TraCIString(std::string v="")
std::string getString() const
std::vector< std::string > value
std::string getString() const
mirrors MSInductLoop::VehicleData
std::string id
The id of the vehicle.
double entryTime
Entry-time of the vehicle in [s].
std::string typeID
Type of the vehicle in.
double length
Length of the vehicle.
std::string getString() const
double leaveTime
Leave-time of the vehicle in [s].
std::string getString() const
std::vector< TraCIVehicleData > value