Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
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
19 changes: 19 additions & 0 deletions embodichain/toolkits/simready_pipeline/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# ----------------------------------------------------------------------------
# Copyright (c) 2021-2026 DexForce Technology Co., Ltd.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ----------------------------------------------------------------------------

from __future__ import annotations

__all__: list[str] = []
19 changes: 19 additions & 0 deletions embodichain/toolkits/simready_pipeline/cli/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# ----------------------------------------------------------------------------
# Copyright (c) 2021-2026 DexForce Technology Co., Ltd.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ----------------------------------------------------------------------------

from __future__ import annotations

__all__: list[str] = []
85 changes: 85 additions & 0 deletions embodichain/toolkits/simready_pipeline/cli/start.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# ----------------------------------------------------------------------------
# Copyright (c) 2021-2026 DexForce Technology Co., Ltd.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ----------------------------------------------------------------------------

import argparse
from pathlib import Path
import os

os.environ["PYOPENGL_PLATFORM"] = "egl"

from embodichain.toolkits.simready_pipeline.pipeline.ingest import ingest_one_asset
from embodichain.toolkits.simready_pipeline.io.json_store import JsonStore
from embodichain.toolkits.simready_pipeline.parser.base import ParserManager


def cli_ingest_single(
input_dir: str, output_dir: str, category: str, simple_ingest: bool
):
input_path = Path(input_dir)
output_path = Path(output_dir)

if not input_path.exists():
raise FileNotFoundError(f"Input directory not found: {input_path}")

output_path.mkdir(parents=True, exist_ok=True)
store = JsonStore(output_path)
manager = ParserManager()

print(f"Processing Single Asset: {input_path.name} (Category: {category})")

asset = ingest_one_asset(
asset_dir=input_path,
category=category,
output_root=output_path,
store=store,
manager=manager,
simple_ingest=simple_ingest,
)

if asset:
print(f"Successfully Processed")
else:
print("no asset returned (might be direct_copy mode)")


def main():
parser = argparse.ArgumentParser(
description="embodichain.toolkits.simready_pipeline Asset Ingestion Pipeline"
)

parser.add_argument(
"--input_dir", type=str, help="Path to the single asset directory"
)
parser.add_argument("--output_root", type=str, help="Path to the output directory")
parser.add_argument(
"--category",
type=str,
required=True,
help="Specify the category for this asset (e.g., 'cup', 'chair')",
)
parser.add_argument(
"--simple", action="store_true", help="trimesh only, skip Blender"
)

args = parser.parse_args()

cli_ingest_single(
args.input_dir, args.output_root, args.category, simple_ingest=args.simple
)


if __name__ == "__main__":
main()
19 changes: 19 additions & 0 deletions embodichain/toolkits/simready_pipeline/configs/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# ----------------------------------------------------------------------------
# Copyright (c) 2021-2026 DexForce Technology Co., Ltd.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ----------------------------------------------------------------------------

from __future__ import annotations

__all__: list[str] = []
28 changes: 28 additions & 0 deletions embodichain/toolkits/simready_pipeline/configs/gen_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"ingest": {
"canonical_asset_name": "asset.obj",
"unprocessed_formats": [".urdf", ".usd"],
"parseable_mesh_formats": [".glb", ".gltf", ".obj", ".ply", ".stl"],
"blender_texture_size": 2048,
"blender_texture_name": "surface_texture.png",
"blender_remesh_bake": {
"voxel_size": 0.01,
"decimate_ratio": 0.9
}
},
"geometry_cleanup": {
"ratio": 0.5,
"weld_distance": 0.0001,
"merge_dist": 0.00001,
"remove_non_manifold": true,
"triangulate": false
},
"llm": {
"azure_openai": {
"api_key": "",
"model": "gpt-4o",
"base_url": "",
"api_version": "2024-02-15-preview"
}
}
}
19 changes: 19 additions & 0 deletions embodichain/toolkits/simready_pipeline/core/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# ----------------------------------------------------------------------------
# Copyright (c) 2021-2026 DexForce Technology Co., Ltd.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ----------------------------------------------------------------------------

from __future__ import annotations

__all__: list[str] = []
90 changes: 90 additions & 0 deletions embodichain/toolkits/simready_pipeline/core/asset.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# ----------------------------------------------------------------------------
# Copyright (c) 2021-2026 DexForce Technology Co., Ltd.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ----------------------------------------------------------------------------

from dataclasses import dataclass, field
from typing import Any, Dict, List, Optional
from datetime import datetime


@dataclass
class Asset:

asset_id: str

identity: Dict[str, Any] = field(default_factory=dict)
asset_data: Dict[str, Any] = field(default_factory=dict)

parsed: Dict[str, Any] = field(
default_factory=dict
) # Visual, Geometry, Topology, 等解析或者入库时而来的信息
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Translate all the Chinese into English

semantics: Dict[str, Any] = field(default_factory=dict)
physics: Dict[str, Any] = field(default_factory=dict)
simulation: Dict[str, Any] = field(default_factory=dict)
affordance: Dict[str, Any] = field(default_factory=dict)
usd: Dict[str, Any] = field(default_factory=dict)

provenance: Dict[str, Any] = field(default_factory=dict)
quality: Dict[str, Any] = field(default_factory=dict)
status: Dict[str, Any] = field(default_factory=dict)
internal: Dict[str, Any] = field(default_factory=dict)

ingest_info: Dict[str, Any] = field(default_factory=dict) # ingest相关的临时信息

def __post_init__(self) -> None:
self._init_simulation_defaults()
self.touch()

def _init_simulation_defaults(self) -> None:
self.simulation.setdefault("articulation", None)
self.simulation.setdefault("sim_ready", {})

def touch(self) -> None:
self.status["last_updated"] = datetime.now().isoformat()

def to_dict(self) -> Dict[str, Any]:
return {
"asset_id": self.asset_id,
"identity": self.identity,
"asset_data": self.asset_data,
"parsed": self.parsed,
"quality": self.quality,
"semantics": self.semantics,
"physics": self.physics,
"simulation": self.simulation,
"usd": self.usd,
"provenance": self.provenance,
"status": self.status,
"internal": self.internal,
"affordance": self.affordance,
}

@classmethod
def from_dict(cls, data: Dict[str, Any]) -> "Asset":
return cls(
asset_id=data["asset_id"],
identity=data.get("identity", {}),
asset_data=data.get("asset_data", []),
parsed=data.get("parsed", {}),
quality=data.get("quality", {}),
semantics=data.get("semantics", {}),
physics=data.get("physics", {}),
simulation=data.get("simulation", {}),
usd=data.get("usd", {}),
provenance=data.get("provenance", {}),
status=data.get("status", {}),
internal=data.get("internal", {}),
affordance=data.get("affordance", {}),
)
19 changes: 19 additions & 0 deletions embodichain/toolkits/simready_pipeline/io/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# ----------------------------------------------------------------------------
# Copyright (c) 2021-2026 DexForce Technology Co., Ltd.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ----------------------------------------------------------------------------

from __future__ import annotations

__all__: list[str] = []
80 changes: 80 additions & 0 deletions embodichain/toolkits/simready_pipeline/io/json_store.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# ----------------------------------------------------------------------------
# Copyright (c) 2021-2026 DexForce Technology Co., Ltd.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ----------------------------------------------------------------------------

import json
from pathlib import Path
from typing import Any, Optional

from embodichain.toolkits.simready_pipeline.core.asset import Asset


class JsonStore:
"""
Simple JSON-based store for Assets and a global registry.
"""

def __init__(self, root_dir: str | Path):
self.root = Path(root_dir)
self.registry_path = self.root / "registry.json"

def _get_asset_json_path(self, asset_id: str) -> Path:
return self.root / asset_id / "asset.json"

def load_registry(self) -> dict[str, Any]:
if not self.registry_path.exists():
return {"assets": {}}

registry = json.loads(self.registry_path.read_text())
registry.setdefault("assets", {})
return registry

def _write_registry(self, registry: dict[str, Any]) -> None:
self.registry_path.parent.mkdir(parents=True, exist_ok=True)
self.registry_path.write_text(json.dumps(registry, indent=2))

def _register_asset(self, asset_id: str, asset_json: dict[str, Any]) -> None:
registry = self.load_registry()
registry["assets"][asset_id] = {
"path": str(self.root / asset_id),
"category": asset_json.get("identity", {}).get("category"),
}
self._write_registry(registry)

def save_asset(self, asset: Asset) -> None:
asset_path = self._get_asset_json_path(asset.asset_id)
asset_path.parent.mkdir(parents=True, exist_ok=True)
asset_json = asset.to_dict()
asset_path.write_text(json.dumps(asset_json, indent=2))
self._register_asset(asset.asset_id, asset_json)

def load_asset(self, asset_id: str) -> Optional[Asset]:
asset_path = self._get_asset_json_path(asset_id)
if not asset_path.exists():
return None
data = json.loads(asset_path.read_text())
return Asset.from_dict(data)

def write_asset(self, asset_id: str, asset_json: dict[str, Any]) -> None:
asset_root = self.root / asset_id
asset_root.mkdir(parents=True, exist_ok=True)

asset_path = asset_root / "asset.json"
asset_path.write_text(json.dumps(asset_json, indent=2))
self._register_asset(asset_id, asset_json)

def list_asset_ids(self) -> list[str]:
registry = self.load_registry()
return list(registry.get("assets", {}).keys())
Loading
Loading