The error regarding non-existant vehicles can be "caught" and the problem may yet continue (and take the appropriate action). see https://docs.python.org/2.7/tutorial/errors.html#handling-exceptions
2016-11-02 1:55 GMT+01:00 Vaibhav Rungta <[email protected]>: > Hello, > I am trying to make some simple applications using TraCI. > > *usingtraci1.py* > This code executes correctly and vehicle with vehicle ID v1 is stops > whenever the traffic light is red irrespective of it's position. > > traci.simulationStep() > if traci.trafficlights.getPhase("B2") == 0: #signal at B2 in > state > GGrr > traci.vehicle.setSpeed("v1", 0) > else: > traci.vehicle.setSpeed("v1", 20) > step = step + 1 > > But the problem once the vehicle v1 leaves the network the execution stops > and an error is generated because v1 is no longer in network. Please help > understand how may I avoid it. > > *My approach to avoid this error*: > I thought of capturing vehicle ID and writing that to txt file. I'll > re-structure the if statement and only if v1 is in the network then the > previous command will be executed. > > However I am getting an in file *usingtraci3.py* > > *Error: tcpip::Socket::recvAndCheck @ recv: Socket reset by peer* > *Quitting (on error).* > > I think it's for the wrong usage of command: > get_id = traci.vehicle.getId() > Please help me identify the correct command. > > Next, I plan write all the values to text file: > with open ("vid.txt", "w") as vehicle_id: > get_id = traci.vehicle.getLastStepVehicleIDs() > vehicle_id.write (str(get_id) + '\n') > > Is there a standard syntax for using commands retrieving vehicle ID? > How can we use these values in run time? > > For eg: > if (traci.vehicle.getId() == 'A1') > traci.trafficlights.setPhase("traffic_light_index", phase_index) > > > Thank you. > > Regards, > Vaibhav Rungta > Graduate Student - Industrial and Systems Engineering > Graduate Assistant - Toyota Production Systems Lab > Research Assistant - University Transport Research Center > 585-754-7133 > > ------------------------------------------------------------ > ------------------ > Developer Access Program for Intel Xeon Phi Processors > Access to Intel Xeon Phi processor-based developer platforms. > With one year of Intel Parallel Studio XE. > Training and support from Colfax. > Order your platform today. http://sdm.link/xeonphi > _______________________________________________ > sumo-user mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/sumo-user > > ------------------------------------------------------------------------------ Developer Access Program for Intel Xeon Phi Processors Access to Intel Xeon Phi processor-based developer platforms. With one year of Intel Parallel Studio XE. Training and support from Colfax. Order your platform today. http://sdm.link/xeonphi _______________________________________________ sumo-user mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/sumo-user
