Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] Randomizing the size and position of static objects (box geoms) makes them partially penetrable and leads to unexpected behavior #1295

Open
Omer1Yuval1 opened this issue Jan 21, 2025 · 0 comments
Labels
question Further information is requested

Comments

@Omer1Yuval1
Copy link

Question

I added static obstacles (box geoms) to the half_cheetah.xml model, and I would like to randomize their position and size during training at the beginning of each episode (by adding a small random number to their original position and size). To do this, I set the following in the reset_model() method

self.model.geom(f"geom_{i}").pos[0] += np.random.uniform(a, b) # Position.
self.model.geom(f"geom_{i}").size[0] += np.random.uniform(c, d) # Depth.
self.model.geom(f"geom_{i}").size[2] += np.random.uniform(e, f) # Height.

The call to self.set_state() comes after setting the above.

However, it seems that this leads to some discrepancy within MuJoCo, as the box geoms become partially penetrable after modifying their position and size (i.e., the cheetah's body partially penetrates the box geoms, and sometimes even gets stuck inside them).

ChatGPT suggested adding mujoco.mj_forward(self.model, self.data) or self.sim.forward() before or after the call to self.set_state(), but this made no difference.

I am using
gymnasium 0.28.1
mujoco 3.2.3

@Omer1Yuval1 Omer1Yuval1 added the question Further information is requested label Jan 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant