Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Apr 15, 2024
1 parent f738386 commit 3e19002
Show file tree
Hide file tree
Showing 188 changed files with 767 additions and 583 deletions.
13 changes: 7 additions & 6 deletions omnigibson/__init__.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import builtins
import logging
import os
import shutil
import signal
import tempfile
import builtins

from omnigibson.controllers import REGISTERED_CONTROLLERS
from omnigibson.envs import Environment

# TODO: Need to fix somehow -- omnigibson gets imported first BEFORE we can actually modify the macros
from omnigibson.macros import gm

from omnigibson.envs import Environment
from omnigibson.scenes import REGISTERED_SCENES
from omnigibson.objects import REGISTERED_OBJECTS
from omnigibson.robots import REGISTERED_ROBOTS
from omnigibson.controllers import REGISTERED_CONTROLLERS
from omnigibson.tasks import REGISTERED_TASKS
from omnigibson.scenes import REGISTERED_SCENES
from omnigibson.sensors import ALL_SENSOR_MODALITIES
from omnigibson.simulator import launch_simulator as launch
from omnigibson.tasks import REGISTERED_TASKS

# Create logger
logging.basicConfig(format='[%(levelname)s] [%(name)s] %(message)s')
Expand All @@ -27,6 +27,7 @@

# Always enable nest_asyncio because MaterialPrim calls asyncio.run()
import nest_asyncio

nest_asyncio.apply()

__version__ = "1.0.0"
Expand Down
2 changes: 1 addition & 1 deletion omnigibson/action_primitives/action_primitive_set_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
from typing import List

from future.utils import with_metaclass
from omnigibson import Environment

from omnigibson import Environment
from omnigibson.robots import BaseRobot
from omnigibson.scenes.interactive_traversable_scene import InteractiveTraversableScene
from omnigibson.tasks.task_base import BaseTask
Expand Down
39 changes: 18 additions & 21 deletions omnigibson/action_primitives/starter_semantic_action_primitives.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,50 +5,47 @@
See provided tiago_primitives.yaml config file for an example. See examples/action_primitives for
runnable examples.
"""
from functools import cached_property
import inspect
import logging
import random
from aenum import IntEnum, auto
from functools import cached_property
from math import ceil
import cv2
from matplotlib import pyplot as plt

import cv2
import gym
import numpy as np
from aenum import IntEnum, auto
from matplotlib import pyplot as plt
from scipy.spatial.transform import Rotation, Slerp

import omnigibson as og
import omnigibson.lazy as lazy
import omnigibson.utils.transform_utils as T
from omnigibson import object_states
from omnigibson.action_primitives.action_primitive_set_base import ActionPrimitiveError, ActionPrimitiveErrorGroup, BaseActionPrimitiveSet
from omnigibson.controllers import JointController, DifferentialDriveController
from omnigibson.action_primitives.action_primitive_set_base import (
ActionPrimitiveError,
ActionPrimitiveErrorGroup,
BaseActionPrimitiveSet,
)
from omnigibson.controllers import DifferentialDriveController, JointController
from omnigibson.controllers.controller_base import ControlType
from omnigibson.macros import create_module_macros
from omnigibson.utils.object_state_utils import sample_cuboid_for_predicate
from omnigibson.objects.object_base import BaseObject
from omnigibson.objects.usd_object import USDObject
from omnigibson.robots import BaseRobot, Fetch, Tiago
from omnigibson.tasks.behavior_task import BehaviorTask
from omnigibson.utils.control_utils import FKSolver, IKSolver
from omnigibson.utils.grasping_planning_utils import get_grasp_poses_for_object_sticky, get_grasp_position_for_open
from omnigibson.utils.motion_planning_utils import (
plan_base_motion,
detect_robot_collision_in_sim,
plan_arm_motion,
plan_arm_motion_ik,
plan_base_motion,
set_base_and_detect_collision,
detect_robot_collision_in_sim
)

import omnigibson.utils.transform_utils as T
from omnigibson.utils.control_utils import IKSolver
from omnigibson.utils.grasping_planning_utils import (
get_grasp_poses_for_object_sticky,
get_grasp_position_for_open
)
from omnigibson.controllers.controller_base import ControlType
from omnigibson.utils.control_utils import FKSolver

from omnigibson.utils.object_state_utils import sample_cuboid_for_predicate
from omnigibson.utils.ui_utils import create_module_logger

from omnigibson.objects.usd_object import USDObject

m = create_module_macros(module_path=__file__)

m.DEFAULT_BODY_OFFSET_FROM_FLOOR = 0.05
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,16 @@
objects directly into their post-condition states. Useful for learning high-level methods.
"""

from aenum import IntEnum, auto

import numpy as np
from omnigibson.robots.robot_base import BaseRobot
from omnigibson.systems.system_base import REGISTERED_SYSTEMS
from omnigibson.transition_rules import REGISTERED_RULES, TransitionRuleAPI
from aenum import IntEnum, auto

from omnigibson import object_states
from omnigibson.action_primitives.action_primitive_set_base import ActionPrimitiveError, ActionPrimitiveErrorGroup
from omnigibson.action_primitives.starter_semantic_action_primitives import StarterSemanticActionPrimitives
from omnigibson.objects import DatasetObject
from omnigibson.robots.robot_base import BaseRobot
from omnigibson.systems.system_base import REGISTERED_SYSTEMS
from omnigibson.transition_rules import REGISTERED_RULES, TransitionRuleAPI


class SymbolicSemanticActionPrimitiveSet(IntEnum):
Expand Down
6 changes: 3 additions & 3 deletions omnigibson/controllers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@
REGISTERED_CONTROLLERS,
REGISTERED_LOCOMOTION_CONTROLLERS,
REGISTERED_MANIPULATION_CONTROLLERS,
IsGraspingState,
ControlType,
GripperController,
IsGraspingState,
LocomotionController,
ManipulationController,
GripperController,
)
from omnigibson.controllers.dd_controller import DifferentialDriveController
from omnigibson.controllers.osc_controller import OperationalSpaceController
from omnigibson.controllers.ik_controller import InverseKinematicsController
from omnigibson.controllers.joint_controller import JointController
from omnigibson.controllers.multi_finger_gripper_controller import MultiFingerGripperController
from omnigibson.controllers.null_joint_controller import NullJointController
from omnigibson.controllers.osc_controller import OperationalSpaceController
from omnigibson.utils.python_utils import assert_valid_key


Expand Down
2 changes: 1 addition & 1 deletion omnigibson/controllers/controller_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import numpy as np

from omnigibson.utils.python_utils import classproperty, assert_valid_key, Serializable, Registerable, Recreatable
from omnigibson.utils.python_utils import Recreatable, Registerable, Serializable, assert_valid_key, classproperty

# Global dicts that will contain mappings
REGISTERED_CONTROLLERS = dict()
Expand Down
4 changes: 2 additions & 2 deletions omnigibson/controllers/ik_controller.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import numpy as np
from omnigibson.macros import gm, create_module_macros

import omnigibson.utils.transform_utils as T
from omnigibson.controllers import ControlType, ManipulationController
from omnigibson.controllers.joint_controller import JointController
from omnigibson.utils.processing_utils import MovingAverageFilter
from omnigibson.macros import create_module_macros, gm
from omnigibson.utils.control_utils import IKSolver
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

Expand Down
12 changes: 8 additions & 4 deletions omnigibson/controllers/joint_controller.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import numpy as np

from omnigibson.controllers import IsGraspingState, ControlType, LocomotionController, ManipulationController, \
GripperController
from omnigibson.utils.python_utils import assert_valid_key
import omnigibson.utils.transform_utils as T

from omnigibson.controllers import (
ControlType,
GripperController,
IsGraspingState,
LocomotionController,
ManipulationController,
)
from omnigibson.macros import create_module_macros
from omnigibson.utils.python_utils import assert_valid_key

# Create settings for this module
m = create_module_macros(module_path=__file__)
Expand Down
2 changes: 1 addition & 1 deletion omnigibson/controllers/multi_finger_gripper_controller.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import numpy as np

from omnigibson.controllers import ControlType, GripperController, IsGraspingState
from omnigibson.macros import create_module_macros
from omnigibson.controllers import IsGraspingState, ControlType, GripperController
from omnigibson.utils.python_utils import assert_valid_key

VALID_MODES = {
Expand Down
2 changes: 1 addition & 1 deletion omnigibson/controllers/osc_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from omnigibson.controllers import ControlType, ManipulationController
from omnigibson.utils.control_utils import orientation_error
from omnigibson.utils.processing_utils import MovingAverageFilter
from omnigibson.utils.python_utils import nums2array, assert_valid_key
from omnigibson.utils.python_utils import assert_valid_key, nums2array
from omnigibson.utils.ui_utils import create_module_logger

# Create module logger
Expand Down
2 changes: 1 addition & 1 deletion omnigibson/envs/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
from omnigibson.envs.env_base import Environment
from omnigibson.envs.env_wrapper import EnvironmentWrapper, create_wrapper, REGISTERED_ENV_WRAPPERS
from omnigibson.envs.env_wrapper import REGISTERED_ENV_WRAPPERS, EnvironmentWrapper, create_wrapper
24 changes: 16 additions & 8 deletions omnigibson/envs/env_base.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,30 @@
from copy import deepcopy

import gym
import numpy as np
from copy import deepcopy

import omnigibson as og
from omnigibson.macros import gm
from omnigibson.objects import REGISTERED_OBJECTS
from omnigibson.robots import REGISTERED_ROBOTS
from omnigibson.scene_graphs.graph_builder import SceneGraphBuilder
from omnigibson.simulator import launch_simulator
from omnigibson.tasks import REGISTERED_TASKS
from omnigibson.scenes import REGISTERED_SCENES
from omnigibson.sensors import create_sensor
from omnigibson.utils.gym_utils import GymObservable, recursively_generate_flat_dict, recursively_generate_compatible_dict
from omnigibson.simulator import launch_simulator
from omnigibson.tasks import REGISTERED_TASKS
from omnigibson.utils.config_utils import parse_config
from omnigibson.utils.gym_utils import (
GymObservable,
recursively_generate_compatible_dict,
recursively_generate_flat_dict,
)
from omnigibson.utils.python_utils import (
Recreatable,
assert_valid_key,
create_class_from_registry_and_config,
merge_nested_dicts,
)
from omnigibson.utils.ui_utils import create_module_logger
from omnigibson.utils.python_utils import assert_valid_key, merge_nested_dicts, create_class_from_registry_and_config,\
Recreatable
from omnigibson.macros import gm


# Create module logger
log = create_module_logger(module_name=__name__)
Expand Down
6 changes: 3 additions & 3 deletions omnigibson/envs/env_wrapper.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from omnigibson.utils.python_utils import Wrapper
from omnigibson.utils.python_utils import Registerable, classproperty, create_class_from_registry_and_config
from omnigibson.utils.ui_utils import create_module_logger
from copy import deepcopy

from omnigibson.utils.python_utils import Registerable, Wrapper, classproperty, create_class_from_registry_and_config
from omnigibson.utils.ui_utils import create_module_logger

# Global dicts that will contain mappings
REGISTERED_ENV_WRAPPERS = dict()

Expand Down
8 changes: 6 additions & 2 deletions omnigibson/examples/action_primitives/rs_int_example.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import os
import yaml

import numpy as np
import yaml

import omnigibson as og
from omnigibson.action_primitives.starter_semantic_action_primitives import (
StarterSemanticActionPrimitives,
StarterSemanticActionPrimitiveSet,
)
from omnigibson.macros import gm
from omnigibson.action_primitives.starter_semantic_action_primitives import StarterSemanticActionPrimitives, StarterSemanticActionPrimitiveSet

# Don't use GPU dynamics and use flatcache for performance boost
# gm.USE_GPU_DYNAMICS = True
Expand Down
8 changes: 6 additions & 2 deletions omnigibson/examples/action_primitives/solve_simple_task.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import os
import yaml

import numpy as np
import yaml

import omnigibson as og
from omnigibson.action_primitives.starter_semantic_action_primitives import (
StarterSemanticActionPrimitives,
StarterSemanticActionPrimitiveSet,
)
from omnigibson.macros import gm
from omnigibson.action_primitives.starter_semantic_action_primitives import StarterSemanticActionPrimitives, StarterSemanticActionPrimitiveSet

# Don't use GPU dynamics and use flatcache for performance boost
# gm.USE_GPU_DYNAMICS = True
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import os
import yaml

import numpy as np
import yaml

import omnigibson as og
from omnigibson.action_primitives.starter_semantic_action_primitives import (
StarterSemanticActionPrimitives,
StarterSemanticActionPrimitiveSet,
)
from omnigibson.macros import gm
from omnigibson.action_primitives.starter_semantic_action_primitives import StarterSemanticActionPrimitives, StarterSemanticActionPrimitiveSet

# Don't use GPU dynamics and use flatcache for performance boost
# gm.USE_GPU_DYNAMICS = True
Expand Down
9 changes: 6 additions & 3 deletions omnigibson/examples/learning/navigation_policy_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
"""

import argparse
import os, time, cv2
import os
import time

import cv2
import yaml

import omnigibson as og
Expand All @@ -15,15 +18,15 @@

try:
import gym
import tensorboard
import torch as th
import torch.nn as nn
import tensorboard
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
from stable_baselines3.common.callbacks import CallbackList, CheckpointCallback, EvalCallback

except ModuleNotFoundError:
og.log.error("torch, stable-baselines3, or tensorboard is not installed. "
Expand Down
2 changes: 1 addition & 1 deletion omnigibson/examples/object_states/attachment_demo.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import yaml
import numpy as np
import yaml

import omnigibson as og
from omnigibson.macros import gm
Expand Down
2 changes: 1 addition & 1 deletion omnigibson/examples/object_states/dicing_demo.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import numpy as np

import omnigibson as og
from omnigibson.macros import gm
import omnigibson.utils.transform_utils as T
from omnigibson.macros import gm

# Make sure object states, GPU dynamics, and transition rules are enabled
gm.ENABLE_OBJECT_STATES = True
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from omnigibson.utils.constants import PrimType
from omnigibson.object_states import Folded, Unfolded
from omnigibson.macros import gm
import numpy as np

import omnigibson as og
from omnigibson.macros import gm
from omnigibson.object_states import Folded, Unfolded
from omnigibson.utils.constants import PrimType

# Make sure object states and GPU dynamics are enabled (GPU dynamics needed for cloth)
gm.ENABLE_OBJECT_STATES = True
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import numpy as np

import omnigibson as og
from omnigibson import object_states
from omnigibson.macros import gm
Expand Down
1 change: 1 addition & 0 deletions omnigibson/examples/object_states/heated_state_demo.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import numpy as np

import omnigibson as og
from omnigibson import object_states
from omnigibson.macros import gm
Expand Down
Loading

0 comments on commit 3e19002

Please sign in to comment.