trackmania-rl / tmrl

Reinforcement Learning for real-time applications - host of the TrackMania Roborace League
https://pypi.org/project/tmrl
MIT License
482 stars 67 forks source link

Car not self driving with the test script and gets stuck in restart loop #70

Closed danielsjf closed 11 months ago

danielsjf commented 11 months ago

I followed all instructions in the tutorial. All tests seem to work. However, when I run the test script, nothing happens. The only thing I see is a restart every few seconds. What I did:

When I run python -m tmrl --test, I get the following output (nothing else).

(.venv) PS C:\PATH\tmrl> python -m tmrl --test
INFO:root:Namespace(server=False, trainer=False, worker=False, test=True, benchmark=False, record_reward=False, check_env=False, no_wandb=False, config={})
INFO:root:10/22/23 15:24:54 server IP: 127.0.0.1
C:\PATH\venv\Lib\site-packages\gymnasium\core.py:311: UserWarning: WARN: env.default_action to get variables from other wrappers is deprecated and will be removed in v1.0, to get this variable you can do `env.unwrapped.default_action` for environment variables or `env.get_wrapper_attr('default_action')` that will search the reminding wrappers.
  logger.warn(
yannbouteiller commented 11 months ago

Hum this is strange, maybe your TrackMania game is configured with non-default controls for the gamepad?

The TrackMania environment creates a virtual gamepad, so you don't want a gamepad connected to your PC when using it. Something you can do to check that the environment controls the gamepad properly is to open the gamepad tester website in another window and check that it displays a gamepad and double check that the axes used by the environment are the same that control your installation of TrackMania.

danielsjf commented 11 months ago

@yannbouteiller When I try this, the gamepad tester never recognises a gamepad, which might be the problem. Any clue how I could debug this? A few specifics regarding the installation:

danielsjf commented 11 months ago

Got one step closer. I tried to reinstall the latest version of the gamepad driver.

Now the gamepas tester actually shows something and I see some inputs passing. However, still no car moving (I did click on the screen). I did get new warnings. According to your description, this could be not enough fps, but the fps is constant at 150.

real_time_env.py:379: UserWarning: Time-step timed out. Elapsed since last time-step: 0.07368739999947138
  warnings.warn(f"Time-step timed out. Elapsed since last time-step: {now - self.__t_end}")
NDR008 commented 11 months ago

This is not about the game FPS, but the observation speed between steps. Is this the only time or does flood the console with similar messages.

On Wed, 1 Nov 2023, 17:49 Jef D, @.***> wrote:

Got one step closer. I tried to reinstall the latest version of the gamepad driver https://github.com/nefarius/ViGEmBus/releases.

Now the gamepas tester actually shows something and I see some inputs passing. However, still no car moving (I did click on the screen). I did get new warnings. According to your description, this could be not enough fps, but the fps is constant at 150.

real_time_env.py:379: UserWarning: Time-step timed out. Elapsed since last time-step: 0.07368739999947138 warnings.warn(f"Time-step timed out. Elapsed since last time-step: {now - self.__t_end}")

— Reply to this email directly, view it on GitHub https://github.com/trackmania-rl/tmrl/issues/70#issuecomment-1789301723, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIKWRWTMJH3O5N6M5Y77EYLYCJ4QFAVCNFSM6AAAAAA6K5WIQWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTOOBZGMYDCNZSGM . You are receiving this because you are subscribed to this thread.Message ID: @.***>

yannbouteiller commented 11 months ago

The timeout is not related, if you can see the input being sent in the gamepad tester, chances are that your trackmania game is configured for a different input scheme?

I don't know how vgamepad works with the last version of vigem, it is built for version 17.333

PS: you can test vgamepad separately to be sure that the issue doesn't come from here, just double-check that the API presses the right buttons in gamepad-tester.

danielsjf commented 11 months ago

Finally managed to get it all working. Somehow it was related to my venv. I think some of the setup did not work correctly. What I did was to install tmrl for my default python (without a venv) to make sure that all setup processes go well. Now I can run it nicely from a venv as well.

yannbouteiller commented 11 months ago

Great! I don't really understand why installing via the venv didn't work though

danielsjf commented 11 months ago

Me neither, but happy that it did. Thanks for all the help to get this up and running. Now the fun can begin.