I am trying to maintain a constant number of vehicles.  Using TRaCI, when I
sense that a vehicle has arrived, I try to add the vehicle back to the same
route, but am getting Invalid route '!x' for vehicle 'x'.

Below is my TRaCI run script.  Please help me understand what to correct.

def run():
    """execute the TraCI control loop"""
    traci.init(PORT)
    traci.simulation.subscribe()
    print traci.simulation.getSubscriptionResults()
    step = 0
    while traci.simulation.getMinExpectedNumber() > 0:
        traci.simulationStep()
        arrived = traci.simulation.getArrivedNumber()
        if arrived > 0:
          arrivedList = traci.simulation.getArrivedIDList()
          print traci.simulation.getCurrentTime(), " arrived list",
arrivedList
          for vehicleId in arrivedList:
            routeId = "!" + str(vehicleId)
            newVehicleId = str(vehicleId)
            print newVehicleId, ", ->", routeId, "<-"
            # the following give "Invalid route" for vehicle
            traci.vehicle.add(newVehicleId, routeId)
        step += 1
    traci.close()
    sys.stdout.flush()


-- 

Best,
Scott Carpenter
Graduate student (PhD track), NCSU Department of Computer Science
[email protected]
919-413-5083
------------------------------------------------------------------------------
_______________________________________________
sumo-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sumo-user

Reply via email to