Closed ucarseyhan closed 6 years ago
Due to a recent API change, the no-argument call is now called traci.vehicle.getAllSubscriptionResults()
whereas traci.vehicle.getSubscriptionResults(vehID) must be called with the vehicle ID of one of the subscribed vehicles.
The error "takes exactly 2 arguments" also counts the implicit "self" argument so actually it's only 1 argument that was missing.
Dear namdre;
Thanks for your quick reply.
I changed the function name as you directed. However, this time SUMO complains as "Error: tcpip::Storage::readIsSafe: want to read 4 bytes from Storage, but only 3 remaining". Is it related to my code or do I miss something?
Thanks, Regard.
This sounds like a mismatch between the python client library version and sumo. getAllSubscriptionResults was added 2 weeks ago but 0.32 dates to 2017
Dear namdre;
Thanks again for your prompt reply. You are right! I downgrade to the older version which is compatible with my SUMO, then all works fine. Thanks in advance.
Regards.
Dear ucarseyhan,
I read the comments but still did not identify the error. Could you tell me how it was resolved? Thank you in advance.
Make sure to use a traci client version that matches your sumo version. That's all.
Dear ucarseyhan,
I read the comments but still did not identify the error. Could you tell me how it was resolved? Thank you in advance.
Hi rose36,
As @namdre has already answered, please check the traci and SUMO version. They need to match with each other. Bests.
I am using version 0.32 of SUMO, which version of traci would be appropriate? Sorry for the question, but I started to study the traci now and I still have a lot of doubts.
I am using version 0.32 of SUMO, which version of traci would be appropriate? Sorry for the question, but I started to study the traci now and I still have a lot of doubts.
Hi rose36,
For exp., let's say you are using python Traci API. When you download the SUMO 0.32, the folder has "tools" sub-folder. There you will find "traci" folder which contains the compatible python API. You need to use that python API for your simulation/emulation/evaluation. Hope this helps. Bests.
Thank you very much for your answer, ucarseyhan!
I was doing this but using the version available on SourceForge. I'll try to do the same with the version available in the git repository.
Hi guys, it seems like I met the same mismatch problem between sumo and traci. My error goes like
Error: tcpip::Storage::readIsSafe: want to read 4 bytes from Storage, but only 3 remaining Quitting (on error). Error during start: Traceback (most recent call last): File "/home/elizabeth/0MA/flow/flow/core/kernel/simulation/traci.py", line 159, in start_simulation traci_connection.simulationStep() File "/home/elizabeth/anaconda3/envs/MultiAgent/lib/python3.6/site-packages/traci/connection.py", line 323, in simulationStep result = self._sendExact() File "/home/elizabeth/anaconda3/envs/MultiAgent/lib/python3.6/site-packages/traci/connection.py", line 99, in _sendExact raise FatalTraCIError("connection closed by SUMO") traci.exceptions.FatalTraCIError: connection closed by SUMO
Traceback (most recent call last): File "examples/stable_baselines/stabilizing_the_ring.py", line 115, in
model = run_model(args.num_cpus, args.rollout_size, args.num_steps) File "examples/stable_baselines/stabilizing_the_ring.py", line 98, in run_model constructor = env_constructor(params=flow_params, version=0)() File "/home/elizabeth/0MA/flow/flow/utils/registry.py", line 124, in create_env return gym.envs.make(env_name) File "/home/elizabeth/anaconda3/envs/MultiAgent/lib/python3.6/site-packages/gym/envs/registration.py", line 156, in make return registry.make(id, kwargs) File "/home/elizabeth/anaconda3/envs/MultiAgent/lib/python3.6/site-packages/gym/envs/registration.py", line 101, in make env = spec.make(kwargs) File "/home/elizabeth/anaconda3/envs/MultiAgent/lib/python3.6/site-packages/gym/envs/registration.py", line 73, in make env = cls(**_kwargs) File "/home/elizabeth/0MA/flow/flow/envs/ring/wave_attenuation.py", line 87, in init super().init(env_params, sim_params, network, simulator) File "/home/elizabeth/0MA/flow/flow/envs/base.py", line 169, in init network=self.k.network, sim_params=sim_params) File "/home/elizabeth/0MA/flow/flow/core/kernel/simulation/traci.py", line 166, in start_simulation raise error File "/home/elizabeth/0MA/flow/flow/core/kernel/simulation/traci.py", line 159, in start_simulation traci_connection.simulationStep() File "/home/elizabeth/anaconda3/envs/MultiAgent/lib/python3.6/site-packages/traci/connection.py", line 323, in simulationStep result = self._sendExact() File "/home/elizabeth/anaconda3/envs/MultiAgent/lib/python3.6/site-packages/traci/connection.py", line 99, in _sendExact raise FatalTraCIError("connection closed by SUMO") traci.exceptions.FatalTraCIError: connection closed by SUMO
I am also new to traci and sumo. After reading your comments I am still confused about how to update traci or find out which version of traci should I use.
I am using python 3.6, flow 0.5 and sumo 1.1.0.
I've tried copy the files under sumo-1.1.0/sumo/tools/traci
to replace the existing folder under /home/elizabeth/anaconda3/envs/MultiAgent/lib/python3.6/site-packages/traci
.
It turned out to a different error
Traceback (most recent call last): File "examples/stable_baselines/stabilizing_the_ring.py", line 115, in
model = run_model(args.num_cpus, args.rollout_size, args.num_steps) File "examples/stable_baselines/stabilizing_the_ring.py", line 104, in run_model model.learn(total_timesteps=num_steps) File "/home/elizabeth/0MA/flow/stable-baselines/stable_baselines/ppo2/ppo2.py", line 319, in learn runner = Runner(env=self.env, model=self, n_steps=self.n_steps, gamma=self.gamma, lam=self.lam) File "/home/elizabeth/0MA/flow/stable-baselines/stable_baselines/ppo2/ppo2.py", line 445, in init super().init(env=env, model=model, n_steps=n_steps) File "/home/elizabeth/0MA/flow/stable-baselines/stable_baselines/common/runners.py", line 19, in init self.obs[:] = env.reset() File "/home/elizabeth/0MA/flow/stable-baselines/stable_baselines/common/vec_env/dummy_vec_env.py", line 51, in reset obs = self.envs[env_idx].reset() File "/home/elizabeth/0MA/flow/flow/envs/ring/waveattenuation.py", line 210, in reset observation = super().reset() File "/home/elizabeth/0MA/flow/flow/envs/base.py", line 541, in reset observation, , , = self.step(rl_actions=None) File "/home/elizabeth/0MA/flow/flow/envs/base.py", line 333, in step self.k.vehicle.get_controlled_ids(), accel) File "/home/elizabeth/0MA/flow/flow/core/kernel/vehicle/traci.py", line 921, in apply_acceleration self.kernel_api.vehicle.slowDown(vid, next_vel, 1e-3) File "/home/elizabeth/anaconda3/envs/MultiAgent/lib/python3.6/site-packages/traci/_vehicle.py", line 812, in slowDown "!BiBdBi", tc.TYPE_COMPOUND, 2, tc.TYPE_DOUBLE, speed, tc.TYPE_INTEGER, duration) struct.error: required argument is not an integer Error: Answered with error to command 0xc4: Slow down needs a compound object description. Error: Answered with error to command 0xc4: Wrong position in requestMessage after dispatching command. Expected command length was 33 but 16 Bytes were read. Error in atexit._run_exitfuncs: Traceback (most recent call last): File "/home/elizabeth/0MA/flow/flow/envs/base.py", line 674, in terminate self.k.close() File "/home/elizabeth/0MA/flow/flow/core/kernel/kernel.py", line 109, in close self.simulation.close() File "/home/elizabeth/0MA/flow/flow/core/kernel/simulation/traci.py", line 64, in close self.kernel_api.close() File "/home/elizabeth/anaconda3/envs/MultiAgent/lib/python3.6/site-packages/traci/connection.py", line 307, in close self._sendExact() File "/home/elizabeth/anaconda3/envs/MultiAgent/lib/python3.6/site-packages/traci/connection.py", line 104, in _sendExact raise TraCIException(prefix[1], _RESULTS[prefix[2]], err) traci.exceptions.TraCIException: Slow down needs a compound object description. Error: tcpip::Socket::recvAndCheck @ recv: peer shutdown
Could you guys please help me with this and tell me more about how to fix the mismatch? Many thanks!
Your error seems to be unconnected to this ticket. Please open a new one. The flow people still seem to recommend their own SUMO version. Did you install this one?
Thank you @behrisch ! I found out that sumo don't need to be install independently when using flow. I fixed this by simply change path in bashrc back to sumo_binaries which automatically downloaded under flow folder. Wonder why it didn't work earlier. Anyway, thanks a lot!
Hi All,
Sorry for this question but it is a newbie's one. I want to use traci (python) for simulation with SUMO (0.32) To do that, I follow the tutorial (http://sumo.dlr.de/wiki/TraCI/Interfacing_TraCI_from_Python) and want to track vehicle position. The code for that is below;
The code successfully makes SUMO start. However, when it comes to getSubscriptionResults, it fails. I know getSubscriptionResults() has multiple implementations. I want to use the no argument one. However, my system always generates the error "getSubscriptionResults() takes exactly 2 arguments". I am working on macOS High Sierra and python version is 2.7. Any help other tutorial is appreciated.
Thanks. Regards.