當前位置: 首頁>>代碼示例>>Python>>正文


Python mujoco_py.MjSimState方法代碼示例

本文整理匯總了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() 
開發者ID:openai,項目名稱:mujoco-worldgen,代碼行數:27,代碼來源:env.py

示例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() 
開發者ID:ArztSamuel,項目名稱:DRL_DeliveryDuel,代碼行數:9,代碼來源:mujoco_env.py

示例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() 
開發者ID:openai,項目名稱:mujoco-worldgen,代碼行數:29,代碼來源:env.py

示例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() 
開發者ID:openai,項目名稱:mujoco-worldgen,代碼行數:14,代碼來源:env.py

示例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() 
開發者ID:KamyarGh,項目名稱:rl_swiss,代碼行數:12,代碼來源:pusher_mujoco_env.py

示例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() 
開發者ID:MushroomRL,項目名稱:mushroom-rl,代碼行數:8,代碼來源:humanoid_gait.py


注:本文中的mujoco_py.MjSimState方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。