Unity-Technologies / ml-agents

The Unity Machine Learning Agents Toolkit (ML-Agents) is an open-source project that enables games and simulations to serve as environments for training intelligent agents using deep reinforcement learning and imitation learning.
https://unity.com/products/machine-learning-agents
Other
17.12k stars 4.15k forks source link

Action not reflected in rendering in UnityToGymWrapper with custom environment #5731

Closed mayukhghosh closed 2 years ago

mayukhghosh commented 2 years ago

I am trying to wrap a unity environment with the Gym wrapper. The environment consists of a quadcopter whose input is the four forces to its propellors. It seems that the actions given to the drone are not being reflected in the actual simulation. The drone keeps falling down even if maximum force is applied to all its propellers. I have checked it in Unity with manual input and it works there. The observations are 84*84 grayscale image stacked 4 times. I am using the following code:

unity_env = UnityEnvironment('Scenes_exec_single/', worker_id=0, seed=1)
env = UnityToGymWrapper(unity_env, uint8_visual=True)
env = Monitor(env, 'gym_results/')
env = DummyVecEnv([lambda: env])

obs = env.reset()
for i in range(1000):
    #action, _states = model.predict(obs)
    action = [[1, 1, 1, 1]]
    obs, rewards, dones, info = env.step(action)

I have provided a link to the unity executable. https://drive.google.com/drive/folders/1tvQc-QX1v-WSL5ObkzLP2IhKPABAQlPa?usp=sharing

maryamhonari commented 2 years ago

Hi @mayukhghosh, 

We are now using the Unity forums to handle issues like this with custom environments. Please create a new thread there, in order to get the community involved in the discussion, and reply with the link to your forum thread.

A quick test for your case could be sampling the action from action_spaces or manage the stepping with UnityEnvironment.

github-actions[bot] commented 2 years ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.