Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to improve the frames per second in gym_torcs.py #31

Open
yanpanlau opened this issue May 2, 2017 · 7 comments
Open

How to improve the frames per second in gym_torcs.py #31

yanpanlau opened this issue May 2, 2017 · 7 comments

Comments

@yanpanlau
Copy link

Hi,
I am working on the new projects in gym_torcs which requires faster frames per second. I found that in

ob, reward, done, _ = env.step(action)

which calls line 122-124 in gym_torcs.py

client.respond_to_server() 
# Get the response of TORCS 
client.get_servers_input() 

is very slow. the 2 lines above took 0.2 seconds (so 5 fps)

Do you know if there is anyway I can improve the fps?

Thanks,

Ben

@kschan
Copy link

kschan commented Jul 24, 2017

I am also having this same issue. Control updates are getting sent at 5Hz which seems excessively slow

@spsancti
Copy link

spsancti commented Mar 5, 2018

Hi, the same issue here. Any workaround for now?

@kschan
Copy link

kschan commented Mar 5, 2018

If you don't need to use the gym-torcs environment specifically, I found using the SCRC patch on TORCS and the Snakeoil Python client together worked very nicely, I get 20Hz game state and control input. See my repo for code: https://github.com/kschan/torcs_scripts

Sorry if the code is not very clean.

@spsancti
Copy link

spsancti commented Mar 5, 2018

Hi, @kschan , thanks for your work!
Is there any possibility to enable image input?

@kschan
Copy link

kschan commented Mar 5, 2018

Not via my code! I bet you could do something clever though.

@spsancti
Copy link

spsancti commented Mar 6, 2018

Oh, I'll try to figure it out.

BTW, vtorcs-RL-color already has scr-patch applied.

I did some profiling, and the most time-consuming part of the code is:

sockdata,addr= self.so.recvfrom(data_size)

which is called at line 168 in snakeoil3_gym.py. It takes about 180 ms to complete.
Also, if I make socket non-blocking, client is still waiting about 180 ms, so issue is on the TORCS side.

@yanpanlau , @ugo-nama-kun , do you have any ideas about this?

@spsancti
Copy link

spsancti commented Mar 6, 2018

Well, I have figured it out.
It is just here.

I got sustainable results with RCM_MAX_DT_ROBOTS of 0.05. If I make it less, TORCS eventually freezes.
Also, in scr_server and here I changed the number of bots to 1 so not to waste precious resources.

And, here it is! As for me, it is really good result!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants