Open Jeffrey28 opened 2 years ago
Did you also receive a FatalTraCIError "connection closed by SUMO"
?
Please attach a minimum working example of your code so we can reproduce the error.
The minimum working example is hard to be produced. Because it happens on different time. I also encounter that when it used traci, vehicles = self.traci.vehicle.getIDList(), it returned the error that 'AttributeError: 'Connection' object has no attribute '_socket'.
After I tried sumo-1.10.0, I got the errors: Traceback (most recent call last): File "/home/ubuntu/data/Jeffrey/gym-sumo-DRL/intersectionPPO/intersection_gym.py", line 178, in addEgoCar self.traci.simulationStep() File "/home/ubuntu/data/sumo/tools/traci/main.py", line 228, in simulationStep return _connections[""].simulationStep(step) File "/home/ubuntu/data/sumo/tools/traci/connection.py", line 315, in simulationStep result = self._sendCmd(tc.CMD_SIMSTEP, None, None, "D", step) File "/home/ubuntu/data/sumo/tools/traci/connection.py", line 181, in _sendCmd return self._sendExact() File "/home/ubuntu/data/sumo/tools/traci/connection.py", line 91, in _sendExact raise FatalTraCIError("connection closed by SUMO") traci.exceptions.FatalTraCIError: connection closed by SUMO
After some tests have been done, it happened on such these versions: 1.12, 1.11, 1.10, 1.9, 1.8 Codes are shown that: def addEgoCar(self): try: vehicles = self.traci.vehicle.getIDList() except: sumoact.exit_sumo() sumoact.start_sumo() vehicles = self.traci.vehicle.getIDList()
for _ in range(2): try: self.traci.simulationStep() except: sumoact.exit_sumo() sumoact.start_sumo() self.traci.simulationStep()
Errors are shown that: Traceback (most recent call last): File "/home/ubuntu/data/Jeffrey/gym-sumo-DRL/intersectionPPO/intersection_gym.py", line 156, in addEgoCar vehicles = self.traci.vehicle.getIDList() File "/home/ubuntu/data/sumo/tools/traci/domain.py", line 196, in getIDList return self._getUniversal(tc.TRACI_ID_LIST, "") File "/home/ubuntu/data/sumo/tools/traci/domain.py", line 172, in _getUniversal return _parse(self._retValFunc, varID, self._getCmd(varID, objectID, format, values)) File "/home/ubuntu/data/sumo/tools/traci/domain.py", line 177, in _getCmd r = self._connection._sendCmd(self._cmdGetID, varID, objID, format, values) File "/home/ubuntu/data/sumo/tools/traci/connection.py", line 181, in _sendCmd return self._sendExact() File "/home/ubuntu/data/sumo/tools/traci/connection.py", line 82, in _sendExact if self._socket is None: AttributeError: 'Connection' object has no attribute '_socket'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/ubuntu/data/Jeffrey/gym-sumo-DRL/intersectionPPO/ppo.py", line 561, in
Traceback (most recent call last): File "/home/ubuntu/data/Jeffrey/gym-sumo-DRL/intersectionPPO/intersection_gym.py", line 178, in addEgoCar self.traci.simulationStep() File "/home/ubuntu/data/sumo/tools/traci/main.py", line 221, in simulationStep return _connections[""].simulationStep(step) File "/home/ubuntu/data/sumo/tools/traci/connection.py", line 302, in simulationStep result = self._sendCmd(tc.CMD_SIMSTEP, None, None, "D", step) File "/home/ubuntu/data/sumo/tools/traci/connection.py", line 180, in _sendCmd return self._sendExact() File "/home/ubuntu/data/sumo/tools/traci/connection.py", line 90, in _sendExact raise FatalTraCIError("connection closed by SUMO") traci.exceptions.FatalTraCIError: connection closed by SUMO
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/ubuntu/data/Jeffrey/gym-sumo-DRL/intersectionPPO/ppo.py", line 561, in
And when I tried under sumo-1.7 and sumo-1.6: Though sometimes it would fail when trying "self.traci.simulationStep()", it can success sun these codes: except: sumoact.exit_sumo() sumoact.start_sumo() self.traci.simulationStep()
It can be concluded that:
I do not know whether it is related with 'take action' codes as following:
def takeAction(self, accel):
accel = lmap(accel, [-1, 1], self.acceleration_range)
dt = self.traci.simulation.getDeltaT() # dt = 0.2
self.speed = self.speed + dt * accel
# Exceeded lane speed limit
if self.speed > self.max_speed:
self.speed = self.max_speed
elif self.speed < 0:
self.speed = 0
self.traci.vehicle.slowDown(self.egoCarID, self.speed, dt)
The disconnect occurs most probably due to sumo receiving faulty input data or crashing. Simply restarting sumo is also probably not what you want since it simply restarts the whole simulation. If you cannot get an MWE to work, please create a TraCI log file and attach it with all relevant config and scenario files.
The problem is why I can not restart the simulation by using traci.start() when it crashed on sumo-1.12.
Is it related with "Vehicle 'ego' teleports beyond arrival edge '5to4', time=14811.60."
I am sure now it is because the "vehicle 'ego' teleports beyond arrival edge '5to4'" after I set "--collision.action", "warn" not "teleport".
Possibly one of the traci commands you are sending to vehicle '5to4' fails while it's teleporting. This may well be a bug on the SUMO side but we need a minimum working example of your simulation. Instead of a your traci script you can provide a log of traci commands: https://sumo.dlr.de/docs/TraCI/Interfacing_TraCI_from_Python.html#generating_a_log_of_all_traci_commands
Please also post the other input files: net and routes
Add your issue description here.
If possible, upload an example that shows your problem.
SUMO-1.12:
linux-ubuntu20.04: Traceback (most recent call last): File "/home/ubuntu/data/Jeffrey/gym-sumo-DRL/intersectionPPO/ppo.py", line 561, in
re_action=args.safe_check, logger_kwargs=logger_kwargs, config=args)
File "/home/ubuntu/data/Jeffrey/gym-sumo-DRL/intersectionPPO/ppo.py", line 477, in ppo
o, ep_ret, ep_cret, ep_len = env.reset(), 0, 0, 0
File "/home/ubuntu/data/Jeffrey/gym-sumo-DRL/intersectionPPO/intersection_gym.py", line 50, in reset
self.addEgoCar() # Add the ego car to the scene
File "/home/ubuntu/data/Jeffrey/gym-sumo-DRL/intersectionPPO/intersection_gym.py", line 159, in addEgoCar
sumoact.exit_sumo()
File "/home/ubuntu/data/Jeffrey/gym-sumo-DRL/intersectionPPO/sumoact.py", line 47, in exit_sumo
traci.close()
File "/home/ubuntu/data/sumo/tools/traci/main.py", line 284, in close
_connections[""].close(wait)
File "/home/ubuntu/data/sumo/tools/traci/connection.py", line 391, in close
if self._socket is not None:
AttributeError: 'Connection' object has no attribute '_socket'