1

[1] I am trying to assign a new route to a vehicle using TraCE Command Interface::Vehicle::change Vehicle Route(const std::list<std::string>& edges) but nothing is happening.

I am getting the current route and ['6/7to6/6', '6/6to5/6', '5/6to4/6', '4/6to3/6', '3/6to3/7', '3/7to3/8', '3/8to3/9', '3/9to2/9', '2/9to2/8'] calculate the new and send ['6/7to6/6', '6/6to5/6', '5/6to4/6', '4/6to3/6', '3/6to2/6', '2/6to2/7', '2/7to2/8', '2/8to3/8', '3/8to3/9', '3/9to2/9', '2/9to2/8'].

but the changeVehicleRoute(edges) return 0, so the new route is not assigned.

A slice of my code is below. Can someone help me?

More questions,

[2] If my current route is [a , b, c, d, e, f] and the vehicle is current in c such that when I calculate the new route [a,b,c,H,I,f], I can assign all routes [a,b,c,H,I,f] or only the rest of them [c,H,I,f]?

[3] If I put only the rest this, it will be influenced in SUMO statistics of route Length, distance, Fuel...?

rot.h

TraCIMobility* mobility;
TraCICommandInterface* traci;
TraCICommandInterface::Vehicle* traciVehicle;
...

rot.cc

initialize(int stage){
...
  mobility = TraCIMobilityAccess().get(getParentModule());
  assert(mobility);
  traci = mobility->getCommandInterface();
  traciVehicle = mobility->getVehicleCommandInterface(); 
  ...
}
...
reroute(std::list<std::string> rList){
   bool rota;
   rota = traciVehicle->changeVehicleRoute(rList);
   std::cout << rota << findHost()->getFullName()  << std::endl;
}
buczek
  • 2,011
  • 7
  • 29
  • 40
  • Hi, I am also trying to reroute my vehicles after they reach their destination. I wanted to know what did you insert in the rList. Does it contains the list of edges values from the .rou.xml ? How did you make the rList and where did you call the reroute . Thank you. –  Sep 20 '17 at 01:41

1 Answers1

0

The new route for a vehicle always needs to start at the edge the vehicle is currently on. If the vehicle is on a junction or so close to a junction that it will not be able to stop in front of it, the approached edge after the junction should be the starting point. Otherwise the rerouting will fail. I admit that it may be hard to tell whether the vehicle can still stop because it depends on the car following model used but the alternative would be an emergency brake in case of conflicts / red traffic lights for the new direction. This could be causing collisions which is much less desirable. all the statistics for the vehicle will be based on the finally driven route, so you do not change history by setting a new route.

Michael
  • 3,510
  • 1
  • 11
  • 23