Reputation: 11
I am trying to create a function to calculate a route based on two arguments/roads (begin and end). The function should return a list of edges that compose the route.
I know that exists a findRoute() function in the sumo, but I think that it was not implemented in the VEINS. I tried to implement it, but the function does not work for me.
My code below
std::string TraCICommandInterface::Vehicle::findRoute(std::string b, std::string e) {
uint8_t variableId = CMD_SUBSCRIBE_ROUTE_CONTEXT;
uint8_t variableType = TYPE_COMPOUND;
uint8_t edgeIdT = TYPE_STRING;
int32_t count = 3;
std::string begin = b;
std::string end = e;
TraCIBuffer buf = connection->query(CMD_SET_VEHICLE_VARIABLE, TraCIBuffer() << variableId << nodeId << variableType << begin << end << "" << 1 << 0);
ASSERT(buf.eof());
}
When I call this function I get an error.
traciVehicle->findRoute("167283892#2", "-439375716#1");
Note1: About the route, in fact, I want to use the options of algorithms implemented on sumo, such as :dijkstra, astar, etc.
Anybody can help me?
Upvotes: 0
Views: 119
Reputation: 3680
findRoute is not a command in the Vehicle domain but rather in the Simulation domain and it needs five parameters, see https://sumo.dlr.de/docs/TraCI/Simulation_Value_Retrieval.html#command_0x86_find_route, so your code should probably look like this (written from mind, not tested):
std::string TraCICommandInterface::Vehicle::findRoute(std::string b, std::string e) {
uint8_t variableId = FIND_ROUTE;
uint8_t variableType = TYPE_COMPOUND;
uint8_t stringT = TYPE_STRING;
uint8_t doubleT = TYPE_DOUBLE;
uint8_t intT = TYPE_INTEGER;
int32_t count = 5;
TraCIBuffer buf = connection->query(CMD_GET_SIM_VARIABLE, TraCIBuffer() << variableId << "" << variableType << count <<
stringT << b << stringT << e << stringT << "" << doubleT << -1. << intT << 0);
ASSERT(buf.eof());
}
Upvotes: 1