Skip to content

Latest commit

 

History

History
120 lines (79 loc) · 5.6 KB

getting_started.md

File metadata and controls

120 lines (79 loc) · 5.6 KB

Getting Started

Table of Contents

Introduction

Welcome to the getting started guide of Godot-RL-Pedestrian-Simulation (GRLPS), a tool for pedestrian simulation using reinforcement learning in Godot.

This guide will walk you through the initial steps to using GRLPS. You'll learn how to run a training phase, execute a testing phase, and visualize pedestrian behaviors and flows during the latter phase.

Before diving into this guide, make sure to read the README first, where you'll find information about the tools used, the codebase and the setup of the tool.

Additionally, it's recommended to have a basic understanding of how the tools used work. To assist with this, brief documentation for each tool has been created and is available in the project's docs folder. For more information, please refer to the documentation for Godot and Godot RL Agents.

Training Phase

Setting up Godot Engine

Once the tool is open, navigate through the FileSystem to the training_scene.tscn, which can be found in the training folder. Set this scene as the main scene by right-clicking it in the FileSystem and selecting "Set as Main Scene". From the Scene panel, by clicking on the only node present, TrainingScene, we'll see on the right, in the Inspector panel, the properties of the node. Among these properties, there is Levels Path, where you can choose the order of environments, add new ones, and delete them. For this experiment, it's recommended not to modify this attribute; instructions on how to modify it will be provided in the user guide documentation. Just check that the items are present, as shown in the image below.

Level

Setting up RL

Open an IDE, in this guide, we use PyCharm, but VSCode should work fine as well. Once the project is open, click on Current File in the top right, and then select Edit Configurations. Once the screen is open, create a new Python configuration. As the first parameter, insert the environment where you installed the dependencies during setup. In the script field, insert main.py. In the working directory, insert the project's path. You should get a result similar to the image below.

PyCharm

Remember to click Apply before finishing with the OK button. Now we can run the project with the Run command or the shortcut SHIFT + F10. At this point, the Python server will be waiting for the Godot client and can be viewed from the IDE shell.

Shell

Running Training

Once the server is waiting, we can go back to Godot Engine and run the scene by clicking the Run Project button or pressing F5. At this point, we should be able to see the training scene running correctly.

Run

Testing Phase

Once a training phase has been successfully executed without encountering an Early Fail, a saved model named model.onnx will be available in the scripts/output/onnx path.

Onnx

Select testing_scene.tscn from the testing_scene directory and set it as the main scene. Now, run the project within Godot. The testing phase should start, allowing you to visualize the agent's behaviors in scenarios not seen during the training phase.

Test

Visualize

PedPy

Once the testing phase is complete, you can visualize the trajectories, densities, and speeds within your environments. Open the notebook plotter.ipynb inside the scripts folder, from your IDE. Run all cells by selecting Run All or pressing Ctrl+Alt+Shift+Enter. All the plots will then be displayed.

pedpy

Tensorboard

To view the duration of episodes or the complete run and the graph of cumulative reward during the training phase, we need to enable visualization with TensorBoard.

  1. Navigate to the project path and enter the following command:

    tensorboard --logdir output/runs/run_{run_number}
    
  2. TensorBoard will be available at the address shown in the shell. Open it by Ctrl + clicking or by copying the address.

  3. Access the Scalars section from the top menu, ensure that Show data download links is enabled.

  4. Open the dropdown menus below the graphs labeled run to download and select the run to export.

  5. Finally, click on CSV and save them to the path output/runs/run_{run_number}/tensorboard_export.

    Tensorboard

  6. Open the PlotTensorBoard plotter and run the code. The graphs will be displayed.

    ts-vis

Learn More

With this guide, you have taken the first steps towards using the Godot-RL-Pedestrian-Simulation (GRLPS) tool for pedestrian simulation with reinforcement learning in Godot. You have learned how to set up and run the training and testing phases and how to visualize the resulting pedestrian behaviors and flows.

If you need further information take a look at our user_guide.md, where you can get more insight into what GRLPS can do for you!