edbeeching / godot_rl_agents

An Open Source package that allows video game creators, AI researchers and hobbyists the opportunity to learn complex behaviors for their Non Player Characters or agents
MIT License
902 stars 63 forks source link

Unable to run godot-rl (stablebaselines3) #186

Closed haseebzeeshan2010 closed 3 months ago

haseebzeeshan2010 commented 3 months ago

I followed the following steps from this tutorial that was listed on the godot_rl github page: https://www.youtube.com/watch?v=f8arMv_rtUU

My computer is running Ubuntu 22.04.4 LTS but I have tried with 24.04 LTS as well and there is no change in result

These are the steps I followed (as stated in the video):

Step 1-3

Screenshot from 2024-05-23 14-35-27

Step 4 - Download raw file

Screenshot from 2024-05-23 14-47-49

Step 5 - Place it alongside the rl folder

Screenshot from 2024-05-23 14-50-16

-----End of Python Setup----

Step 6 - Create project

Screenshot from 2024-05-23 14-54-12

Now the filesystem looks like this:

Screenshot from 2024-05-23 14-55-48

Step 7 - Create CharacterBody3D

Screenshot from 2024-05-23 14-57-45

Step 8 - Add emission

Screenshot from 2024-05-23 14-59-34

Step 9 - Add floor

Screenshot from 2024-05-23 15-01-36

Step 10 - Add target(Emission included in this step)

Screenshot from 2024-05-23 15-05-00

Step 11 - Add walls

Screenshot from 2024-05-23 15-57-04

Step 12 - Add template script for player

Screenshot from 2024-05-23 16-05-58

Step 13 - Add Camera3D

Screenshot from 2024-05-23 16-12-29

Step 14 - Re-arrange target and cube in the scene

Screenshot from 2024-05-23 16-14-11

Step 15 - Add signals for wall and target to move cube back to original position

Screenshot from 2024-05-23 16-19-22

Step 16 - Comment out control code

Screenshot from 2024-05-23 16-20-00

Step 17 - Download the godot_rl_agents_plugin-main.zip from github

Screenshot from 2024-05-23 16-22-30

Step 18 - Select the script_templates and addons folder

Screenshot from 2024-05-23 16-27-11

Step 19 - Copy them over

Screenshot from 2024-05-23 16-31-22

Step 20 - Enable the Plugin

Screenshot from 2024-05-23 16-33-01

Step 21 - Add and extend script of AIController3D

Screenshot from 2024-05-23 19-39-14

Add the script_templates script and edit it for purpose of the project

Screenshot from 2024-05-23 19-52-15

Alter the cube.gd script for AI to control velocity

Screenshot from 2024-05-23 19-55-07 Screenshot from 2024-05-23 19-55-23

Step 22 - Finally run the script in the virtual environment through: python3 stable_baselines3_example.py

Step 23 - Add the Sync node in godot

After all this an error appears:

Screenshot from 2024-05-23 20-04-10

Please check if I've missed a step, I've tried this in both the version of godot used in the tutorial (v4.2.dev1) and the latest stable version, but there is the same issue

Adding ": Node3D" in step 15 does not make a difference to the result

It would be very much appreciated if you could help with this issue

Thanks in advance

Ivan-267 commented 3 months ago

Hello, I think it's a version mismatch issue. Try installing the latest version of Godot RL Agents from this repository (main branch).

haseebzeeshan2010 commented 3 months ago

Thanks for the reply!

I have downloaded the entire main branch, but where do I find the folders for the plugin as there is no addon or script_templates file to copy over to the godot project?

Ivan-267 commented 3 months ago

For the main project, try using pip install https://github.com/edbeeching/godot_rl_agents/archive/refs/heads/main.zip

For plugin (the files to copy to the Godot project), use the plugin repository to get the latest version: https://github.com/edbeeching/godot_rl_agents_plugin

haseebzeeshan2010 commented 3 months ago

I used the command in the environment and made sure I installed the updated plugin but unfortunately the problem still persists.

I looked a little deeper into the error and it looks like the handshake does complete but then it returns a null value that the handle_message() function cannot manage and the server disconnects.

My logic could be mistaken as there might be a problem with the stable_baselines3_example.py(even though I've downloaded it from the correct branch) but here are some images of the error:

Screenshot from 2024-05-24 10-30-14

Screenshot from 2024-05-24 10-32-18

Ivan-267 commented 3 months ago

Perhaps you can try an example from the examples repository: https://github.com/edbeeching/godot_rl_agents_examples

You could also try unistalling godot rl agents with pip uninstall before installing (if you didn't try already).

haseebzeeshan2010 commented 3 months ago

Thanks for the advice, will try and complete one of the examples before coming back to this

haseebzeeshan2010 commented 3 months ago

I got the example working. Thanks for the help!