35typedef Domain<libsumo::CMD_GET_SIM_VARIABLE, libsumo::CMD_SET_SIM_VARIABLE>
Dom;
41std::pair<int, std::string>
42Simulation::init(
int port,
int numRetries,
const std::string& host,
const std::string& label, FILE*
const pipe) {
44 switchConnection(label);
49std::pair<int, std::string>
50Simulation::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);
76Simulation::isLibsumo() {
93Simulation::switchConnection(
const std::string& label) {
99Simulation::getLabel() {
105Simulation::setOrder(
int order) {
111Simulation::load(
const std::vector<std::string>& args) {
120Simulation::isLoaded() {
126Simulation::step(
const double time) {
132Simulation::close(
const std::string& ) {
137std::pair<int, std::string>
138Simulation::getVersion() {
142 const int traciVersion = inMsg.
readInt();
143 return std::make_pair(traciVersion, inMsg.
readString());
148Simulation::getOption(
const std::string& option) {
154Simulation::getCurrentTime() {
160Simulation::getTime() {
166Simulation::getEndTime() {
172Simulation::getLoadedNumber() {
177std::vector<std::string>
178Simulation::getLoadedIDList() {
184Simulation::getDepartedNumber() {
189std::vector<std::string>
190Simulation::getDepartedIDList() {
196Simulation::getArrivedNumber() {
201std::vector<std::string>
202Simulation::getArrivedIDList() {
208Simulation::getParkingStartingVehiclesNumber() {
213std::vector<std::string>
214Simulation::getParkingStartingVehiclesIDList() {
220Simulation::getParkingEndingVehiclesNumber() {
225std::vector<std::string>
226Simulation::getParkingEndingVehiclesIDList() {
232Simulation::getStopStartingVehiclesNumber() {
237std::vector<std::string>
238Simulation::getStopStartingVehiclesIDList() {
244Simulation::getStopEndingVehiclesNumber() {
249std::vector<std::string>
250Simulation::getStopEndingVehiclesIDList() {
256Simulation::getCollidingVehiclesNumber() {
261std::vector<std::string>
262Simulation::getCollidingVehiclesIDList() {
268Simulation::getEmergencyStoppingVehiclesNumber() {
273std::vector<std::string>
274Simulation::getEmergencyStoppingVehiclesIDList() {
280Simulation::getStartingTeleportNumber() {
285std::vector<std::string>
286Simulation::getStartingTeleportIDList() {
292Simulation::getEndingTeleportNumber() {
297std::vector<std::string>
298Simulation::getEndingTeleportIDList() {
304Simulation::getDepartedPersonNumber() {
309std::vector<std::string>
310Simulation::getDepartedPersonIDList() {
316Simulation::getArrivedPersonNumber() {
321std::vector<std::string>
322Simulation::getArrivedPersonIDList() {
327std::vector<std::string>
328Simulation::getBusStopIDList() {
333Simulation::getBusStopWaiting(
const std::string& stopID) {
337std::vector<std::string>
338Simulation::getBusStopWaitingIDList(
const std::string& stopID) {
343std::vector<std::string>
344Simulation::getPendingVehicles() {
348std::vector<libsumo::TraCICollision>
349Simulation::getCollisions() {
350 std::vector<libsumo::TraCICollision> result;
356Simulation::getScale() {
362Simulation::getDeltaT() {
368Simulation::getNetBoundary() {
374Simulation::getMinExpectedNumber() {
380Simulation::convert2D(
const std::string& edgeID,
double pos,
int laneIndex,
bool toGeo) {
394Simulation::convert3D(
const std::string& edgeID,
double pos,
int laneIndex,
bool toGeo) {
408Simulation::convertRoad(
double x,
double y,
bool isGeo,
const std::string& vClass) {
427Simulation::convertGeo(
double x,
double y,
bool fromGeo) {
440Simulation::getDistance2D(
double x1,
double y1,
double x2,
double y2,
bool isGeo,
bool isDriving) {
455Simulation::getDistanceRoad(
const std::string& edgeID1,
double pos1,
const std::string& edgeID2,
double pos2,
bool isDriving) {
472Simulation::findRoute(
const std::string& fromEdge,
const std::string& toEdge,
const std::string& vType,
const double depart,
const int routingMode) {
484std::vector<libsumo::TraCIStage>
485Simulation::findIntermodalRoute(
const std::string& fromEdge,
const std::string& toEdge,
486 const std::string& modes,
double depart,
const int routingMode,
double speed,
double walkFactor,
487 double departPos,
double arrivalPos,
const double departPosLat,
488 const std::string& pType,
const std::string& vType,
const std::string& destStop) {
505 int numStages = result.
readInt();
506 std::vector<libsumo::TraCIStage> ret;
507 while (numStages-- > 0) {
531Simulation::setScale(
double value) {
536Simulation::clearPending(
const std::string& routeID) {
542Simulation::saveState(
const std::string& fileName) {
547Simulation::loadState(
const std::string& fileName) {
553Simulation::writeMessage(
const std::string& msg) {
559Simulation::subscribe(
const std::vector<int>& varIDs,
double begin,
double end,
const libsumo::TraCIResults& params) {
565Simulation::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 std::vector< std::string > readTypedStringList(tcpip::Storage &ret, 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 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
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)
const std::string & getLabel()
static void switchCon(const std::string &label)
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 void setString(int var, const std::string &id, const std::string &value)
static tcpip::Storage & get(int var, const std::string &id, tcpip::Storage *add=nullptr, int expectedType=libsumo::TYPE_COMPOUND)
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 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}
TRACI_CONST int VAR_OPTION
Domain< libsumo::CMD_GET_BUSSTOP_VARIABLE, libsumo::CMD_SET_BUSSTOP_VARIABLE > Dom
An edgeId, position and laneIndex.