gym icon indicating copy to clipboard operation
gym copied to clipboard

[Question] Modifying and Analyzing mujoco's qpos and qvel

Open JinzhuLuo opened this issue 1 year ago • 1 comments

I'm currently conducting research on state's variables in the Mujoco environment and need to modify some of these variables. Specifically, I intend to make adjustments to the state in Mujoco by adding or removing certain variables. However, after reviewing the code, I've noticed a lack of documentation about how to create a state in mujoco.

For example:

def init(self, **kwargs): observation_space = Box(low=-np.inf, high=np.inf, shape=(11,), dtype=np.float64) MuJocoPyEnv.init( self, "hopper.xml", 4, observation_space=observation_space, **kwargs ) utils.EzPickle.init(self, **kwargs)

def _get_obs(self): return np.concatenate( [self.sim.data.qpos.flat[1:], np.clip(self.sim.data.qvel.flat, -10, 10)] )

In this code snippet, the initial dimension of the observation space is defined as 11. Then the values are directly retrieved from qpos and qvel. Even though I've found some documentation on qpos and the hopper environment, there's no clear explanation on how to create or change qpos and qvel, which makes it hard to figure out which parts of qpos relate to specific things in the Mujoco simulator.

I'm trying to figure out how to find the axes and velocities of specific parts in the qpos and qvel arrays. Also, I want to know how I can change the state format in Mujoco if I want to add or remove some variables.

Any help is appreciated!

JinzhuLuo avatar Feb 22 '24 04:02 JinzhuLuo

Check the code for Humanoid-v5 for examples of using extra sensors

The documentation for hopper can be found here: https://gymnasium.farama.org/main/environments/mujoco/hopper/#observation-space

Note: We have launched gymnasium, a fork of Gym by the maintainers where all maintenance and improvements will happen moving forward. Therefore, we are not supporting or maintaining this repo anymore,

Kallinteris-Andreas avatar Mar 07 '24 09:03 Kallinteris-Andreas