diff --git a/examples/panda_mujoco.py b/examples/panda_mujoco.py index 728bddb5..f9c4fbf5 100644 --- a/examples/panda_mujoco.py +++ b/examples/panda_mujoco.py @@ -1,27 +1,28 @@ import numpy as np import sys import gymnasium as gym -from urdfenvs.urdf_common.generic_mujoco_env import GenericMujocoEnv -from urdfenvs.urdf_common.generic_mujoco_robot import GenericMujocoRobot +from urdfenvs.generic_mujoco.generic_mujoco_env import GenericMujocoEnv +from urdfenvs.generic_mujoco.generic_mujoco_robot import GenericMujocoRobot from urdfenvs.robots.generic_urdf import GenericUrdfReacher from urdfenvs.urdf_common.urdf_env import UrdfEnv from urdfenvs.scene_examples.obstacles import sphereObst1, sphereObst2, wall_obstacles, cylinder_obstacle -def run_panda(n_steps: int = 1000, render: bool = True, physics_engine: str = 'bullet'): +def run_panda(n_steps: int = 1000, render: bool = True, physics_engine: str = "bullet"): obstacles = [sphereObst1, sphereObst2, cylinder_obstacle] + wall_obstacles - if physics_engine == 'mujoco': + if physics_engine == "mujoco": + robots = [ - GenericMujocoRobot(xml_file='panda_scene.xml'), + GenericMujocoRobot(xml_file="panda_scene.xml", mode="vel"), ] - env = GenericMujocoEnv(robots, obstacles, render=True) - if physics_engine == 'bullet': + env = GenericMujocoEnv(robots, obstacles, render=render) + if physics_engine == "bullet": robots = [ GenericUrdfReacher(urdf="panda.urdf", mode="vel"), ] env= UrdfEnv( dt=0.01, robots=robots, - render=True, + render=render, observation_checking=False, ) for obstacle in obstacles: @@ -29,16 +30,17 @@ def run_panda(n_steps: int = 1000, render: bool = True, physics_engine: str = 'b env.set_spaces() - #observation, info = env.reset(seed=42) - pos0=np.array([0,0,0,-1.57079,0,1.57079,-0.7853,0.04,0.04]) - env.reset(pos=pos0) + ob, info = env.reset() - action_mag = np.array([0.3, -0.2, 0.3, -0.15, 0.2, -0.01, 0.35, 0.01]) + action_mag = np.array([0.8, -0.2, 0.3, -0.15, 0.2, -0.01, 0.35, 0.01]) t = 0.0 for _ in range(n_steps): t += env.dt action = action_mag * np.cos(t) - observation, *_ = env.step(action) + ob, _, terminated, _, info = env.step(action) + if terminated: + print(info) + break env.close() if __name__ == "__main__":