gnns4hri / SocNavGym

GNU General Public License v3.0
14 stars 2 forks source link

Query #3

Open AmolHarsh opened 3 months ago

AmolHarsh commented 3 months ago

Hello Hardworking Contributors, Is there is a way for me to see the robot in action in the real virtual experimental environment after training it on Dueling DQN using StableBaselines3 ? I understand that I can manually control the bot but I am not able to find any code in the repo to translate and see the trained parameters in the real virtual environment.

sushant1212 commented 2 months ago

Hi @AmolHarsh, thanks for using SocNavGym. I'm a bit unclear with the terminology used in your query "real virtual environment". Nevertheless, I'll try to explain to the best of my understanding. I suppose that you want to see the trained model guide the robot in the environment that it was trained on. You can easily achieve this by the following lines of code:

import gym
import socnavgym

def get_action(state):
    # fill this function with code to return the action from the trained model given the state
   ...

env = gym.make("SocNavGym-v1", config="YOUR_ENV_CONFIG")
state, info = env.reset()

done = False
while not done:
    next_state, reward, terminated, truncated, info = env.step(get_action(state))
    env.render()  # this renders the environment on the screen helping you visualize what's happening
    done = terminated or truncated
    state = next_state