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) {
121Simulation::isLoaded() {
127Simulation::step(
const double time) {
133Simulation::executeMove() {
140Simulation::close(
const std::string& ) {
145std::pair<int, std::string>
146Simulation::getVersion() {
151 const int traciVersion = inMsg.
readInt();
152 return std::make_pair(traciVersion, inMsg.
readString());
157Simulation::getOption(
const std::string& option) {
163Simulation::getCurrentTime() {
169Simulation::getTime() {
175Simulation::getEndTime() {
181Simulation::getLoadedNumber() {
186std::vector<std::string>
187Simulation::getLoadedIDList() {
193Simulation::getDepartedNumber() {
198std::vector<std::string>
199Simulation::getDepartedIDList() {
205Simulation::getArrivedNumber() {
210std::vector<std::string>
211Simulation::getArrivedIDList() {
217Simulation::getParkingStartingVehiclesNumber() {
222std::vector<std::string>
223Simulation::getParkingStartingVehiclesIDList() {
229Simulation::getParkingEndingVehiclesNumber() {
234std::vector<std::string>
235Simulation::getParkingEndingVehiclesIDList() {
241Simulation::getStopStartingVehiclesNumber() {
246std::vector<std::string>
247Simulation::getStopStartingVehiclesIDList() {
253Simulation::getStopEndingVehiclesNumber() {
258std::vector<std::string>
259Simulation::getStopEndingVehiclesIDList() {
265Simulation::getCollidingVehiclesNumber() {
270std::vector<std::string>
271Simulation::getCollidingVehiclesIDList() {
277Simulation::getEmergencyStoppingVehiclesNumber() {
282std::vector<std::string>
283Simulation::getEmergencyStoppingVehiclesIDList() {
289Simulation::getStartingTeleportNumber() {
294std::vector<std::string>
295Simulation::getStartingTeleportIDList() {
301Simulation::getEndingTeleportNumber() {
306std::vector<std::string>
307Simulation::getEndingTeleportIDList() {
313Simulation::getDepartedPersonNumber() {
318std::vector<std::string>
319Simulation::getDepartedPersonIDList() {
325Simulation::getArrivedPersonNumber() {
330std::vector<std::string>
331Simulation::getArrivedPersonIDList() {
336std::vector<std::string>
337Simulation::getBusStopIDList() {
342Simulation::getBusStopWaiting(
const std::string& stopID) {
346std::vector<std::string>
347Simulation::getBusStopWaitingIDList(
const std::string& stopID) {
352std::vector<std::string>
353Simulation::getPendingVehicles() {
358std::vector<libsumo::TraCICollision>
359Simulation::getCollisions() {
362 std::vector<libsumo::TraCICollision> result;
364 int numCollisions = ret.
readInt();
365 while (numCollisions-- > 0) {
376 result.emplace_back(c);
383Simulation::getScale() {
389Simulation::getDeltaT() {
395Simulation::getNetBoundary() {
401Simulation::getMinExpectedNumber() {
407Simulation::convert2D(
const std::string& edgeID,
double pos,
int laneIndex,
bool toGeo) {
421Simulation::convert3D(
const std::string& edgeID,
double pos,
int laneIndex,
bool toGeo) {
435Simulation::convertRoad(
double x,
double y,
bool isGeo,
const std::string& vClass) {
455Simulation::convertGeo(
double x,
double y,
bool fromGeo) {
468Simulation::getDistance2D(
double x1,
double y1,
double x2,
double y2,
bool isGeo,
bool isDriving) {
483Simulation::getDistanceRoad(
const std::string& edgeID1,
double pos1,
const std::string& edgeID2,
double pos2,
bool isDriving) {
500Simulation::findRoute(
const std::string& fromEdge,
const std::string& toEdge,
const std::string& vType,
const double depart,
const int routingMode) {
512std::vector<libsumo::TraCIStage>
513Simulation::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) {
560Simulation::setScale(
double value) {
565Simulation::clearPending(
const std::string& routeID) {
571Simulation::saveState(
const std::string& fileName) {
576Simulation::loadState(
const std::string& fileName) {
582Simulation::writeMessage(
const std::string& msg) {
588Simulation::subscribe(
const std::vector<int>& varIDs,
double begin,
double end,
const libsumo::TraCIResults& params) {
594Simulation::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()
std::mutex & getMutex() const
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.
libsumo::SubscriptionResults & getAllSubscriptionResults(const int domain)
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)
const std::string & getLabel() const
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 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.