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) {
120 Simulation::isLoaded() {
126 Simulation::step(
const double time) {
132 Simulation::close(
const std::string& ) {
137 std::pair<int, std::string>
138 Simulation::getVersion() {
142 const int traciVersion = inMsg.
readInt();
143 return std::make_pair(traciVersion, inMsg.
readString());
148 Simulation::getCurrentTime() {
154 Simulation::getTime() {
160 Simulation::getEndTime() {
166 Simulation::getLoadedNumber() {
171 std::vector<std::string>
172 Simulation::getLoadedIDList() {
178 Simulation::getDepartedNumber() {
183 std::vector<std::string>
184 Simulation::getDepartedIDList() {
190 Simulation::getArrivedNumber() {
195 std::vector<std::string>
196 Simulation::getArrivedIDList() {
202 Simulation::getParkingStartingVehiclesNumber() {
207 std::vector<std::string>
208 Simulation::getParkingStartingVehiclesIDList() {
214 Simulation::getParkingEndingVehiclesNumber() {
219 std::vector<std::string>
220 Simulation::getParkingEndingVehiclesIDList() {
226 Simulation::getStopStartingVehiclesNumber() {
231 std::vector<std::string>
232 Simulation::getStopStartingVehiclesIDList() {
238 Simulation::getStopEndingVehiclesNumber() {
243 std::vector<std::string>
244 Simulation::getStopEndingVehiclesIDList() {
250 Simulation::getCollidingVehiclesNumber() {
255 std::vector<std::string>
256 Simulation::getCollidingVehiclesIDList() {
262 Simulation::getEmergencyStoppingVehiclesNumber() {
267 std::vector<std::string>
268 Simulation::getEmergencyStoppingVehiclesIDList() {
274 Simulation::getStartingTeleportNumber() {
279 std::vector<std::string>
280 Simulation::getStartingTeleportIDList() {
286 Simulation::getEndingTeleportNumber() {
291 std::vector<std::string>
292 Simulation::getEndingTeleportIDList() {
298 Simulation::getDepartedPersonNumber() {
303 std::vector<std::string>
304 Simulation::getDepartedPersonIDList() {
310 Simulation::getArrivedPersonNumber() {
315 std::vector<std::string>
316 Simulation::getArrivedPersonIDList() {
321 std::vector<std::string>
322 Simulation::getBusStopIDList() {
327 Simulation::getBusStopWaiting(
const std::string& stopID) {
331 std::vector<std::string>
332 Simulation::getBusStopWaitingIDList(
const std::string& stopID) {
337 std::vector<std::string>
338 Simulation::getPendingVehicles() {
342 std::vector<libsumo::TraCICollision>
343 Simulation::getCollisions() {
344 std::vector<libsumo::TraCICollision> result;
351 Simulation::getDeltaT() {
357 Simulation::getNetBoundary() {
363 Simulation::getMinExpectedNumber() {
369 Simulation::convert2D(
const std::string& edgeID,
double pos,
int laneIndex,
bool toGeo) {
383 Simulation::convert3D(
const std::string& edgeID,
double pos,
int laneIndex,
bool toGeo) {
397 Simulation::convertRoad(
double x,
double y,
bool isGeo,
const std::string& vClass) {
416 Simulation::convertGeo(
double x,
double y,
bool fromGeo) {
429 Simulation::getDistance2D(
double x1,
double y1,
double x2,
double y2,
bool isGeo,
bool isDriving) {
444 Simulation::getDistanceRoad(
const std::string& edgeID1,
double pos1,
const std::string& edgeID2,
double pos2,
bool isDriving) {
461 Simulation::findRoute(
const std::string& fromEdge,
const std::string& toEdge,
const std::string& vType,
const double depart,
const int routingMode) {
473 std::vector<libsumo::TraCIStage>
474 Simulation::findIntermodalRoute(
const std::string& fromEdge,
const std::string& toEdge,
475 const std::string& modes,
double depart,
const int routingMode,
double speed,
double walkFactor,
476 double departPos,
double arrivalPos,
const double departPosLat,
477 const std::string& pType,
const std::string& vType,
const std::string& destStop) {
494 int numStages = result.
readInt();
495 std::vector<libsumo::TraCIStage> ret;
496 while (numStages-- > 0) {
520 Simulation::clearPending(
const std::string& routeID) {
526 Simulation::saveState(
const std::string& fileName) {
531 Simulation::loadState(
const std::string& fileName) {
537 Simulation::writeMessage(
const std::string& msg) {
543 Simulation::subscribe(
const std::vector<int>& varIDs,
double begin,
double end,
const libsumo::TraCIResults& params) {
549 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
const std::string & getLabel()
static Connection & getActive()
void setOrder(int order)
Sends a SetOrder command.
libsumo::SubscriptionResults getAllSubscriptionResults(const int domain)
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.
tcpip::Storage & doCommand(int command, int var, const std::string &id, tcpip::Storage *add=nullptr)
static void switchCon(const std::string &label)
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 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_DEPARTED_VEHICLES_NUMBER
TRACI_CONST int CMD_LOAD_SIMSTATE
TRACI_CONST int VAR_COLLIDING_VEHICLES_NUMBER
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 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}
Domain< libsumo::CMD_GET_BUSSTOP_VARIABLE, libsumo::CMD_SET_BUSSTOP_VARIABLE > Dom
An edgeId, position and laneIndex.