omnet++ veins module have a function getRoadId()
that returns current "road id" of vehicles but how can I have "route id" or "flow id" of a vehicle.

- 77
- 8
4 Answers
Ok, I am sorry for that question, actually I was using veins-3.0 previously. In veins-3.0 there was no such function.
Today I have migrated to veins-4a2. Here it can be easily found by using traciVehicle->getRouteId()
. Many thanks to Sir. Christoph Sommer for this update.

- 77
- 8
I am currently using Veins 2.0-rc1, even if such function is not implemented, you can easily implement it, by creating a new function that do the job under the TraCIScenarioManager class.
In order to do it, you have to check functions implemented under this class, along to a good reading/understanding of TraCI Python module already documented under SUMO.

- 535
- 6
- 18
If someone wants to use it in an older version of veins is possible to add it manually as it follows:
In TraCICommandInterface.h write the std::string getRoadId();
definition:
// 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);
}
In TraCICommandInterface.cc write the std::string getRoadId();
declaration:
std::string TraCICommandInterface::Vehicle::getRoadId() {
return traci->genericGetString(CMD_GET_VEHICLE_VARIABLE, nodeId, VAR_ROAD_ID, RESPONSE_GET_VEHICLE_VARIABLE);
}

- 539
- 1
- 3
- 14