pythonsumo

SUMO TraCI how can i get id junction by ID vehicle or ID edge?


I need the junction that vehicle is approaching I mean the vehicle on the junction lane This is the junction I need

I can get the lane and edge by

edge = traci.vehicle.getRoadID(id_veh])
lane = traci.vehicle.getLaneID(id_veh)

Solution

  • The easiest solution is to parse the network with sumolib and get the junction from there:

    # import the library
    import sumolib
    # parse the net
    net = sumolib.net.readNet('myNet.net.xml')
    
    # retrieve the successor node ID of an edge
    nextNodeID = net.getEdge('myEdgeID').getToNode().getID()
    

    This is directly from the examples