Reputation: 37
I am using a simple network to change route of the following vehicles. My code is not showing any errors . Both SUMO and omnet++ working properly; however, the vehicles are not changing the route. I have tried it with the given demo network of veins but still not working. I have tried several methods that I found in different source so far (that you can see in the actual code as i left them in comments), but still not any of the vehicle is changing route.
My rou.xml is :
<vehicle id="0" depart="5.00">
<route edges="-gneE4 -gneE3 -gneE2 "/>
</vehicle>
<vehicle id="1" depart="5.00">
<route edges="-gneE4 -gneE3 -gneE2 "/>
</vehicle>
<vehicle id="2" depart="5.90">
<route edges="-gneE4 -gneE3 -gneE2 "/>
</vehicle>
<vehicle id="3" depart="6.0">
<route edges="-gneE4 -gneE3 -gneE2 "/>
</vehicle>
<vehicle id="4" depart="7.0">
<route edges="gneE2 gneE3 gneE4"/>
</vehicle>
<vehicle id="5" depart="40.0">
<route edges="-gneE4 -gneE3 -gneE2 "/>
</vehicle>
and change route is chnage route in TraCIDemo11p.cc....
void TraCIDemo11p::onWSM(BaseFrame1609_4* frame){
TraCIDemo11pMessage* wsm = check_and_cast<TraCIDemo11pMessage*>(frame);
findHost()->getDisplayString().setTagArg("i", 1, "green");
//traciVehicle->changeVehicleRoute({"-gneE11","-gneE11"});
// mobility = TraCIMobilityAccess().get(getParentModule());
// traci = mobility->getCommandInterface();
//traciVehicle = mobility->getVehicleCommandInterface();
// traciVehicle->changeRoute("-gneE11", 6);
if (mobility->getRoadId()[0] != ':'){traciVehicle->changeRoute("-gneE11", 3600);}
if (!sentMessage) {
sentMessage = true;
// repeat the received traffic update once in 2 seconds plus some random delay
wsm->setSenderAddress(myId);
wsm->setSerial(3);
scheduleAt(simTime() + 2 + uniform(0.01, 0.2), wsm->dup());
}
}
Upvotes: 0
Views: 531
Reputation: 6943
If you are curious to see what the various SUMO methods do, I would advise you look directly into the source code, e.g., https://github.com/sommer/veins/blob/veins-5.1/src/veins/modules/mobility/traci/TraCICommandInterface.cc#L313. You will see that, what your code does, is to change the routing of a car to assume an effort of 3600
(1 hour, that is, a lot of effort) for edge -gneE11
. This edge is not part of any of your vehicles' routes, so none of your vehicle cares: the routes they intended to take are still "perfectly fine".
For alternatives, see also the methods of https://github.com/sommer/veins/blob/veins-5.1/subprojects/veins_testsims/src/veins_testsims/traci/TraCITestApp.cc which call all SUMO methods implemented in Veins 5.1 once to see if they behave as intended. For example, https://github.com/sommer/veins/blob/veins-5.1/subprojects/veins_testsims/src/veins_testsims/traci/TraCITestApp.cc#L285 changes (for one vehicle) the assumed effort of edge 42
to 9999
, then (later) checks if the vehicle indeed avoided taking that edge.
Judging by your commented-out code, the code in https://github.com/sommer/veins/blob/veins-5.1/subprojects/veins_testsims/src/veins_testsims/traci/TraCITestApp.cc#L475 is more in line with what you wanted to do: give a new route to a vehicle.
Upvotes: 1