dosssman / GymTorcs

A Gym wrapper for the Torcs Racing car simulator
32 stars 7 forks source link

KeyError: 'lap' #4

Closed betacatZ closed 1 year ago

betacatZ commented 1 year ago

Thank you for your work. How did you get the current laps of the car? I have the following problem

Traceback (most recent call last):
  File "main.py", line 78, in <module>
    ob = env.reset(relaunch = True)
  File "/home/zdm/anaconda3/envs/torcs/lib/python3.7/site-packages/gym/wrappers/order_enforcing.py", line 16, in reset
    return self.env.reset(**kwargs)
  File "/home/zdm/GymTorcs-master/gym_torcs/torcs_env.py", line 490, in reset
    self.observation = self.make_observaton(obs)
  File "/home/zdm/GymTorcs-master/gym_torcs/torcs_env.py", line 608, in make_observaton
    dict_obs[obs_name] = raw_obs[obs_name]
KeyError: 'lap'
dosssman commented 1 year ago

Thanks for reaching out.

What steps have you followed to install the vtorcs binaries (simulator) ? Moreover, could you please provide details on how you initialize and use the wrapper ?

The error you got suggests that the torcs-bin simulator is not providing data to the python environment in the expected format, hence the 'lap' key missing.

Hope to hear from you soon.

betacatZ commented 1 year ago

I forgot to install torcs-bin. I installed it and ran it successfully. It seems that you have modified a lot of code about vtorcs-RL-color. The default gym-torcs does not havelap. After training the set number of laps, client.R.d ['meta '] is not set to true. The program will not terminate or restart the game. It just keeps returning the same reward value. I have been troubled by this problem for a long time, You successfully solved it.

Thank you again for your work!

dosssman commented 1 year ago

There was indeed some moderate rewrite to make the simulator and python interaction smoother and easier to experiment. Unfortunately, support for pixel-based observation had to be sacrificed due to lack of time. Glad it has proven to be of some use to you. Let me know if there is anything else.