Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[sumo-user] Issue with getLeader method

Hi,

I used the code below to get the position of leading vehicle. However, sometimes the simulation gives the position of the leading vehicle behind the ego vehicle (as shown in the output). How does this happen ?

 leader = traci.vehicle.getLeader(ego_id)
 if leader != None:
    leader_id = leader[0]
    lead_pos = traci.vehicle.getPosition(leader_id)
    ego_pos = traci.vehicle.getPosition(ego_id)
    print("Ego position {}, Lead position {}".format(ego_pos, lead_pos))

Ego position (795.95, -1.6), Lead position (781.706206685247, -1.6) Ego position (797.5900467095553, -1.6), Lead position (783.2492279457477, -1.6) Ego position (799.1890996324844, -1.6), Lead position (784.7922492062485, -1.6)

Regards,
Deepthi

Back to the top