maxspahn / gym_envs_urdf

URDF environments for gym
https://maxspahn.github.io/gym_envs_urdf/
GNU General Public License v3.0
46 stars 14 forks source link

Running multiple threaded envs in parallel #271

Open yj-Tang opened 3 months ago

yj-Tang commented 3 months ago

Hi Max, I’m currently trying to run multiple urdfenvs in parallel, as suggested here. While everything runs smoothly overall, I'm encountering an issue with goal generation in the parallel environments, except for the first one.

In both the regular environments and the first parallel environment, the key for the goal is '1'. However, in the other parallel environments, the key unexpectedly changes to '0', and the goal position defaults to [0,0,0]. Could you clarify what the key represents in this context? Do you have any insights into what might be causing this issue?

Thank you for your time. Best regards, Yujie

maxspahn commented 3 months ago

Hi @yj-Tang,

it is a very interesting use case for this repository, and I haven't played around with parallelization at all myself, so I am curious about this. And i am very eager to help here.

The indices of goals and obstacles have no meaning at all, so are simply the index provided by pybullet at creation of the instances. I hoped they would be unique, which does not seem to be true. For now, I have no quick fix.

Can you also provide me with a small example here?

Best, Max.

yj-Tang commented 3 months ago

Hi Max,

I've forked this repo to my GitHub repository. My changes are in the "vectorized_envs" branch. Here's a summary of the modifications:

  1. Flattened the observation of burden and created a CustomizedFlattenObservation wrapper.
  2. Implemented a vectorized environment using the flattened observation, allowing multiple environments to run independently.
  3. Modified gym_envs_urdf/urdfenvs/urdf_common/urdf_env.py to support running multiple PyBullet environments in parallel.
  4. Added a simple script gym_envs_urdf/examples/test_parallel_env.py to test the vectorized environment.

The vectorized environment appears to be running, but I've noticed an issue: the goal information (first 3 elements in the observation) seems incorrect.

I would greatly appreciate if you could give any comment on the goal information discrepancy.