Skip to content

[WIP] Structured configs #1069

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 50 commits into
base: og-develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
b55d664
feat: Add structured config dataclasses for OmniGibson using OmegaConf
cgokmen Dec 31, 2024
3f8a578
feat: Migrate Environment config to OmegaConf structured configs
cgokmen Dec 31, 2024
7698c06
refactor: Implement structured configs for robot, object, and prim cl…
cgokmen Dec 31, 2024
e6dc817
refactor: Enhance object configuration with comprehensive config classes
cgokmen Dec 31, 2024
6bfbf66
refactor: Update BaseObject and StatefulObject to use structured configs
cgokmen Dec 31, 2024
a1d1097
refactor: Update object classes to use structured configs
cgokmen Dec 31, 2024
272844c
refactor: Introduce config objects for prim classes with base configu…
cgokmen Jan 2, 2025
c55c071
refactor: Update prim classes to use config objects
cgokmen Jan 2, 2025
72c9f45
refactor: Update MaterialPrim to use config object pattern
cgokmen Jan 2, 2025
e12f36e
feat: Import PrimConfig in material_prim.py to resolve undefined name…
cgokmen Jan 2, 2025
1cdcceb
refactor: Update prim classes to use config object pattern consistently
cgokmen Jan 2, 2025
1b5607e
refactor: Update prim classes to use config object pattern
cgokmen Jan 2, 2025
2c4a968
refactor: Fix config object handling in prim classes during refactoring
cgokmen Jan 2, 2025
9dc32bf
refactor: Update prim creation method to use PrimConfig
cgokmen Jan 2, 2025
eb42e5c
refactor: Add Hydra config objects for robot and controller configura…
cgokmen Jan 2, 2025
4dbddac
refactor: Create separate config classes for different robot types
cgokmen Jan 2, 2025
3bf0a9e
refactor: Update Husky robot to use HuskyConfig in constructor
cgokmen Jan 2, 2025
f12caae
Based on the changes, I'll generate a concise commit message that cap…
cgokmen Jan 2, 2025
98c3624
refactor: Add MISSING import from omegaconf for config validation
cgokmen Jan 2, 2025
9fbe387
refactor: Update LocomotionRobot with config-based validation and doc…
cgokmen Jan 2, 2025
61a2ef3
refactor: Update LocomotionRobot to use config-based base joint control
cgokmen Jan 2, 2025
4ec0bca
docs: Update docstring for LocomotionRobot configuration description
cgokmen Jan 2, 2025
14356c3
Some help from cline
cgokmen Jan 2, 2025
b0614f1
feat: Create structured config hierarchy for OmegaConf configuration
cgokmen Jan 2, 2025
53639a2
The changes look good. I've added the necessary imports and fixed the…
cgokmen Jan 2, 2025
30136a0
refactor: Update controller config imports and types in RobotConfig
cgokmen Jan 2, 2025
55df619
Remove useless and tricky copy method
cgokmen Jan 2, 2025
618b4d7
feat: Refactor PrimitiveObject to use structured configs and remove k…
cgokmen Jan 2, 2025
7d2d209
feat: Refactor StatefulObject to use structured config with type hint…
cgokmen Jan 2, 2025
bfbdd3d
refactor: Simplify StatefulObject initialization and type hint config…
cgokmen Jan 2, 2025
bb387d5
feat: Add import for StatefulObjectConfig to resolve undefined name e…
cgokmen Jan 2, 2025
1f060a5
refactor: Convert DatasetObject to use structured config with Hydra/O…
cgokmen Jan 2, 2025
0d96887
refactor: Add imports for DatasetObjectConfig and USDObjectConfig
cgokmen Jan 2, 2025
d84e2a8
refactor: Convert USDObject to use structured config with proper conf…
cgokmen Jan 2, 2025
f077cc8
refactor: Update USDObject to use structured USDObjectConfig
cgokmen Jan 2, 2025
aec3baf
refactor: Convert LightObject to use structured config with direct co…
cgokmen Jan 2, 2025
71560ba
refactor: Update LightObject to use structured config with import
cgokmen Jan 2, 2025
5369032
refactor: Migrate ControllableObject to use structured Hydra/OmegaCon…
cgokmen Jan 2, 2025
3d76e40
The changes look good. I'll generate a concise commit message for the…
cgokmen Jan 2, 2025
528e49d
refactor: Migrate ControllableObject to use structured configs and re…
cgokmen Jan 2, 2025
a35a1bf
fix: Remove unused subsume controller code and update controller conf…
cgokmen Jan 3, 2025
fd36ce0
refactor: Simplify ControllableObject config handling and controller …
cgokmen Jan 3, 2025
39cc75a
refactor: Improve structured config handling in ControllableObject
cgokmen Jan 3, 2025
e284b56
feat: Add import for ControllableObjectConfig in controllable_object.py
cgokmen Jan 3, 2025
e5515f6
feat: Refactor object classes to use config object directly
cgokmen Jan 3, 2025
cdff843
refactor: Update primitive_type access from self._primitive_type to s…
cgokmen Jan 3, 2025
a04ae8c
refactor: Update PrimitiveObject to use structured config pattern
cgokmen Jan 3, 2025
0119a6b
refactor: Add import for PrimitiveObjectConfig in primitive_object.py
cgokmen Jan 3, 2025
32edd89
Read primitive type
cgokmen Jan 3, 2025
80806e3
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 3, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,5 @@ docs/reference
site/

# Tests of examples
tests/tests_of_examples
tests/tests_of_examples
.aider*
99 changes: 99 additions & 0 deletions omnigibson/configs/base_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
from dataclasses import dataclass, field
from typing import Optional, List, Dict, Any
from omegaconf import MISSING
from omnigibson.configs.robot_config import ControllerConfig


@dataclass
class BaseConfig:
"""Base configuration class that all other configs inherit from"""

name: str = MISSING


@dataclass
class BasePrimConfig(BaseConfig):
"""Base configuration for all prims"""

relative_prim_path: Optional[str] = None
load_config: Dict[str, Any] = field(default_factory=dict)


@dataclass
class EntityConfig(BasePrimConfig):
"""Configuration for entities"""

scale: Optional[List[float]] = None
visible: bool = True
visual_only: bool = False
kinematic_only: Optional[bool] = None
self_collisions: bool = False
prim_type: str = MISSING


@dataclass
class ObjectConfig(EntityConfig):
"""Configuration for all objects"""

category: str = "object"
fixed_base: bool = False
abilities: Dict[str, Dict[str, Any]] = field(default_factory=dict)
include_default_states: bool = True


@dataclass
class StatefulObjectConfig(ObjectConfig):
"""Configuration for stateful objects"""

abilities: Optional[Dict[str, Dict[str, Any]]] = None
include_default_states: bool = True


@dataclass
class USDObjectConfig(StatefulObjectConfig):
"""Configuration for USD-based objects"""

usd_path: str = MISSING
encrypted: bool = False


@dataclass
class DatasetObjectConfig(StatefulObjectConfig):
"""Configuration for dataset objects"""

model: Optional[str] = None
dataset_type: str = "BEHAVIOR"
bounding_box: Optional[List[float]] = None
in_rooms: Optional[List[str]] = None
xform_props_pre_loaded: bool = True


@dataclass
class PrimitiveObjectConfig(StatefulObjectConfig):
"""Configuration for primitive objects"""

primitive_type: str = MISSING
rgba: List[float] = field(default_factory=lambda: [0.5, 0.5, 0.5, 1.0])
radius: Optional[float] = None
height: Optional[float] = None
size: Optional[float] = None


@dataclass
class LightObjectConfig(StatefulObjectConfig):
"""Configuration for light objects"""

light_type: str = MISSING
radius: float = 1.0
intensity: float = 50000.0


@dataclass
class ControllableObjectConfig(StatefulObjectConfig):
"""Configuration for controllable objects"""

control_freq: Optional[float] = None
action_type: str = "continuous"
action_normalize: bool = True
reset_joint_pos: Optional[List[float]] = None
controllers: Dict[str, ControllerConfig] = field(default_factory=dict)
122 changes: 122 additions & 0 deletions omnigibson/configs/controller_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
from dataclasses import dataclass, field
from typing import Optional, Dict, Any, List, Tuple, Union
from omegaconf import MISSING
import torch as th


@dataclass
class BaseControllerConfig:
"""Base configuration for all controllers"""

control_freq: float = MISSING
control_limits: Dict[str, Any] = MISSING # Dict with position, velocity, effort limits and has_limit
dof_idx: List[int] = MISSING
command_input_limits: Optional[Union[str, Tuple[float, float], Tuple[List[float], List[float]]]] = "default"
command_output_limits: Optional[Union[str, Tuple[float, float], Tuple[List[float], List[float]]]] = "default"


@dataclass
class JointControllerConfig(BaseControllerConfig):
"""Configuration for joint controllers"""

motor_type: str = MISSING # One of {position, velocity, effort}
pos_kp: Optional[float] = None
pos_damping_ratio: Optional[float] = None
vel_kp: Optional[float] = None
use_impedances: bool = False
use_gravity_compensation: bool = False
use_cc_compensation: bool = True
use_delta_commands: bool = False
compute_delta_in_quat_space: Optional[List[Tuple[int, int, int]]] = None


@dataclass
class VisionSensorConfig:
"""Configuration for vision sensors"""

enabled: bool = True
noise_type: Optional[str] = None
noise_kwargs: Optional[Dict[str, Any]] = None
modalities: Optional[List[str]] = None
sensor_kwargs: Dict[str, Any] = field(
default_factory=lambda: {
"image_height": 128,
"image_width": 128,
}
)


@dataclass
class ScanSensorConfig:
"""Configuration for scan sensors"""

enabled: bool = True
noise_type: Optional[str] = None
noise_kwargs: Optional[Dict[str, Any]] = None
modalities: Optional[List[str]] = None
sensor_kwargs: Dict[str, Any] = field(
default_factory=lambda: {
"min_range": 0.05,
"max_range": 10.0,
"horizontal_fov": 360.0,
"vertical_fov": 1.0,
"yaw_offset": 0.0,
"horizontal_resolution": 1.0,
"vertical_resolution": 1.0,
"rotation_rate": 0.0,
"draw_points": False,
"draw_lines": False,
"occupancy_grid_resolution": 128,
"occupancy_grid_range": 5.0,
"occupancy_grid_inner_radius": 0.5,
"occupancy_grid_local_link": None,
}
)


@dataclass
class DifferentialDriveControllerConfig(BaseControllerConfig):
"""Configuration for differential drive controllers"""

wheel_radius: float = MISSING
wheel_axle_length: float = MISSING
wheel_control_idx: List[int] = MISSING # [left_wheel_idx, right_wheel_idx]


@dataclass
class InverseKinematicsControllerConfig(BaseControllerConfig):
"""Configuration for inverse kinematics controllers"""

control_freq: float = MISSING
control_limits: Dict[str, Any] = MISSING
dof_idx: List[int] = MISSING
command_input_limits: Optional[Union[str, Tuple[float, float], Tuple[List[float], List[float]]]] = "default"
command_output_limits: Optional[Union[str, Tuple[float, float], Tuple[List[float], List[float]]]] = "default"
rest_poses: Optional[th.Tensor] = None
position_limits: Optional[Tuple[th.Tensor, th.Tensor]] = None
rotation_limits: Optional[Tuple[th.Tensor, th.Tensor]] = None
position_gain: float = 1.0
rotation_gain: float = 0.5
position_threshold: float = 0.005
rotation_threshold: float = 0.05
num_ik_seeds: int = 10
num_ik_solutions: int = 1
regularization_weight: float = 0.01
collision_checking: bool = True


@dataclass
class MultiFingerGripperControllerConfig(BaseControllerConfig):
"""Configuration for multi-finger gripper controllers"""

mode: str = "binary" # One of {binary, continuous}
grasp_thresh: float = 0.5
release_thresh: float = -0.5


@dataclass
class SensorConfig:
"""Configuration for all sensors"""

VisionSensor: VisionSensorConfig = field(default_factory=VisionSensorConfig)
ScanSensor: ScanSensorConfig = field(default_factory=ScanSensorConfig)
60 changes: 60 additions & 0 deletions omnigibson/configs/env_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
from dataclasses import dataclass, field
from typing import List, Optional, Dict, Any
from omegaconf import MISSING

from omnigibson.configs.object_config import ObjectConfig, RobotConfig


@dataclass
class RenderConfig:
viewer_width: int = 1280
viewer_height: int = 720


@dataclass
class EnvConfig:
action_frequency: int = 60
rendering_frequency: int = 60
physics_frequency: int = 60
device: Optional[str] = None
automatic_reset: bool = False
flatten_action_space: bool = False
flatten_obs_space: bool = False
initial_pos_z_offset: float = 0.1
external_sensors: Optional[List[Dict[str, Any]]] = None


@dataclass
class SceneConfig:
type: str = MISSING
model: str = MISSING
waypoint_resolution: float = 0.2
num_waypoints: int = 10
trav_map_resolution: float = 0.1
default_erosion_radius: float = 0.0
trav_map_with_objects: bool = True
scene_instance: Optional[str] = None
scene_file: Optional[str] = None


@dataclass
class TaskConfig:
type: str = "DummyTask"
params: Dict[str, Any] = field(default_factory=dict)


@dataclass
class WrapperConfig:
type: Optional[str] = None
params: Dict[str, Any] = field(default_factory=dict)


@dataclass
class OmniGibsonConfig:
env: EnvConfig = field(default_factory=EnvConfig)
render: RenderConfig = field(default_factory=RenderConfig)
scene: SceneConfig = field(default_factory=SceneConfig)
robots: List[RobotConfig] = field(default_factory=list)
objects: List[ObjectConfig] = field(default_factory=list)
task: TaskConfig = field(default_factory=TaskConfig)
wrapper: WrapperConfig = field(default_factory=WrapperConfig)
57 changes: 57 additions & 0 deletions omnigibson/configs/object_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
from dataclasses import dataclass, field
from typing import Dict, List, Optional, Union
from omegaconf import MISSING

from omnigibson.configs.base_config import (
ObjectConfig,
USDObjectConfig,
DatasetObjectConfig,
PrimitiveObjectConfig,
LightObjectConfig,
ControllableObjectConfig,
)
from omnigibson.configs.robot_config import (
ControllerConfig,
JointControllerConfig,
IKControllerConfig,
OSCControllerConfig,
DifferentialDriveConfig,
GripperControllerConfig,
)
from omnigibson.configs.sensor_config import SensorConfig

__all__ = [
"ObjectConfig",
"USDObjectConfig",
"DatasetObjectConfig",
"PrimitiveObjectConfig",
"LightObjectConfig",
"ControllableObjectConfig",
"RobotConfig",
]


@dataclass
class RobotConfig(ControllableObjectConfig):
"""Configuration for robots"""

type: str = MISSING
obs_modalities: List[str] = field(default_factory=lambda: ["rgb", "proprio"])
proprio_obs: str = "default"
sensor_config: Optional[SensorConfig] = field(default_factory=SensorConfig)
grasping_mode: str = "physical"
grasping_direction: str = "lower"
disable_grasp_handling: bool = False
default_reset_mode: str = "untuck"
default_arm_pose: str = "vertical"
controllers: Dict[
str,
Union[
ControllerConfig,
JointControllerConfig,
IKControllerConfig,
OSCControllerConfig,
DifferentialDriveConfig,
GripperControllerConfig,
],
] = field(default_factory=dict)
Loading
Loading