35 typedef Domain<libsumo::CMD_GET_SIM_VARIABLE, libsumo::CMD_SET_SIM_VARIABLE>
Dom;
41 std::pair<int, std::string>
42 Simulation::init(
int port,
int numRetries,
const std::string& host,
const std::string& label, FILE*
const pipe) {
44 switchConnection(label);
49 std::pair<int, std::string>
50 Simulation::start(
const std::vector<std::string>& cmd,
int port,
int numRetries,
const std::string& label,
const bool verbose,
51 const std::string& ,
bool ,
void* ) {
55 std::ostringstream oss;
56 for (
const std::string& s : cmd) {
59 oss <<
"--remote-port " << port <<
" 2>&1";
64 std::cout <<
"Calling " << oss.str() << std::endl;
67 FILE* pipe = _popen(oss.str().c_str(),
"r");
69 FILE* pipe = popen(oss.str().c_str(),
"r");
71 return init(port, numRetries,
"localhost", label, pipe);
76 Simulation::isLibsumo() {
82 Simulation::hasGUI() {
93 Simulation::switchConnection(
const std::string& label) {
99 Simulation::getLabel() {
105 Simulation::setOrder(
int order) {
111 Simulation::load(
const std::vector<std::string>& args) {
121 Simulation::isLoaded() {
127 Simulation::step(
const double time) {
133 Simulation::executeMove() {
140 Simulation::close(
const std::string& ) {
145 std::pair<int, std::string>
146 Simulation::getVersion() {
151 const int traciVersion = inMsg.
readInt();
152 return std::make_pair(traciVersion, inMsg.
readString());
157 Simulation::getOption(
const std::string& option) {
163 Simulation::getCurrentTime() {
169 Simulation::getTime() {
175 Simulation::getEndTime() {
181 Simulation::getLoadedNumber() {
186 std::vector<std::string>
187 Simulation::getLoadedIDList() {
193 Simulation::getDepartedNumber() {
198 std::vector<std::string>
199 Simulation::getDepartedIDList() {
205 Simulation::getArrivedNumber() {
210 std::vector<std::string>
211 Simulation::getArrivedIDList() {
217 Simulation::getParkingStartingVehiclesNumber() {
222 std::vector<std::string>
223 Simulation::getParkingStartingVehiclesIDList() {
229 Simulation::getParkingEndingVehiclesNumber() {
234 std::vector<std::string>
235 Simulation::getParkingEndingVehiclesIDList() {
241 Simulation::getStopStartingVehiclesNumber() {
246 std::vector<std::string>
247 Simulation::getStopStartingVehiclesIDList() {
253 Simulation::getStopEndingVehiclesNumber() {
258 std::vector<std::string>
259 Simulation::getStopEndingVehiclesIDList() {
265 Simulation::getCollidingVehiclesNumber() {
270 std::vector<std::string>
271 Simulation::getCollidingVehiclesIDList() {
277 Simulation::getEmergencyStoppingVehiclesNumber() {
282 std::vector<std::string>
283 Simulation::getEmergencyStoppingVehiclesIDList() {
289 Simulation::getStartingTeleportNumber() {
294 std::vector<std::string>
295 Simulation::getStartingTeleportIDList() {
301 Simulation::getEndingTeleportNumber() {
306 std::vector<std::string>
307 Simulation::getEndingTeleportIDList() {
313 Simulation::getDepartedPersonNumber() {
318 std::vector<std::string>
319 Simulation::getDepartedPersonIDList() {
325 Simulation::getArrivedPersonNumber() {
330 std::vector<std::string>
331 Simulation::getArrivedPersonIDList() {
336 std::vector<std::string>
337 Simulation::getBusStopIDList() {
342 Simulation::getBusStopWaiting(
const std::string& stopID) {
346 std::vector<std::string>
347 Simulation::getBusStopWaitingIDList(
const std::string& stopID) {
352 std::vector<std::string>
353 Simulation::getPendingVehicles() {
358 std::vector<libsumo::TraCICollision>
359 Simulation::getCollisions() {
362 std::vector<libsumo::TraCICollision> result;
364 int numCollisions = ret.
readInt();
365 while (numCollisions-- > 0) {
376 result.emplace_back(c);
383 Simulation::getScale() {
389 Simulation::getDeltaT() {
395 Simulation::getNetBoundary() {
401 Simulation::getMinExpectedNumber() {
407 Simulation::convert2D(
const std::string& edgeID,
double pos,
int laneIndex,
bool toGeo) {
421 Simulation::convert3D(
const std::string& edgeID,
double pos,
int laneIndex,
bool toGeo) {
435 Simulation::convertRoad(
double x,
double y,
bool isGeo,
const std::string& vClass) {
455 Simulation::convertGeo(
double x,
double y,
bool fromGeo) {
468 Simulation::getDistance2D(
double x1,
double y1,
double x2,
double y2,
bool isGeo,
bool isDriving) {
483 Simulation::getDistanceRoad(
const std::string& edgeID1,
double pos1,
const std::string& edgeID2,
double pos2,
bool isDriving) {
500 Simulation::findRoute(
const std::string& fromEdge,
const std::string& toEdge,
const std::string& vType,
const double depart,
const int routingMode) {
512 std::vector<libsumo::TraCIStage>
513 Simulation::findIntermodalRoute(
const std::string& fromEdge,
const std::string& toEdge,
514 const std::string& modes,
double depart,
const int routingMode,
double speed,
double walkFactor,
515 double departPos,
double arrivalPos,
const double departPosLat,
516 const std::string& pType,
const std::string& vType,
const std::string& destStop) {
534 int numStages = result.
readInt();
535 std::vector<libsumo::TraCIStage> ret;
536 while (numStages-- > 0) {
560 Simulation::setScale(
double value) {
565 Simulation::clearPending(
const std::string& routeID) {
571 Simulation::saveState(
const std::string& fileName) {
576 Simulation::loadState(
const std::string& fileName) {
582 Simulation::writeMessage(
const std::string& msg) {
588 Simulation::subscribe(
const std::vector<int>& varIDs,
double begin,
double end,
const libsumo::TraCIResults& params) {
594 Simulation::getSubscriptionResults() {
#define LIBTRACI_SUBSCRIPTION_IMPLEMENTATION(CLASS, DOMAIN)
#define LIBTRACI_PARAMETER_IMPLEMENTATION(CLASS, DOMAIN)
static void writeTypedDouble(tcpip::Storage &content, double value)
static int readCompound(tcpip::Storage &ret, int expectedSize=-1, const std::string &error="")
static int readTypedInt(tcpip::Storage &ret, const std::string &error="")
static void writeCompound(tcpip::Storage &content, int size)
static std::string readTypedString(tcpip::Storage &ret, const std::string &error="")
static void writeTypedInt(tcpip::Storage &content, int value)
static std::vector< std::string > readTypedStringList(tcpip::Storage &ret, const std::string &error="")
static void writeTypedString(tcpip::Storage &content, const std::string &value)
static double readTypedDouble(tcpip::Storage &ret, const std::string &error="")
An error which allows to continue.
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.
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.
void simulationStep(double time)
Sends a SimulationStep command.
static void connect(const std::string &host, int port, int numRetries, const std::string &label, FILE *const pipe)
void close()
ends the simulation and closes the connection
std::mutex & getMutex() const
static Connection & getActive()
void setOrder(int order)
Sends a SetOrder command.
void subscribe(int domID, const std::string &objID, double beginTime, double endTime, int domain, double range, const std::vector< int > &vars, const libsumo::TraCIResults ¶ms)
Sends a SubscribeContext or a SubscribeVariable request.
const std::string & getLabel() const
tcpip::Storage & doCommand(int command, int var=-1, const std::string &id="", tcpip::Storage *add=nullptr, int expectedType=-1)
static void switchCon(const std::string &label)
libsumo::SubscriptionResults & getAllSubscriptionResults(const int domain)
static void setDouble(int var, const std::string &id, double value)
static libsumo::TraCIPosition getPos(int var, const std::string &id, tcpip::Storage *add=nullptr, const bool isGeo=false)
static std::vector< std::string > getStringVector(int var, const std::string &id, tcpip::Storage *add=nullptr)
static std::string getString(int var, const std::string &id, tcpip::Storage *add=nullptr)
static int getInt(int var, const std::string &id, tcpip::Storage *add=nullptr)
static libsumo::TraCIStage getTraCIStage(int var, const std::string &id, tcpip::Storage *add=nullptr)
static libsumo::TraCIPositionVector getPolygon(int var, const std::string &id, tcpip::Storage *add=nullptr)
static libsumo::TraCIPosition getPos3D(int var, const std::string &id, tcpip::Storage *add=nullptr, const bool isGeo=false)
static double getDouble(int var, const std::string &id, tcpip::Storage *add=nullptr)
static tcpip::Storage & get(int var, const std::string &id, tcpip::Storage *add=nullptr, int expectedType=libsumo::TYPE_COMPOUND)
static void setString(int var, const std::string &id, const std::string &value)
static int getFreeSocketPort()
Returns an free port on the system.
virtual std::string readString()
virtual void writeString(const std::string &s)
virtual void writeDouble(double)
virtual int readUnsignedByte()
virtual void writeStringList(const std::vector< std::string > &s)
virtual void writeUnsignedByte(int)
virtual double readDouble()
TRACI_CONST int VAR_MIN_EXPECTED_VEHICLES
TRACI_CONST int CMD_SAVE_SIMSTATE
TRACI_CONST int VAR_STOP_ENDING_VEHICLES_IDS
TRACI_CONST int CMD_SUBSCRIBE_SIM_VARIABLE
TRACI_CONST int POSITION_3D
TRACI_CONST int POSITION_ROADMAP
TRACI_CONST int VAR_ARRIVED_VEHICLES_NUMBER
TRACI_CONST int VAR_STOP_STARTING_VEHICLES_NUMBER
TRACI_CONST int VAR_SCALE
TRACI_CONST int VAR_DEPARTED_VEHICLES_NUMBER
TRACI_CONST int CMD_LOAD_SIMSTATE
TRACI_CONST int VAR_COLLIDING_VEHICLES_NUMBER
TRACI_CONST int VAR_COLLISIONS
TRACI_CONST int CMD_CLEAR_PENDING_VEHICLES
TRACI_CONST int VAR_PARKING_ENDING_VEHICLES_IDS
TRACI_CONST int VAR_PARKING_STARTING_VEHICLES_IDS
TRACI_CONST int CMD_EXECUTEMOVE
TRACI_CONST int FIND_INTERMODAL_ROUTE
TRACI_CONST int VAR_DEPARTED_PERSONS_NUMBER
TRACI_CONST int TYPE_UBYTE
TRACI_CONST int POSITION_2D
TRACI_CONST int VAR_ARRIVED_PERSONS_IDS
TRACI_CONST int VAR_NET_BOUNDING_BOX
TRACI_CONST int TYPE_STRINGLIST
TRACI_CONST int VAR_PENDING_VEHICLES
TRACI_CONST int VAR_BUS_STOP_ID_LIST
TRACI_CONST int POSITION_LON_LAT
TRACI_CONST int VAR_EMERGENCYSTOPPING_VEHICLES_IDS
TRACI_CONST int VAR_BUS_STOP_WAITING_IDS
TRACI_CONST int VAR_DEPARTED_VEHICLES_IDS
TRACI_CONST int VAR_TELEPORT_ENDING_VEHICLES_NUMBER
TRACI_CONST int CMD_MESSAGE
TRACI_CONST int VAR_PARKING_ENDING_VEHICLES_NUMBER
TRACI_CONST int VAR_LOADED_VEHICLES_IDS
TRACI_CONST int VAR_DELTA_T
TRACI_CONST int REQUEST_DRIVINGDIST
TRACI_CONST int VAR_DEPARTED_PERSONS_IDS
TRACI_CONST int VAR_ARRIVED_PERSONS_NUMBER
TRACI_CONST int VAR_STOP_STARTING_VEHICLES_IDS
TRACI_CONST int FIND_ROUTE
TRACI_CONST int VAR_STOP_ENDING_VEHICLES_NUMBER
TRACI_CONST int POSITION_CONVERSION
TRACI_CONST int DISTANCE_REQUEST
TRACI_CONST int VAR_LOADED_VEHICLES_NUMBER
TRACI_CONST int VAR_TELEPORT_ENDING_VEHICLES_IDS
TRACI_CONST int VAR_COLLIDING_VEHICLES_IDS
TRACI_CONST int VAR_TELEPORT_STARTING_VEHICLES_NUMBER
TRACI_CONST int VAR_TELEPORT_STARTING_VEHICLES_IDS
TRACI_CONST int CMD_GETVERSION
TRACI_CONST int REQUEST_AIRDIST
TRACI_CONST int VAR_BUS_STOP_WAITING
TRACI_CONST int VAR_TIME_STEP
TRACI_CONST int VAR_ARRIVED_VEHICLES_IDS
TRACI_CONST int RESPONSE_SUBSCRIBE_SIM_VARIABLE
TRACI_CONST int VAR_PARKING_STARTING_VEHICLES_NUMBER
TRACI_CONST int POSITION_LON_LAT_ALT
TRACI_CONST int VAR_EMERGENCYSTOPPING_VEHICLES_NUMBER
std::map< int, std::shared_ptr< libsumo::TraCIResult > > TraCIResults
{variable->value}
TRACI_CONST int VAR_OPTION
Domain< libsumo::CMD_GET_BUSSTOP_VARIABLE, libsumo::CMD_SET_BUSSTOP_VARIABLE > Dom
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.
A 2D or 3D-position, for 2D positions z == INVALID_DOUBLE_VALUE.
An edgeId, position and laneIndex.