本文整理汇总了Python中mujoco_py.MjSimState方法的典型用法代码示例。如果您正苦于以下问题:Python mujoco_py.MjSimState方法的具体用法?Python mujoco_py.MjSimState怎么用?Python mujoco_py.MjSimState使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mujoco_py
的用法示例。
在下文中一共展示了mujoco_py.MjSimState方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: reset_to_state
# 需要导入模块: import mujoco_py [as 别名]
# 或者: from mujoco_py import MjSimState [as 别名]
def reset_to_state(self, state, call_forward=True):
"""
Reset to given state.
Args:
- state (MjSimState): desired state.
"""
if not isinstance(state, MjSimState):
raise TypeError(
"You must reset to an explicit state (MjSimState).")
if self.sim is None:
if self._current_seed is None:
self._update_seed()
self.sim = self.get_sim(self._current_seed)
else:
# Ensure environment state not captured in MuJoCo's qpos/qvel
# is reset to the state defined by the model.
self.sim.reset()
self.set_state(state, call_forward=call_forward)
self.t = 0
return self._reset_sim_and_spaces()
示例2: set_state
# 需要导入模块: import mujoco_py [as 别名]
# 或者: from mujoco_py import MjSimState [as 别名]
def set_state(self, qpos, qvel):
assert qpos.shape == (self.model.nq,) and qvel.shape == (self.model.nv,)
old_state = self.sim.get_state()
new_state = mujoco_py.MjSimState(old_state.time, qpos, qvel,
old_state.act, old_state.udd_state)
self.sim.set_state(new_state)
self.sim.forward()
示例3: set_state
# 需要导入模块: import mujoco_py [as 别名]
# 或者: from mujoco_py import MjSimState [as 别名]
def set_state(self, state, call_forward=True):
"""
Sets the state of the enviroment to the given value. It does not
set time.
Warning: This only sets the MuJoCo state by setting qpos/qvel
(and the user-defined state "udd_state"). It doesn't set
the state of objects which don't have joints.
Args:
- state (MjSimState): desired state.
- call_forward (bool): if True, forward simulation after setting
state.
"""
if not isinstance(state, MjSimState):
raise TypeError("state must be an MjSimState")
if self.sim is None:
raise EmptyEnvException(
"You must call reset() or reset_to_state() before setting the "
"state the first time")
# Call forward to write out values in the MuJoCo data.
# Note: if udd_callback is set on the MjSim instance, then the
# user will need to call forward() manually before calling step.
self.sim.set_state(state)
if call_forward:
self.sim.forward()
示例4: get_state
# 需要导入模块: import mujoco_py [as 别名]
# 或者: from mujoco_py import MjSimState [as 别名]
def get_state(self):
"""
Returns a copy of the current environment state.
Returns:
- state (MjSimState): state of the environment's MjSim object.
"""
if self.sim is None:
raise EmptyEnvException(
"You must call reset() or reset_to_state() before accessing "
"the state the first time")
return self.sim.get_state()
示例5: set_state
# 需要导入模块: import mujoco_py [as 别名]
# 或者: from mujoco_py import MjSimState [as 别名]
def set_state(self, qpos, qvel):
assert qpos.shape == (self.model.nq,) and qvel.shape == (self.model.nv,)
old_state = self.sim.get_state()
new_state = mujoco_py.MjSimState(old_state.time, qpos, qvel,
old_state.act, old_state.udd_state)
self.sim.set_state(new_state)
# print(self.sim)
# print(qpos)
# print(qvel)
self.sim.forward()
示例6: _set_state
# 需要导入模块: import mujoco_py [as 别名]
# 或者: from mujoco_py import MjSimState [as 别名]
def _set_state(self, qpos, qvel):
old_state = self.sim.get_state()
new_state = mujoco_py.MjSimState(old_state.time, qpos, qvel,
old_state.act, old_state.udd_state)
self.sim.set_state(new_state)
self.sim.forward()