本文整理匯總了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()