eclipse-sumo / sumo

Eclipse SUMO is an open source, highly portable, microscopic and continuous traffic simulation package designed to handle large networks. It allows for intermodal simulation including pedestrians and comes with a large set of tools for scenario creation.
https://eclipse.dev/sumo
Eclipse Public License 2.0
2.58k stars 1.44k forks source link

getLeader() returns 'None' while the leader present #14049

Open caferavci opened 1 year ago

caferavci commented 1 year ago

Hi,

I have issue with getLeader() function as indicated screenshot below. It returns 'None' while the leading vehicle present.

I debugged getFollower with that leading vehicle, it returns correct value. What are the possible issues in my approach?

This is error line in my code: control_cacc(ids, traci.vehicle.getLeader(ids)[0])

If possible, upload an example that shows your problem.

image

SUMO-version: 1.13.0 operating system: Win OS 11 Pro 22621.2428

m-kro commented 1 year ago

You use a relatively old SUMO release. Can you please update to v.1.19 and check whether the problem still is present?

caferavci commented 1 year ago

I have updated with v.1.19, it is still same.

m-kro commented 1 year ago

I cannot reproduce this using a very similar circular driving scenario. Do you want to share a minimal scenario including python code (either your script or a log of your commands, see docs)?

caferavci commented 1 year ago

net.zip Here is the .zip file.

robertalms commented 1 year ago

Your example code crashes - respectively the getLeader() function returns 'None' - because the leading vehicle 'CACC_3' is already on the next edge in the current time step that you're calling the getLeader() function.

I am not sure what would be a convenient solution to get the leading vehicle across consecutive edges. Not that simple I guess, but maybe my colleagues have an idea or I simply missed something.

caferavci commented 1 year ago

This structure can be common problem in most of the simulation platforms. I want to get help especially in building the strcuture for the consecutive edges part. This scenario is first step for my study. If I solve edge issues, remaining steps could be easier for me.

m-kro commented 1 year ago

There is something special with your example I haven't entirely discovered yet. The problem happens only at a specific node. I'll keep you posted.

m-kro commented 1 year ago

@caferavci As a workaround, please call traci.vehicle.getLeader(vehID, dist=DIST) where DIST is the minimum lookahead distance in meters. The automatic lookahead computed out of the brake gap triggered by the default dist=0 seems not to be reliable. We'll have to work on that.

caferavci commented 1 year ago

Thank you very much for your quick and efficient responses. It works now. I can continue with DIST until your update. All the best.

m-kro commented 1 year ago

There seems to be a discontinuity in our search for the leader vehicle. When the leader has left the edge with the front, the search does not check for vehicles with the back still on the same edge as the follower. Instead, it already stops the search before:

https://github.com/eclipse-sumo/sumo/blob/aee3bde9d8245b17673b6290684e5535723292e8/src/microsim/MSLane.cpp#L2834-L2836

Additionally, the search distance currently does not play a role as long as the vehicles are on the same lane.

caferavci commented 1 year ago

Thank you for the update. Yes, I realized that part when I applied shockwave in the simulation. There were continuous peaks for the accelerations. So, I need further suggestions.

m-kro commented 1 year ago

The results from using the brake gap with dist=0 are conform to their description in the documentation but we understand that the discontinuities across edges are problematic for users. So we have decided to change the default distance of traci.vehicle.getLeader to 100 [m]. As the internal logic used for this function is used on more places, we cannot change it easily.