Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[sumo-dev] Adding stop behind player

Hello,

I currently manually and dynamically assign routes to sumo vehicles in my application.  I link right into the microsim to do this (which works great).  When I assign a new route, I remove all the stops from the the vehicle, since it will be a completely new route, with only one stop at the end.  However, when I try to assign a new route on the same edge/lane as the player is on, only behind him, the application gets an out of bounds exception from the myStops variable in MSVehicle.  

What I suspect is happening is this:
If there is a stop on the lane that the vehicle is currently on, myStopDist is being calculated.
The addition of the route is successful (it's just the same edge I was on, only behind me)
When I remove that stop, myStops (list of stops) goes to zero.  However, the next time myStopDist is calculated is during planMoveInternal() , which is called after checkActionStep() is true.  If it's not time to plan the next move, planMoveInternal() is not called.  What causes the crash is in the executeMovements() function, where the blinker information is updated.  
Specifically, line 5277 (version 1.4) of MSVehicle.  
if (myStopDist < (myLane->getLength() - getPositionOnLane()) && myStops.begin()->pars.parking && myStopDist < getCarFollowModel().......

It passes the myStopDist check, since myStopDist hasn't been reset to double max.  So when it tries to dive into myStop.begin() that's where the crash occurs, because myStops is empty!  I think a good fix would be to check when a stop is deleted, and update the myStop distance if the stop is the one you are going to.  That would be in addTraciStop() in the MSVehicle class.

To Summarize (the best I can, I know this is an obscure use case).
SUMO will allow me to reroute behind me, on the same lane or another lane.  However, it will not let me add a stop behind me.  I tried ignoring route requests behind me in the same lane, but then with multi-lane roads I get the same error.  What I did that seems to work the best is add one line in the MSVehicle::addTraciStop(), after we delete the iteration (when deleting stops) - line 5750: 
myStops.erase(iter);
// my code
if (myStops.empty()) {
  myStopDist = std::numerical_limits<double>::max();
}
// SUMO code

This seems to work well.  Let me know if any or none of this makes sense!
Thanks,
JB





Back to the top