Hello, 1) adding a route only succeeds if the name is not already used by another route. Therefore, adding the same route again and again in a loop cannot work. The resulting error is not fatal, however. You can catch the TraCIException and continue with your script. 2) adding a trip (a route with two non-consecutive edges) only works if the vehicle is equipped with a rerouting device. This is even explained in the documentation you linked: http://sumo.dlr.de/wiki/TraCI/Interfacing_TraCI_from_Python#Add_trips_.28incomplete_routes.29_dynamically If no route is found between the two edges (because they are in disconnected parts of the network) you will get an exception but you can catch that as well.
regards, Jakob 2018-07-02 19:18 GMT+02:00 Stefano Niero <stefano.ni...@hotmail.it>: > Dear SUMO Community, > > I tried generate a new trip and a new vehicle using the example written > in the following page: > > http://sumo.dlr.de/wiki/TraCI/Interfacing_TraCI_from_Python > > At the beginning, to understand how it works I decided to keep things > simple and used a minimal map (attached). > > The line of codes I wrote are: > > > > def run(): > > step = 0 > > while step < 1000: > > #traci.simulationStep() > > traci.route.add("route1", ["gneE2", "gneE5"]) > > traci.vehicle.add("car", "route1", typeID="newCar") > > step +=1 > > traci.close() > > sys.stdout.flush() > > > > where the two edges are contiguous because if I select two edges that are > far one from the other it tells me that no connection is available (why?). > Starting the program it opens the GUI but playing the simulation it stops > immediately saying: > > > > ------------------------------------------------------------ > ---------------------------- > > Loading configuration... done. > > ***Starting server on port 56264 *** > > Loading net-file from 'bus.net.xml'... done (2ms). > > Loading additional-files from 'bus.add.xml'... done (0ms). > > Loading done. > > Simulation started with time: 0.00 > > Error: Answered with error to command 0xc6: Could not add route. > > Error: tcpip::Socket::recvAndCheck @ recv: Socket reset by peer > > Quitting (on error). > > ------------------------- > > On SUMO-GUI, while PyCharm log gives me: > > > > Loading configuration... done. > > Traceback (most recent call last): > > File "C:/Stefano/For school/Tesi/TraCI/Simulation/runner.py", line 100, > in <module> > > run() > > File "C:/Stefano/For school/Tesi/TraCI/Simulation/runner.py", line 67, > in run > > traci.route.add("route1", ["gneE2", "gneE5"]) > > File "C:\Program Files (x86)\DLR\Sumo\tools\traci\_route.py", line 46, > in add > > self._connection._sendExact() > > File "C:\Program Files (x86)\DLR\Sumo\tools\traci\connection.py", line > 104, in _sendExact > > raise TraCIException(prefix[1], _RESULTS[prefix[2]], err) > > traci.exceptions.TraCIException: Could not add route. > > > > Process finished with exit code 1 > > > > Can you tell me what I did wrong? > > Thank you very much > > Stefano Niero > > > > _______________________________________________ > sumo-user mailing list > sumo-user@eclipse.org > To change your delivery options, retrieve your password, or unsubscribe > from this list, visit > https://dev.eclipse.org/mailman/listinfo/sumo-user > >
_______________________________________________ sumo-user mailing list sumo-user@eclipse.org To change your delivery options, retrieve your password, or unsubscribe from this list, visit https://dev.eclipse.org/mailman/listinfo/sumo-user