Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ the finalize stage idempotent and the MJCF rooted at the CAD root link.
## Re-generating from CAD

```bash
uv sync
uv sync --extra cad
sudo apt install openscad # for collider editing (onshape-to-robot)
```

Expand Down
6 changes: 5 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ version = "0.3.1"
description = "Robot asset tool: generate URDF / MJCF / xacro from Onshape CAD, and load robot descriptions"
readme = "README.md"
requires-python = ">=3.10"
dependencies = [
dependencies = []

[project.optional-dependencies]
cad = [
"mujoco>=3.4.0",
"onshape-to-robot>=1.8.0",
"pymeshlab>=2025.7.post1",
Expand All @@ -26,6 +29,7 @@ robot-assets-urdf-to-xacro = "robot_assets.workflow.urdf_to_xacro:main"
[dependency-groups]
test = [
"pytest>=8.0",
"robot-assets[cad]",
]

[tool.pytest.ini_options]
Expand Down
14 changes: 12 additions & 2 deletions robot_assets/workflow/onshape_to_urdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,18 @@


def _onshape_to_robot_bin() -> str:
"""Locate the onshape-to-robot CLI (PATH, else alongside the running interpreter)."""
return shutil.which("onshape-to-robot") or str(Path(sys.executable).parent / "onshape-to-robot")
"""Locate the onshape-to-robot CLI (PATH, else alongside the running interpreter).

Raises:
FileNotFoundError: If the CLI is missing, i.e. the `cad` extra is not installed.
"""
binary = shutil.which("onshape-to-robot") or str(Path(sys.executable).parent / "onshape-to-robot")
if not Path(binary).exists():
raise FileNotFoundError(
"The onshape-to-robot CLI was not found. It ships with the CAD toolchain rather than "
"the base install; install it with `pip install robot-assets[cad]`."
)
return binary


def export(robot_dir: Path, *, keep_assets: bool = False, convert: bool = False) -> Path:
Expand Down
8 changes: 7 additions & 1 deletion robot_assets/workflow/urdf_to_mjcf.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,13 @@
import tempfile
import xml.etree.ElementTree as ET

import mujoco
try:
import mujoco
except ModuleNotFoundError as error:
raise ModuleNotFoundError(
"MuJoCo is needed to compile MJCF, and ships with the CAD toolchain rather than the "
"base install. Install it with `pip install robot-assets[cad]`."
) from error

from . import robot_model

Expand Down
17 changes: 12 additions & 5 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading