2016-01-15 30 views

回答

3

好的,我對這個問題感到抱歉,實際上我以前使用veins-3.0。在靜脈-3.0中沒有這樣的功能。

今天我已經遷移到靜脈-4a2。在這裏可以通過使用traciVehicle->getRouteId()輕鬆找到。非常感謝爵士。 Christoph Sommer爲此更新。

0

我目前使用的是Veins 2.0-rc1,即使沒有實現這樣的功能,您也可以通過創建一個新的函數來執行該類下的作業。

爲了做到這一點,你必須檢查在這個類下實現的函數,以及在SUMO下已經記錄的Traci Python模塊的良好閱讀/理解。

0

如果有人想在舊版本的靜脈使用它是可能的,它遵循手動添加:

TraCICommandInterface.hstd::string getRoadId();定義:

// Vehicle methods 
     bool addVehicle(std::string vehicleId, std::string vehicleTypeId, std::string routeId, simtime_t emitTime_st = -DEPART_NOW, double emitPosition = -DEPART_POS_BASE, double emitSpeed = -DEPART_SPEED_MAX, int8_t emitLane = -DEPART_LANE_BEST_FREE); 

    class Vehicle { 
     public: 
      Vehicle(TraCICommandInterface* traci, std::string nodeId) : traci(traci), nodeId(nodeId) { 
       connection = &traci->connection; 
      } 

      ... 
      std::string getRoadId(); //here is the definition 
      ... 

     protected: 
      TraCICommandInterface* traci; 
      TraCIConnection* connection; 
      std::string nodeId; 
    }; 

    Vehicle vehicle(std::string nodeId) { 
     return Vehicle(this, nodeId); 
    } 

TraCICommandInterface.cc編寫std::string getRoadId();聲明:

std::string TraCICommandInterface::Vehicle::getRoadId() { 
return traci->genericGetString(CMD_GET_VEHICLE_VARIABLE, nodeId, VAR_ROAD_ID, RESPONSE_GET_VEHICLE_VARIABLE); 
}