diff --git a/examples/.gitignore b/examples/.gitignore index bee8a64..98201a7 100644 --- a/examples/.gitignore +++ b/examples/.gitignore @@ -1 +1,2 @@ __pycache__ +panda diff --git a/examples/dual_arm.py b/examples/dual_arm.py index 7e3f661..d72bf3a 100644 --- a/examples/dual_arm.py +++ b/examples/dual_arm.py @@ -5,7 +5,7 @@ def run_dual_arm(n_steps=5000, render=False, goal=True, obstacles=True): robots = [ - GenericUrdfReacher(urdf="dual_arm.urdf", mode="vel"), + GenericUrdfReacher(urdf="dualArm.urdf", mode="vel"), ] env = gym.make( "urdf-env-v0", diff --git a/examples/mobile_reacher.py b/examples/mobile_reacher.py index 1dcc2af..98a179b 100644 --- a/examples/mobile_reacher.py +++ b/examples/mobile_reacher.py @@ -5,7 +5,7 @@ def run_mobile_reacher(n_steps=1000, render=False, goal=True, obstacles=True): robots = [ - GenericUrdfReacher(urdf="mobilePandaWithGripper.urdf", mode="vel"), + GenericUrdfReacher(urdf="mobilePanda_with_gripper.urdf", mode="vel"), ] env = gym.make( "urdf-env-v0", diff --git a/examples/panda_mujoco.py b/examples/panda_mujoco.py index 5e6175d..80a78db 100644 --- a/examples/panda_mujoco.py +++ b/examples/panda_mujoco.py @@ -1,6 +1,9 @@ -import numpy as np +import os import sys +import shutil +import numpy as np import gymnasium as gym +from robotmodels.utils.robotmodel import RobotModel, LocalRobotModel 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 @@ -10,10 +13,16 @@ def run_panda(n_steps: int = 1000, render: bool = True, physics_engine: str = "bullet"): obstacles = [sphereObst1, sphereObst2, cylinder_obstacle] + wall_obstacles + shutil.rmtree('panda') + robot_model_original = RobotModel('panda', 'panda_scene') + robot_model_original.copy_model(os.path.join(os.getcwd(), 'panda')) + robot_model = LocalRobotModel('panda', 'panda_scene') + + xml_file = robot_model.get_xml_path() if physics_engine == "mujoco": robots = [ - GenericMujocoRobot(xml_file="panda_scene.xml", mode="vel"), + GenericMujocoRobot(xml_file=xml_file, mode="vel"), ] env = GenericMujocoEnv(robots, obstacles, render=render) if physics_engine == "bullet": diff --git a/examples/panda_reacher.py b/examples/panda_reacher.py index fa70153..6c4bea3 100644 --- a/examples/panda_reacher.py +++ b/examples/panda_reacher.py @@ -1,13 +1,16 @@ import gymnasium as gym import numpy as np +from robotmodels.utils.robotmodel import RobotModel from urdfenvs.robots.generic_urdf import GenericUrdfReacher from urdfenvs.scene_examples.goal import dynamicGoal from urdfenvs.scene_examples.obstacles import dynamicSphereObst2 from urdfenvs.urdf_common.urdf_env import UrdfEnv def run_panda(n_steps=1000, render=False, goal=True, obstacles=True): + robot_model = RobotModel('panda', model_name='panda_with_gripper') + urdf_file = robot_model.get_urdf_path() robots = [ - GenericUrdfReacher(urdf="panda_with_gripper.urdf", mode="vel"), + GenericUrdfReacher(urdf=urdf_file, mode="vel"), ] env: UrdfEnv = gym.make( "urdf-env-v0", @@ -19,7 +22,7 @@ def run_panda(n_steps=1000, render=False, goal=True, obstacles=True): env.add_obstacle(dynamicSphereObst2) env.set_spaces() action = np.ones(env.n()) * 0.1 - ob = env.reset() + ob = env.reset(pos=robot_model.home_cfg()) env.add_collision_link( robot_index=0, link_index=5, diff --git a/examples/tiago.py b/examples/tiago.py index d0a43e6..f0dadf1 100644 --- a/examples/tiago.py +++ b/examples/tiago.py @@ -20,7 +20,7 @@ def run_tiago(n_steps=1000, render=False, goal=True, obstacles=True): robots = [ GenericDiffDriveRobot( - urdf="tiago_dual.urdf", + urdf="tiago.urdf", mode="vel", actuated_wheels=["wheel_right_joint", "wheel_left_joint"], castor_wheels=[ diff --git a/tests/test_acc_envs.py b/tests/test_acc_envs.py index 89a0015..e828890 100644 --- a/tests/test_acc_envs.py +++ b/tests/test_acc_envs.py @@ -28,7 +28,7 @@ def nLinkRobotEnv(): @pytest.fixture def dualArmEnv(): - robot = GenericUrdfReacher(urdf="dual_arm.urdf", mode="acc") + robot = GenericUrdfReacher(urdf="dualArm.urdf", mode="acc") init_pos = np.zeros(robot.n()) init_vel = np.zeros(robot.n()) return (robot, init_pos, init_vel) @@ -72,7 +72,7 @@ def tiagoReacherEnv(): init_pos[3] = 0.1 init_vel = np.zeros(23) robot = GenericDiffDriveRobot( - urdf="tiago_dual.urdf", + urdf="tiago.urdf", mode="acc", actuated_wheels=["wheel_right_joint", "wheel_left_joint"], castor_wheels=[ diff --git a/tests/test_vel_envs.py b/tests/test_vel_envs.py index d1b68ed..3030038 100644 --- a/tests/test_vel_envs.py +++ b/tests/test_vel_envs.py @@ -65,7 +65,7 @@ def tiagoReacherEnv(): init_pos[3] = 0.1 init_vel = np.zeros(23) robot = GenericDiffDriveRobot( - urdf="tiago_dual.urdf", + urdf="tiago.urdf", mode="vel", actuated_wheels=["wheel_right_joint", "wheel_left_joint"], castor_wheels=[ @@ -112,7 +112,7 @@ def priusEnv(): @pytest.fixture def dualArmEnv(): from urdfenvs.robots.generic_urdf import GenericUrdfReacher - robot = GenericUrdfReacher(urdf="dual_arm.urdf", mode="vel") + robot = GenericUrdfReacher(urdf="dualArm.urdf", mode="vel") init_pos = np.zeros(robot.n()) init_vel = np.zeros(robot.n()) return (robot, init_pos, init_vel)