diff --git a/robosuite/controllers/composite/composite_controller.py b/robosuite/controllers/composite/composite_controller.py index b832827c38..91e040cb18 100644 --- a/robosuite/controllers/composite/composite_controller.py +++ b/robosuite/controllers/composite/composite_controller.py @@ -200,7 +200,7 @@ def create_action_vector(self, action_dict): A helper function that creates the action vector given a dictionary """ full_action_vector = np.zeros(self.action_limits[0].shape) - for (part_name, action_vector) in action_dict.items(): + for part_name, action_vector in action_dict.items(): if part_name not in self._action_split_indexes: ROBOSUITE_DEFAULT_LOGGER.debug(f"{part_name} is not specified in the action space") continue @@ -349,7 +349,7 @@ def action_limits(self): def create_action_vector(self, action_dict: Dict[str, np.ndarray]) -> np.ndarray: full_action_vector = np.zeros(self.action_limits[0].shape) - for (part_name, action_vector) in action_dict.items(): + for part_name, action_vector in action_dict.items(): if part_name not in self._whole_body_controller_action_split_indexes: ROBOSUITE_DEFAULT_LOGGER.debug(f"{part_name} is not specified in the action space") continue diff --git a/robosuite/controllers/parts/controller_factory.py b/robosuite/controllers/parts/controller_factory.py index 8c780f8d48..8f72454749 100644 --- a/robosuite/controllers/parts/controller_factory.py +++ b/robosuite/controllers/parts/controller_factory.py @@ -1,6 +1,7 @@ """ Set of functions that streamline controller initialization process """ + import json import os from copy import deepcopy diff --git a/robosuite/demos/demo_gripper_selection.py b/robosuite/demos/demo_gripper_selection.py index 1da85c9ddd..8c817718e5 100644 --- a/robosuite/demos/demo_gripper_selection.py +++ b/robosuite/demos/demo_gripper_selection.py @@ -2,6 +2,7 @@ This script shows you how to select gripper for an environment. This is controlled by gripper_type keyword argument. """ + import time import numpy as np diff --git a/robosuite/demos/demo_segmentation.py b/robosuite/demos/demo_segmentation.py index bb53b72d34..4123ae13a2 100644 --- a/robosuite/demos/demo_segmentation.py +++ b/robosuite/demos/demo_segmentation.py @@ -1,6 +1,7 @@ """ Play random actions in an environment and render a video that demonstrates segmentation. """ + import argparse import colorsys import json diff --git a/robosuite/demos/demo_usd_export.py b/robosuite/demos/demo_usd_export.py index 0e0cbd756f..55b912f508 100644 --- a/robosuite/demos/demo_usd_export.py +++ b/robosuite/demos/demo_usd_export.py @@ -1,4 +1,4 @@ -""" Exports a USD file corresponding to the collected trajectory. +"""Exports a USD file corresponding to the collected trajectory. The USD (Universal Scene Description) file format allows users to save trajectories such that they can be rendered in external renderers such @@ -8,8 +8,9 @@ ***IMPORTANT***: If you are using mujoco version 3.1.1, please make sure that you also have numpy < 2 installed in your environment. Failure to do -so may result in incorrect renderings. +so may result in incorrect renderings. """ + import argparse import mujoco diff --git a/robosuite/devices/device.py b/robosuite/devices/device.py index 32da777a0d..6880665acd 100644 --- a/robosuite/devices/device.py +++ b/robosuite/devices/device.py @@ -166,7 +166,7 @@ def input2action(self, mirror_actions=False) -> Optional[Dict]: ac_dict[f"{active_arm}_gripper"] = np.array([grasp] * gripper_dof) # clip actions between -1 and 1 - for (k, v) in ac_dict.items(): + for k, v in ac_dict.items(): if "abs" not in k: ac_dict[k] = np.clip(v, -1, 1) diff --git a/robosuite/environments/robot_env.py b/robosuite/environments/robot_env.py index 9c58f2964a..e99759b0dd 100644 --- a/robosuite/environments/robot_env.py +++ b/robosuite/environments/robot_env.py @@ -345,7 +345,7 @@ def _setup_observables(self): # Create sensor information sensors = [] names = [] - for (cam_name, cam_w, cam_h, cam_d, cam_segs) in zip( + for cam_name, cam_w, cam_h, cam_d, cam_segs in zip( self.camera_names, self.camera_widths, self.camera_heights, diff --git a/robosuite/models/assets/grippers/meshes/xarm7_gripper/base_link.stl b/robosuite/models/assets/grippers/meshes/xarm7_gripper/base_link.stl new file mode 100644 index 0000000000..6a3263b5b5 Binary files /dev/null and b/robosuite/models/assets/grippers/meshes/xarm7_gripper/base_link.stl differ diff --git a/robosuite/models/assets/grippers/meshes/xarm7_gripper/end_tool.stl b/robosuite/models/assets/grippers/meshes/xarm7_gripper/end_tool.stl new file mode 100644 index 0000000000..e2324f41ef Binary files /dev/null and b/robosuite/models/assets/grippers/meshes/xarm7_gripper/end_tool.stl differ diff --git a/robosuite/models/assets/grippers/meshes/xarm7_gripper/left_finger.stl b/robosuite/models/assets/grippers/meshes/xarm7_gripper/left_finger.stl new file mode 100644 index 0000000000..41f2c0d76f Binary files /dev/null and b/robosuite/models/assets/grippers/meshes/xarm7_gripper/left_finger.stl differ diff --git a/robosuite/models/assets/grippers/meshes/xarm7_gripper/left_inner_knuckle.stl b/robosuite/models/assets/grippers/meshes/xarm7_gripper/left_inner_knuckle.stl new file mode 100644 index 0000000000..abeff0cec0 Binary files /dev/null and b/robosuite/models/assets/grippers/meshes/xarm7_gripper/left_inner_knuckle.stl differ diff --git a/robosuite/models/assets/grippers/meshes/xarm7_gripper/left_outer_knuckle.stl b/robosuite/models/assets/grippers/meshes/xarm7_gripper/left_outer_knuckle.stl new file mode 100644 index 0000000000..639add9e0e Binary files /dev/null and b/robosuite/models/assets/grippers/meshes/xarm7_gripper/left_outer_knuckle.stl differ diff --git a/robosuite/models/assets/grippers/meshes/xarm7_gripper/link1.stl b/robosuite/models/assets/grippers/meshes/xarm7_gripper/link1.stl new file mode 100644 index 0000000000..a5ca309d62 Binary files /dev/null and b/robosuite/models/assets/grippers/meshes/xarm7_gripper/link1.stl differ diff --git a/robosuite/models/assets/grippers/meshes/xarm7_gripper/link2.stl b/robosuite/models/assets/grippers/meshes/xarm7_gripper/link2.stl new file mode 100644 index 0000000000..1539adb628 Binary files /dev/null and b/robosuite/models/assets/grippers/meshes/xarm7_gripper/link2.stl differ diff --git a/robosuite/models/assets/grippers/meshes/xarm7_gripper/link3.stl b/robosuite/models/assets/grippers/meshes/xarm7_gripper/link3.stl new file mode 100644 index 0000000000..23926351ee Binary files /dev/null and b/robosuite/models/assets/grippers/meshes/xarm7_gripper/link3.stl differ diff --git a/robosuite/models/assets/grippers/meshes/xarm7_gripper/link4.stl b/robosuite/models/assets/grippers/meshes/xarm7_gripper/link4.stl new file mode 100644 index 0000000000..a24cc91df0 Binary files /dev/null and b/robosuite/models/assets/grippers/meshes/xarm7_gripper/link4.stl differ diff --git a/robosuite/models/assets/grippers/meshes/xarm7_gripper/link5.stl b/robosuite/models/assets/grippers/meshes/xarm7_gripper/link5.stl new file mode 100644 index 0000000000..7f91e37cfa Binary files /dev/null and b/robosuite/models/assets/grippers/meshes/xarm7_gripper/link5.stl differ diff --git a/robosuite/models/assets/grippers/meshes/xarm7_gripper/link6.stl b/robosuite/models/assets/grippers/meshes/xarm7_gripper/link6.stl new file mode 100644 index 0000000000..04fc480566 Binary files /dev/null and b/robosuite/models/assets/grippers/meshes/xarm7_gripper/link6.stl differ diff --git a/robosuite/models/assets/grippers/meshes/xarm7_gripper/link7.stl b/robosuite/models/assets/grippers/meshes/xarm7_gripper/link7.stl new file mode 100644 index 0000000000..0e9963c387 Binary files /dev/null and b/robosuite/models/assets/grippers/meshes/xarm7_gripper/link7.stl differ diff --git a/robosuite/models/assets/grippers/meshes/xarm7_gripper/link_base.stl b/robosuite/models/assets/grippers/meshes/xarm7_gripper/link_base.stl new file mode 100644 index 0000000000..555d6f2ea3 Binary files /dev/null and b/robosuite/models/assets/grippers/meshes/xarm7_gripper/link_base.stl differ diff --git a/robosuite/models/assets/grippers/meshes/xarm7_gripper/right_finger.stl b/robosuite/models/assets/grippers/meshes/xarm7_gripper/right_finger.stl new file mode 100644 index 0000000000..53f0eecae8 Binary files /dev/null and b/robosuite/models/assets/grippers/meshes/xarm7_gripper/right_finger.stl differ diff --git a/robosuite/models/assets/grippers/meshes/xarm7_gripper/right_inner_knuckle.stl b/robosuite/models/assets/grippers/meshes/xarm7_gripper/right_inner_knuckle.stl new file mode 100644 index 0000000000..f1a486daf3 Binary files /dev/null and b/robosuite/models/assets/grippers/meshes/xarm7_gripper/right_inner_knuckle.stl differ diff --git a/robosuite/models/assets/grippers/meshes/xarm7_gripper/right_outer_knuckle.stl b/robosuite/models/assets/grippers/meshes/xarm7_gripper/right_outer_knuckle.stl new file mode 100644 index 0000000000..3099dfdeda Binary files /dev/null and b/robosuite/models/assets/grippers/meshes/xarm7_gripper/right_outer_knuckle.stl differ diff --git a/robosuite/models/assets/grippers/xarm7_gripper.xml b/robosuite/models/assets/grippers/xarm7_gripper.xml new file mode 100644 index 0000000000..a6527d1051 --- /dev/null +++ b/robosuite/models/assets/grippers/xarm7_gripper.xml @@ -0,0 +1,138 @@ + + + + diff --git a/robosuite/models/assets/robots/xarm7/assets/base_link.stl b/robosuite/models/assets/robots/xarm7/assets/base_link.stl new file mode 100644 index 0000000000..6a3263b5b5 Binary files /dev/null and b/robosuite/models/assets/robots/xarm7/assets/base_link.stl differ diff --git a/robosuite/models/assets/robots/xarm7/assets/end_tool.stl b/robosuite/models/assets/robots/xarm7/assets/end_tool.stl new file mode 100644 index 0000000000..e2324f41ef Binary files /dev/null and b/robosuite/models/assets/robots/xarm7/assets/end_tool.stl differ diff --git a/robosuite/models/assets/robots/xarm7/assets/left_finger.stl b/robosuite/models/assets/robots/xarm7/assets/left_finger.stl new file mode 100644 index 0000000000..41f2c0d76f Binary files /dev/null and b/robosuite/models/assets/robots/xarm7/assets/left_finger.stl differ diff --git a/robosuite/models/assets/robots/xarm7/assets/left_inner_knuckle.stl b/robosuite/models/assets/robots/xarm7/assets/left_inner_knuckle.stl new file mode 100644 index 0000000000..abeff0cec0 Binary files /dev/null and b/robosuite/models/assets/robots/xarm7/assets/left_inner_knuckle.stl differ diff --git a/robosuite/models/assets/robots/xarm7/assets/left_outer_knuckle.stl b/robosuite/models/assets/robots/xarm7/assets/left_outer_knuckle.stl new file mode 100644 index 0000000000..639add9e0e Binary files /dev/null and b/robosuite/models/assets/robots/xarm7/assets/left_outer_knuckle.stl differ diff --git a/robosuite/models/assets/robots/xarm7/assets/link1.stl b/robosuite/models/assets/robots/xarm7/assets/link1.stl new file mode 100644 index 0000000000..a5ca309d62 Binary files /dev/null and b/robosuite/models/assets/robots/xarm7/assets/link1.stl differ diff --git a/robosuite/models/assets/robots/xarm7/assets/link2.stl b/robosuite/models/assets/robots/xarm7/assets/link2.stl new file mode 100644 index 0000000000..1539adb628 Binary files /dev/null and b/robosuite/models/assets/robots/xarm7/assets/link2.stl differ diff --git a/robosuite/models/assets/robots/xarm7/assets/link3.stl b/robosuite/models/assets/robots/xarm7/assets/link3.stl new file mode 100644 index 0000000000..23926351ee Binary files /dev/null and b/robosuite/models/assets/robots/xarm7/assets/link3.stl differ diff --git a/robosuite/models/assets/robots/xarm7/assets/link4.stl b/robosuite/models/assets/robots/xarm7/assets/link4.stl new file mode 100644 index 0000000000..a24cc91df0 Binary files /dev/null and b/robosuite/models/assets/robots/xarm7/assets/link4.stl differ diff --git a/robosuite/models/assets/robots/xarm7/assets/link5.stl b/robosuite/models/assets/robots/xarm7/assets/link5.stl new file mode 100644 index 0000000000..7f91e37cfa Binary files /dev/null and b/robosuite/models/assets/robots/xarm7/assets/link5.stl differ diff --git a/robosuite/models/assets/robots/xarm7/assets/link6.stl b/robosuite/models/assets/robots/xarm7/assets/link6.stl new file mode 100644 index 0000000000..04fc480566 Binary files /dev/null and b/robosuite/models/assets/robots/xarm7/assets/link6.stl differ diff --git a/robosuite/models/assets/robots/xarm7/assets/link7.stl b/robosuite/models/assets/robots/xarm7/assets/link7.stl new file mode 100644 index 0000000000..0e9963c387 Binary files /dev/null and b/robosuite/models/assets/robots/xarm7/assets/link7.stl differ diff --git a/robosuite/models/assets/robots/xarm7/assets/link_base.stl b/robosuite/models/assets/robots/xarm7/assets/link_base.stl new file mode 100644 index 0000000000..555d6f2ea3 Binary files /dev/null and b/robosuite/models/assets/robots/xarm7/assets/link_base.stl differ diff --git a/robosuite/models/assets/robots/xarm7/assets/right_finger.stl b/robosuite/models/assets/robots/xarm7/assets/right_finger.stl new file mode 100644 index 0000000000..53f0eecae8 Binary files /dev/null and b/robosuite/models/assets/robots/xarm7/assets/right_finger.stl differ diff --git a/robosuite/models/assets/robots/xarm7/assets/right_inner_knuckle.stl b/robosuite/models/assets/robots/xarm7/assets/right_inner_knuckle.stl new file mode 100644 index 0000000000..f1a486daf3 Binary files /dev/null and b/robosuite/models/assets/robots/xarm7/assets/right_inner_knuckle.stl differ diff --git a/robosuite/models/assets/robots/xarm7/assets/right_outer_knuckle.stl b/robosuite/models/assets/robots/xarm7/assets/right_outer_knuckle.stl new file mode 100644 index 0000000000..3099dfdeda Binary files /dev/null and b/robosuite/models/assets/robots/xarm7/assets/right_outer_knuckle.stl differ diff --git a/robosuite/models/assets/robots/xarm7/meshes/base_link.stl b/robosuite/models/assets/robots/xarm7/meshes/base_link.stl new file mode 100644 index 0000000000..6a3263b5b5 Binary files /dev/null and b/robosuite/models/assets/robots/xarm7/meshes/base_link.stl differ diff --git a/robosuite/models/assets/robots/xarm7/meshes/end_tool.stl b/robosuite/models/assets/robots/xarm7/meshes/end_tool.stl new file mode 100644 index 0000000000..e2324f41ef Binary files /dev/null and b/robosuite/models/assets/robots/xarm7/meshes/end_tool.stl differ diff --git a/robosuite/models/assets/robots/xarm7/meshes/left_finger.stl b/robosuite/models/assets/robots/xarm7/meshes/left_finger.stl new file mode 100644 index 0000000000..41f2c0d76f Binary files /dev/null and b/robosuite/models/assets/robots/xarm7/meshes/left_finger.stl differ diff --git a/robosuite/models/assets/robots/xarm7/meshes/left_inner_knuckle.stl b/robosuite/models/assets/robots/xarm7/meshes/left_inner_knuckle.stl new file mode 100644 index 0000000000..abeff0cec0 Binary files /dev/null and b/robosuite/models/assets/robots/xarm7/meshes/left_inner_knuckle.stl differ diff --git a/robosuite/models/assets/robots/xarm7/meshes/left_outer_knuckle.stl b/robosuite/models/assets/robots/xarm7/meshes/left_outer_knuckle.stl new file mode 100644 index 0000000000..639add9e0e Binary files /dev/null and b/robosuite/models/assets/robots/xarm7/meshes/left_outer_knuckle.stl differ diff --git a/robosuite/models/assets/robots/xarm7/meshes/link1.stl b/robosuite/models/assets/robots/xarm7/meshes/link1.stl new file mode 100644 index 0000000000..a5ca309d62 Binary files /dev/null and b/robosuite/models/assets/robots/xarm7/meshes/link1.stl differ diff --git a/robosuite/models/assets/robots/xarm7/meshes/link2.stl b/robosuite/models/assets/robots/xarm7/meshes/link2.stl new file mode 100644 index 0000000000..1539adb628 Binary files /dev/null and b/robosuite/models/assets/robots/xarm7/meshes/link2.stl differ diff --git a/robosuite/models/assets/robots/xarm7/meshes/link3.stl b/robosuite/models/assets/robots/xarm7/meshes/link3.stl new file mode 100644 index 0000000000..23926351ee Binary files /dev/null and b/robosuite/models/assets/robots/xarm7/meshes/link3.stl differ diff --git a/robosuite/models/assets/robots/xarm7/meshes/link4.stl b/robosuite/models/assets/robots/xarm7/meshes/link4.stl new file mode 100644 index 0000000000..a24cc91df0 Binary files /dev/null and b/robosuite/models/assets/robots/xarm7/meshes/link4.stl differ diff --git a/robosuite/models/assets/robots/xarm7/meshes/link5.stl b/robosuite/models/assets/robots/xarm7/meshes/link5.stl new file mode 100644 index 0000000000..7f91e37cfa Binary files /dev/null and b/robosuite/models/assets/robots/xarm7/meshes/link5.stl differ diff --git a/robosuite/models/assets/robots/xarm7/meshes/link6.stl b/robosuite/models/assets/robots/xarm7/meshes/link6.stl new file mode 100644 index 0000000000..04fc480566 Binary files /dev/null and b/robosuite/models/assets/robots/xarm7/meshes/link6.stl differ diff --git a/robosuite/models/assets/robots/xarm7/meshes/link7.stl b/robosuite/models/assets/robots/xarm7/meshes/link7.stl new file mode 100644 index 0000000000..0e9963c387 Binary files /dev/null and b/robosuite/models/assets/robots/xarm7/meshes/link7.stl differ diff --git a/robosuite/models/assets/robots/xarm7/meshes/link_base.stl b/robosuite/models/assets/robots/xarm7/meshes/link_base.stl new file mode 100644 index 0000000000..555d6f2ea3 Binary files /dev/null and b/robosuite/models/assets/robots/xarm7/meshes/link_base.stl differ diff --git a/robosuite/models/assets/robots/xarm7/meshes/right_finger.stl b/robosuite/models/assets/robots/xarm7/meshes/right_finger.stl new file mode 100644 index 0000000000..53f0eecae8 Binary files /dev/null and b/robosuite/models/assets/robots/xarm7/meshes/right_finger.stl differ diff --git a/robosuite/models/assets/robots/xarm7/meshes/right_inner_knuckle.stl b/robosuite/models/assets/robots/xarm7/meshes/right_inner_knuckle.stl new file mode 100644 index 0000000000..f1a486daf3 Binary files /dev/null and b/robosuite/models/assets/robots/xarm7/meshes/right_inner_knuckle.stl differ diff --git a/robosuite/models/assets/robots/xarm7/meshes/right_outer_knuckle.stl b/robosuite/models/assets/robots/xarm7/meshes/right_outer_knuckle.stl new file mode 100644 index 0000000000..3099dfdeda Binary files /dev/null and b/robosuite/models/assets/robots/xarm7/meshes/right_outer_knuckle.stl differ diff --git a/robosuite/models/assets/robots/xarm7/robot.xml b/robosuite/models/assets/robots/xarm7/robot.xml new file mode 100644 index 0000000000..b8602f0878 --- /dev/null +++ b/robosuite/models/assets/robots/xarm7/robot.xml @@ -0,0 +1,102 @@ + + + + diff --git a/robosuite/models/bases/floating_legged_base.py b/robosuite/models/bases/floating_legged_base.py index 2a41ed9bea..f8163010a8 100644 --- a/robosuite/models/bases/floating_legged_base.py +++ b/robosuite/models/bases/floating_legged_base.py @@ -1,6 +1,7 @@ """ Rethink's Generic Mount (Officially used on Sawyer). """ + import numpy as np from robosuite.models.bases.mobile_base_model import MobileBaseModel diff --git a/robosuite/models/bases/leg_base_model.py b/robosuite/models/bases/leg_base_model.py index d272e4c0ef..de4c54701c 100644 --- a/robosuite/models/bases/leg_base_model.py +++ b/robosuite/models/bases/leg_base_model.py @@ -1,6 +1,7 @@ """ Defines the base class of all mobile bases """ + from xml.etree import ElementTree as ET import numpy as np diff --git a/robosuite/models/bases/no_actuation_base.py b/robosuite/models/bases/no_actuation_base.py index 5c77f3ab19..971ed0304c 100644 --- a/robosuite/models/bases/no_actuation_base.py +++ b/robosuite/models/bases/no_actuation_base.py @@ -1,6 +1,7 @@ """ Rethink's Generic Mount (Officially used on Sawyer). """ + import numpy as np from robosuite.models.bases.mobile_base_model import MobileBaseModel diff --git a/robosuite/models/bases/null_mobile_base.py b/robosuite/models/bases/null_mobile_base.py index a3e8e6d5a7..125bf8bd32 100644 --- a/robosuite/models/bases/null_mobile_base.py +++ b/robosuite/models/bases/null_mobile_base.py @@ -1,6 +1,7 @@ """ Rethink's Generic Mount (Officially used on Sawyer). """ + import numpy as np from robosuite.models.bases.mobile_base_model import MobileBaseModel diff --git a/robosuite/models/bases/null_mount.py b/robosuite/models/bases/null_mount.py index a7896be35e..53a45be089 100644 --- a/robosuite/models/bases/null_mount.py +++ b/robosuite/models/bases/null_mount.py @@ -1,6 +1,7 @@ """ Rethink's Generic Mount (Officially used on Sawyer). """ + import numpy as np from robosuite.models.bases.mount_model import MountModel diff --git a/robosuite/models/bases/omron_mobile_base.py b/robosuite/models/bases/omron_mobile_base.py index 12f40bb96a..49b2967819 100644 --- a/robosuite/models/bases/omron_mobile_base.py +++ b/robosuite/models/bases/omron_mobile_base.py @@ -1,6 +1,7 @@ """ Omron LD-60 Mobile Base. """ + import numpy as np from robosuite.models.bases.mobile_base_model import MobileBaseModel diff --git a/robosuite/models/bases/rethink_minimal_mount.py b/robosuite/models/bases/rethink_minimal_mount.py index a0263bd200..ea05cb6d48 100644 --- a/robosuite/models/bases/rethink_minimal_mount.py +++ b/robosuite/models/bases/rethink_minimal_mount.py @@ -1,6 +1,7 @@ """ Rethink's Alternative Mount (Officially used on Baxter). """ + import numpy as np from robosuite.models.bases.mount_model import MountModel diff --git a/robosuite/models/bases/rethink_mount.py b/robosuite/models/bases/rethink_mount.py index 3277ba2128..d9ac7f28b0 100644 --- a/robosuite/models/bases/rethink_mount.py +++ b/robosuite/models/bases/rethink_mount.py @@ -1,6 +1,7 @@ """ Rethink's Generic Mount (Officially used on Sawyer). """ + import numpy as np from robosuite.models.bases.mount_model import MountModel diff --git a/robosuite/models/bases/robot_base_model.py b/robosuite/models/bases/robot_base_model.py index f1353f103c..cda9ead519 100644 --- a/robosuite/models/bases/robot_base_model.py +++ b/robosuite/models/bases/robot_base_model.py @@ -1,6 +1,7 @@ """ Defines the base class of all mounts """ + from typing import Dict, List import numpy as np diff --git a/robosuite/models/grippers/__init__.py b/robosuite/models/grippers/__init__.py index 56089af8f7..03d8d9ac99 100644 --- a/robosuite/models/grippers/__init__.py +++ b/robosuite/models/grippers/__init__.py @@ -14,6 +14,7 @@ from .null_gripper import NullGripper from .inspire_hands import InspireLeftHand, InspireRightHand from .fourier_hands import FourierLeftHand, FourierRightHand +from .xarm7_gripper import XArm7Gripper GRIPPER_MAPPING = { "RethinkGripper": RethinkGripper, @@ -30,6 +31,7 @@ "InspireRightHand": InspireRightHand, "FourierLeftHand": FourierLeftHand, "FourierRightHand": FourierRightHand, + "XArm7Gripper": XArm7Gripper, None: NullGripper, } diff --git a/robosuite/models/grippers/fourier_hands.py b/robosuite/models/grippers/fourier_hands.py index 6a2a368d0f..ef0f3e8fad 100644 --- a/robosuite/models/grippers/fourier_hands.py +++ b/robosuite/models/grippers/fourier_hands.py @@ -1,6 +1,7 @@ """ Dexterous hands for GR1 robot. """ + import numpy as np from robosuite.models.grippers.gripper_model import GripperModel diff --git a/robosuite/models/grippers/gripper_factory.py b/robosuite/models/grippers/gripper_factory.py index 79f5348e67..41c7b235fd 100644 --- a/robosuite/models/grippers/gripper_factory.py +++ b/robosuite/models/grippers/gripper_factory.py @@ -1,6 +1,7 @@ """ Defines a string based method of initializing grippers """ + from typing import Optional from robosuite.models.grippers.gripper_model import GripperModel diff --git a/robosuite/models/grippers/gripper_model.py b/robosuite/models/grippers/gripper_model.py index 5ebe18b3ae..44c73f5be6 100644 --- a/robosuite/models/grippers/gripper_model.py +++ b/robosuite/models/grippers/gripper_model.py @@ -1,6 +1,7 @@ """ Defines the base class of all grippers """ + import numpy as np import robosuite.utils.transform_utils as T diff --git a/robosuite/models/grippers/gripper_tester.py b/robosuite/models/grippers/gripper_tester.py index 8221d855fa..963dbe48af 100644 --- a/robosuite/models/grippers/gripper_tester.py +++ b/robosuite/models/grippers/gripper_tester.py @@ -1,6 +1,7 @@ """ Defines GripperTester that is used to test the physical properties of various grippers """ + import xml.etree.ElementTree as ET import numpy as np diff --git a/robosuite/models/grippers/inspire_hands.py b/robosuite/models/grippers/inspire_hands.py index 1484fe55ea..097b2f1853 100644 --- a/robosuite/models/grippers/inspire_hands.py +++ b/robosuite/models/grippers/inspire_hands.py @@ -1,6 +1,7 @@ """ Dexterous hands for GR1 robot. """ + import numpy as np from robosuite.models.grippers.gripper_model import GripperModel diff --git a/robosuite/models/grippers/jaco_three_finger_gripper.py b/robosuite/models/grippers/jaco_three_finger_gripper.py index 3a379a37dc..5e2b1acdff 100644 --- a/robosuite/models/grippers/jaco_three_finger_gripper.py +++ b/robosuite/models/grippers/jaco_three_finger_gripper.py @@ -1,6 +1,7 @@ """ Gripper for Kinova's Jaco robot arm (has three fingers). """ + import numpy as np from robosuite.models.grippers.gripper_model import GripperModel diff --git a/robosuite/models/grippers/null_gripper.py b/robosuite/models/grippers/null_gripper.py index 48f6a80474..11017b09c9 100644 --- a/robosuite/models/grippers/null_gripper.py +++ b/robosuite/models/grippers/null_gripper.py @@ -1,6 +1,7 @@ """ Null Gripper (if we don't want to attach gripper to robot eef). """ + from robosuite.models.grippers.gripper_model import GripperModel from robosuite.utils.mjcf_utils import xml_path_completion diff --git a/robosuite/models/grippers/panda_gripper.py b/robosuite/models/grippers/panda_gripper.py index 738d49f950..30f4473c7a 100644 --- a/robosuite/models/grippers/panda_gripper.py +++ b/robosuite/models/grippers/panda_gripper.py @@ -1,6 +1,7 @@ """ Gripper for Franka's Panda (has two fingers). """ + import numpy as np from robosuite.models.grippers.gripper_model import GripperModel diff --git a/robosuite/models/grippers/rethink_gripper.py b/robosuite/models/grippers/rethink_gripper.py index 0c13154b4d..32ca352720 100644 --- a/robosuite/models/grippers/rethink_gripper.py +++ b/robosuite/models/grippers/rethink_gripper.py @@ -1,6 +1,7 @@ """ Gripper with two fingers for Rethink Robots. """ + import numpy as np from robosuite.models.grippers.gripper_model import GripperModel diff --git a/robosuite/models/grippers/robotiq_140_gripper.py b/robosuite/models/grippers/robotiq_140_gripper.py index f5a31e250d..ddce616786 100644 --- a/robosuite/models/grippers/robotiq_140_gripper.py +++ b/robosuite/models/grippers/robotiq_140_gripper.py @@ -1,6 +1,7 @@ """ Gripper with 140mm Jaw width from Robotiq (has two fingers). """ + import numpy as np from robosuite.models.grippers.gripper_model import GripperModel diff --git a/robosuite/models/grippers/robotiq_85_gripper.py b/robosuite/models/grippers/robotiq_85_gripper.py index 6eaeb39afe..5a3543aac2 100644 --- a/robosuite/models/grippers/robotiq_85_gripper.py +++ b/robosuite/models/grippers/robotiq_85_gripper.py @@ -1,6 +1,7 @@ """ 6-DoF gripper with its open/close variant """ + import numpy as np from robosuite.models.grippers.gripper_model import GripperModel diff --git a/robosuite/models/grippers/robotiq_three_finger_gripper.py b/robosuite/models/grippers/robotiq_three_finger_gripper.py index c7cc7c830f..0b6398c5ac 100644 --- a/robosuite/models/grippers/robotiq_three_finger_gripper.py +++ b/robosuite/models/grippers/robotiq_three_finger_gripper.py @@ -1,6 +1,7 @@ """ Gripper with 11-DoF controlling three fingers and its open/close variant. """ + import numpy as np from robosuite.models.grippers.gripper_model import GripperModel diff --git a/robosuite/models/grippers/wiping_gripper.py b/robosuite/models/grippers/wiping_gripper.py index 692475efab..d3654dde30 100644 --- a/robosuite/models/grippers/wiping_gripper.py +++ b/robosuite/models/grippers/wiping_gripper.py @@ -1,6 +1,7 @@ """ Gripper without fingers to wipe a surface """ + from robosuite.models.grippers.gripper_model import GripperModel from robosuite.utils.mjcf_utils import xml_path_completion diff --git a/robosuite/models/grippers/xarm7_gripper.py b/robosuite/models/grippers/xarm7_gripper.py new file mode 100644 index 0000000000..ca93cbe0c7 --- /dev/null +++ b/robosuite/models/grippers/xarm7_gripper.py @@ -0,0 +1,57 @@ +""" +Gripper for UFactory's XArm7 (has two fingers). +""" +import numpy as np + +from robosuite.models.grippers.gripper_model import GripperModel +from robosuite.utils.mjcf_utils import xml_path_completion + + +class XArm7GripperBase(GripperModel): + """ + Gripper for UFactory's XArm7. + + Args: + idn (int or str): Number or some other unique identification string for this gripper instance + """ + + def __init__(self, idn=0): + super().__init__(xml_path_completion("grippers/xarm7_gripper.xml"), idn=idn) + + def format_action(self, action): + return action + + @property + def init_qpos(self): + return np.array([0.02, 0.0, 0.0, -0.02, 0.0, 0.0]) + + @property + def _important_geoms(self): + return { + "left_fingerpad": ["finger1_pad_collision"], + "right_fingerpad": ["finger2_pad_collision"], + } + + +class XArm7Gripper(XArm7GripperBase): + """ + Modifies XArm7 Gripper to only take one action. + """ + + def format_action(self, action): + """ + -1 => fully open, +1 => fully closed + """ + assert len(action) == self.dof # i.e., 1 + # Suppose self.current_action is also shape (1,). Then: + delta = self.speed * np.sign(action) + self.current_action = np.clip(self.current_action + delta, -1.0, 1.0) + return self.current_action + + @property + def speed(self): + return 0.2 + + @property + def dof(self): + return 1 diff --git a/robosuite/models/objects/composite/hammer.py b/robosuite/models/objects/composite/hammer.py index dcfa96c9d0..acbe33b40c 100644 --- a/robosuite/models/objects/composite/hammer.py +++ b/robosuite/models/objects/composite/hammer.py @@ -146,9 +146,11 @@ def _get_geom_attrs(self): geom_types="cylinder" if self.handle_shape == "cylinder" else "box", geom_locations=(0, 0, 0), geom_quats=(1, 0, 0, 0), - geom_sizes=np.array([self.handle_radius, self.handle_length / 2.0]) - if self.handle_shape == "cylinder" - else np.array([self.handle_radius, self.handle_radius, self.handle_length / 2.0]), + geom_sizes=( + np.array([self.handle_radius, self.handle_length / 2.0]) + if self.handle_shape == "cylinder" + else np.array([self.handle_radius, self.handle_radius, self.handle_length / 2.0]) + ), geom_names="handle", geom_rgbas=None if self.use_texture else self.rgba_handle, geom_materials="wood_mat" if self.use_texture else None, diff --git a/robosuite/models/objects/composite/pot_with_handles.py b/robosuite/models/objects/composite/pot_with_handles.py index 157c162477..89340fdfb0 100644 --- a/robosuite/models/objects/composite/pot_with_handles.py +++ b/robosuite/models/objects/composite/pot_with_handles.py @@ -290,7 +290,6 @@ def _get_geom_attrs(self): @property def handle_distance(self): - """ Calculates how far apart the handles are diff --git a/robosuite/models/objects/objects.py b/robosuite/models/objects/objects.py index e7681f8f39..8f43c05e0e 100644 --- a/robosuite/models/objects/objects.py +++ b/robosuite/models/objects/objects.py @@ -110,7 +110,6 @@ def exclude_from_prefixing(self, inp): raise NotImplementedError def _get_object_subtree(self): - """ Returns a ET.Element It is a subtree that defines all collision and / or visualization related fields @@ -560,7 +559,7 @@ def set_scale(self, scale, obj=None): # scale bodies body_pairs = self._get_elements(obj, "body") - for (_, elem) in body_pairs: + for _, elem in body_pairs: b_pos = elem.get("pos") if b_pos is not None: b_pos = string_to_array(b_pos) * self._scale @@ -568,7 +567,7 @@ def set_scale(self, scale, obj=None): # scale joints joint_pairs = self._get_elements(obj, "joint") - for (_, elem) in joint_pairs: + for _, elem in joint_pairs: j_pos = elem.get("pos") if j_pos is not None: j_pos = string_to_array(j_pos) * self._scale @@ -576,7 +575,7 @@ def set_scale(self, scale, obj=None): # scale sites site_pairs = self._get_elements(self.worldbody, "site") - for (_, elem) in site_pairs: + for _, elem in site_pairs: s_pos = elem.get("pos") if s_pos is not None: s_pos = string_to_array(s_pos) * self._scale diff --git a/robosuite/models/robots/manipulators/__init__.py b/robosuite/models/robots/manipulators/__init__.py index 8536f9cefe..9b56b54d9a 100644 --- a/robosuite/models/robots/manipulators/__init__.py +++ b/robosuite/models/robots/manipulators/__init__.py @@ -9,3 +9,4 @@ from .spot_arm import SpotArm from .tiago_robot import Tiago from .gr1_robot import GR1, GR1FixedLowerBody, GR1ArmsOnly, GR1FloatingBody +from .xarm7_robot import XArm7 diff --git a/robosuite/models/robots/manipulators/xarm7_robot.py b/robosuite/models/robots/manipulators/xarm7_robot.py new file mode 100644 index 0000000000..6e8fdf6b3d --- /dev/null +++ b/robosuite/models/robots/manipulators/xarm7_robot.py @@ -0,0 +1,57 @@ +import numpy as np + +from robosuite.models.robots.manipulators.manipulator_model import ManipulatorModel +from robosuite.utils.mjcf_utils import xml_path_completion + + +class XArm7(ManipulatorModel): + """ + XArm7 is a sensitive single-arm 7 DOF robot designed by UFactory. + + Args: + idn (int or str): Number or some other unique identification string for this robot instance + """ + + arms = ["right"] + + def __init__(self, idn=0): + super().__init__(xml_path_completion("robots/xarm7/robot.xml"), idn=idn) + + # Set joint damping + self.set_joint_attribute(attrib="damping", values=np.array((0.1, 0.1, 0.1, 0.1, 0.1, 0.01, 0.01))) + + @property + def default_base(self): + return "RethinkMount" + + @property + def default_gripper(self): + return {"right": "XArm7Gripper"} + + @property + def default_controller_config(self): + return {"right": "default_xarm7"} + + @property + def init_qpos(self): + return np.array([0.0, 0.0, 0.0, 0.39 * np.pi, 0.0, 0.39 * np.pi, 0.0]) + + @property + def base_xpos_offset(self): + return { + "bins": (-0.5, -0.1, 0), + "empty": (-0.6, 0, 0), + "table": lambda table_length: (-0.16 - table_length / 2, 0, 0), + } + + @property + def top_offset(self): + return np.array((0, 0, 1.0)) + + @property + def _horizontal_radius(self): + return 0.5 + + @property + def arm_type(self): + return "single" diff --git a/robosuite/robots/__init__.py b/robosuite/robots/__init__.py index d58a193186..86714f7dbc 100644 --- a/robosuite/robots/__init__.py +++ b/robosuite/robots/__init__.py @@ -30,6 +30,7 @@ "GR1FloatingBody": LeggedRobot, "PandaDexRH": FixedBaseRobot, "PandaDexLH": FixedBaseRobot, + "XArm7": FixedBaseRobot, } target_type_mapping = { diff --git a/robosuite/scripts/make_reset_video.py b/robosuite/scripts/make_reset_video.py index 249dd630b0..78f4625526 100644 --- a/robosuite/scripts/make_reset_video.py +++ b/robosuite/scripts/make_reset_video.py @@ -1,5 +1,5 @@ """ -Convenience script to make a video out of initial environment +Convenience script to make a video out of initial environment configurations. This can be a useful debugging tool to understand what different sampled environment configurations look like. """ diff --git a/robosuite/utils/buffers.py b/robosuite/utils/buffers.py index b2a1bc20f8..5f0782504b 100644 --- a/robosuite/utils/buffers.py +++ b/robosuite/utils/buffers.py @@ -2,7 +2,6 @@ Collection of Buffer objects with general functionality """ - import numpy as np diff --git a/robosuite/utils/camera_utils.py b/robosuite/utils/camera_utils.py index 733e65c57c..5fa445a0dc 100644 --- a/robosuite/utils/camera_utils.py +++ b/robosuite/utils/camera_utils.py @@ -6,6 +6,7 @@ - Utility functions for performing common camera operations such as retrieving camera matrices and transforming from world to camera frame or vice-versa. """ + import json import xml.etree.ElementTree as ET diff --git a/robosuite/utils/input_utils.py b/robosuite/utils/input_utils.py index 2a558df1ee..31a73cc0ce 100644 --- a/robosuite/utils/input_utils.py +++ b/robosuite/utils/input_utils.py @@ -119,7 +119,7 @@ def choose_robots(exclude_bimanual=False, use_humanoids=False, exclude_single_ar if exclude_single_arm: robots = set() else: - robots = {"Sawyer", "Panda", "Jaco", "Kinova3", "IIWA", "UR5e", "SpotWithArmFloating"} + robots = {"Sawyer", "Panda", "Jaco", "Kinova3", "IIWA", "UR5e", "SpotWithArmFloating", "XArm7"} # Add Baxter if bimanual robots are not excluded if not exclude_bimanual: diff --git a/robosuite/utils/log_utils.py b/robosuite/utils/log_utils.py index e2dc96c983..534479b3a7 100644 --- a/robosuite/utils/log_utils.py +++ b/robosuite/utils/log_utils.py @@ -2,6 +2,7 @@ This file contains utility classes and functions for logging to stdout and stderr Adapted from robomimic: https://github.com/ARISE-Initiative/robomimic/blob/master/robomimic/utils/log_utils.py """ + import inspect import logging import os diff --git a/robosuite/utils/numba.py b/robosuite/utils/numba.py index bd5d854975..7579e1be1f 100644 --- a/robosuite/utils/numba.py +++ b/robosuite/utils/numba.py @@ -1,6 +1,7 @@ """ Numba utils. """ + import numba import robosuite.macros as macros diff --git a/robosuite/utils/observables.py b/robosuite/utils/observables.py index 2c23e8189b..805141b7d5 100644 --- a/robosuite/utils/observables.py +++ b/robosuite/utils/observables.py @@ -30,6 +30,7 @@ def sensor(modality): Returns: function: decorator function """ + # Define standard decorator (with no args) def decorator(func): # Add modality attribute diff --git a/robosuite/utils/opencv_renderer.py b/robosuite/utils/opencv_renderer.py index c6d6386b75..b55c6bfa49 100644 --- a/robosuite/utils/opencv_renderer.py +++ b/robosuite/utils/opencv_renderer.py @@ -1,6 +1,7 @@ """ opencv renderer class. """ + import cv2 import numpy as np diff --git a/robosuite/wrappers/demo_sampler_wrapper.py b/robosuite/wrappers/demo_sampler_wrapper.py index 227045fa52..21d400c313 100644 --- a/robosuite/wrappers/demo_sampler_wrapper.py +++ b/robosuite/wrappers/demo_sampler_wrapper.py @@ -1,7 +1,7 @@ """ This file contains a wrapper for sampling environment states -from a set of demonstrations on every reset. The main use case is for -altering the start state distribution of training episodes for +from a set of demonstrations on every reset. The main use case is for +altering the start state distribution of training episodes for learning RL policies. """ diff --git a/robosuite/wrappers/domain_randomization_wrapper.py b/robosuite/wrappers/domain_randomization_wrapper.py index ce27582663..faf62c7fd0 100644 --- a/robosuite/wrappers/domain_randomization_wrapper.py +++ b/robosuite/wrappers/domain_randomization_wrapper.py @@ -2,6 +2,7 @@ This file implements a wrapper for facilitating domain randomization over robosuite environments. """ + import mujoco import numpy as np diff --git a/robosuite/wrappers/visualization_wrapper.py b/robosuite/wrappers/visualization_wrapper.py index 64b847af6e..0ad5d5d972 100644 --- a/robosuite/wrappers/visualization_wrapper.py +++ b/robosuite/wrappers/visualization_wrapper.py @@ -5,6 +5,7 @@ for a given environment can be found by calling `get_visualization_settings()`, and can be set individually by calling `set_visualization_setting(setting, visible)`. """ + import xml.etree.ElementTree as ET from copy import deepcopy