diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d19d93fb6..a4f472c5e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,14 +1,12 @@ repos: - - repo: https://github.com/psf/black-pre-commit-mirror - rev: 24.3.0 + - repo: https://github.com/astral-sh/ruff-pre-commit + # Ruff version. + rev: v0.8.4 hooks: - - id: black - language_version: python3.10 - - repo: https://github.com/pycqa/isort - rev: 5.13.2 - hooks: - - id: isort - name: isort (python) + # Run the linter. + - id: ruff + # Run the formatter. + - id: ruff-format - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.4.0 hooks: diff --git a/omnigibson/__init__.py b/omnigibson/__init__.py index edf20ac27..62f0273d9 100644 --- a/omnigibson/__init__.py +++ b/omnigibson/__init__.py @@ -5,6 +5,8 @@ import signal import tempfile +import nest_asyncio + from omnigibson.controllers import REGISTERED_CONTROLLERS from omnigibson.envs import Environment, VectorEnvironment from omnigibson.macros import gm @@ -24,8 +26,6 @@ ) # We set this in the kernel.json file # Always enable nest_asyncio because MaterialPrim calls asyncio.run() -import nest_asyncio - nest_asyncio.apply() __version__ = "1.1.1" @@ -33,6 +33,7 @@ root_path = os.path.dirname(os.path.realpath(__file__)) # Store paths to example configs +# TODO: Move this elsewhere. example_config_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), "configs") # Initialize global variables @@ -142,3 +143,24 @@ def shutdown_handler(*args, **kwargs): # Something somewhere disables the default SIGINT handler, so we need to re-enable it signal.signal(signal.SIGINT, shutdown_handler) + +__all__ = [ + "ALL_SENSOR_MODALITIES", + "app", + "cleanup", + "clear", + "Environment", + "example_config_path", + "gm", + "launch", + "log", + "REGISTERED_CONTROLLERS", + "REGISTERED_OBJECTS", + "REGISTERED_ROBOTS", + "REGISTERED_SCENES", + "REGISTERED_TASKS", + "shutdown", + "sim", + "tempdir", + "VectorEnvironment", +] diff --git a/omnigibson/action_primitives/curobo.py b/omnigibson/action_primitives/curobo.py index 3450c98a4..ac24ad718 100644 --- a/omnigibson/action_primitives/curobo.py +++ b/omnigibson/action_primitives/curobo.py @@ -1,5 +1,4 @@ import math -import os from collections.abc import Iterable from enum import Enum @@ -11,10 +10,8 @@ from omnigibson.macros import create_module_macros from omnigibson.object_states.factory import METALINK_PREFIXES from omnigibson.prims.rigid_prim import RigidPrim -from omnigibson.robots.articulated_trunk_robot import ArticulatedTrunkRobot from omnigibson.robots.holonomic_base_robot import HolonomicBaseRobot -from omnigibson.utils.constants import GROUND_CATEGORIES, JointType -from omnigibson.utils.control_utils import FKSolver +from omnigibson.utils.constants import JointType # Gives 1 - 5% better speedup, according to https://github.com/NVlabs/curobo/discussions/245#discussioncomment-9265692 th.backends.cudnn.benchmark = True diff --git a/omnigibson/action_primitives/starter_semantic_action_primitives.py b/omnigibson/action_primitives/starter_semantic_action_primitives.py index 2f11fc5b8..682254898 100644 --- a/omnigibson/action_primitives/starter_semantic_action_primitives.py +++ b/omnigibson/action_primitives/starter_semantic_action_primitives.py @@ -7,10 +7,8 @@ """ import inspect -import logging import math import random -from functools import cached_property import cv2 import gymnasium as gym @@ -28,11 +26,9 @@ BaseActionPrimitiveSet, ) from omnigibson.controllers import DifferentialDriveController, InverseKinematicsController, JointController -from omnigibson.controllers.controller_base import ControlType from omnigibson.macros import create_module_macros from omnigibson.objects.object_base import BaseObject -from omnigibson.objects.usd_object import USDObject -from omnigibson.robots import * +from omnigibson.robots import R1, BaseRobot, BehaviorRobot, Fetch, Freight, Husky, Locobot, Stretch, Tiago, Turtlebot from omnigibson.robots.locomotion_robot import LocomotionRobot from omnigibson.robots.manipulation_robot import ManipulationRobot from omnigibson.tasks.behavior_task import BehaviorTask @@ -313,11 +309,9 @@ def __init__( self.robot.controllers["base"], (JointController, DifferentialDriveController) ), "StarterSemanticActionPrimitives only works with a JointController or DifferentialDriveController at the robot base." if self._base_controller_is_joint: - assert not self.robot.controllers[ - "base" - ].use_delta_commands, ( - "StarterSemanticActionPrimitives only works with a base JointController with absolute mode." - ) + assert ( + not self.robot.controllers["base"].use_delta_commands + ), "StarterSemanticActionPrimitives only works with a base JointController with absolute mode." self.robot_model = self.robot.model_name self.add_context = add_context @@ -342,7 +336,6 @@ def __init__( quat_relative_axis_angle = T.quat2axisangle(quat_relative) self._arm_targets[arm] = (pos_relative, quat_relative_axis_angle) else: - arm_target = cb.to_torch(control_dict["joint_position"])[arm_ctrl.dof_idx] self._arm_targets[arm] = arm_target @@ -1171,7 +1164,6 @@ def _move_hand_direct_ik( target_pos = target_pose[0] target_orn = target_pose[1] target_orn_axisangle = T.quat2axisangle(target_pose[1]) - control_idx = self.robot.controller_action_idx["arm_" + self.arm] prev_pos = prev_orn = None # All we need to do here is save the target IK position so that empty action takes us towards it @@ -1200,7 +1192,7 @@ def _move_hand_direct_ik( pos_diff = th.norm(prev_pos - current_pos) orn_diff = T.get_orientation_diff_in_radian(current_orn, prev_orn) if pos_diff < 0.0003 and orn_diff < 0.01: - raise ActionPrimitiveError(ActionPrimitiveError.Reason.EXECUTION_ERROR, f"Hand is stuck") + raise ActionPrimitiveError(ActionPrimitiveError.Reason.EXECUTION_ERROR, "Hand is stuck") prev_pos = current_pos prev_orn = current_orn diff --git a/omnigibson/action_primitives/symbolic_semantic_action_primitives.py b/omnigibson/action_primitives/symbolic_semantic_action_primitives.py index a30b95420..04c0ae6c9 100644 --- a/omnigibson/action_primitives/symbolic_semantic_action_primitives.py +++ b/omnigibson/action_primitives/symbolic_semantic_action_primitives.py @@ -12,7 +12,7 @@ from omnigibson.action_primitives.starter_semantic_action_primitives import StarterSemanticActionPrimitives from omnigibson.objects import DatasetObject from omnigibson.robots.robot_base import BaseRobot -from omnigibson.transition_rules import REGISTERED_RULES, SlicingRule, TransitionRuleAPI +from omnigibson.transition_rules import SlicingRule class SymbolicSemanticActionPrimitiveSet(IntEnum): diff --git a/omnigibson/controllers/__init__.py b/omnigibson/controllers/__init__.py index a56c7c54b..0ba8fb006 100644 --- a/omnigibson/controllers/__init__.py +++ b/omnigibson/controllers/__init__.py @@ -32,3 +32,22 @@ def create_controller(name, **kwargs): controller_cls = REGISTERED_CONTROLLERS[name] return controller_cls(**kwargs) + + +__all__ = [ + "ControlType", + "create_controller", + "DifferentialDriveController", + "GripperController", + "InverseKinematicsController", + "IsGraspingState", + "JointController", + "LocomotionController", + "ManipulationController", + "MultiFingerGripperController", + "NullJointController", + "OperationalSpaceController", + "REGISTERED_CONTROLLERS", + "REGISTERED_LOCOMOTION_CONTROLLERS", + "REGISTERED_MANIPULATION_CONTROLLERS", +] diff --git a/omnigibson/controllers/controller_base.py b/omnigibson/controllers/controller_base.py index 60e5e7adc..92538a45c 100644 --- a/omnigibson/controllers/controller_base.py +++ b/omnigibson/controllers/controller_base.py @@ -129,12 +129,12 @@ def __init__( # Standardize command input / output limits to be (min_array, max_array) command_input_limits = ( self._generate_default_command_input_limits() - if type(command_input_limits) == str and command_input_limits == "default" + if type(command_input_limits) is str and command_input_limits == "default" else command_input_limits ) command_output_limits = ( self._generate_default_command_output_limits() - if type(command_output_limits) == str and command_output_limits == "default" + if type(command_output_limits) is str and command_output_limits == "default" else command_output_limits ) self._command_input_limits = ( @@ -451,7 +451,9 @@ def nums2array(nums, dim): return ( nums if isinstance(nums, cb.arr_type) - else cb.array(nums) if isinstance(nums, Iterable) else cb.ones(dim) * nums + else cb.array(nums) + if isinstance(nums, Iterable) + else cb.ones(dim) * nums ) @property diff --git a/omnigibson/controllers/dd_controller.py b/omnigibson/controllers/dd_controller.py index c4f15a246..dbd1aae9e 100644 --- a/omnigibson/controllers/dd_controller.py +++ b/omnigibson/controllers/dd_controller.py @@ -53,7 +53,7 @@ def __init__( self._wheel_axle_halflength = wheel_axle_length / 2.0 # If we're using default command output limits, map this to maximum linear / angular velocities - if type(command_output_limits) == str and command_output_limits == "default": + if type(command_output_limits) is str and command_output_limits == "default": min_vels = control_limits["velocity"][0][dof_idx] assert ( min_vels[0] == min_vels[1] diff --git a/omnigibson/controllers/ik_controller.py b/omnigibson/controllers/ik_controller.py index 5a2b73b21..0a6e9e06b 100644 --- a/omnigibson/controllers/ik_controller.py +++ b/omnigibson/controllers/ik_controller.py @@ -1,6 +1,12 @@ import math from collections.abc import Iterable +import numpy as np +import torch as th +from numba import jit + +import omnigibson.utils.transform_utils as TT +import omnigibson.utils.transform_utils_np as NT from omnigibson.controllers import ControlType, ManipulationController from omnigibson.controllers.joint_controller import JointController from omnigibson.utils.backend_utils import _compute_backend as cb @@ -142,7 +148,7 @@ def limiter(target_pos: Array[float], target_quat: Array[float], control_dict: D # The output orientation limits are also set to be values assuming delta commands, so those are updated too if self.mode == "pose_absolute_ori": if command_input_limits is not None: - if type(command_input_limits) == str and command_input_limits == "default": + if type(command_input_limits) is str and command_input_limits == "default": command_input_limits = [ cb.array([-1.0, -1.0, -1.0, -math.pi, -math.pi, -math.pi]), cb.array([1.0, 1.0, 1.0, math.pi, math.pi, math.pi]), @@ -156,7 +162,7 @@ def limiter(target_pos: Array[float], target_quat: Array[float], control_dict: D cb.array(command_output_limits[0]), cb.array(command_output_limits[1]), ] - if type(command_output_limits) == str and command_output_limits == "default": + if type(command_output_limits) is str and command_output_limits == "default": command_output_limits = [ cb.array([-1.0, -1.0, -1.0, -math.pi, -math.pi, -math.pi]), cb.array([1.0, 1.0, 1.0, math.pi, math.pi, math.pi]), @@ -371,11 +377,6 @@ def command_dim(self): return IK_MODE_COMMAND_DIMS[self.mode] -import torch as th - -import omnigibson.utils.transform_utils as TT - - @th.jit.script def _compute_ik_qpos_torch( q: th.Tensor, @@ -405,12 +406,6 @@ def _compute_ik_qpos_torch( ) -import numpy as np -from numba import jit - -import omnigibson.utils.transform_utils_np as NT - - # Use numba since faster @jit(nopython=True) def _compute_ik_qpos_numpy( diff --git a/omnigibson/controllers/joint_controller.py b/omnigibson/controllers/joint_controller.py index 9dcb7ea33..0797157bc 100644 --- a/omnigibson/controllers/joint_controller.py +++ b/omnigibson/controllers/joint_controller.py @@ -1,5 +1,9 @@ import math +import numpy as np +import torch as th +from numba import jit + from omnigibson.controllers import ( ControlType, GripperController, @@ -127,7 +131,7 @@ def __init__( # When in delta mode, it doesn't make sense to infer output range using the joint limits (since that's an # absolute range and our values are relative). So reject the default mode option in that case. assert not ( - self._use_delta_commands and type(command_output_limits) == str and command_output_limits == "default" + self._use_delta_commands and type(command_output_limits) is str and command_output_limits == "default" ), "Cannot use 'default' command output limits in delta commands mode of JointController. Try None instead." # Run super init @@ -210,7 +214,7 @@ def compute_control(self, goal_dict, control_dict): if self._motor_type == "position": # Run impedance controller -- effort = pos_err * kp + vel_err * kd position_error = target - base_value - vel_pos_error = -control_dict[f"joint_velocity"][self.dof_idx] + vel_pos_error = -control_dict["joint_velocity"][self.dof_idx] u = position_error * self.pos_kp + vel_pos_error * self.pos_kd elif self._motor_type == "velocity": # Compute command torques via PI velocity controller plus gravity compensation torques @@ -252,10 +256,10 @@ def _compute_no_op_action(self, control_dict): if self._use_delta_commands: return cb.zeros(self.command_dim) else: - return control_dict[f"joint_position"][self.dof_idx] + return control_dict["joint_position"][self.dof_idx] elif self.motor_type == "velocity": if self._use_delta_commands: - return -control_dict[f"joint_velocity"][self.dof_idx] + return -control_dict["joint_velocity"][self.dof_idx] else: return cb.zeros(self.command_dim) @@ -293,9 +297,6 @@ def command_dim(self): return len(self.dof_idx) -import torch as th - - @th.compile def _compute_joint_torques_torch( u: th.Tensor, @@ -306,10 +307,6 @@ def _compute_joint_torques_torch( return mm[dof_idxs_mat] @ u -import numpy as np -from numba import jit - - # Use numba since faster @jit(nopython=True) def numba_ix(arr, rows, cols): diff --git a/omnigibson/controllers/multi_finger_gripper_controller.py b/omnigibson/controllers/multi_finger_gripper_controller.py index 1774e3c69..bf8e10010 100644 --- a/omnigibson/controllers/multi_finger_gripper_controller.py +++ b/omnigibson/controllers/multi_finger_gripper_controller.py @@ -304,7 +304,7 @@ def _compute_no_op_action(self, control_dict): return cb.array([command_val]) if self._motor_type == "position": - command = control_dict[f"joint_position"][self.dof_idx] + command = control_dict["joint_position"][self.dof_idx] elif self._motor_type == "velocity": command = cb.zeros(self.command_dim) else: diff --git a/omnigibson/controllers/osc_controller.py b/omnigibson/controllers/osc_controller.py index d7165f931..1f41557d7 100644 --- a/omnigibson/controllers/osc_controller.py +++ b/omnigibson/controllers/osc_controller.py @@ -1,9 +1,14 @@ import math +import numpy as np +import torch as th +from numba import jit + +import omnigibson.utils.transform_utils as TT +import omnigibson.utils.transform_utils_np as NT from omnigibson.controllers import ControlType, ManipulationController from omnigibson.utils.backend_utils import _compute_backend as cb from omnigibson.utils.backend_utils import add_compute_function -from omnigibson.utils.processing_utils import MovingAverageFilter from omnigibson.utils.python_utils import assert_valid_key from omnigibson.utils.ui_utils import create_module_logger @@ -176,7 +181,7 @@ def limiter(target_pos: Array[float], target_quat: Array[float], control_dict: D self.mode = mode if self.mode == "pose_absolute_ori": if command_input_limits is not None: - if type(command_input_limits) == str and command_input_limits == "default": + if type(command_input_limits) is str and command_input_limits == "default": command_input_limits = [ [-1.0, -1.0, -1.0, -math.pi, -math.pi, -math.pi], [1.0, 1.0, 1.0, math.pi, math.pi, math.pi], @@ -185,7 +190,7 @@ def limiter(target_pos: Array[float], target_quat: Array[float], control_dict: D command_input_limits[0][3:] = -math.pi command_input_limits[1][3:] = math.pi if command_output_limits is not None: - if type(command_output_limits) == str and command_output_limits == "default": + if type(command_output_limits) is str and command_output_limits == "default": command_output_limits = [ [-1.0, -1.0, -1.0, -math.pi, -math.pi, -math.pi], [1.0, 1.0, 1.0, math.pi, math.pi, math.pi], @@ -489,11 +494,6 @@ def command_dim(self): return self._command_dim -import torch as th - -import omnigibson.utils.transform_utils as TT - - @th.jit.script def _compute_osc_torques_torch( q: th.Tensor, @@ -569,12 +569,6 @@ def _compute_osc_torques_torch( return u -import numpy as np -from numba import jit - -import omnigibson.utils.transform_utils_np as NT - - # Use numba since faster @jit(nopython=True) def _compute_osc_torques_numpy( diff --git a/omnigibson/download_datasets.py b/omnigibson/download_datasets.py index f850e50e7..871b32f40 100644 --- a/omnigibson/download_datasets.py +++ b/omnigibson/download_datasets.py @@ -17,11 +17,11 @@ def main(): dataset_exists, assets_exist = os.path.exists(gm.DATASET_PATH), os.path.exists(gm.ASSET_PATH) if not (dataset_exists and assets_exist): # Ask user which dataset to install - print(f"OmniGibson will now install data under the following locations:") + print("OmniGibson will now install data under the following locations:") print(f" dataset (~25GB): {gm.DATASET_PATH}") print(f" assets (~2.5GB): {gm.ASSET_PATH}") print( - f"If you want to install data under a different path, please change the DATA_PATH variable in omnigibson/macros.py and rerun omnigibson/download_datasets.py." + "If you want to install data under a different path, please change the DATA_PATH variable in omnigibson/macros.py and rerun omnigibson/download_datasets.py." ) if click.confirm("Do you want to continue?", default=True): # Only download if the dataset path doesn't exist diff --git a/omnigibson/envs/__init__.py b/omnigibson/envs/__init__.py index 7cce73898..0f645edfe 100644 --- a/omnigibson/envs/__init__.py +++ b/omnigibson/envs/__init__.py @@ -2,3 +2,13 @@ from omnigibson.envs.env_base import Environment from omnigibson.envs.env_wrapper import REGISTERED_ENV_WRAPPERS, EnvironmentWrapper, create_wrapper from omnigibson.envs.vec_env_base import VectorEnvironment + +__all__ = [ + "create_wrapper", + "DataCollectionWrapper", + "DataPlaybackWrapper", + "Environment", + "EnvironmentWrapper", + "REGISTERED_ENV_WRAPPERS", + "VectorEnvironment", +] diff --git a/omnigibson/envs/data_wrapper.py b/omnigibson/envs/data_wrapper.py index 8e3e19557..30326a463 100644 --- a/omnigibson/envs/data_wrapper.py +++ b/omnigibson/envs/data_wrapper.py @@ -196,7 +196,7 @@ def flush_current_traj(self): success = self.env.task.success or not self.only_successes if success and self.hdf5_file is not None: traj_grp_name = f"demo_{self.traj_count}" - traj_grp = self.process_traj_to_hdf5(self.current_traj_history, traj_grp_name, nested_keys=["obs"]) + self.process_traj_to_hdf5(self.current_traj_history, traj_grp_name, nested_keys=["obs"]) self.traj_count += 1 else: # Remove this demo @@ -232,7 +232,6 @@ def save_data(self): self.flush_current_traj() if self.hdf5_file is not None: - log.info( f"\nSaved:\n" f"{self.traj_count} trajectories / {self.step_count} total steps\n" diff --git a/omnigibson/envs/vec_env_base.py b/omnigibson/envs/vec_env_base.py index 00f1bb6e3..0ed2c6bfb 100644 --- a/omnigibson/envs/vec_env_base.py +++ b/omnigibson/envs/vec_env_base.py @@ -1,5 +1,4 @@ import copy -import time from tqdm import trange diff --git a/omnigibson/examples/action_primitives/rs_int_example.py b/omnigibson/examples/action_primitives/rs_int_example.py index fbecc2595..6314625a3 100644 --- a/omnigibson/examples/action_primitives/rs_int_example.py +++ b/omnigibson/examples/action_primitives/rs_int_example.py @@ -7,7 +7,6 @@ StarterSemanticActionPrimitives, StarterSemanticActionPrimitiveSet, ) -from omnigibson.macros import gm # Don't use GPU dynamics and use flatcache for performance boost # gm.USE_GPU_DYNAMICS = True @@ -46,7 +45,6 @@ def main(): # Load the environment env = og.Environment(configs=config) scene = env.scene - robot = env.robots[0] # Allow user to move camera more easily og.sim.enable_viewer_camera_teleoperation() diff --git a/omnigibson/examples/action_primitives/solve_simple_task.py b/omnigibson/examples/action_primitives/solve_simple_task.py index 168e3d239..c6328fa5f 100644 --- a/omnigibson/examples/action_primitives/solve_simple_task.py +++ b/omnigibson/examples/action_primitives/solve_simple_task.py @@ -7,7 +7,6 @@ StarterSemanticActionPrimitives, StarterSemanticActionPrimitiveSet, ) -from omnigibson.macros import gm # Don't use GPU dynamics and use flatcache for performance boost # gm.USE_GPU_DYNAMICS = True @@ -55,7 +54,6 @@ def main(): # Load the environment env = og.Environment(configs=config) scene = env.scene - robot = env.robots[0] # Allow user to move camera more easily og.sim.enable_viewer_camera_teleoperation() diff --git a/omnigibson/examples/action_primitives/wip_solve_behavior_task.py b/omnigibson/examples/action_primitives/wip_solve_behavior_task.py index 3036fc42e..04ea0c79c 100644 --- a/omnigibson/examples/action_primitives/wip_solve_behavior_task.py +++ b/omnigibson/examples/action_primitives/wip_solve_behavior_task.py @@ -1,6 +1,5 @@ import os -import torch as th import yaml import omnigibson as og @@ -8,7 +7,6 @@ StarterSemanticActionPrimitives, StarterSemanticActionPrimitiveSet, ) -from omnigibson.macros import gm # Don't use GPU dynamics and use flatcache for performance boost # gm.USE_GPU_DYNAMICS = True @@ -46,8 +44,6 @@ def main(): # Load the environment env = og.Environment(configs=config) - scene = env.scene - robot = env.robots[0] # Allow user to move camera more easily og.sim.enable_viewer_camera_teleoperation() diff --git a/omnigibson/examples/environments/navigation_env_demo.py b/omnigibson/examples/environments/navigation_env_demo.py index e24be50da..00744b524 100644 --- a/omnigibson/examples/environments/navigation_env_demo.py +++ b/omnigibson/examples/environments/navigation_env_demo.py @@ -17,7 +17,7 @@ def main(random_selection=False, headless=False, short_exec=False): og.log.info(f"Demo {__file__}\n " + "*" * 80 + "\n Description:\n" + main.__doc__ + "*" * 80) # Load the config - config_filename = os.path.join(og.example_config_path, f"turtlebot_nav.yaml") + config_filename = os.path.join(og.example_config_path, "turtlebot_nav.yaml") config = yaml.load(open(config_filename, "r"), Loader=yaml.FullLoader) # check if we want to quick load or full load the scene diff --git a/omnigibson/examples/environments/vector_env_demo.py b/omnigibson/examples/environments/vector_env_demo.py index d0882e7a6..989427aae 100644 --- a/omnigibson/examples/environments/vector_env_demo.py +++ b/omnigibson/examples/environments/vector_env_demo.py @@ -1,11 +1,6 @@ -import argparse -import cProfile -import io import os -import pstats import time -import torch as th import yaml import omnigibson as og @@ -26,7 +21,6 @@ def main(random_selection=False, headless=False, short_exec=False): # Load the environment vec_env = og.VectorEnvironment(5, config) - import time max_iterations = 100 if not short_exec else 1 for _ in range(max_iterations): diff --git a/omnigibson/examples/learning/navigation_policy_demo.py b/omnigibson/examples/learning/navigation_policy_demo.py index 33d905aa5..2aa66167d 100644 --- a/omnigibson/examples/learning/navigation_policy_demo.py +++ b/omnigibson/examples/learning/navigation_policy_demo.py @@ -17,13 +17,12 @@ try: import gymnasium as gym - import tensorboard + import tensorboard # noqa: F401 import torch as th import torch.nn as nn from stable_baselines3 import PPO from stable_baselines3.common.callbacks import CallbackList, CheckpointCallback, EvalCallback from stable_baselines3.common.evaluation import evaluate_policy - from stable_baselines3.common.preprocessing import maybe_transpose from stable_baselines3.common.torch_layers import BaseFeaturesExtractor from stable_baselines3.common.utils import set_random_seed diff --git a/omnigibson/examples/object_states/attachment_demo.py b/omnigibson/examples/object_states/attachment_demo.py index e91c58818..3c79179a3 100644 --- a/omnigibson/examples/object_states/attachment_demo.py +++ b/omnigibson/examples/object_states/attachment_demo.py @@ -45,7 +45,7 @@ def main(random_selection=False, headless=False, short_exec=False): obj_cfgs.append( dict( type="DatasetObject", - name=f"shelf_side_left", + name="shelf_side_left", category="shelf_side", model="bxfkjj", position=[-0.4, 0, base_z + delta_z * idx], @@ -57,7 +57,7 @@ def main(random_selection=False, headless=False, short_exec=False): obj_cfgs.append( dict( type="DatasetObject", - name=f"shelf_side_right", + name="shelf_side_right", category="shelf_side", model="yujrmw", position=[0.4, 0, base_z + delta_z * idx], @@ -95,7 +95,7 @@ def main(random_selection=False, headless=False, short_exec=False): obj_cfgs.append( dict( type="DatasetObject", - name=f"shelf_baseboard", + name="shelf_baseboard", category="shelf_baseboard", model="hlhneo", position=[0, -10.97884506, base_z + delta_z * idx], diff --git a/omnigibson/examples/object_states/dicing_demo.py b/omnigibson/examples/object_states/dicing_demo.py index 6141e8fee..08c26e9de 100644 --- a/omnigibson/examples/object_states/dicing_demo.py +++ b/omnigibson/examples/object_states/dicing_demo.py @@ -95,14 +95,14 @@ def main(random_selection=False, headless=False, short_exec=False): orientation=T.euler2quat(th.tensor([-math.pi / 2, 0, 0])), ) - if short_exec == False: + if not short_exec: input("The knife will fall on the apple and dice it. Press [ENTER] to continue.") # Step simulation for a bit so that apple is diced for _ in range(1000): env.step(th.empty(0)) - if short_exec == False: + if not short_exec: input("Apple has been diced! Press [ENTER] to terminate the demo.") # Always close simulator at the end diff --git a/omnigibson/examples/object_states/heated_state_demo.py b/omnigibson/examples/object_states/heated_state_demo.py index 13d34e25b..e24fe9bc5 100644 --- a/omnigibson/examples/object_states/heated_state_demo.py +++ b/omnigibson/examples/object_states/heated_state_demo.py @@ -89,7 +89,7 @@ def report_states(objs): env.step(th.empty(0)) # Also print temperatures temps = [f"{obj.states[object_states.Temperature].get_value():>7.2f}" for obj in objs] - print(f"obj temps:", *temps, end="\r") + print("obj temps:", *temps, end="\r") print() # Objects are not heated anymore. diff --git a/omnigibson/examples/object_states/particle_applier_remover_demo.py b/omnigibson/examples/object_states/particle_applier_remover_demo.py index 24fbee551..f379e70db 100644 --- a/omnigibson/examples/object_states/particle_applier_remover_demo.py +++ b/omnigibson/examples/object_states/particle_applier_remover_demo.py @@ -3,7 +3,6 @@ import omnigibson as og from omnigibson.macros import gm, macros from omnigibson.object_states import Covered, ToggledOn -from omnigibson.utils.constants import ParticleModifyMethod from omnigibson.utils.ui_utils import choose_from_options # Set macros for this example diff --git a/omnigibson/examples/object_states/sample_kinematics_demo.py b/omnigibson/examples/object_states/sample_kinematics_demo.py index f5a60a864..11b6c79fb 100644 --- a/omnigibson/examples/object_states/sample_kinematics_demo.py +++ b/omnigibson/examples/object_states/sample_kinematics_demo.py @@ -1,11 +1,8 @@ -import os - import torch as th import omnigibson as og from omnigibson import object_states from omnigibson.macros import gm -from omnigibson.objects import DatasetObject # Make sure object states are enabled gm.ENABLE_OBJECT_STATES = True @@ -67,7 +64,7 @@ def main(random_selection=False, headless=False, short_exec=False): shelf_cfg = dict( type="DatasetObject", - name=f"shelf", + name="shelf", category="shelf", model="pkgbcp", bounding_box=th.tensor([1.0, 0.4, 2.0]), diff --git a/omnigibson/examples/objects/import_custom_object.py b/omnigibson/examples/objects/import_custom_object.py index 959d80281..1b435f5cb 100644 --- a/omnigibson/examples/objects/import_custom_object.py +++ b/omnigibson/examples/objects/import_custom_object.py @@ -106,15 +106,15 @@ def import_custom_object( if confirm_bbox: if any(size > 3.0 for size in bbox_size): click.echo( - f"Warning: The bounding box sounds a bit large. Are you sure you don't need to scale? " - f"We just wanted to confirm this is intentional. You can skip this check by passing --no-confirm-bbox." + "Warning: The bounding box sounds a bit large. Are you sure you don't need to scale? " + "We just wanted to confirm this is intentional. You can skip this check by passing --no-confirm-bbox." ) click.confirm("Do you want to continue?", abort=True) elif any(size < 0.01 for size in bbox_size): click.echo( - f"Warning: The bounding box sounds a bit small. Are you sure you don't need to scale? " - f"We just wanted to confirm this is intentional. You can skip this check by passing --no-confirm-bbox." + "Warning: The bounding box sounds a bit small. Are you sure you don't need to scale? " + "We just wanted to confirm this is intentional. You can skip this check by passing --no-confirm-bbox." ) click.confirm("Do you want to continue?", abort=True) diff --git a/omnigibson/examples/objects/load_object_selector.py b/omnigibson/examples/objects/load_object_selector.py index 075415135..f16eca9e8 100644 --- a/omnigibson/examples/objects/load_object_selector.py +++ b/omnigibson/examples/objects/load_object_selector.py @@ -1,11 +1,7 @@ import torch as th import omnigibson as og -from omnigibson.utils.asset_utils import ( - get_all_object_categories, - get_all_object_category_models, - get_og_avg_category_specs, -) +from omnigibson.utils.asset_utils import get_all_object_categories, get_all_object_category_models from omnigibson.utils.ui_utils import choose_from_options @@ -35,9 +31,6 @@ def main(random_selection=False, headless=False, short_exec=False): options=available_obj_models, name="object model", random_selection=random_selection ) - # Load the specs of the object categories, e.g., common scaling factor - avg_category_spec = get_og_avg_category_specs() - # Create and load this object into the simulator obj_cfg = dict( type="DatasetObject", diff --git a/omnigibson/examples/renderer_settings/renderer_settings_example.py b/omnigibson/examples/renderer_settings/renderer_settings_example.py index e47748326..3d0b85910 100644 --- a/omnigibson/examples/renderer_settings/renderer_settings_example.py +++ b/omnigibson/examples/renderer_settings/renderer_settings_example.py @@ -89,14 +89,14 @@ def steps(n): renderer_setting.common_settings.materials_settings.skip_material_loading.set(True) # Get setting (3 lines below are equivalent). - assert renderer_setting.get_setting_from_path(path="/app/renderer/skipMaterialLoading") == True - assert renderer_setting.common_settings.materials_settings.skip_material_loading.value == True - assert renderer_setting.common_settings.materials_settings.skip_material_loading.get() == True + assert renderer_setting.get_setting_from_path(path="/app/renderer/skipMaterialLoading") + assert renderer_setting.common_settings.materials_settings.skip_material_loading.value + assert renderer_setting.common_settings.materials_settings.skip_material_loading.get() # Reset setting (2 lines below are equivalent). renderer_setting.reset_setting(path="/app/renderer/skipMaterialLoading") renderer_setting.common_settings.materials_settings.skip_material_loading.reset() - assert renderer_setting.get_setting_from_path(path="/app/renderer/skipMaterialLoading") == False + assert not renderer_setting.get_setting_from_path(path="/app/renderer/skipMaterialLoading") # Set setting to an unallowed value using top-level method. # Examples below will use the "top-level" setting method. diff --git a/omnigibson/examples/robots/advanced/ik_example.py b/omnigibson/examples/robots/advanced/ik_example.py index 72d0a6434..ab4f0afca 100644 --- a/omnigibson/examples/robots/advanced/ik_example.py +++ b/omnigibson/examples/robots/advanced/ik_example.py @@ -6,8 +6,6 @@ import omnigibson as og import omnigibson.lazy as lazy from omnigibson.objects import PrimitiveObject -from omnigibson.robots import Fetch -from omnigibson.scenes import Scene from omnigibson.utils.control_utils import IKSolver @@ -117,7 +115,7 @@ def execute_ik(pos, quat=None, max_iter=100): else: # Create a visual marker to be moved by the user, representing desired end-effector position marker = PrimitiveObject( - relative_prim_path=f"/marker", + relative_prim_path="/marker", name="marker", primitive_type="Sphere", radius=0.03, @@ -164,7 +162,7 @@ def keyboard_event_handler(event, *args, **kwargs): appwindow = lazy.omni.appwindow.get_default_app_window() input_interface = lazy.carb.input.acquire_input_interface() keyboard = appwindow.get_keyboard() - sub_keyboard = input_interface.subscribe_to_keyboard_events(keyboard, keyboard_event_handler) + input_interface.subscribe_to_keyboard_events(keyboard, keyboard_event_handler) # Print out helpful information to the user print_message() diff --git a/omnigibson/examples/robots/curobo_example.py b/omnigibson/examples/robots/curobo_example.py index ae54ce866..1e94c52df 100644 --- a/omnigibson/examples/robots/curobo_example.py +++ b/omnigibson/examples/robots/curobo_example.py @@ -3,11 +3,8 @@ import torch as th import omnigibson as og -import omnigibson.lazy as lazy import omnigibson.utils.transform_utils as T from omnigibson.action_primitives.curobo import CuRoboEmbodimentSelection, CuRoboMotionGenerator -from omnigibson.macros import gm, macros -from omnigibson.object_states import Touching from omnigibson.utils.ui_utils import choose_from_options @@ -301,7 +298,7 @@ def test_curobo(): ) attached_obj = {robot.eef_link_names["left"]: cologne.root_link} control_gripper(env, robot, attached_obj) - assert robot._ag_obj_in_hand["left"] == cologne and robot._ag_obj_in_hand["right"] == None + assert robot._ag_obj_in_hand["left"] == cologne and robot._ag_obj_in_hand["right"] is None # Reset to reset pose (both hands) target_pos = { @@ -362,7 +359,7 @@ def test_curobo(): ) attached_obj = {robot.eef_link_names["left"]: cologne.root_link} control_gripper(env, robot, attached_obj) - assert robot._ag_obj_in_hand["left"] == cologne and robot._ag_obj_in_hand["right"] == None + assert robot._ag_obj_in_hand["left"] == cologne and robot._ag_obj_in_hand["right"] is None # Place the cologne (left hand) left_hand_pos, left_hand_quat = T.pose_transform(*fridge.get_position_orientation(), *fridge_place_local_pose) @@ -376,7 +373,7 @@ def test_curobo(): ) attached_obj = None control_gripper(env, robot, attached_obj) - assert robot._ag_obj_in_hand["left"] == None and robot._ag_obj_in_hand["right"] == None + assert robot._ag_obj_in_hand["left"] is None and robot._ag_obj_in_hand["right"] is None og.shutdown() diff --git a/omnigibson/examples/robots/import_custom_robot.py b/omnigibson/examples/robots/import_custom_robot.py index 462812e7a..4e800a308 100644 --- a/omnigibson/examples/robots/import_custom_robot.py +++ b/omnigibson/examples/robots/import_custom_robot.py @@ -410,11 +410,9 @@ def add_sensor(stage, root_prim, sensor_type, link_name, parent_link_name=None, link_prim_path = f"{root_prim_path}/{link_name}" link_prim_exists = lazy.omni.isaac.core.utils.prims.is_prim_path_valid(link_prim_path) if parent_link_prim is not None: - assert ( - not link_prim_exists - ), f"Since parent link is defined, link_name {link_name} must be a link that is NOT pre-existing within the robot's set of links!" + assert not link_prim_exists, f"Since parent link is defined, link_name {link_name} must be a link that is NOT pre-existing within the robot's set of links!" # Manually create a new prim (specified offset) - link_prim = create_rigid_prim( + create_rigid_prim( stage=stage, link_prim_path=link_prim_path, ) @@ -443,10 +441,7 @@ def add_sensor(stage, root_prim, sensor_type, link_name, parent_link_name=None, else: # Otherwise, link prim MUST exist - assert ( - link_prim_exists - ), f"Since no parent link is defined, link_name {link_name} must be a link that IS pre-existing within the robot's set of links!" - link_prim = lazy.omni.isaac.core.utils.prims.get_prim_at_path(link_prim_path) + assert link_prim_exists, f"Since no parent link is defined, link_name {link_name} must be a link that IS pre-existing within the robot's set of links!" # Define functions to generate the desired sensor prim if sensor_type == "Camera": @@ -721,11 +716,6 @@ def get_joint_upper_limit(root_prim, joint_name): assert joint_prim is not None, f"Could not find joint prim with name {joint_name}!" return joint_prim.GetAttribute("physics:upperLimit").Get() - all_links = _find_prims_with_condition( - condition=lambda prim: prim.HasAPI(lazy.pxr.UsdPhysics.RigidBodyAPI), - root_prim=robot_prim, - ) - # Generate list of collision link names -- this is simply the list of all link names from the # collision spheres specification collision_spheres = curobo_cfg.collision_spheres.to_dict() diff --git a/omnigibson/examples/scenes/scene_tour_demo.py b/omnigibson/examples/scenes/scene_tour_demo.py index 4bcc57992..058418156 100644 --- a/omnigibson/examples/scenes/scene_tour_demo.py +++ b/omnigibson/examples/scenes/scene_tour_demo.py @@ -67,7 +67,7 @@ def add_waypoint(): def clear_waypoints(): nonlocal waypoints - print(f"Cleared all waypoints!") + print("Cleared all waypoints!") waypoints = [] KeyboardEventHandler.initialize() @@ -95,10 +95,10 @@ def clear_waypoints(): ) # Print out additional keyboard commands - print(f"\t X: Save the current camera pose as a waypoint") - print(f"\t C: Clear all waypoints") - print(f"\t J: Record the camera trajectory from the current set of waypoints") - print(f"\t ESC: Terminate the demo") + print("\t X: Save the current camera pose as a waypoint") + print("\t C: Clear all waypoints") + print("\t J: Record the camera trajectory from the current set of waypoints") + print("\t ESC: Terminate the demo") # Loop indefinitely steps = 0 diff --git a/omnigibson/examples/scenes/traversability_map_example.py b/omnigibson/examples/scenes/traversability_map_example.py index f2c912b29..2818f51b1 100644 --- a/omnigibson/examples/scenes/traversability_map_example.py +++ b/omnigibson/examples/scenes/traversability_map_example.py @@ -3,7 +3,6 @@ import cv2 import matplotlib.pyplot as plt import torch as th -from PIL import Image import omnigibson as og from omnigibson.utils.asset_utils import get_available_og_scenes, get_og_scene_path diff --git a/omnigibson/install.py b/omnigibson/install.py index eec12a267..302c68bf6 100644 --- a/omnigibson/install.py +++ b/omnigibson/install.py @@ -5,7 +5,6 @@ import sys import tempfile import urllib.request -from importlib.util import find_spec from pathlib import Path from typing import List, Optional @@ -254,7 +253,7 @@ def _pip_based_install(): # Check that it can now be imported os.environ["OMNI_KIT_ACCEPT_EULA"] = "YES" - import isaacsim + import isaacsim # noqa: F401 except ImportError: return False @@ -323,7 +322,10 @@ def setup_omnigibson(install_datasets: bool, launcher_install: bool, isaac_sim_p # Check if the isaacsim package is already installed try: os.environ["OMNI_KIT_ACCEPT_EULA"] = "YES" - import isaacsim + + # We import this, skip the unused import warning, because the import actually has side effects + # in terms of what's included in the Python path. + import isaacsim # noqa: F401 click.echo("Isaac Sim is already installed via pip in your current env.") click.echo("If you need to download the datasets, please run omnigibson/download_datasets.py.") @@ -363,12 +365,12 @@ def setup_omnigibson(install_datasets: bool, launcher_install: bool, isaac_sim_p dataset_exists, assets_exist = os.path.exists(gm.DATASET_PATH), os.path.exists(gm.ASSET_PATH) if not (dataset_exists and assets_exist): # Ask user which dataset to install - click.echo(f"OmniGibson will now install data under the following locations:") + click.echo("OmniGibson will now install data under the following locations:") click.echo(f" dataset (~25GB): {gm.DATASET_PATH}") click.echo(f" assets (~2.5GB): {gm.ASSET_PATH}") click.echo( - f"If you want to install data under a different path, please change the DATA_PATH variable in omnigibson/macros.py and " - f"rerun omnigibson/download_datasets.py." + "If you want to install data under a different path, please change the DATA_PATH variable in omnigibson/macros.py and " + "rerun omnigibson/download_datasets.py." ) if click.confirm("Do you want to continue?", default=True): # Only download if the dataset path doesn't exist diff --git a/omnigibson/maps/__init__.py b/omnigibson/maps/__init__.py index b57ce6a5d..f25d9dfac 100644 --- a/omnigibson/maps/__init__.py +++ b/omnigibson/maps/__init__.py @@ -1,3 +1,9 @@ from omnigibson.maps.map_base import BaseMap from omnigibson.maps.segmentation_map import SegmentationMap from omnigibson.maps.traversable_map import TraversableMap + +__all__ = [ + "BaseMap", + "SegmentationMap", + "TraversableMap", +] diff --git a/omnigibson/maps/segmentation_map.py b/omnigibson/maps/segmentation_map.py index c289b2030..c3faa04e1 100644 --- a/omnigibson/maps/segmentation_map.py +++ b/omnigibson/maps/segmentation_map.py @@ -3,7 +3,6 @@ import cv2 import torch as th -import omnigibson as og from omnigibson.macros import gm from omnigibson.maps.map_base import BaseMap from omnigibson.utils.python_utils import torch_delete diff --git a/omnigibson/object_states/__init__.py b/omnigibson/object_states/__init__.py index c6d487333..d385acc42 100644 --- a/omnigibson/object_states/__init__.py +++ b/omnigibson/object_states/__init__.py @@ -34,3 +34,49 @@ from omnigibson.object_states.toggle import ToggledOn from omnigibson.object_states.touching import Touching from omnigibson.object_states.under import Under + +__all__ = [ + "AABB", + "AttachedTo", + "Burnt", + "ContactBodies", + "ContactParticles", + "ContainedParticles", + "Contains", + "Cooked", + "Covered", + "Draped", + "Filled", + "Folded", + "FoldedLevel", + "Frozen", + "Heated", + "HeatSourceOrSink", + "HorizontalAdjacency", + "Inside", + "IsGrasping", + "Joint", + "MaxTemperature", + "NextTo", + "ObjectsInFOVOfRobot", + "OnFire", + "OnTop", + "Open", + "Overlaid", + "ParticleApplier", + "ParticleRemover", + "ParticleRequirement", + "ParticleSink", + "ParticleSource", + "Pose", + "REGISTERED_OBJECT_STATES", + "Saturated", + "SliceableRequirement", + "SlicerActive", + "Temperature", + "ToggledOn", + "Touching", + "Under", + "Unfolded", + "VerticalAdjacency", +] diff --git a/omnigibson/object_states/adjacency.py b/omnigibson/object_states/adjacency.py index 736acb1d1..c75aee4f7 100644 --- a/omnigibson/object_states/adjacency.py +++ b/omnigibson/object_states/adjacency.py @@ -3,7 +3,6 @@ import torch as th -import omnigibson as og from omnigibson.macros import create_module_macros from omnigibson.object_states.aabb import AABB from omnigibson.object_states.object_state_base import AbsoluteObjectState diff --git a/omnigibson/object_states/attached_to.py b/omnigibson/object_states/attached_to.py index 904d3c51b..30a7b35fb 100644 --- a/omnigibson/object_states/attached_to.py +++ b/omnigibson/object_states/attached_to.py @@ -14,7 +14,7 @@ from omnigibson.utils.constants import JointType from omnigibson.utils.python_utils import classproperty from omnigibson.utils.ui_utils import create_module_logger -from omnigibson.utils.usd_utils import CollisionAPI, create_joint +from omnigibson.utils.usd_utils import create_joint # Create module logger log = create_module_logger(module_name=__name__) @@ -423,7 +423,7 @@ def _load_state(self, state): self.set_value(self.parent, False) # assert self.parent is None, "parent reference is not cleared after detachment" if self.parent is not None: - log.warning(f"parent reference is not cleared after detachment") + log.warning("parent reference is not cleared after detachment") # If the loaded state requires attachment, attach. if attached_obj is not None: @@ -436,7 +436,7 @@ def _load_state(self, state): ) # assert self.parent == attached_obj, "parent reference is not updated after attachment" if self.parent != attached_obj: - log.warning(f"parent reference is not updated after attachment") + log.warning("parent reference is not updated after attachment") def serialize(self, state): return th.tensor([state["attached_obj_uuid"]], dtype=th.float32) diff --git a/omnigibson/object_states/contact_bodies.py b/omnigibson/object_states/contact_bodies.py index e9a63ea74..b6ba6187f 100644 --- a/omnigibson/object_states/contact_bodies.py +++ b/omnigibson/object_states/contact_bodies.py @@ -1,6 +1,5 @@ -import omnigibson as og from omnigibson.object_states.object_state_base import AbsoluteObjectState -from omnigibson.utils.sim_utils import prim_paths_to_rigid_prims, prims_to_rigid_prim_set +from omnigibson.utils.sim_utils import prim_paths_to_rigid_prims class ContactBodies(AbsoluteObjectState): diff --git a/omnigibson/object_states/factory.py b/omnigibson/object_states/factory.py index c4d26c88c..9df7c96ab 100644 --- a/omnigibson/object_states/factory.py +++ b/omnigibson/object_states/factory.py @@ -2,7 +2,41 @@ import networkx as nx -from omnigibson.object_states import * +from omnigibson.object_states import ( + REGISTERED_OBJECT_STATES, + AttachedTo, + Burnt, + Contains, + Cooked, + Covered, + Draped, + Filled, + Folded, + Frozen, + Heated, + HeatSourceOrSink, + Inside, + IsGrasping, + MaxTemperature, + NextTo, + ObjectsInFOVOfRobot, + OnFire, + OnTop, + Open, + Overlaid, + ParticleApplier, + ParticleRemover, + ParticleRequirement, + ParticleSink, + ParticleSource, + Saturated, + SliceableRequirement, + SlicerActive, + ToggledOn, + Touching, + Under, + Unfolded, +) from omnigibson.object_states.kinematics_mixin import KinematicsMixin from omnigibson.object_states.link_based_state_mixin import LinkBasedStateMixin diff --git a/omnigibson/object_states/filled.py b/omnigibson/object_states/filled.py index 4eceee2bb..bb8df249c 100644 --- a/omnigibson/object_states/filled.py +++ b/omnigibson/object_states/filled.py @@ -1,5 +1,3 @@ -import torch as th - from omnigibson.macros import create_module_macros from omnigibson.object_states.contains import ContainedParticles from omnigibson.object_states.object_state_base import BooleanStateMixin, RelativeObjectState @@ -15,7 +13,6 @@ class Filled(RelativeObjectState, BooleanStateMixin): - def _get_value(self, system): # Sanity check to make sure system is valid assert self.obj.scene.is_physical_particle_system( diff --git a/omnigibson/object_states/heat_source_or_sink.py b/omnigibson/object_states/heat_source_or_sink.py index b3e3f32fd..3644bfab1 100644 --- a/omnigibson/object_states/heat_source_or_sink.py +++ b/omnigibson/object_states/heat_source_or_sink.py @@ -1,7 +1,7 @@ import torch as th import omnigibson as og -from omnigibson.macros import create_module_macros, macros +from omnigibson.macros import create_module_macros from omnigibson.object_states.aabb import AABB from omnigibson.object_states.inside import Inside from omnigibson.object_states.link_based_state_mixin import LinkBasedStateMixin @@ -199,7 +199,6 @@ def affects_obj(self, obj): def _update(self): # Avoid circular imports from omnigibson.object_states.temperature import Temperature - from omnigibson.objects.stateful_object import StatefulObject # Update the internally tracked nearby objects to accelerate filtering for affects_obj affected_objects = set() diff --git a/omnigibson/object_states/inside.py b/omnigibson/object_states/inside.py index f3899540b..7f9bb8761 100644 --- a/omnigibson/object_states/inside.py +++ b/omnigibson/object_states/inside.py @@ -5,7 +5,6 @@ from omnigibson.object_states.adjacency import HorizontalAdjacency, VerticalAdjacency, flatten_planes from omnigibson.object_states.kinematics_mixin import KinematicsMixin from omnigibson.object_states.object_state_base import BooleanStateMixin, RelativeObjectState -from omnigibson.object_states.pose import Pose from omnigibson.utils.constants import PrimType from omnigibson.utils.object_state_utils import m as os_m from omnigibson.utils.object_state_utils import sample_kinematics diff --git a/omnigibson/object_states/joint_state.py b/omnigibson/object_states/joint_state.py index 7293fee9f..dedc62d07 100644 --- a/omnigibson/object_states/joint_state.py +++ b/omnigibson/object_states/joint_state.py @@ -10,7 +10,6 @@ class Joint(AbsoluteObjectState): - def _get_value(self): return self.obj.get_joint_positions() if self.obj.n_joints > 0 else th.tensor([]) diff --git a/omnigibson/object_states/next_to.py b/omnigibson/object_states/next_to.py index bbf7d11c4..7b224ff7a 100644 --- a/omnigibson/object_states/next_to.py +++ b/omnigibson/object_states/next_to.py @@ -7,7 +7,6 @@ class NextTo(KinematicsMixin, RelativeObjectState, BooleanStateMixin): - @classmethod def get_dependencies(cls): deps = super().get_dependencies() diff --git a/omnigibson/object_states/on_top.py b/omnigibson/object_states/on_top.py index 95ba5a08b..09a6ecd62 100644 --- a/omnigibson/object_states/on_top.py +++ b/omnigibson/object_states/on_top.py @@ -9,7 +9,6 @@ class OnTop(KinematicsMixin, RelativeObjectState, BooleanStateMixin): - @classmethod def get_dependencies(cls): deps = super().get_dependencies() diff --git a/omnigibson/object_states/overlaid.py b/omnigibson/object_states/overlaid.py index 12f6369c5..3f0a4d408 100644 --- a/omnigibson/object_states/overlaid.py +++ b/omnigibson/object_states/overlaid.py @@ -23,7 +23,6 @@ class Overlaid(KinematicsMixin, RelativeObjectState, BooleanStateMixin): - @classmethod def get_dependencies(cls): deps = super().get_dependencies() diff --git a/omnigibson/object_states/particle.py b/omnigibson/object_states/particle.py index 25c2ea4df..c35316e00 100644 --- a/omnigibson/object_states/particle.py +++ b/omnigibson/object_states/particle.py @@ -1,5 +1,3 @@ -import torch as th - from omnigibson.object_states.object_state_base import BaseObjectRequirement @@ -13,6 +11,6 @@ def is_compatible(cls, obj, **kwargs): from omnigibson.macros import gm if not gm.USE_GPU_DYNAMICS: - return False, f"Particle systems are not enabled when GPU dynamics is off." + return False, "Particle systems are not enabled when GPU dynamics is off." return True, None diff --git a/omnigibson/object_states/particle_modifier.py b/omnigibson/object_states/particle_modifier.py index a7f655eab..053baf1b6 100644 --- a/omnigibson/object_states/particle_modifier.py +++ b/omnigibson/object_states/particle_modifier.py @@ -19,7 +19,7 @@ from omnigibson.object_states.update_state_mixin import UpdateStateMixin from omnigibson.prims.geom_prim import VisualGeomPrim from omnigibson.prims.prim_base import BasePrim -from omnigibson.systems.system_base import PhysicalParticleSystem, VisualParticleSystem +from omnigibson.systems.system_base import PhysicalParticleSystem from omnigibson.utils.constants import ParticleModifyCondition, ParticleModifyMethod, PrimType from omnigibson.utils.geometry_utils import ( generate_points_in_volume_checker_function, @@ -224,7 +224,6 @@ def condition(obj) --> bool """ def __init__(self, obj, conditions, method=ParticleModifyMethod.ADJACENCY, projection_mesh_params=None): - # Store internal variables self.method = method self.projection_source_sphere = None @@ -564,7 +563,7 @@ def condition(obj) --> bool # Make sure conds isn't empty and is a list if conds is None: continue - assert type(conds) == list, f"Expected list of conditions for system {system_name}, got {conds}" + assert type(conds) is list, f"Expected list of conditions for system {system_name}, got {conds}" system_conditions = [] for cond_type, cond_val in conds: cond = self._generate_condition(condition_type=cond_type, value=cond_val) diff --git a/omnigibson/object_states/pose.py b/omnigibson/object_states/pose.py index bf1a7bc36..0d5555263 100644 --- a/omnigibson/object_states/pose.py +++ b/omnigibson/object_states/pose.py @@ -11,7 +11,6 @@ class Pose(AbsoluteObjectState): - def _get_value(self): pos, orn = self.obj.get_position_orientation() return pos, orn diff --git a/omnigibson/object_states/robot_related_states.py b/omnigibson/object_states/robot_related_states.py index 6567951d8..108147f44 100644 --- a/omnigibson/object_states/robot_related_states.py +++ b/omnigibson/object_states/robot_related_states.py @@ -1,6 +1,3 @@ -import torch as th - -import omnigibson as og from omnigibson.object_states.object_state_base import AbsoluteObjectState, BooleanStateMixin, RelativeObjectState from omnigibson.sensors import VisionSensor diff --git a/omnigibson/object_states/sliceable.py b/omnigibson/object_states/sliceable.py index 784226eb8..3c20898db 100644 --- a/omnigibson/object_states/sliceable.py +++ b/omnigibson/object_states/sliceable.py @@ -16,7 +16,7 @@ def is_compatible(cls, obj, **kwargs): return False, f"Only compatible with DatasetObject, but {obj} is of type {type(obj)}" # Check to make sure object parts are properly annotated in this object's metadata if not obj.metadata["object_parts"]: - return False, f"Missing required metadata 'object_parts'." + return False, "Missing required metadata 'object_parts'." return True, None @@ -25,6 +25,6 @@ def is_compatible_asset(cls, prim, **kwargs): # Check to make sure object parts are properly annotated in this object's metadata metadata = prim.GetCustomData().get("metadata", dict()) if not metadata.get("object_parts", None): - return False, f"Missing required metadata 'object_parts'." + return False, "Missing required metadata 'object_parts'." return True, None diff --git a/omnigibson/object_states/temperature.py b/omnigibson/object_states/temperature.py index f1b8b33d2..306f3d14f 100644 --- a/omnigibson/object_states/temperature.py +++ b/omnigibson/object_states/temperature.py @@ -17,7 +17,6 @@ class Temperature(TensorizedValueState): - def __init__(self, obj): # Run super first super(Temperature, self).__init__(obj) diff --git a/omnigibson/object_states/toggle.py b/omnigibson/object_states/toggle.py index 9088d8482..297a37cae 100644 --- a/omnigibson/object_states/toggle.py +++ b/omnigibson/object_states/toggle.py @@ -21,7 +21,6 @@ class ToggledOn(AbsoluteObjectState, BooleanStateMixin, LinkBasedStateMixin, UpdateStateMixin, GlobalUpdateStateMixin): - # List of set of prim paths defining robot finger links belonging to any manipulation robots per scene _robot_finger_paths = None @@ -107,7 +106,7 @@ def _initialize(self): self.scale = m.DEFAULT_SCALE if self.scale is None else self.scale # Note: We have to create a mesh (instead of a sphere shape) because physx complains about non-uniform # scaling for non-meshes - mesh = create_primitive_mesh( + create_primitive_mesh( prim_path=mesh_prim_path, primitive_type="Sphere", extents=1.0, diff --git a/omnigibson/object_states/touching.py b/omnigibson/object_states/touching.py index 06a97e65f..ce80c66f6 100644 --- a/omnigibson/object_states/touching.py +++ b/omnigibson/object_states/touching.py @@ -5,7 +5,6 @@ class Touching(KinematicsMixin, RelativeObjectState, BooleanStateMixin): - @staticmethod def _check_contact(obj_a, obj_b): return len(set(obj_a.links.values()) & obj_b.states[ContactBodies].get_value()) > 0 diff --git a/omnigibson/objects/__init__.py b/omnigibson/objects/__init__.py index e2c635672..6a52b7d46 100644 --- a/omnigibson/objects/__init__.py +++ b/omnigibson/objects/__init__.py @@ -5,3 +5,14 @@ from omnigibson.objects.primitive_object import PrimitiveObject from omnigibson.objects.stateful_object import StatefulObject from omnigibson.objects.usd_object import USDObject + +__all__ = [ + "BaseObject", + "ControllableObject", + "DatasetObject", + "LightObject", + "PrimitiveObject", + "REGISTERED_OBJECTS", + "StatefulObject", + "USDObject", +] diff --git a/omnigibson/objects/dataset_object.py b/omnigibson/objects/dataset_object.py index 11b525b83..98fce936b 100644 --- a/omnigibson/objects/dataset_object.py +++ b/omnigibson/objects/dataset_object.py @@ -5,7 +5,6 @@ import torch as th -import omnigibson as og import omnigibson.lazy as lazy import omnigibson.utils.transform_utils as T from omnigibson.macros import create_module_macros, gm diff --git a/omnigibson/objects/light_object.py b/omnigibson/objects/light_object.py index 4a99a7f43..cc97af77f 100644 --- a/omnigibson/objects/light_object.py +++ b/omnigibson/objects/light_object.py @@ -96,10 +96,10 @@ def __init__( def _load(self): # Define XForm and base link for this light prim = og.sim.stage.DefinePrim(self.prim_path, "Xform") - base_link = og.sim.stage.DefinePrim(f"{self.prim_path}/base_link", "Xform") + og.sim.stage.DefinePrim(f"{self.prim_path}/base_link", "Xform") # Define the actual light link - light_prim = ( + ( getattr(lazy.pxr.UsdLux, f"{self.light_type}Light") .Define(og.sim.stage, f"{self.prim_path}/base_link/light") .GetPrim() @@ -118,7 +118,7 @@ def _post_load(self): self._light_link.load(self.scene) # Apply Shaping API and set default cone angle attribute - shaping_api = lazy.pxr.UsdLux.ShapingAPI.Apply(self._light_link.prim).GetShapingConeAngleAttr().Set(180.0) + lazy.pxr.UsdLux.ShapingAPI.Apply(self._light_link.prim).GetShapingConeAngleAttr().Set(180.0) # Optionally set the intensity if self._load_config.get("intensity", None) is not None: diff --git a/omnigibson/objects/object_base.py b/omnigibson/objects/object_base.py index a4101b42f..c85a9a917 100644 --- a/omnigibson/objects/object_base.py +++ b/omnigibson/objects/object_base.py @@ -1,20 +1,18 @@ -import math from abc import ABCMeta from collections.abc import Iterable from functools import cached_property import torch as th -import trimesh import omnigibson as og import omnigibson.lazy as lazy import omnigibson.utils.transform_utils as T -from omnigibson.macros import create_module_macros, gm +from omnigibson.macros import create_module_macros from omnigibson.prims.entity_prim import EntityPrim -from omnigibson.utils.constants import PrimType, semantic_class_name_to_id +from omnigibson.utils.constants import PrimType from omnigibson.utils.python_utils import Registerable, classproperty, get_uuid from omnigibson.utils.ui_utils import create_module_logger, suppress_omni_log -from omnigibson.utils.usd_utils import CollisionAPI, create_joint +from omnigibson.utils.usd_utils import create_joint # Global dicts that will contain mappings REGISTERED_OBJECTS = dict() @@ -92,7 +90,9 @@ def __init__( load_config["scale"] = ( scale if isinstance(scale, th.Tensor) - else th.tensor(scale, dtype=th.float32) if isinstance(scale, Iterable) else scale + else th.tensor(scale, dtype=th.float32) + if isinstance(scale, Iterable) + else scale ) load_config["visible"] = visible load_config["visual_only"] = visual_only @@ -144,7 +144,7 @@ def _post_load(self): if ( self.n_joints == 0 and (th.all(th.isclose(scale, th.ones_like(scale), atol=1e-3)).item() or self.n_fixed_joints == 0) - and (self._load_config["kinematic_only"] != False) + and (self._load_config["kinematic_only"] is not False) and not self.has_attachment_points ): kinematic_only = True diff --git a/omnigibson/objects/primitive_object.py b/omnigibson/objects/primitive_object.py index de72478c3..3f280d2cf 100644 --- a/omnigibson/objects/primitive_object.py +++ b/omnigibson/objects/primitive_object.py @@ -119,7 +119,7 @@ def _load(self): prim = og.sim.stage.DefinePrim(self.prim_path, "Xform") # Define a nested mesh corresponding to the root link for this prim - base_link = og.sim.stage.DefinePrim(f"{self.prim_path}/base_link", "Xform") + og.sim.stage.DefinePrim(f"{self.prim_path}/base_link", "Xform") self._vis_geom = create_primitive_mesh( prim_path=f"{self.prim_path}/base_link/visuals", primitive_type=self._primitive_type ) @@ -135,7 +135,7 @@ def _load(self): # Create a material for this object for the base link og.sim.stage.DefinePrim(f"{self.prim_path}/Looks", "Scope") mat_path = f"{self.prim_path}/Looks/default" - mat = create_pbr_material(prim_path=mat_path) + create_pbr_material(prim_path=mat_path) bind_material(prim_path=self._vis_geom.GetPrim().GetPrimPath().pathString, material_path=mat_path) return prim diff --git a/omnigibson/objects/stateful_object.py b/omnigibson/objects/stateful_object.py index a1bd5fc1e..54e3ba96f 100644 --- a/omnigibson/objects/stateful_object.py +++ b/omnigibson/objects/stateful_object.py @@ -1,4 +1,3 @@ -import sys from collections import defaultdict from typing import Literal @@ -24,7 +23,6 @@ from omnigibson.object_states.heat_source_or_sink import HeatSourceOrSink from omnigibson.object_states.object_state_base import REGISTERED_OBJECT_STATES from omnigibson.object_states.on_fire import OnFire -from omnigibson.object_states.particle_modifier import ParticleRemover from omnigibson.objects.object_base import BaseObject from omnigibson.renderer_settings.renderer_settings import RendererSettings from omnigibson.utils.constants import EmitterType, PrimType diff --git a/omnigibson/objects/usd_object.py b/omnigibson/objects/usd_object.py index 1ef06da99..f4d87a3d6 100644 --- a/omnigibson/objects/usd_object.py +++ b/omnigibson/objects/usd_object.py @@ -2,11 +2,10 @@ import tempfile import omnigibson as og -import omnigibson.lazy as lazy from omnigibson.objects.stateful_object import StatefulObject from omnigibson.utils.asset_utils import decrypt_file from omnigibson.utils.constants import PrimType -from omnigibson.utils.usd_utils import add_asset_to_stage, deep_copy_prim +from omnigibson.utils.usd_utils import add_asset_to_stage class USDObject(StatefulObject): diff --git a/omnigibson/prims/__init__.py b/omnigibson/prims/__init__.py index ec7f6a9f6..01f5f8ff8 100644 --- a/omnigibson/prims/__init__.py +++ b/omnigibson/prims/__init__.py @@ -5,3 +5,16 @@ from omnigibson.prims.prim_base import BasePrim from omnigibson.prims.rigid_prim import RigidPrim from omnigibson.prims.xform_prim import XFormPrim + +__all__ = [ + "BasePrim", + "ClothPrim", + "CollisionGeomPrim", + "CollisionVisualGeomPrim", + "EntityPrim", + "GeomPrim", + "JointPrim", + "RigidPrim", + "VisualGeomPrim", + "XFormPrim", +] diff --git a/omnigibson/prims/cloth_prim.py b/omnigibson/prims/cloth_prim.py index 9c416eaeb..ee0a875ef 100644 --- a/omnigibson/prims/cloth_prim.py +++ b/omnigibson/prims/cloth_prim.py @@ -8,7 +8,6 @@ # import math -from collections.abc import Iterable from functools import cached_property import torch as th @@ -20,7 +19,7 @@ from omnigibson.prims.geom_prim import GeomPrim from omnigibson.utils.numpy_utils import vtarray_to_torch from omnigibson.utils.sim_utils import CsRawData -from omnigibson.utils.usd_utils import array_to_vtarray, mesh_prim_to_trimesh_mesh, sample_mesh_keypoints +from omnigibson.utils.usd_utils import mesh_prim_to_trimesh_mesh, sample_mesh_keypoints # Create settings for this module m = create_module_macros(module_path=__file__) diff --git a/omnigibson/prims/geom_prim.py b/omnigibson/prims/geom_prim.py index 7b03dad9e..a27e8ef1f 100644 --- a/omnigibson/prims/geom_prim.py +++ b/omnigibson/prims/geom_prim.py @@ -31,7 +31,6 @@ def __init__( name, load_config=None, ): - # Run super method super().__init__( relative_prim_path=relative_prim_path, @@ -117,7 +116,7 @@ def opacity(self, opacity): if self.has_material(): self.material.opacity_constant = opacity else: - self.set_attribute("primvars:displayOpacity", np.array([opacity])) + self.set_attribute("primvars:displayOpacity", [opacity]) @property def points(self): @@ -193,7 +192,6 @@ def extent(self): class CollisionGeomPrim(GeomPrim): - def __init__( self, relative_prim_path, @@ -436,7 +434,6 @@ class VisualGeomPrim(GeomPrim): class CollisionVisualGeomPrim(CollisionGeomPrim, VisualGeomPrim): - def _post_load(self): # run super first super()._post_load() diff --git a/omnigibson/prims/prim_base.py b/omnigibson/prims/prim_base.py index 1d40b60dc..0331a736a 100644 --- a/omnigibson/prims/prim_base.py +++ b/omnigibson/prims/prim_base.py @@ -1,7 +1,6 @@ import string -from abc import ABC, abstractmethod +from abc import ABC -import omnigibson as og import omnigibson.lazy as lazy from omnigibson.utils.python_utils import Recreatable, Serializable from omnigibson.utils.ui_utils import create_module_logger diff --git a/omnigibson/prims/rigid_prim.py b/omnigibson/prims/rigid_prim.py index 6167f4ea9..1d547fdd7 100644 --- a/omnigibson/prims/rigid_prim.py +++ b/omnigibson/prims/rigid_prim.py @@ -3,12 +3,12 @@ from typing import Literal import torch as th -from scipy.spatial import ConvexHull, QhullError +from scipy.spatial import ConvexHull import omnigibson as og import omnigibson.lazy as lazy import omnigibson.utils.transform_utils as T -from omnigibson.macros import create_module_macros, gm +from omnigibson.macros import create_module_macros from omnigibson.prims.geom_prim import CollisionGeomPrim, VisualGeomPrim from omnigibson.prims.xform_prim import XFormPrim from omnigibson.utils.constants import GEOM_TYPES diff --git a/omnigibson/renderer_settings/__init__.py b/omnigibson/renderer_settings/__init__.py index 9dd9126a4..211feb3bd 100644 --- a/omnigibson/renderer_settings/__init__.py +++ b/omnigibson/renderer_settings/__init__.py @@ -1 +1,5 @@ from omnigibson.renderer_settings.renderer_settings import RendererSettings + +__all__ = [ + "RendererSettings", +] diff --git a/omnigibson/renderer_settings/path_tracing_settings.py b/omnigibson/renderer_settings/path_tracing_settings.py index d53e34786..b64636616 100644 --- a/omnigibson/renderer_settings/path_tracing_settings.py +++ b/omnigibson/renderer_settings/path_tracing_settings.py @@ -18,7 +18,7 @@ class PathTracingSettings(SettingsBase): def __init__(self): self.anti_aliasing_settings = AntiAliasingSettings() self.firefly_filter_settings = FireflyFilterSettings() - self.path_tracing_settings = PathTracingSettings() + self.path_tracing_settings = PathTracingSpecificSettings() self.sampling_and_caching_settings = SamplingAndCachingSettings() self.denoising_settings = DenoisingSettings() self.path_traced_fog_settings = PathTracedFogSettings() @@ -101,7 +101,7 @@ def enabled_setting_path(self): return "/rtx/pathtracing/fireflyFilter/enabled" -class PathTracingSettings(SubSettingsBase): +class PathTracingSpecificSettings(SubSettingsBase): def __init__(self): self._carb_settings = lazy.carb.settings.get_settings() diff --git a/omnigibson/reward_functions/__init__.py b/omnigibson/reward_functions/__init__.py index 2f10acdce..ac9e61a5d 100644 --- a/omnigibson/reward_functions/__init__.py +++ b/omnigibson/reward_functions/__init__.py @@ -4,3 +4,13 @@ from omnigibson.reward_functions.potential_reward import PotentialReward from omnigibson.reward_functions.reaching_goal_reward import ReachingGoalReward from omnigibson.reward_functions.reward_function_base import REGISTERED_REWARD_FUNCTIONS, BaseRewardFunction + +__all__ = [ + "BaseRewardFunction", + "CollisionReward", + "GraspReward", + "PointGoalReward", + "PotentialReward", + "ReachingGoalReward", + "REGISTERED_REWARD_FUNCTIONS", +] diff --git a/omnigibson/robots/__init__.py b/omnigibson/robots/__init__.py index e53c76662..0625a95fa 100644 --- a/omnigibson/robots/__init__.py +++ b/omnigibson/robots/__init__.py @@ -16,3 +16,25 @@ from omnigibson.robots.turtlebot import Turtlebot from omnigibson.robots.two_wheel_robot import TwoWheelRobot from omnigibson.robots.vx300s import VX300S + +__all__ = [ + "A1", + "ActiveCameraRobot", + "BaseRobot", + "BehaviorRobot", + "Fetch", + "FrankaMounted", + "FrankaPanda", + "Freight", + "Husky", + "Locobot", + "LocomotionRobot", + "ManipulationRobot", + "R1", + "REGISTERED_ROBOTS", + "Stretch", + "Tiago", + "Turtlebot", + "TwoWheelRobot", + "VX300S", +] diff --git a/omnigibson/robots/a1.py b/omnigibson/robots/a1.py index 17b9549fe..b4cb60f14 100644 --- a/omnigibson/robots/a1.py +++ b/omnigibson/robots/a1.py @@ -98,15 +98,15 @@ def __init__( ) self._teleop_rotation_offset = th.tensor([0, 0, 0.707, 0.707]) self._ag_start_points = [ - GraspingPoint(link_name=f"base_link", position=th.tensor([-0.025, -0.07, 0.012])), - GraspingPoint(link_name=f"base_link", position=th.tensor([-0.015, -0.11, 0.012])), - GraspingPoint(link_name=f"link14", position=th.tensor([-0.01, 0.015, 0.004])), + GraspingPoint(link_name="base_link", position=th.tensor([-0.025, -0.07, 0.012])), + GraspingPoint(link_name="base_link", position=th.tensor([-0.015, -0.11, 0.012])), + GraspingPoint(link_name="link14", position=th.tensor([-0.01, 0.015, 0.004])), ] self._ag_end_points = [ - GraspingPoint(link_name=f"link22", position=th.tensor([0.006, 0.04, 0.003])), - GraspingPoint(link_name=f"link32", position=th.tensor([0.006, 0.045, 0.003])), - GraspingPoint(link_name=f"link42", position=th.tensor([0.006, 0.04, 0.003])), - GraspingPoint(link_name=f"link52", position=th.tensor([0.006, 0.04, 0.003])), + GraspingPoint(link_name="link22", position=th.tensor([0.006, 0.04, 0.003])), + GraspingPoint(link_name="link32", position=th.tensor([0.006, 0.045, 0.003])), + GraspingPoint(link_name="link42", position=th.tensor([0.006, 0.04, 0.003])), + GraspingPoint(link_name="link52", position=th.tensor([0.006, 0.04, 0.003])), ] else: raise ValueError(f"End effector {end_effector} not supported for A1") diff --git a/omnigibson/robots/active_camera_robot.py b/omnigibson/robots/active_camera_robot.py index 10153bdc8..ef2a21948 100644 --- a/omnigibson/robots/active_camera_robot.py +++ b/omnigibson/robots/active_camera_robot.py @@ -5,7 +5,6 @@ from omnigibson.robots.robot_base import BaseRobot from omnigibson.utils.python_utils import classproperty -from omnigibson.utils.usd_utils import ControllableObjectViewAPI class ActiveCameraRobot(BaseRobot): diff --git a/omnigibson/robots/articulated_trunk_robot.py b/omnigibson/robots/articulated_trunk_robot.py index 7491c05bd..2ebbfb4f9 100644 --- a/omnigibson/robots/articulated_trunk_robot.py +++ b/omnigibson/robots/articulated_trunk_robot.py @@ -4,7 +4,6 @@ from omnigibson.robots.manipulation_robot import ManipulationRobot from omnigibson.utils.python_utils import classproperty -from omnigibson.utils.usd_utils import ControllableObjectViewAPI class ArticulatedTrunkRobot(ManipulationRobot): diff --git a/omnigibson/robots/behavior_robot.py b/omnigibson/robots/behavior_robot.py index b1eebd3de..442358653 100644 --- a/omnigibson/robots/behavior_robot.py +++ b/omnigibson/robots/behavior_robot.py @@ -8,7 +8,6 @@ import torch as th -import omnigibson as og import omnigibson.lazy as lazy import omnigibson.utils.transform_utils as T from omnigibson.macros import create_module_macros, gm @@ -469,8 +468,9 @@ def teleop_data_to_action(self, teleop_action) -> th.Tensor: # Process local transform adjustments hand_data = 0 if teleop_action.is_valid[part_name]: - des_world_part_pos, des_world_part_orn = teleop_action[part_name][:3], T.euler2quat( - teleop_action[part_name][3:6] + des_world_part_pos, des_world_part_orn = ( + teleop_action[part_name][:3], + T.euler2quat(teleop_action[part_name][3:6]), ) if part_name in self.arm_names: # compute gripper action diff --git a/omnigibson/robots/fetch.py b/omnigibson/robots/fetch.py index 47df3eea3..325cf2f10 100644 --- a/omnigibson/robots/fetch.py +++ b/omnigibson/robots/fetch.py @@ -1,20 +1,15 @@ import math -import os from functools import cached_property import torch as th -from omnigibson.controllers import ControlType -from omnigibson.macros import gm from omnigibson.robots.active_camera_robot import ActiveCameraRobot from omnigibson.robots.articulated_trunk_robot import ArticulatedTrunkRobot from omnigibson.robots.manipulation_robot import GraspingPoint from omnigibson.robots.two_wheel_robot import TwoWheelRobot from omnigibson.robots.untucked_arm_pose_robot import UntuckedArmPoseRobot -from omnigibson.utils.python_utils import assert_valid_key from omnigibson.utils.transform_utils import euler2quat from omnigibson.utils.ui_utils import create_module_logger -from omnigibson.utils.usd_utils import ControllableObjectViewAPI, JointType log = create_module_logger(module_name=__name__) diff --git a/omnigibson/robots/franka.py b/omnigibson/robots/franka.py index 30619c71e..ccb64e358 100644 --- a/omnigibson/robots/franka.py +++ b/omnigibson/robots/franka.py @@ -5,7 +5,6 @@ from omnigibson.macros import gm from omnigibson.robots.manipulation_robot import GraspingPoint, ManipulationRobot -from omnigibson.utils.transform_utils import euler2quat class FrankaPanda(ManipulationRobot): @@ -114,14 +113,14 @@ def __init__( ) self._teleop_rotation_offset = th.tensor([0, 0.7071, 0, 0.7071]) self._ag_start_points = [ - GraspingPoint(link_name=f"base_link", position=th.tensor([0.015, 0, -0.03])), - GraspingPoint(link_name=f"base_link", position=th.tensor([0.015, 0, -0.08])), - GraspingPoint(link_name=f"link_15_0_tip", position=th.tensor([0, 0.015, 0.007])), + GraspingPoint(link_name="base_link", position=th.tensor([0.015, 0, -0.03])), + GraspingPoint(link_name="base_link", position=th.tensor([0.015, 0, -0.08])), + GraspingPoint(link_name="link_15_0_tip", position=th.tensor([0, 0.015, 0.007])), ] self._ag_end_points = [ - GraspingPoint(link_name=f"link_3_0_tip", position=th.tensor([0.012, 0, 0.007])), - GraspingPoint(link_name=f"link_7_0_tip", position=th.tensor([0.012, 0, 0.007])), - GraspingPoint(link_name=f"link_11_0_tip", position=th.tensor([0.012, 0, 0.007])), + GraspingPoint(link_name="link_3_0_tip", position=th.tensor([0.012, 0, 0.007])), + GraspingPoint(link_name="link_7_0_tip", position=th.tensor([0.012, 0, 0.007])), + GraspingPoint(link_name="link_11_0_tip", position=th.tensor([0.012, 0, 0.007])), ] elif "leap" in end_effector: self._model_name = f"franka_{end_effector}" @@ -139,14 +138,14 @@ def __init__( ) self._teleop_rotation_offset = th.tensor([-0.7071, 0.7071, 0, 0]) self._ag_start_points = [ - GraspingPoint(link_name=f"palm_center", position=th.tensor([0, -0.025, 0.035])), - GraspingPoint(link_name=f"palm_center", position=th.tensor([0, 0.03, 0.035])), - GraspingPoint(link_name=f"fingertip_4", position=th.tensor([-0.0115, -0.07, -0.015])), + GraspingPoint(link_name="palm_center", position=th.tensor([0, -0.025, 0.035])), + GraspingPoint(link_name="palm_center", position=th.tensor([0, 0.03, 0.035])), + GraspingPoint(link_name="fingertip_4", position=th.tensor([-0.0115, -0.07, -0.015])), ] self._ag_end_points = [ - GraspingPoint(link_name=f"fingertip_1", position=th.tensor([-0.0115, -0.06, 0.015])), - GraspingPoint(link_name=f"fingertip_2", position=th.tensor([-0.0115, -0.06, 0.015])), - GraspingPoint(link_name=f"fingertip_3", position=th.tensor([-0.0115, -0.06, 0.015])), + GraspingPoint(link_name="fingertip_1", position=th.tensor([-0.0115, -0.06, 0.015])), + GraspingPoint(link_name="fingertip_2", position=th.tensor([-0.0115, -0.06, 0.015])), + GraspingPoint(link_name="fingertip_3", position=th.tensor([-0.0115, -0.06, 0.015])), ] elif end_effector == "inspire": self._model_name = f"franka_{end_effector}" @@ -162,15 +161,15 @@ def __init__( self._teleop_rotation_offset = th.tensor([0, 0, 0.707, 0.707]) # TODO: add ag support for inspire hand self._ag_start_points = [ - GraspingPoint(link_name=f"base_link", position=th.tensor([-0.025, -0.07, 0.012])), - GraspingPoint(link_name=f"base_link", position=th.tensor([-0.015, -0.11, 0.012])), - GraspingPoint(link_name=f"link14", position=th.tensor([-0.01, 0.015, 0.004])), + GraspingPoint(link_name="base_link", position=th.tensor([-0.025, -0.07, 0.012])), + GraspingPoint(link_name="base_link", position=th.tensor([-0.015, -0.11, 0.012])), + GraspingPoint(link_name="link14", position=th.tensor([-0.01, 0.015, 0.004])), ] self._ag_end_points = [ - GraspingPoint(link_name=f"link22", position=th.tensor([0.006, 0.04, 0.003])), - GraspingPoint(link_name=f"link32", position=th.tensor([0.006, 0.045, 0.003])), - GraspingPoint(link_name=f"link42", position=th.tensor([0.006, 0.04, 0.003])), - GraspingPoint(link_name=f"link52", position=th.tensor([0.006, 0.04, 0.003])), + GraspingPoint(link_name="link22", position=th.tensor([0.006, 0.04, 0.003])), + GraspingPoint(link_name="link32", position=th.tensor([0.006, 0.045, 0.003])), + GraspingPoint(link_name="link42", position=th.tensor([0.006, 0.04, 0.003])), + GraspingPoint(link_name="link52", position=th.tensor([0.006, 0.04, 0.003])), ] else: raise ValueError(f"End effector {end_effector} not supported for FrankaPanda") diff --git a/omnigibson/robots/franka_mounted.py b/omnigibson/robots/franka_mounted.py index c26d0a49a..bf531aa1f 100644 --- a/omnigibson/robots/franka_mounted.py +++ b/omnigibson/robots/franka_mounted.py @@ -1,5 +1,7 @@ import os +import torch as th + from omnigibson.macros import gm from omnigibson.robots.franka import FrankaPanda from omnigibson.robots.manipulation_robot import GraspingPoint diff --git a/omnigibson/robots/freight.py b/omnigibson/robots/freight.py index 9f579bb1e..f6126d07c 100644 --- a/omnigibson/robots/freight.py +++ b/omnigibson/robots/freight.py @@ -1,9 +1,7 @@ -import os from functools import cached_property import torch as th -from omnigibson.macros import gm from omnigibson.robots.two_wheel_robot import TwoWheelRobot from omnigibson.utils.ui_utils import create_module_logger diff --git a/omnigibson/robots/holonomic_base_robot.py b/omnigibson/robots/holonomic_base_robot.py index 89abac3ee..9babbb1c4 100644 --- a/omnigibson/robots/holonomic_base_robot.py +++ b/omnigibson/robots/holonomic_base_robot.py @@ -1,4 +1,3 @@ -from abc import abstractmethod from functools import cached_property from typing import Literal diff --git a/omnigibson/robots/husky.py b/omnigibson/robots/husky.py index a893f9d87..9f0dfc0a5 100644 --- a/omnigibson/robots/husky.py +++ b/omnigibson/robots/husky.py @@ -1,9 +1,7 @@ -import os from functools import cached_property import torch as th -from omnigibson.macros import gm from omnigibson.robots.locomotion_robot import LocomotionRobot diff --git a/omnigibson/robots/locobot.py b/omnigibson/robots/locobot.py index 846fffaae..7006af231 100644 --- a/omnigibson/robots/locobot.py +++ b/omnigibson/robots/locobot.py @@ -1,9 +1,7 @@ -import os from functools import cached_property import torch as th -from omnigibson.macros import gm from omnigibson.robots.two_wheel_robot import TwoWheelRobot diff --git a/omnigibson/robots/locomotion_robot.py b/omnigibson/robots/locomotion_robot.py index 5f5d06926..136189bac 100644 --- a/omnigibson/robots/locomotion_robot.py +++ b/omnigibson/robots/locomotion_robot.py @@ -7,7 +7,6 @@ from omnigibson.robots.robot_base import BaseRobot from omnigibson.utils.python_utils import classproperty from omnigibson.utils.transform_utils import euler2quat, quat2mat, quat_multiply -from omnigibson.utils.usd_utils import ControllableObjectViewAPI class LocomotionRobot(BaseRobot): diff --git a/omnigibson/robots/manipulation_robot.py b/omnigibson/robots/manipulation_robot.py index 752447992..00f572fc1 100644 --- a/omnigibson/robots/manipulation_robot.py +++ b/omnigibson/robots/manipulation_robot.py @@ -28,7 +28,7 @@ from omnigibson.utils.geometry_utils import generate_points_in_volume_checker_function from omnigibson.utils.python_utils import assert_valid_key, classproperty from omnigibson.utils.sampling_utils import raytest_batch -from omnigibson.utils.usd_utils import ControllableObjectViewAPI, GripperRigidContactAPI, RigidContactAPI, create_joint +from omnigibson.utils.usd_utils import ControllableObjectViewAPI, GripperRigidContactAPI, create_joint # Create settings for this module m = create_module_macros(module_path=__file__) @@ -1246,9 +1246,9 @@ def _establish_grasp_rigid(self, arm="default", ag_data=None, contact_pos=None): break assert contact_pos is not None, ( - f"contact_pos in self._find_gripper_contacts(return_contact_positions=True) is not found in " - f"self._find_gripper_contacts(return_contact_positions=False). This is likely because " - f"GripperRigidContactAPI.get_contact_pairs and get_contact_data return inconsistent results." + "contact_pos in self._find_gripper_contacts(return_contact_positions=True) is not found in " + "self._find_gripper_contacts(return_contact_positions=False). This is likely because " + "GripperRigidContactAPI.get_contact_pairs and get_contact_data return inconsistent results." ) # Joint frame set at the contact point diff --git a/omnigibson/robots/mobile_manipulation_robot.py b/omnigibson/robots/mobile_manipulation_robot.py index 957abf26d..09ae8d7a2 100644 --- a/omnigibson/robots/mobile_manipulation_robot.py +++ b/omnigibson/robots/mobile_manipulation_robot.py @@ -1,7 +1,3 @@ -from abc import abstractmethod - -import torch as th - from omnigibson.robots.manipulation_robot import ManipulationRobot from omnigibson.utils.python_utils import assert_valid_key, classproperty diff --git a/omnigibson/robots/r1.py b/omnigibson/robots/r1.py index 3321192c4..f5a4232f0 100644 --- a/omnigibson/robots/r1.py +++ b/omnigibson/robots/r1.py @@ -1,19 +1,12 @@ -import os from functools import cached_property import torch as th -import omnigibson as og -import omnigibson.lazy as lazy -import omnigibson.utils.transform_utils as T -from omnigibson.action_primitives.curobo import CuRoboEmbodimentSelection -from omnigibson.macros import create_module_macros, gm from omnigibson.robots.articulated_trunk_robot import ArticulatedTrunkRobot from omnigibson.robots.holonomic_base_robot import HolonomicBaseRobot from omnigibson.robots.manipulation_robot import GraspingPoint from omnigibson.robots.mobile_manipulation_robot import MobileManipulationRobot -from omnigibson.utils.python_utils import assert_valid_key, classproperty -from omnigibson.utils.usd_utils import ControllableObjectViewAPI +from omnigibson.utils.python_utils import classproperty class R1(HolonomicBaseRobot, ArticulatedTrunkRobot, MobileManipulationRobot): diff --git a/omnigibson/robots/robot_base.py b/omnigibson/robots/robot_base.py index 969a8d0b1..1a925b8f5 100644 --- a/omnigibson/robots/robot_base.py +++ b/omnigibson/robots/robot_base.py @@ -112,7 +112,9 @@ def __init__( self._obs_modalities = ( obs_modalities if obs_modalities == "all" - else {obs_modalities} if isinstance(obs_modalities, str) else set(obs_modalities) + else {obs_modalities} + if isinstance(obs_modalities, str) + else set(obs_modalities) ) # this will get updated later when we fill in our sensors self._proprio_obs = self.default_proprio_obs if proprio_obs == "default" else list(proprio_obs) self._sensor_config = sensor_config diff --git a/omnigibson/robots/stretch.py b/omnigibson/robots/stretch.py index 87ae373e3..8ba67b4ad 100644 --- a/omnigibson/robots/stretch.py +++ b/omnigibson/robots/stretch.py @@ -1,10 +1,8 @@ import math -import os from functools import cached_property import torch as th -from omnigibson.macros import gm from omnigibson.robots.active_camera_robot import ActiveCameraRobot from omnigibson.robots.manipulation_robot import GraspingPoint, ManipulationRobot from omnigibson.robots.two_wheel_robot import TwoWheelRobot diff --git a/omnigibson/robots/tiago.py b/omnigibson/robots/tiago.py index 2cfa8876a..0d3892538 100644 --- a/omnigibson/robots/tiago.py +++ b/omnigibson/robots/tiago.py @@ -1,22 +1,13 @@ -import math -import os from functools import cached_property -from typing import Literal import torch as th -import omnigibson as og -import omnigibson.lazy as lazy -import omnigibson.utils.transform_utils as T -from omnigibson.action_primitives.curobo import CuRoboEmbodimentSelection -from omnigibson.macros import create_module_macros, gm from omnigibson.robots.active_camera_robot import ActiveCameraRobot from omnigibson.robots.articulated_trunk_robot import ArticulatedTrunkRobot from omnigibson.robots.holonomic_base_robot import HolonomicBaseRobot from omnigibson.robots.manipulation_robot import GraspingPoint from omnigibson.robots.untucked_arm_pose_robot import UntuckedArmPoseRobot -from omnigibson.utils.python_utils import assert_valid_key, classproperty -from omnigibson.utils.usd_utils import ControllableObjectViewAPI +from omnigibson.utils.python_utils import classproperty class Tiago(HolonomicBaseRobot, ArticulatedTrunkRobot, UntuckedArmPoseRobot, ActiveCameraRobot): diff --git a/omnigibson/robots/turtlebot.py b/omnigibson/robots/turtlebot.py index b184147eb..4e524ed5d 100644 --- a/omnigibson/robots/turtlebot.py +++ b/omnigibson/robots/turtlebot.py @@ -1,9 +1,7 @@ -import os from functools import cached_property import torch as th -from omnigibson.macros import gm from omnigibson.robots.two_wheel_robot import TwoWheelRobot diff --git a/omnigibson/robots/two_wheel_robot.py b/omnigibson/robots/two_wheel_robot.py index 3e5c64205..3ba55d2ae 100644 --- a/omnigibson/robots/two_wheel_robot.py +++ b/omnigibson/robots/two_wheel_robot.py @@ -120,9 +120,9 @@ def _default_controller_config(self): cfg = super()._default_controller_config # Add differential drive option to base - cfg["base"][ - self._default_base_differential_drive_controller_config["name"] - ] = self._default_base_differential_drive_controller_config + cfg["base"][self._default_base_differential_drive_controller_config["name"]] = ( + self._default_base_differential_drive_controller_config + ) return cfg diff --git a/omnigibson/robots/untucked_arm_pose_robot.py b/omnigibson/robots/untucked_arm_pose_robot.py index 8acbb3d7c..4000969ce 100644 --- a/omnigibson/robots/untucked_arm_pose_robot.py +++ b/omnigibson/robots/untucked_arm_pose_robot.py @@ -1,5 +1,3 @@ -from abc import abstractmethod - import torch as th from omnigibson.robots.mobile_manipulation_robot import MobileManipulationRobot diff --git a/omnigibson/robots/vx300s.py b/omnigibson/robots/vx300s.py index 624a4206c..ac55c2b74 100644 --- a/omnigibson/robots/vx300s.py +++ b/omnigibson/robots/vx300s.py @@ -1,10 +1,8 @@ import math -import os from functools import cached_property import torch as th -from omnigibson.macros import gm from omnigibson.robots.manipulation_robot import GraspingPoint, ManipulationRobot from omnigibson.utils.transform_utils import euler2quat diff --git a/omnigibson/scenes/__init__.py b/omnigibson/scenes/__init__.py index 9eade9bd2..ecf9a802f 100644 --- a/omnigibson/scenes/__init__.py +++ b/omnigibson/scenes/__init__.py @@ -2,3 +2,11 @@ from omnigibson.scenes.scene_base import REGISTERED_SCENES, Scene from omnigibson.scenes.static_traversable_scene import StaticTraversableScene from omnigibson.scenes.traversable_scene import TraversableScene + +__all__ = [ + "InteractiveTraversableScene", + "REGISTERED_SCENES", + "Scene", + "StaticTraversableScene", + "TraversableScene", +] diff --git a/omnigibson/scenes/interactive_traversable_scene.py b/omnigibson/scenes/interactive_traversable_scene.py index 78d44525f..4c22f3713 100644 --- a/omnigibson/scenes/interactive_traversable_scene.py +++ b/omnigibson/scenes/interactive_traversable_scene.py @@ -3,7 +3,6 @@ import omnigibson as og from omnigibson.maps.segmentation_map import SegmentationMap from omnigibson.robots.robot_base import REGISTERED_ROBOTS -from omnigibson.robots.robot_base import m as robot_macros from omnigibson.scenes.traversable_scene import TraversableScene from omnigibson.utils.asset_utils import get_og_scene_path from omnigibson.utils.constants import STRUCTURE_CATEGORIES diff --git a/omnigibson/scenes/scene_base.py b/omnigibson/scenes/scene_base.py index acb76ec18..4a5c9bef8 100644 --- a/omnigibson/scenes/scene_base.py +++ b/omnigibson/scenes/scene_base.py @@ -4,18 +4,14 @@ import shutil import tempfile from abc import ABC -from itertools import combinations import torch as th import omnigibson as og import omnigibson.lazy as lazy import omnigibson.utils.transform_utils as T -from omnigibson.macros import create_module_macros, gm -from omnigibson.objects.dataset_object import DatasetObject -from omnigibson.objects.light_object import LightObject +from omnigibson.macros import gm from omnigibson.objects.object_base import BaseObject -from omnigibson.prims.material_prim import MaterialPrim from omnigibson.prims.xform_prim import XFormPrim from omnigibson.robots.robot_base import m as robot_macros from omnigibson.systems import Cloth @@ -143,7 +139,7 @@ def object_registry(self): Returns: SerializableRegistry: Object registry containing all active standalone objects in the scene """ - return self._registry(key="name", value=f"object_registry") + return self._registry(key="name", value="object_registry") @property def system_registry(self): @@ -547,7 +543,7 @@ def _create_registry(self): # Add registry for objects registry.add( obj=SerializableRegistry( - name=f"object_registry", + name="object_registry", class_types=BaseObject, default_key="name", hash_key="uuid", @@ -628,7 +624,7 @@ def add_object(self, obj, register=True, _batched_call=False): ), f"Object with name {obj.name} already exists in scene!" # Load the object. - prim = obj.load(self) + obj.load(self) if register: # If this object is fixed and is NOT an agent, disable collisions between the fixed links of the fixed objects diff --git a/omnigibson/scenes/static_traversable_scene.py b/omnigibson/scenes/static_traversable_scene.py index 79416ca97..c8753b6d7 100644 --- a/omnigibson/scenes/static_traversable_scene.py +++ b/omnigibson/scenes/static_traversable_scene.py @@ -74,7 +74,7 @@ def _load(self): scene_mesh_relative_path = "/scene" scene_mesh_absolute_path = scene_relative_prim_path_to_absolute(self, scene_mesh_relative_path) - scene_mesh_prim = add_asset_to_stage( + add_asset_to_stage( asset_path=filename, prim_path=scene_mesh_absolute_path, ) diff --git a/omnigibson/sensors/__init__.py b/omnigibson/sensors/__init__.py index 7d58cac0f..c71c55d2a 100644 --- a/omnigibson/sensors/__init__.py +++ b/omnigibson/sensors/__init__.py @@ -74,3 +74,16 @@ def create_sensor( ) return sensor + + +__all__ = [ + "ALL_SENSOR_MODALITIES", + "BaseSensor", + "BaseSensorNoise", + "create_sensor", + "DropoutSensorNoise", + "REGISTERED_SENSOR_NOISES", + "REGISTERED_SENSORS", + "ScanSensor", + "VisionSensor", +] diff --git a/omnigibson/sensors/scan_sensor.py b/omnigibson/sensors/scan_sensor.py index 196619675..f786ef711 100644 --- a/omnigibson/sensors/scan_sensor.py +++ b/omnigibson/sensors/scan_sensor.py @@ -100,7 +100,7 @@ def __init__( # Sanity check modalities -- if we're using occupancy_grid without scan modality, raise an error if isinstance(modalities, Iterable) and not isinstance(modalities, str) and "occupancy_grid" in modalities: - assert "scan" in modalities, f"'scan' modality must be included in order to get occupancy_grid modality!" + assert "scan" in modalities, "'scan' modality must be included in order to get occupancy_grid modality!" # Run super method super().__init__( diff --git a/omnigibson/sensors/vision_sensor.py b/omnigibson/sensors/vision_sensor.py index e4902b68b..f0b0ec11e 100644 --- a/omnigibson/sensors/vision_sensor.py +++ b/omnigibson/sensors/vision_sensor.py @@ -1,5 +1,4 @@ import math -import time import gymnasium as gym import torch as th @@ -312,13 +311,13 @@ def _preprocess_cpu_obs(self, obs, modality): # All segmentation modalities return uint32 numpy arrays on cpu, but PyTorch doesn't support it if "seg_" in modality: obs = obs.astype(NumpyTypes.INT32) - return th.from_numpy(obs) if not "bbox_" in modality else obs + return th.from_numpy(obs) if "bbox_" not in modality else obs def _preprocess_gpu_obs(self, obs, modality): # All segmentation modalities return uint32 warp arrays on gpu, but PyTorch doesn't support it if "seg_" in modality: obs = obs.view(lazy.warp.int32) - return lazy.warp.to_torch(obs) if not "bbox_" in modality else obs + return lazy.warp.to_torch(obs) if "bbox_" not in modality else obs def _remap_modality(self, modality, obs, info, raw_obs): id_to_labels = raw_obs["info"]["idToLabels"] diff --git a/omnigibson/simulator.py b/omnigibson/simulator.py index ebfc01508..88acb9b64 100644 --- a/omnigibson/simulator.py +++ b/omnigibson/simulator.py @@ -1,11 +1,8 @@ -import atexit import contextlib -import itertools import json import logging import math import os -import re import shutil import signal import socket @@ -96,7 +93,6 @@ def _launch_app(): # Omni's logging is super annoying and overly verbose, so suppress it by modifying the logging levels if not gm.DEBUG: - import sys import warnings try: @@ -118,7 +114,7 @@ def _launch_app(): os.environ["OMNI_KIT_ACCEPT_EULA"] = "YES" import isaacsim # noqa: F401 except ImportError: - isaacsim = None + pass # First obtain the Isaac Sim version isaac_path = os.environ["ISAAC_PATH"] @@ -235,7 +231,7 @@ def _launch_app(): # TODO: Automated cleanup in callback doesn't work for some reason. Need to investigate. shutdown_stream = lazy.omni.kit.app.get_app().get_shutdown_event_stream() - sub = shutdown_stream.create_subscription_to_pop(og.cleanup, name="og_cleanup", order=0) + shutdown_stream.create_subscription_to_pop(og.cleanup, name="og_cleanup", order=0) # Loading Isaac Sim disables Ctrl+C, so we need to re-enable it signal.signal(signal.SIGINT, og.shutdown_handler) @@ -451,7 +447,7 @@ def _set_physics_engine_settings(self): """ Set the physics engine with specified settings """ - assert self.is_stopped(), f"Cannot set simulator physics settings while simulation is playing!" + assert self.is_stopped(), "Cannot set simulator physics settings while simulation is playing!" self._physics_context.set_gravity(value=-self.gravity) # Also make sure we don't invert the collision group filter settings so that different collision groups by # default collide with each other, and modify settings for speed optimization diff --git a/omnigibson/systems/__init__.py b/omnigibson/systems/__init__.py index fcd7bf74d..fe8f42afc 100644 --- a/omnigibson/systems/__init__.py +++ b/omnigibson/systems/__init__.py @@ -1,2 +1,27 @@ -from omnigibson.systems.macro_particle_system import * -from omnigibson.systems.micro_particle_system import * +from omnigibson.systems.system_base import BaseSystem, PhysicalParticleSystem, VisualParticleSystem +from omnigibson.systems.macro_particle_system import ( + MacroParticleSystem, + MacroPhysicalParticleSystem, + MacroVisualParticleSystem, +) +from omnigibson.systems.micro_particle_system import ( + Cloth, + FluidSystem, + GranularSystem, + MicroParticleSystem, + MicroPhysicalParticleSystem, +) + +__all__ = [ + "BaseSystem", + "Cloth", + "FluidSystem", + "GranularSystem", + "MacroParticleSystem", + "MacroPhysicalParticleSystem", + "MacroVisualParticleSystem", + "MicroParticleSystem", + "MicroPhysicalParticleSystem", + "PhysicalParticleSystem", + "VisualParticleSystem", +] diff --git a/omnigibson/systems/micro_particle_system.py b/omnigibson/systems/micro_particle_system.py index a9322638a..cca211d6d 100644 --- a/omnigibson/systems/micro_particle_system.py +++ b/omnigibson/systems/micro_particle_system.py @@ -9,7 +9,6 @@ import omnigibson as og import omnigibson.lazy as lazy -import omnigibson.utils.transform_utils as T from omnigibson.macros import create_module_macros, gm from omnigibson.prims.geom_prim import VisualGeomPrim from omnigibson.prims.material_prim import MaterialPrim @@ -57,8 +56,8 @@ def set_carb_settings_for_fluid_isosurface(): min_frame_rate = 60 # Make sure we have at least 60 FPS before setting "persistent/simulation/minFrameRate" to 60 assert ( - 1 / og.sim.get_rendering_dt() - ) >= min_frame_rate, f"isosurface HQ rendering requires at least {min_frame_rate} FPS; consider increasing rendering_frequency of env_config to {min_frame_rate}." + (1 / og.sim.get_rendering_dt()) >= min_frame_rate + ), f"isosurface HQ rendering requires at least {min_frame_rate} FPS; consider increasing rendering_frequency of env_config to {min_frame_rate}." # Settings for Isosurface isregistry = lazy.carb.settings.acquire_settings_interface() @@ -582,8 +581,8 @@ def _get_particle_material_template(self): prim_path=self.mat_path, name=self.mat_name, load_config={ - "mdl_name": f"OmniPBR.mdl", - "mtl_name": f"OmniPBR", + "mdl_name": "OmniPBR.mdl", + "mtl_name": "OmniPBR", }, ) diff --git a/omnigibson/systems/system_base.py b/omnigibson/systems/system_base.py index 3e45e061a..bd867bbc3 100644 --- a/omnigibson/systems/system_base.py +++ b/omnigibson/systems/system_base.py @@ -10,7 +10,6 @@ from omnigibson.utils.asset_utils import get_all_system_categories from omnigibson.utils.geometry_utils import generate_points_in_volume_checker_function from omnigibson.utils.python_utils import Serializable, get_uuid -from omnigibson.utils.registry_utils import SerializableRegistry from omnigibson.utils.sampling_utils import sample_cuboid_on_object_full_grid_topdown from omnigibson.utils.ui_utils import create_module_logger from omnigibson.utils.usd_utils import scene_relative_prim_path_to_absolute diff --git a/omnigibson/tasks/__init__.py b/omnigibson/tasks/__init__.py index eaf8abc0d..591bb6b35 100644 --- a/omnigibson/tasks/__init__.py +++ b/omnigibson/tasks/__init__.py @@ -4,3 +4,12 @@ from omnigibson.tasks.point_navigation_task import PointNavigationTask from omnigibson.tasks.point_reaching_task import PointReachingTask from omnigibson.tasks.task_base import REGISTERED_TASKS + +__all__ = [ + "BehaviorTask", + "DummyTask", + "GraspTask", + "PointNavigationTask", + "PointReachingTask", + "REGISTERED_TASKS", +] diff --git a/omnigibson/tasks/behavior_task.py b/omnigibson/tasks/behavior_task.py index 1f8d2c65d..706cf2ef0 100644 --- a/omnigibson/tasks/behavior_task.py +++ b/omnigibson/tasks/behavior_task.py @@ -17,7 +17,6 @@ from omnigibson.macros import gm from omnigibson.object_states import Pose from omnigibson.reward_functions.potential_reward import PotentialReward -from omnigibson.robots.robot_base import BaseRobot from omnigibson.scenes.scene_base import Scene from omnigibson.scenes.traversable_scene import TraversableScene from omnigibson.tasks.task_base import BaseTask @@ -393,7 +392,6 @@ def _get_obs(self, env): for (obj, obj_exist), obj_rpy, obj_rpy_cos, obj_rpy_sin in zip( objs_exist.items(), objs_rpy, objs_rpy_cos, objs_rpy_sin ): - # TODO: May need to update checking here to USDObject? Or even baseobject? # TODO: How to handle systems as part of obs? if obj_exist: diff --git a/omnigibson/tasks/dummy_task.py b/omnigibson/tasks/dummy_task.py index 16a3fcd11..c74f2a997 100644 --- a/omnigibson/tasks/dummy_task.py +++ b/omnigibson/tasks/dummy_task.py @@ -1,7 +1,6 @@ from omnigibson.scenes.scene_base import Scene from omnigibson.tasks.task_base import BaseTask from omnigibson.utils.python_utils import classproperty -from omnigibson.utils.sim_utils import land_object class DummyTask(BaseTask): diff --git a/omnigibson/tasks/grasp_task.py b/omnigibson/tasks/grasp_task.py index 40198119c..5e71cefee 100644 --- a/omnigibson/tasks/grasp_task.py +++ b/omnigibson/tasks/grasp_task.py @@ -1,5 +1,4 @@ import json -import os import random import torch as th @@ -10,18 +9,14 @@ PlanningContext, StarterSemanticActionPrimitives, ) -from omnigibson.macros import gm from omnigibson.objects.object_base import REGISTERED_OBJECTS from omnigibson.reward_functions.grasp_reward import GraspReward from omnigibson.scenes.scene_base import Scene from omnigibson.tasks.task_base import BaseTask -from omnigibson.termination_conditions.falling import Falling -from omnigibson.termination_conditions.grasp_goal import GraspGoal from omnigibson.termination_conditions.timeout import Timeout from omnigibson.utils.grasping_planning_utils import get_grasp_poses_for_object_sticky from omnigibson.utils.motion_planning_utils import set_arm_and_detect_collision from omnigibson.utils.python_utils import classproperty, create_class_from_registry_and_config -from omnigibson.utils.sim_utils import land_object MAX_JOINT_RANDOMIZATION_ATTEMPTS = 50 diff --git a/omnigibson/termination_conditions/__init__.py b/omnigibson/termination_conditions/__init__.py index 5fb070d2a..0cd567f97 100644 --- a/omnigibson/termination_conditions/__init__.py +++ b/omnigibson/termination_conditions/__init__.py @@ -11,3 +11,17 @@ BaseTerminationCondition, ) from omnigibson.termination_conditions.timeout import Timeout + +__all__ = [ + "BaseTerminationCondition", + "Falling", + "GraspGoal", + "MaxCollision", + "PointGoal", + "PredicateGoal", + "ReachingGoal", + "REGISTERED_FAILURE_CONDITIONS", + "REGISTERED_SUCCESS_CONDITIONS", + "REGISTERED_TERMINATION_CONDITIONS", + "Timeout", +] diff --git a/omnigibson/termination_conditions/grasp_goal.py b/omnigibson/termination_conditions/grasp_goal.py index 3a5ae62f5..0eba3edef 100644 --- a/omnigibson/termination_conditions/grasp_goal.py +++ b/omnigibson/termination_conditions/grasp_goal.py @@ -1,4 +1,3 @@ -import omnigibson.utils.transform_utils as T from omnigibson.termination_conditions.termination_condition_base import SuccessCondition diff --git a/omnigibson/transition_rules.py b/omnigibson/transition_rules.py index ecdca6e87..1ff6fc12f 100644 --- a/omnigibson/transition_rules.py +++ b/omnigibson/transition_rules.py @@ -1,4 +1,3 @@ -import itertools import json import math import operator @@ -14,17 +13,29 @@ import omnigibson as og import omnigibson.utils.transform_utils as T -from omnigibson.macros import create_module_macros, gm -from omnigibson.object_states import * -from omnigibson.object_states.factory import get_system_states -from omnigibson.object_states.object_state_base import AbsoluteObjectState, RelativeObjectState +from omnigibson.macros import create_module_macros +from omnigibson.object_states import ( + ContactParticles, + ContainedParticles, + Contains, + Cooked, + Covered, + Filled, + Heated, + HeatSourceOrSink, + MaxTemperature, + OnTop, + Open, + Saturated, + SlicerActive, + ToggledOn, +) from omnigibson.objects.dataset_object import DatasetObject from omnigibson.utils.asset_utils import get_all_object_category_models from omnigibson.utils.bddl_utils import translate_bddl_recipe_to_og_recipe, translate_bddl_washer_rule_to_og_washer_rule -from omnigibson.utils.constants import PrimType -from omnigibson.utils.python_utils import Registerable, classproperty, subclass_factory, torch_delete +from omnigibson.utils.python_utils import Registerable, classproperty, torch_delete from omnigibson.utils.registry_utils import Registry -from omnigibson.utils.ui_utils import create_module_logger, disclaimer +from omnigibson.utils.ui_utils import create_module_logger from omnigibson.utils.usd_utils import RigidContactAPI # Create module logger @@ -179,7 +190,6 @@ def execute_transition(self, added_obj_attrs, removed_objs): # Then add new objects if len(added_obj_attrs) > 0: - state = og.sim.dump_state() for added_obj_attr in added_obj_attrs: new_obj = added_obj_attr.obj self.scene.add_object(new_obj) @@ -996,7 +1006,6 @@ def transition(self, object_candidates): objs_to_remove = [] for diceable_obj in object_candidates["diceable"]: - obj_category = diceable_obj.category # We expect all diced particle systems to follow the naming convention (cooked__)diced__ system_name = "diced__" + diceable_obj.category.removeprefix("half_") if Cooked in diceable_obj.states and diceable_obj.states[Cooked].get_value(): @@ -1517,8 +1526,6 @@ def _is_recipe_executable(self, recipe, container, global_info, container_info): Returns: bool: True if the recipe is active, else False """ - in_volume = container_info["in_volume"] - # Verify the container category is valid if not self._validate_recipe_container_is_valid(recipe=recipe, container=container): return False diff --git a/omnigibson/utils/asset_conversion_utils.py b/omnigibson/utils/asset_conversion_utils.py index ed49e3130..2936f2814 100644 --- a/omnigibson/utils/asset_conversion_utils.py +++ b/omnigibson/utils/asset_conversion_utils.py @@ -671,7 +671,7 @@ def _process_meta_link(stage, obj_model, meta_link_type, meta_link_infos): continue # TODO: Remove this after this is fixed. - if type(mesh_info_list) == dict: + if type(mesh_info_list) is dict: keys = [str(x) for x in range(len(mesh_info_list))] assert set(mesh_info_list.keys()) == set(keys), "Unexpected keys" mesh_info_list = [mesh_info_list[k] for k in keys] @@ -735,8 +735,9 @@ def _process_meta_link(stage, obj_model, meta_link_type, meta_link_infos): xform_prim = lazy.omni.isaac.core.prims.xform_prim.XFormPrim(prim_path=prim_path) # Get the mesh/light pose in the parent link frame - mesh_in_parent_link_pos, mesh_in_parent_link_orn = th.tensor(mesh_info["position"]), th.tensor( - mesh_info["orientation"] + mesh_in_parent_link_pos, mesh_in_parent_link_orn = ( + th.tensor(mesh_info["position"]), + th.tensor(mesh_info["orientation"]), ) # Get the mesh/light pose in the meta link frame @@ -1259,7 +1260,7 @@ def _create_urdf_joint( # Create the initial joint jnt = ET.Element("joint", name=name, type=joint_type) # Create origin subtag - origin = ET.SubElement( + ET.SubElement( jnt, "origin", attrib={"rpy": _convert_to_xml_string(rpy), "xyz": _convert_to_xml_string(pos)}, @@ -1274,16 +1275,16 @@ def _create_urdf_joint( child = ET.SubElement(jnt, "child", link=child) # Add additional parameters if specified if axis is not None: - ax = ET.SubElement(jnt, "axis", xyz=_convert_to_xml_string(axis)) + ET.SubElement(jnt, "axis", xyz=_convert_to_xml_string(axis)) dynamic_params = {} if damping is not None: dynamic_params["damping"] = _convert_to_xml_string(damping) if friction is not None: dynamic_params["friction"] = _convert_to_xml_string(friction) if dynamic_params: - dp = ET.SubElement(jnt, "dynamics", **dynamic_params) + ET.SubElement(jnt, "dynamics", **dynamic_params) if limits is not None: - lim = ET.SubElement(jnt, "limit", lower=limits[0], upper=limits[1]) + ET.SubElement(jnt, "limit", lower=limits[0], upper=limits[1]) # Return this element return jnt @@ -1465,7 +1466,7 @@ def _add_metalinks_to_urdf(urdf_path, obj_category, obj_model, dataset_root): ), f"Expected only one instance for meta_link {meta_link_name}_{ml_id}, but found {len(attrs_list)}" # TODO: Remove this after this is fixed. - if type(attrs_list) == dict: + if type(attrs_list) is dict: keys = [str(x) for x in range(len(attrs_list))] assert set(attrs_list.keys()) == set(keys), "Unexpected keys" attrs_list = [attrs_list[k] for k in keys] @@ -1938,7 +1939,7 @@ def get_collision_approximation_for_urdf( generated_new_col = False idx = 0 if link_name not in visual_only_links: - for vis in link.findall(f"visual"): + for vis in link.findall("visual"): # Get origin origin = vis.find("origin") # Check all geometries diff --git a/omnigibson/utils/asset_utils.py b/omnigibson/utils/asset_utils.py index 903aa4f06..37a1d4169 100644 --- a/omnigibson/utils/asset_utils.py +++ b/omnigibson/utils/asset_utils.py @@ -11,7 +11,6 @@ from urllib.request import urlretrieve import progressbar -import yaml from cryptography.fernet import Fernet import omnigibson as og diff --git a/omnigibson/utils/backend_utils.py b/omnigibson/utils/backend_utils.py index 43c4303a6..dfdf8a32d 100644 --- a/omnigibson/utils/backend_utils.py +++ b/omnigibson/utils/backend_utils.py @@ -21,7 +21,6 @@ def add_compute_function(name, np_function, th_function): class _ComputeBackend: - # Dictionary mapping custom externally-defined function name to function _custom_fcns = None diff --git a/omnigibson/utils/bddl_utils.py b/omnigibson/utils/bddl_utils.py index 7499bb100..829916ca7 100644 --- a/omnigibson/utils/bddl_utils.py +++ b/omnigibson/utils/bddl_utils.py @@ -1,4 +1,3 @@ -import json import os import random from collections import defaultdict @@ -15,11 +14,10 @@ import omnigibson as og from omnigibson import object_states -from omnigibson.macros import create_module_macros, gm +from omnigibson.macros import create_module_macros from omnigibson.object_states.factory import _KINEMATIC_STATE_SET, get_system_states from omnigibson.object_states.object_state_base import AbsoluteObjectState, RelativeObjectState from omnigibson.objects.dataset_object import DatasetObject -from omnigibson.robots import BaseRobot from omnigibson.utils.asset_utils import ( get_all_object_categories, get_all_object_category_models_with_abilities, @@ -96,7 +94,7 @@ BAD_CLOTH_MODELS = { "bandana": {"wbhliu"}, - "curtain": {"ohvomi"}, + "curtain": {"ohvomi", "shbakk"}, "cardigan": {"itrkhr"}, "sweatshirt": {"nowqqh"}, "jeans": {"nmvvil", "pvzxyp"}, @@ -115,7 +113,6 @@ "scarf": {"kclcrj"}, "sock": {"vpafgj"}, "tank_top": {"fzldgi"}, - "curtain": {"shbakk"}, } diff --git a/omnigibson/utils/constants.py b/omnigibson/utils/constants.py index 4cd7b8ab8..1bfcf539d 100644 --- a/omnigibson/utils/constants.py +++ b/omnigibson/utils/constants.py @@ -3,14 +3,11 @@ """ import hashlib -import os from enum import Enum, IntEnum from functools import cache import torch as th -import omnigibson as og -from omnigibson.macros import gm from omnigibson.utils.asset_utils import get_all_object_categories, get_all_system_categories MAX_INSTANCE_COUNT = th.iinfo(th.int32).max diff --git a/omnigibson/utils/deprecated_utils.py b/omnigibson/utils/deprecated_utils.py index 740407476..4878b4010 100644 --- a/omnigibson/utils/deprecated_utils.py +++ b/omnigibson/utils/deprecated_utils.py @@ -17,14 +17,14 @@ from omni.isaac.core.articulations import ArticulationView as _ArticulationView from omni.isaac.core.prims import RigidPrimView as _RigidPrimView from omni.isaac.core.prims import XFormPrimView as _XFormPrimView -from omni.isaac.core.utils.prims import get_prim_at_path, get_prim_parent +from omni.isaac.core.utils.prims import get_prim_at_path from omni.kit.primitive.mesh.command import CreateMeshPrimWithDefaultXformCommand as CMPWDXC from omni.kit.primitive.mesh.command import _get_all_evaluators from omni.particle.system.core.scripts.core import Core as OmniCore from omni.particle.system.core.scripts.utils import Utils as OmniUtils from omni.replicator.core import random_colours from PIL import Image, ImageDraw -from pxr import PhysxSchema, Sdf, Usd, UsdGeom, UsdPhysics, UsdShade +from pxr import PhysxSchema, Sdf, Usd, UsdGeom, UsdPhysics from scipy.spatial.transform import Rotation as R DEG2RAD = math.pi / 180.0 diff --git a/omnigibson/utils/grasping_planning_utils.py b/omnigibson/utils/grasping_planning_utils.py index 728303132..e36784f66 100644 --- a/omnigibson/utils/grasping_planning_utils.py +++ b/omnigibson/utils/grasping_planning_utils.py @@ -7,7 +7,7 @@ import omnigibson.utils.transform_utils as T from omnigibson.macros import create_module_macros from omnigibson.object_states.open_state import _get_relevant_joints -from omnigibson.utils.constants import JointAxis, JointType +from omnigibson.utils.constants import JointType m = create_module_macros(module_path=__file__) diff --git a/omnigibson/utils/motion_planning_utils.py b/omnigibson/utils/motion_planning_utils.py index 3184a71d2..cf1c47729 100644 --- a/omnigibson/utils/motion_planning_utils.py +++ b/omnigibson/utils/motion_planning_utils.py @@ -7,7 +7,6 @@ import omnigibson.lazy as lazy import omnigibson.utils.transform_utils as T from omnigibson.macros import create_module_macros -from omnigibson.object_states import ContactBodies from omnigibson.utils.control_utils import IKSolver from omnigibson.utils.sim_utils import prim_paths_to_rigid_prims from omnigibson.utils.ui_utils import create_module_logger @@ -55,7 +54,6 @@ def plan_base_motion( from ompl import geometric as ompl_geo class CustomMotionValidator(ob.MotionValidator): - def __init__(self, si, space): super(CustomMotionValidator, self).__init__(si) self.si = si diff --git a/omnigibson/utils/object_utils.py b/omnigibson/utils/object_utils.py index 296cd6252..85b5dee7b 100644 --- a/omnigibson/utils/object_utils.py +++ b/omnigibson/utils/object_utils.py @@ -119,7 +119,7 @@ def compute_obj_kinematic_metadata(obj): """ assert obj.scene is not None assert og.sim.floor_plane is not None - assert type(obj.scene) == Scene, "An empty scene must be used in order to compute kinematic metadata!" + assert type(obj.scene) is Scene, "An empty scene must be used in order to compute kinematic metadata!" assert th.all(obj.scale == 1.0), "Object must have scale [1, 1, 1] in order to compute kinematic metadata!" og.sim.stop() diff --git a/omnigibson/utils/physx_utils.py b/omnigibson/utils/physx_utils.py index ef2503cc2..48ce2157a 100644 --- a/omnigibson/utils/physx_utils.py +++ b/omnigibson/utils/physx_utils.py @@ -2,7 +2,7 @@ import omnigibson as og import omnigibson.lazy as lazy -from omnigibson.macros import create_module_macros, gm +from omnigibson.macros import create_module_macros from omnigibson.utils.ui_utils import suppress_omni_log # Create settings for this module diff --git a/omnigibson/utils/profiling_utils.py b/omnigibson/utils/profiling_utils.py index d3433cc80..956f6c9aa 100644 --- a/omnigibson/utils/profiling_utils.py +++ b/omnigibson/utils/profiling_utils.py @@ -9,7 +9,7 @@ # Method copied from: https://github.com/wandb/wandb/blob/main/wandb/sdk/internal/system/assets/gpu.py -def gpu_in_use_by_this_process(gpu_handle: "GPUHandle", pid: int) -> bool: +def gpu_in_use_by_this_process(gpu_handle, pid: int) -> bool: if psutil is None: return False @@ -26,7 +26,8 @@ def gpu_in_use_by_this_process(gpu_handle: "GPUHandle", pid: int) -> bool: compute_pids = {process.pid for process in pynvml.nvmlDeviceGetComputeRunningProcesses(gpu_handle)} # type: ignore graphics_pids = { - process.pid for process in pynvml.nvmlDeviceGetGraphicsRunningProcesses(gpu_handle) # type: ignore + process.pid + for process in pynvml.nvmlDeviceGetGraphicsRunningProcesses(gpu_handle) # type: ignore } pids_using_device = compute_pids | graphics_pids diff --git a/omnigibson/utils/pynvml_utils.py b/omnigibson/utils/pynvml_utils.py index f211aae80..2aef49389 100644 --- a/omnigibson/utils/pynvml_utils.py +++ b/omnigibson/utils/pynvml_utils.py @@ -48,7 +48,6 @@ # Python bindings for the NVML library ## from ctypes import * -from ctypes.util import find_library from functools import wraps ## C Type mappings ## @@ -1831,14 +1830,14 @@ def _LoadNvmlLibrary(): for dll_path in search_paths: try: nvmlLib = CDLL(dll_path) - except OSError as ose: + except OSError: continue break else: # assume linux try: nvmlLib = CDLL("libnvidia-ml.so.1") - except OSError as ose: + except OSError: _nvmlCheckReturn(NVML_ERROR_LIBRARY_NOT_FOUND) if nvmlLib is None: _nvmlCheckReturn(NVML_ERROR_LIBRARY_NOT_FOUND) diff --git a/omnigibson/utils/python_utils.py b/omnigibson/utils/python_utils.py index 9f1e96bbe..a999bbfa2 100644 --- a/omnigibson/utils/python_utils.py +++ b/omnigibson/utils/python_utils.py @@ -3,11 +3,10 @@ """ import inspect -import re from abc import ABCMeta from collections.abc import Iterable from copy import deepcopy -from functools import cache, wraps +from functools import wraps from hashlib import md5 from importlib import import_module @@ -20,7 +19,6 @@ class classproperty: - def __init__(self, fget): self.fget = fget diff --git a/omnigibson/utils/registry_utils.py b/omnigibson/utils/registry_utils.py index ef0c88bf3..8a890b712 100644 --- a/omnigibson/utils/registry_utils.py +++ b/omnigibson/utils/registry_utils.py @@ -386,7 +386,7 @@ def add(self, obj): validate_class = issubclass if isclass(obj) else isinstance assert any( [validate_class(obj, class_type) for class_type in (Serializable, SerializableNonInstance)] - ), f"Added object must be either an instance or subclass of Serializable or SerializableNonInstance!" + ), "Added object must be either an instance or subclass of Serializable or SerializableNonInstance!" # Run super like normal super().add(obj=obj) diff --git a/omnigibson/utils/render_utils.py b/omnigibson/utils/render_utils.py index 5980dabdd..1dd6735d6 100644 --- a/omnigibson/utils/render_utils.py +++ b/omnigibson/utils/render_utils.py @@ -27,8 +27,8 @@ def make_glass(prim): visual_meshes = [prim] else: raise ValueError( - f"Inputted prim must an instance of EntityPrim, RigidPrim, or VisualGeomPrim " - f"in order to be converted into glass!" + "Inputted prim must an instance of EntityPrim, RigidPrim, or VisualGeomPrim " + "in order to be converted into glass!" ) # Grab the glass material prim; if it doesn't exist, we create it on the fly diff --git a/omnigibson/utils/sim_utils.py b/omnigibson/utils/sim_utils.py index 1ccb9c4bf..d717b7d48 100644 --- a/omnigibson/utils/sim_utils.py +++ b/omnigibson/utils/sim_utils.py @@ -163,7 +163,6 @@ def get_contacts(inp_prims): # Only run the following (expensive) code if we are actively using filtering criteria if should_check_collisions or should_filter_collisions: - # First filter out unnecessary collisions if should_filter_collisions: # First filter pass, remove the intersection of the main contacts and the contacts from the exclusion set minus diff --git a/omnigibson/utils/teleop_utils.py b/omnigibson/utils/teleop_utils.py index 9a48eec31..9cac80a91 100644 --- a/omnigibson/utils/teleop_utils.py +++ b/omnigibson/utils/teleop_utils.py @@ -88,8 +88,9 @@ def get_action(self, robot_obs: TeleopObservation) -> th.Tensor: # optionally update control marker if self.show_control_marker: for arm_name in self.control_markers: - delta_pos, delta_orn = self.teleop_action[arm_name][:3], T.euler2quat( - th.tensor(self.teleop_action[arm_name][3:6]) + delta_pos, delta_orn = ( + self.teleop_action[arm_name][:3], + T.euler2quat(th.tensor(self.teleop_action[arm_name][3:6])), ) rel_target_pos = robot_obs[arm_name][:3] + delta_pos rel_target_orn = T.quat_multiply(delta_orn, robot_obs[arm_name][3:7]) diff --git a/omnigibson/utils/transform_utils.py b/omnigibson/utils/transform_utils.py index a89a25491..6db9445bf 100644 --- a/omnigibson/utils/transform_utils.py +++ b/omnigibson/utils/transform_utils.py @@ -7,7 +7,7 @@ """ import math -from typing import List, Optional, Tuple +from typing import Optional, Tuple import torch @@ -575,7 +575,6 @@ def euler2quat(euler: torch.Tensor) -> torch.Tensor: @torch.compile def quat2euler(q): - single_dim = q.dim() == 1 if single_dim: diff --git a/omnigibson/utils/transform_utils_np.py b/omnigibson/utils/transform_utils_np.py index ddf2ac0c3..b76b2606c 100644 --- a/omnigibson/utils/transform_utils_np.py +++ b/omnigibson/utils/transform_utils_np.py @@ -82,12 +82,12 @@ def unit_vector(data, axis=None, out=None): >>> v0 = numpy.random.rand(5, 4, 3) >>> v1 = unit_vector(v0, axis=-1) - >>> v2 = v0 / numpy.expand_dims(numpy.sqrt(numpy.sum(v0*v0, axis=2)), 2) + >>> v2 = v0 / numpy.expand_dims(numpy.sqrt(numpy.sum(v0 * v0, axis=2)), 2) >>> numpy.allclose(v1, v2) True >>> v1 = unit_vector(v0, axis=1) - >>> v2 = v0 / numpy.expand_dims(numpy.sqrt(numpy.sum(v0*v0, axis=1)), 1) + >>> v2 = v0 / numpy.expand_dims(numpy.sqrt(numpy.sum(v0 * v0, axis=1)), 1) >>> numpy.allclose(v1, v2) True @@ -840,11 +840,11 @@ def rotation_matrix(angle, direction, point=None): Returns matrix to rotate about axis defined by point and direction. E.g.: - >>> angle = (random.random() - 0.5) * (2*math.pi) + >>> angle = (random.random() - 0.5) * (2 * math.pi) >>> direc = numpy.random.random(3) - 0.5 >>> point = numpy.random.random(3) - 0.5 >>> R0 = rotation_matrix(angle, direc, point) - >>> R1 = rotation_matrix(angle-2*math.pi, direc, point) + >>> R1 = rotation_matrix(angle - 2 * math.pi, direc, point) >>> is_same_transform(R0, R1) True @@ -854,11 +854,10 @@ def rotation_matrix(angle, direction, point=None): True >>> I = numpy.identity(4, numpy.float32) - >>> numpy.allclose(I, rotation_matrix(math.pi*2, direc)) + >>> numpy.allclose(I, rotation_matrix(math.pi * 2, direc)) True - >>> numpy.allclose(2., numpy.trace(rotation_matrix(math.pi/2, - ... direc, point))) + >>> numpy.allclose(2.0, numpy.trace(rotation_matrix(math.pi / 2, direc, point))) True Args: diff --git a/omnigibson/utils/ui_utils.py b/omnigibson/utils/ui_utils.py index 4be556d63..53ef44289 100644 --- a/omnigibson/utils/ui_utils.py +++ b/omnigibson/utils/ui_utils.py @@ -355,13 +355,13 @@ def print_info(self): print("*" * 40) print("CameraMover! Commands:") print() - print(f"\t Right Click + Drag: Rotate camera") - print(f"\t W / S : Move camera forward / backward") - print(f"\t A / D : Move camera left / right") - print(f"\t T / G : Move camera up / down") - print(f"\t 9 / 0 : Increase / decrease the lights") - print(f"\t P : Print current camera pose") - print(f"\t O: Save the current camera view as an image") + print("\t Right Click + Drag: Rotate camera") + print("\t W / S : Move camera forward / backward") + print("\t A / D : Move camera left / right") + print("\t T / G : Move camera up / down") + print("\t 9 / 0 : Increase / decrease the lights") + print("\t P : Print current camera pose") + print("\t O: Save the current camera view as an image") def print_cam_pose(self): """ @@ -550,7 +550,6 @@ def _sub_keyboard_event(self, event, *args, **kwargs): event.type == lazy.carb.input.KeyboardEventType.KEY_PRESS or event.type == lazy.carb.input.KeyboardEventType.KEY_REPEAT ): - if event.type == lazy.carb.input.KeyboardEventType.KEY_PRESS and event.input in self.input_to_function: self.input_to_function[event.input]() @@ -631,7 +630,7 @@ def register_keyboard_handler(self): appwindow = lazy.omni.appwindow.get_default_app_window() input_interface = lazy.carb.input.acquire_input_interface() keyboard = appwindow.get_keyboard() - sub_keyboard = input_interface.subscribe_to_keyboard_events(keyboard, self.keyboard_event_handler) + input_interface.subscribe_to_keyboard_events(keyboard, self.keyboard_event_handler) def register_custom_keymapping(self, key, description, callback_fn): """ @@ -763,7 +762,6 @@ def keyboard_event_handler(self, event, *args, **kwargs): event.type == lazy.carb.input.KeyboardEventType.KEY_PRESS or event.type == lazy.carb.input.KeyboardEventType.KEY_REPEAT ): - # Handle special cases if ( event.input in {lazy.carb.input.KeyboardInput.KEY_1, lazy.carb.input.KeyboardInput.KEY_2} @@ -883,7 +881,6 @@ def get_teleop_action(self): # Possibly set the persistent gripper action if len(self.binary_grippers) > 0 and self.keypress_mapping[lazy.carb.input.KeyboardInput.T]["val"] is not None: - for i, binary_gripper in enumerate(self.binary_grippers): # Possibly update the stored value if the toggle gripper key has been pressed and # it's the active gripper being controlled @@ -1011,9 +1008,7 @@ def draw_line(start, end, color=(1.0, 0.0, 0.0, 1.0), size=1.0): """ Draws a single line between two points. """ - from omni.isaac.debug_draw import _debug_draw - - draw = _debug_draw.acquire_debug_draw_interface() + draw = lazy.omni.isaac.debug_draw._debug_draw.acquire_debug_draw_interface() draw.draw_lines([start], [end], [color], [size]) @@ -1039,7 +1034,5 @@ def clear_debug_drawing(): """ Clears all debug drawings. """ - from omni.isaac.debug_draw import _debug_draw - - draw = _debug_draw.acquire_debug_draw_interface() + draw = lazy.omni.isaac.debug_draw._debug_draw.acquire_debug_draw_interface() draw.clear_lines() diff --git a/omnigibson/utils/urdfpy_utils.py b/omnigibson/utils/urdfpy_utils.py index f65199172..cc17b10c1 100644 --- a/omnigibson/utils/urdfpy_utils.py +++ b/omnigibson/utils/urdfpy_utils.py @@ -130,8 +130,9 @@ def _parse_simple_elements(cls, node, path): vs = node.findall(t._TAG) if len(vs) == 0 and r: raise ValueError( - "Missing required subelement(s) of type {} when " - "parsing an object of type {}".format(t.__name__, cls.__name__) + "Missing required subelement(s) of type {} when " "parsing an object of type {}".format( + t.__name__, cls.__name__ + ) ) v = [t._from_xml(n, path) for n in vs] kwargs[a] = v @@ -3323,20 +3324,20 @@ def animate(self, cfg_trajectory=None, loop_time=3.0, use_collision=False): You can run this without specifying a ``cfg_trajectory`` to view the full articulation of the URDF - >>> robot = URDF.load('ur5.urdf') + >>> robot = URDF.load("ur5.urdf") >>> robot.animate() .. image:: /_static/ur5.gif - >>> ct = {'shoulder_pan_joint': [0.0, 2 * np.pi]} + >>> ct = {"shoulder_pan_joint": [0.0, 2 * np.pi]} >>> robot.animate(cfg_trajectory=ct) .. image:: /_static/ur5_shoulder.gif >>> ct = { - ... 'shoulder_pan_joint' : [-np.pi / 4, np.pi / 4], - ... 'shoulder_lift_joint' : [0.0, -np.pi / 2.0], - ... 'elbow_joint' : [0.0, np.pi / 2.0] + ... "shoulder_pan_joint": [-np.pi / 4, np.pi / 4], + ... "shoulder_lift_joint": [0.0, -np.pi / 2.0], + ... "elbow_joint": [0.0, np.pi / 2.0], ... } >>> robot.animate(cfg_trajectory=ct) diff --git a/omnigibson/utils/usd_utils.py b/omnigibson/utils/usd_utils.py index 41c847fb7..ac7e568b8 100644 --- a/omnigibson/utils/usd_utils.py +++ b/omnigibson/utils/usd_utils.py @@ -13,6 +13,8 @@ import omnigibson as og import omnigibson.lazy as lazy import omnigibson.utils.transform_utils as T +import omnigibson.utils.transform_utils as TT +import omnigibson.utils.transform_utils_np as NT from omnigibson.macros import gm from omnigibson.utils.backend_utils import _compute_backend as cb from omnigibson.utils.backend_utils import add_compute_function @@ -128,7 +130,7 @@ def create_joint( # Make sure at least body0 or body1 is specified assert ( body0 is not None or body1 is not None - ), f"At least either body0 or body1 must be specified when creating a joint!" + ), "At least either body0 or body1 must be specified when creating a joint!" # Create the joint joint = getattr(lazy.pxr.UsdPhysics, joint_type).Define(og.sim.stage, prim_path) @@ -1723,7 +1725,7 @@ def add_asset_to_stage(asset_path, prim_path): """ # Make sure this is actually a supported asset type asset_type = asset_path.split(".")[-1] - assert asset_type in {"usd", "usda", "obj"}, f"Cannot load a non-USD or non-OBJ file as a USD prim!" + assert asset_type in {"usd", "usda", "obj"}, "Cannot load a non-USD or non-OBJ file as a USD prim!" # Make sure the path exists assert os.path.exists(asset_path), f"Cannot load {asset_type.upper()} file {asset_path} because it does not exist!" @@ -1876,9 +1878,6 @@ def delete_or_deactivate_prim(prim_path): return True -import omnigibson.utils.transform_utils as TT - - @th.compile def _compute_relative_poses_torch( idx: int, @@ -1906,9 +1905,6 @@ def _compute_relative_poses_torch( return rel_poses -import omnigibson.utils.transform_utils_np as NT - - @jit(nopython=True) def _compute_relative_poses_numpy(idx, n_links, all_tfs, base_pose): tfs = np.zeros((n_links, 4, 4), dtype=np.float32) diff --git a/omnigibson/utils/vision_utils.py b/omnigibson/utils/vision_utils.py index 303688fab..c3fe5bb9f 100644 --- a/omnigibson/utils/vision_utils.py +++ b/omnigibson/utils/vision_utils.py @@ -3,9 +3,6 @@ import torch as th from PIL import Image, ImageDraw -import omnigibson as og -from omnigibson.utils.constants import semantic_class_name_to_id - try: import accimage except ImportError: @@ -139,7 +136,7 @@ def remap(self, old_mapping, new_mapping, image, image_keys=None): for key in th.unique(image) if image_keys is None else image_keys: if key.item() not in old_mapping.keys(): new_key = next((k for k, v in new_mapping.items() if v == "unlabelled"), None) - assert new_key is not None, f"Could not find a new key for label 'unlabelled' in new_mapping!" + assert new_key is not None, "Could not find a new key for label 'unlabelled' in new_mapping!" self.key_array[key] = new_key # Apply remapping diff --git a/pyproject.toml b/pyproject.toml index 9333e2f86..709cc9b7c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,18 +1,3 @@ -[tool.black] -line-length = 120 -target-version = ['py310'] -force-exclude = 'omnigibson/(data|external)' - -[tool.isort] -profile = "black" -line_length = 120 -py_version = '310' -filter_files = true -extend_skip_glob = [ - 'omnigibson/data/*', - 'omnigibson/external/*' -] - [tool.pyright] exclude = [ 'omnigibson/data', @@ -25,5 +10,29 @@ testpaths = [ "tests", ] -[tool.coverage.run] -omit = ["omnigibson/external/*"] +[tool.ruff] +# Exclude a variety of commonly ignored directories. +extend-exclude = ["omnigibson/utils/pynvml_utils.py", "omnigibson/data"] + +# Same as Black. +line-length = 120 +indent-width = 4 + +# Assume Python 3.10 +target-version = "py310" + +[tool.ruff.lint] +# Enable Pyflakes (`F`) and a subset of the pycodestyle (`E`) codes by default. +# Unlike Flake8, Ruff doesn't enable pycodestyle warnings (`W`) or +# McCabe complexity (`C901`) by default. +select = ["E4", "E7", "E9", "F"] +ignore = [ + "E731", # lambda expressions assigned to variables. this keeps some files short. + "E722", # bare except. We don't want to dig deep to find what exception is being raised. + "E741", # ambiguous variable name for the character 'l', but we use it a lot for length. +] + +[tool.ruff.format] +# Enable auto-formatting of code examples in docstrings. Markdown, +# reStructuredText code/literal blocks and doctests are all supported. +docstring-code-format = true diff --git a/tests/create_tests_of_examples.py b/tests/create_tests_of_examples.py index 6ba35beb1..5f22f754f 100644 --- a/tests/create_tests_of_examples.py +++ b/tests/create_tests_of_examples.py @@ -1,4 +1,3 @@ -import importlib import json import os import pkgutil diff --git a/tests/test_controllers.py b/tests/test_controllers.py index a25c9d1ba..00bc960ed 100644 --- a/tests/test_controllers.py +++ b/tests/test_controllers.py @@ -1,5 +1,4 @@ import numpy as np -import pytest import torch as th import omnigibson as og diff --git a/tests/test_curobo.py b/tests/test_curobo.py index caf230df4..7ba94c89e 100644 --- a/tests/test_curobo.py +++ b/tests/test_curobo.py @@ -8,8 +8,7 @@ import omnigibson as og import omnigibson.utils.transform_utils as T from omnigibson.action_primitives.curobo import CuRoboMotionGenerator -from omnigibson.macros import gm, macros -from omnigibson.object_states import Touching +from omnigibson.macros import gm from omnigibson.robots.holonomic_base_robot import HolonomicBaseRobot from omnigibson.robots.locomotion_robot import LocomotionRobot diff --git a/tests/test_data_collection.py b/tests/test_data_collection.py index ebbe87bb5..30625b3b1 100644 --- a/tests/test_data_collection.py +++ b/tests/test_data_collection.py @@ -1,13 +1,11 @@ import tempfile -import pytest import torch as th import omnigibson as og from omnigibson.envs import DataCollectionWrapper, DataPlaybackWrapper from omnigibson.macros import gm from omnigibson.objects import DatasetObject -from omnigibson.utils.ui_utils import create_module_logger def test_data_collect_and_playback(): @@ -117,7 +115,7 @@ def test_data_collect_and_playback(): { "sensor_type": "VisionSensor", "name": "external_sensor0", - "relative_prim_path": f"/robot0/root_link/external_sensor0", + "relative_prim_path": "/robot0/root_link/external_sensor0", "modalities": ["rgb"], "sensor_kwargs": { "image_height": 16, diff --git a/tests/test_dump_load_states.py b/tests/test_dump_load_states.py index c31f6c7eb..702713579 100644 --- a/tests/test_dump_load_states.py +++ b/tests/test_dump_load_states.py @@ -1,9 +1,11 @@ -import pytest +import tempfile + +import torch as th from utils import SYSTEM_EXAMPLES, og_test import omnigibson as og from omnigibson.object_states import Covered -from omnigibson.systems import * +from omnigibson.systems import VisualParticleSystem @og_test diff --git a/tests/test_envs.py b/tests/test_envs.py index 33b56a1a8..05eb49a81 100644 --- a/tests/test_envs.py +++ b/tests/test_envs.py @@ -1,5 +1,3 @@ -import pytest - import omnigibson as og from omnigibson.macros import gm diff --git a/tests/test_multiple_envs.py b/tests/test_multiple_envs.py index 5ee8b6d1b..8bb6dc348 100644 --- a/tests/test_multiple_envs.py +++ b/tests/test_multiple_envs.py @@ -2,7 +2,6 @@ import torch as th import omnigibson as og -import omnigibson.lazy as lazy import omnigibson.utils.transform_utils as T from omnigibson import object_states from omnigibson.macros import gm diff --git a/tests/test_object_removal.py b/tests/test_object_removal.py index bce9c889f..35574f4ef 100644 --- a/tests/test_object_removal.py +++ b/tests/test_object_removal.py @@ -3,7 +3,6 @@ import omnigibson as og from omnigibson.objects import DatasetObject -from omnigibson.utils.python_utils import NAMES @og_test diff --git a/tests/test_object_states.py b/tests/test_object_states.py index 82cdd1816..6b9d8691a 100644 --- a/tests/test_object_states.py +++ b/tests/test_object_states.py @@ -7,7 +7,43 @@ import omnigibson as og import omnigibson.utils.transform_utils as T from omnigibson.macros import macros as m -from omnigibson.object_states import * +from omnigibson.object_states import ( + AABB, + AttachedTo, + Burnt, + ContactBodies, + ContactParticles, + Contains, + Cooked, + Covered, + Draped, + Filled, + Folded, + Frozen, + Heated, + HeatSourceOrSink, + HorizontalAdjacency, + Inside, + Joint, + MaxTemperature, + NextTo, + OnFire, + OnTop, + Open, + Overlaid, + ParticleApplier, + ParticleRemover, + ParticleSink, + ParticleSource, + Pose, + Saturated, + Temperature, + ToggledOn, + Touching, + Under, + Unfolded, + VerticalAdjacency, +) from omnigibson.systems import VisualParticleSystem from omnigibson.utils.constants import PrimType from omnigibson.utils.physx_utils import apply_force_at_pos diff --git a/tests/test_primitives.py b/tests/test_primitives.py index f77827c9d..75c799ad2 100644 --- a/tests/test_primitives.py +++ b/tests/test_primitives.py @@ -7,7 +7,6 @@ from pytest_rerunfailures import pytest import omnigibson as og -import omnigibson.utils.transform_utils as T from omnigibson.action_primitives.starter_semantic_action_primitives import ( StarterSemanticActionPrimitives, StarterSemanticActionPrimitiveSet, diff --git a/tests/test_robot_states_flatcache.py b/tests/test_robot_states_flatcache.py index 77ff4af8a..0242ad697 100644 --- a/tests/test_robot_states_flatcache.py +++ b/tests/test_robot_states_flatcache.py @@ -4,7 +4,7 @@ import omnigibson.lazy as lazy from omnigibson.action_primitives.starter_semantic_action_primitives import StarterSemanticActionPrimitives from omnigibson.macros import gm -from omnigibson.robots import * +from omnigibson.robots import REGISTERED_ROBOTS, Fetch, LocomotionRobot, ManipulationRobot, Stretch from omnigibson.sensors import VisionSensor from omnigibson.utils.transform_utils import mat2pose, pose2mat, quaternions_close, relative_pose_transform from omnigibson.utils.usd_utils import PoseAPI @@ -145,7 +145,6 @@ def test_robot_load_drive(): # Iterate over all robots and test their motion for robot_name, robot_cls in REGISTERED_ROBOTS.items(): - if robot_name in ["FrankaMounted", "Stretch"]: # TODO: skipping FrankaMounted and Stretch for now because CI doesn't have the required assets continue @@ -214,7 +213,6 @@ def test_robot_load_drive(): def test_grasping_mode(): - if og.sim is None: # Set global flags gm.ENABLE_FLATCACHE = True @@ -227,7 +225,7 @@ def test_grasping_mode(): objects_cfg.append( dict( type="DatasetObject", - name=f"table", + name="table", category="breakfast_table", model="lcsizg", bounding_box=[0.5, 0.5, 0.8], @@ -238,7 +236,7 @@ def test_grasping_mode(): objects_cfg.append( dict( type="PrimitiveObject", - name=f"box", + name="box", primitive_type="Cube", rgba=[1.0, 0, 0, 1.0], size=0.05, @@ -269,7 +267,7 @@ def object_is_in_hand(robot, obj): robot = Fetch( name="Fetch", obs_modalities=[], - controller_config={f"arm_0": {"name": "InverseKinematicsController", "mode": "pose_absolute_ori"}}, + controller_config={"arm_0": {"name": "InverseKinematicsController", "mode": "pose_absolute_ori"}}, grasping_mode=grasping_mode, ) env.scene.add_object(robot) diff --git a/tests/test_scene_graph.py b/tests/test_scene_graph.py index a6cf6d458..0a15b11fd 100644 --- a/tests/test_scene_graph.py +++ b/tests/test_scene_graph.py @@ -11,7 +11,6 @@ def test_scene_graph(): - if og.sim is None: # Set global flags gm.ENABLE_OBJECT_STATES = True @@ -73,8 +72,7 @@ def create_robot_config(name, position): } env = og.Environment(configs=config) - - scene = og.sim.scenes[0] + scene = env.scene breakfast_table = scene.object_registry("name", "breakfast_table") bowl = scene.object_registry("name", "bowl") diff --git a/tests/test_sensors.py b/tests/test_sensors.py index b7d0ff32d..3cb8efd70 100644 --- a/tests/test_sensors.py +++ b/tests/test_sensors.py @@ -1,11 +1,7 @@ -import math - import torch as th from utils import SYSTEM_EXAMPLES, og_test, place_obj_on_floor_plane import omnigibson as og -import omnigibson.utils.transform_utils as T -from omnigibson.sensors import VisionSensor from omnigibson.utils.constants import semantic_class_id_to_name @@ -13,7 +9,6 @@ def test_segmentation_modalities(env): breakfast_table = env.scene.object_registry("name", "breakfast_table") dishtowel = env.scene.object_registry("name", "dishtowel") - robot = env.scene.robots[0] place_obj_on_floor_plane(breakfast_table) dishtowel.set_position_orientation(position=[-0.4, 0.0, 0.55], orientation=[0, 0, 0, 1]) @@ -96,7 +91,6 @@ def test_segmentation_modalities(env): def test_bbox_modalities(env): breakfast_table = env.scene.object_registry("name", "breakfast_table") dishtowel = env.scene.object_registry("name", "dishtowel") - robot = env.scene.robots[0] place_obj_on_floor_plane(breakfast_table) dishtowel.set_position_orientation(position=[-0.4, 0.0, 0.55], orientation=[0, 0, 0, 1]) diff --git a/tests/test_symbolic_primitives.py b/tests/test_symbolic_primitives.py index 4793686b7..99064d428 100644 --- a/tests/test_symbolic_primitives.py +++ b/tests/test_symbolic_primitives.py @@ -1,6 +1,4 @@ import os -import random -import string import pytest import yaml @@ -12,9 +10,6 @@ SymbolicSemanticActionPrimitiveSet, ) from omnigibson.macros import gm -from omnigibson.objects import DatasetObject -from omnigibson.robots import REGISTERED_ROBOTS -from omnigibson.utils.python_utils import create_class_from_registry_and_config gm.USE_GPU_DYNAMICS = True gm.ENABLE_TRANSITION_RULES = True @@ -282,8 +277,8 @@ def test_wipe(self, env, prim_gen, robot, sponge, sink, countertop): @pytest.mark.skip("Disabled until env reset can add/remove objects") def test_cut(self, env, prim_gen, apple, knife, countertop): # Store the apple object information for scene reset - deleted_objs = [apple] - deleted_objs_cfg = [retrieve_obj_cfg(obj) for obj in deleted_objs] + # deleted_objs = [apple] + # deleted_objs_cfg = [retrieve_obj_cfg(obj) for obj in deleted_objs] # assert not apple.states[object_states.Cut].get_value(knife) # start a new environment to enable transition rules diff --git a/tests/test_systems.py b/tests/test_systems.py index 30dc4ed5e..3a831acd9 100644 --- a/tests/test_systems.py +++ b/tests/test_systems.py @@ -1,9 +1,8 @@ -import pytest from utils import SYSTEM_EXAMPLES, og_test import omnigibson as og from omnigibson.object_states import Covered -from omnigibson.systems import * +from omnigibson.systems import VisualParticleSystem @og_test diff --git a/tests/test_transform_utils.py b/tests/test_transform_utils.py index 318dfae81..14d7b681c 100644 --- a/tests/test_transform_utils.py +++ b/tests/test_transform_utils.py @@ -1,7 +1,6 @@ import math import numpy as np -import pytest import torch as th import trimesh from scipy.spatial.transform import Rotation as R @@ -9,7 +8,44 @@ from torch.testing import assert_close from omnigibson.utils.numpy_utils import NumpyTypes -from omnigibson.utils.transform_utils import * +from omnigibson.utils.transform_utils import ( + align_vector_sets, + anorm, + axisangle2quat, + cartesian_to_polar, + check_quat_right_angle, + convert_quat, + copysign, + dot, + euler2mat, + euler2quat, + integer_spiral_coordinates, + l2_distance, + mat2euler, + mat2pose, + matrix_inverse, + normalize, + pose2mat, + pose_inv, + quat2axisangle, + quat2euler, + quat2mat, + quat_apply, + quat_conjugate, + quat_distance, + quat_inverse, + quat_multiply, + quat_slerp, + quaternions_close, + random_axis_angle, + random_quaternion, + rotation_matrix, + transform_points, + transformation_matrix, + vecs2axisangle, + vecs2quat, + z_angle_from_quat, +) # Create constants for vectors RANDOM_VECTORS = [ diff --git a/tests/test_transition_rules.py b/tests/test_transition_rules.py index ddece38da..ddf76d6df 100644 --- a/tests/test_transition_rules.py +++ b/tests/test_transition_rules.py @@ -1,24 +1,27 @@ import math -import pytest import torch as th -from utils import ( - get_random_pose, - og_test, - place_obj_on_floor_plane, - place_objA_on_objB_bbox, - remove_all_systems, - retrieve_obj_cfg, -) +from utils import og_test, place_obj_on_floor_plane, remove_all_systems, retrieve_obj_cfg import omnigibson as og import omnigibson.utils.transform_utils as T from omnigibson.macros import macros as m -from omnigibson.object_states import * +from omnigibson.object_states import ( + Contains, + Cooked, + Covered, + Heated, + HeatSourceOrSink, + Inside, + OnTop, + Open, + Saturated, + Temperature, + ToggledOn, + Touching, +) from omnigibson.objects import DatasetObject from omnigibson.transition_rules import REGISTERED_RULES -from omnigibson.utils.constants import PrimType -from omnigibson.utils.physx_utils import apply_force_at_pos, apply_torque @og_test @@ -1047,7 +1050,10 @@ def test_cooking_object_rule_failure_wrong_heat_source(env): place_obj_on_floor_plane(stove) og.sim.step() - heat_source_position = stove.states[HeatSourceOrSink].link.get_position_orientation()[0] + # Check that the stove heat source link exists + stove.states[HeatSourceOrSink].link.get_position_orientation()[0] + + # Put the baking sheet on the stove baking_sheet.set_position_orientation(position=[-0.20, 0, 0.80], orientation=[0, 0, 0, 1]) og.sim.step() diff --git a/tests/utils.py b/tests/utils.py index 0d4aeb0a4..2088cc209 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -5,8 +5,7 @@ import omnigibson as og import omnigibson.utils.transform_utils as T from omnigibson.macros import gm -from omnigibson.object_states import * -from omnigibson.systems import * +from omnigibson.systems import FluidSystem, GranularSystem, MacroPhysicalParticleSystem, MacroVisualParticleSystem from omnigibson.utils.constants import ParticleModifyCondition, ParticleModifyMethod, PrimType TEMP_RELATED_ABILITIES = {"cookable": {}, "freezable": {}, "burnable": {}, "heatable": {}}