0

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");

The error message: enter image description here

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?

Edson Mota
  • 11
  • 5
  • So are looking to implement a [graph traversal](https://en.wikipedia.org/wiki/Graph_traversal) algorithm or use an existing one? Also, please include any error messages in your question. – Mansoor Feb 13 '21 at 22:20

1 Answers1

1

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());
}
Michael
  • 3,510
  • 1
  • 11
  • 23
  • Thanks for your help. FIND_ROUTE is not recognized in this code. I replace it with CMD_SUBSCRIBE_ROUTE_CONTEXT, but another error is observed on SUMO. "Error: tcpip::Storage::readIsSafe: want to read 32564 bytes from Storage, but only 65 remaining". Anybody knows how can I solve it? Thanks! – Edson Mota Feb 16 '21 at 18:30
  • Which SUMO version do you use? – Michael Feb 22 '21 at 20:15
  • Hi, I am using the SUMO 0.32.0 – Edson Mota Feb 23 '21 at 23:55
  • FIND_ROUTE should be available in 0.32.0. What exactly is the error message? – Michael Feb 27 '21 at 21:13