Datasets:
Add pinned source: behavior-1k-bddl
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- source_data/pinned/behavior-1k-bddl/v3.9.3-post2/.dockerignore +20 -0
- source_data/pinned/behavior-1k-bddl/v3.9.3-post2/.gitattributes +1 -0
- source_data/pinned/behavior-1k-bddl/v3.9.3-post2/.github/ISSUE_TEMPLATE/bug_report.md +32 -0
- source_data/pinned/behavior-1k-bddl/v3.9.3-post2/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
- source_data/pinned/behavior-1k-bddl/v3.9.3-post2/.github/ISSUE_TEMPLATE/question.md +10 -0
- source_data/pinned/behavior-1k-bddl/v3.9.3-post2/.github/scripts/check_types_diff.py +112 -0
- source_data/pinned/behavior-1k-bddl/v3.9.3-post2/.github/scripts/cprofile_to_html.py +82 -0
- source_data/pinned/behavior-1k-bddl/v3.9.3-post2/.github/scripts/resolve_diff_range.sh +16 -0
- source_data/pinned/behavior-1k-bddl/v3.9.3-post2/.github/workflows/build-push-containers.yml +157 -0
- source_data/pinned/behavior-1k-bddl/v3.9.3-post2/.github/workflows/build-website.yml +89 -0
- source_data/pinned/behavior-1k-bddl/v3.9.3-post2/.github/workflows/profiling.yml +305 -0
- source_data/pinned/behavior-1k-bddl/v3.9.3-post2/.github/workflows/profiling_vector.yml +306 -0
- source_data/pinned/behavior-1k-bddl/v3.9.3-post2/.github/workflows/publish-pypi.yml +38 -0
- source_data/pinned/behavior-1k-bddl/v3.9.3-post2/.github/workflows/pull-sheets-bddl.yml +100 -0
- source_data/pinned/behavior-1k-bddl/v3.9.3-post2/.github/workflows/pull-sheets.yml +44 -0
- source_data/pinned/behavior-1k-bddl/v3.9.3-post2/.github/workflows/tests.yml +249 -0
- source_data/pinned/behavior-1k-bddl/v3.9.3-post2/.github/workflows/type-check.yml +104 -0
- source_data/pinned/behavior-1k-bddl/v3.9.3-post2/.gitignore +11 -0
- source_data/pinned/behavior-1k-bddl/v3.9.3-post2/.pre-commit-config.yaml +12 -0
- source_data/pinned/behavior-1k-bddl/v3.9.3-post2/AGENTS.md +109 -0
- source_data/pinned/behavior-1k-bddl/v3.9.3-post2/CLAUDE.md +3 -0
- source_data/pinned/behavior-1k-bddl/v3.9.3-post2/LICENSE +21 -0
- source_data/pinned/behavior-1k-bddl/v3.9.3-post2/OmniGibson/.gitignore +97 -0
- source_data/pinned/behavior-1k-bddl/v3.9.3-post2/OmniGibson/.gitmodules +15 -0
- source_data/pinned/behavior-1k-bddl/v3.9.3-post2/OmniGibson/LICENSE +21 -0
- source_data/pinned/behavior-1k-bddl/v3.9.3-post2/OmniGibson/MANIFEST.in +6 -0
- source_data/pinned/behavior-1k-bddl/v3.9.3-post2/OmniGibson/README.md +54 -0
- source_data/pinned/behavior-1k-bddl/v3.9.3-post2/OmniGibson/omnigibson/.gitignore +4 -0
- source_data/pinned/behavior-1k-bddl/v3.9.3-post2/OmniGibson/omnigibson/__init__.py +199 -0
- source_data/pinned/behavior-1k-bddl/v3.9.3-post2/OmniGibson/omnigibson/action_primitives/action_primitive_set_base.py +89 -0
- source_data/pinned/behavior-1k-bddl/v3.9.3-post2/OmniGibson/omnigibson/action_primitives/curobo.py +1006 -0
- source_data/pinned/behavior-1k-bddl/v3.9.3-post2/OmniGibson/omnigibson/action_primitives/starter_semantic_action_primitives.py +2093 -0
- source_data/pinned/behavior-1k-bddl/v3.9.3-post2/OmniGibson/omnigibson/action_primitives/symbolic_semantic_action_primitives.py +622 -0
- source_data/pinned/behavior-1k-bddl/v3.9.3-post2/OmniGibson/omnigibson/configs/avg_category_specs.json +0 -0
- source_data/pinned/behavior-1k-bddl/v3.9.3-post2/OmniGibson/omnigibson/configs/controllers/dd.yaml +10 -0
- source_data/pinned/behavior-1k-bddl/v3.9.3-post2/OmniGibson/omnigibson/configs/controllers/ik.yaml +17 -0
- source_data/pinned/behavior-1k-bddl/v3.9.3-post2/OmniGibson/omnigibson/configs/controllers/joint.yaml +12 -0
- source_data/pinned/behavior-1k-bddl/v3.9.3-post2/OmniGibson/omnigibson/configs/controllers/multi_finger_gripper.yaml +15 -0
- source_data/pinned/behavior-1k-bddl/v3.9.3-post2/OmniGibson/omnigibson/configs/controllers/null_gripper.yaml +9 -0
- source_data/pinned/behavior-1k-bddl/v3.9.3-post2/OmniGibson/omnigibson/configs/default_cfg.yaml +16 -0
- source_data/pinned/behavior-1k-bddl/v3.9.3-post2/OmniGibson/omnigibson/configs/franka_vector_env.yaml +64 -0
- source_data/pinned/behavior-1k-bddl/v3.9.3-post2/OmniGibson/omnigibson/configs/r1_primitives.yaml +114 -0
- source_data/pinned/behavior-1k-bddl/v3.9.3-post2/OmniGibson/omnigibson/configs/r1pro_behavior.yaml +114 -0
- source_data/pinned/behavior-1k-bddl/v3.9.3-post2/OmniGibson/omnigibson/configs/r1pro_primitives.yaml +117 -0
- source_data/pinned/behavior-1k-bddl/v3.9.3-post2/OmniGibson/omnigibson/configs/robots/fetch.yaml +42 -0
- source_data/pinned/behavior-1k-bddl/v3.9.3-post2/OmniGibson/omnigibson/configs/robots/freight.yaml +26 -0
- source_data/pinned/behavior-1k-bddl/v3.9.3-post2/OmniGibson/omnigibson/configs/robots/husky.yaml +26 -0
- source_data/pinned/behavior-1k-bddl/v3.9.3-post2/OmniGibson/omnigibson/configs/robots/locobot.yaml +26 -0
- source_data/pinned/behavior-1k-bddl/v3.9.3-post2/OmniGibson/omnigibson/configs/robots/turtlebot.yaml +26 -0
- source_data/pinned/behavior-1k-bddl/v3.9.3-post2/OmniGibson/omnigibson/configs/sensors/scan.yaml +30 -0
source_data/pinned/behavior-1k-bddl/v3.9.3-post2/.dockerignore
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
gha-creds-*.json
|
| 2 |
+
/site
|
| 3 |
+
.vscode
|
| 4 |
+
.DS_Store
|
| 5 |
+
|
| 6 |
+
# training
|
| 7 |
+
outputs/
|
| 8 |
+
/*.ipynb
|
| 9 |
+
|
| 10 |
+
# Dataset
|
| 11 |
+
datasets/*
|
| 12 |
+
!datasets/README
|
| 13 |
+
|
| 14 |
+
# No DVC caches
|
| 15 |
+
asset_pipeline/.dvc
|
| 16 |
+
asset_pipeline/tmp
|
| 17 |
+
asset_pipeline/logs
|
| 18 |
+
asset_pipeline/artifacts
|
| 19 |
+
asset_pipeline/cad
|
| 20 |
+
.git
|
source_data/pinned/behavior-1k-bddl/v3.9.3-post2/.gitattributes
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
*.ipynb linguist-detectable=false
|
source_data/pinned/behavior-1k-bddl/v3.9.3-post2/.github/ISSUE_TEMPLATE/bug_report.md
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
name: Bug report
|
| 3 |
+
about: Create a report to help us improve
|
| 4 |
+
title: ''
|
| 5 |
+
labels: bug
|
| 6 |
+
assignees: ''
|
| 7 |
+
|
| 8 |
+
---
|
| 9 |
+
|
| 10 |
+
**Describe the bug**
|
| 11 |
+
A clear and concise description of what the bug is.
|
| 12 |
+
|
| 13 |
+
**To Reproduce**
|
| 14 |
+
Steps to reproduce the behavior:
|
| 15 |
+
1. Go to '...'
|
| 16 |
+
2. Click on '....'
|
| 17 |
+
3. Scroll down to '....'
|
| 18 |
+
4. See error
|
| 19 |
+
|
| 20 |
+
**Expected behavior**
|
| 21 |
+
A clear and concise description of what you expected to happen.
|
| 22 |
+
|
| 23 |
+
**Screenshots**
|
| 24 |
+
If applicable, add screenshots to help explain your problem.
|
| 25 |
+
|
| 26 |
+
**Desktop (please complete the following information):**
|
| 27 |
+
- OS: [e.g. Ubuntu 22.04]
|
| 28 |
+
- Isaac Sim Version [e.g. 4.1.0]
|
| 29 |
+
- OmniGibson Version [e.g. 1.1.0]
|
| 30 |
+
|
| 31 |
+
**Additional context**
|
| 32 |
+
Add any other context about the problem here.
|
source_data/pinned/behavior-1k-bddl/v3.9.3-post2/.github/ISSUE_TEMPLATE/feature_request.md
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
name: Feature request
|
| 3 |
+
about: Suggest an idea for this project
|
| 4 |
+
title: ''
|
| 5 |
+
labels: enhancement
|
| 6 |
+
assignees: cgokmen
|
| 7 |
+
|
| 8 |
+
---
|
| 9 |
+
|
| 10 |
+
**Is your feature request related to a problem? Please describe.**
|
| 11 |
+
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
| 12 |
+
|
| 13 |
+
**Describe the solution you'd like**
|
| 14 |
+
A clear and concise description of what you want to happen.
|
| 15 |
+
|
| 16 |
+
**Describe alternatives you've considered**
|
| 17 |
+
A clear and concise description of any alternative solutions or features you've considered.
|
| 18 |
+
|
| 19 |
+
**Additional context**
|
| 20 |
+
Add any other context or screenshots about the feature request here.
|
source_data/pinned/behavior-1k-bddl/v3.9.3-post2/.github/ISSUE_TEMPLATE/question.md
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
name: Question
|
| 3 |
+
about: PLEASE POST QUESTIONS IN THE DISCUSSIONS TAB
|
| 4 |
+
title: ''
|
| 5 |
+
labels: question
|
| 6 |
+
assignees: ''
|
| 7 |
+
|
| 8 |
+
---
|
| 9 |
+
|
| 10 |
+
**PLEASE POST QUESTIONS IN THE DISCUSSIONS TAB**
|
source_data/pinned/behavior-1k-bddl/v3.9.3-post2/.github/scripts/check_types_diff.py
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""Run pyright on the files changed between two git refs, but only fail CI on
|
| 3 |
+
errors that land on lines actually touched by the diff. Pre-existing errors
|
| 4 |
+
in the rest of a changed file are reported but do not fail the build, so we
|
| 5 |
+
can turn on type checking without first fixing the entire legacy codebase.
|
| 6 |
+
"""
|
| 7 |
+
|
| 8 |
+
import argparse
|
| 9 |
+
import json
|
| 10 |
+
import re
|
| 11 |
+
import subprocess
|
| 12 |
+
import sys
|
| 13 |
+
from pathlib import Path
|
| 14 |
+
|
| 15 |
+
HUNK_RE = re.compile(r"^@@ -\d+(?:,\d+)? \+(\d+)(?:,(\d+))? @@")
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
def run(cmd, cwd=None):
|
| 19 |
+
return subprocess.run(cmd, cwd=cwd, capture_output=True, text=True)
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
def changed_python_files(base, head, package_dir):
|
| 23 |
+
result = run(
|
| 24 |
+
["git", "diff", "--name-only", "--diff-filter=ACMR", f"{base}", f"{head}", "--", package_dir]
|
| 25 |
+
)
|
| 26 |
+
if result.returncode != 0:
|
| 27 |
+
print(result.stderr, file=sys.stderr)
|
| 28 |
+
sys.exit(2)
|
| 29 |
+
files = [line.strip() for line in result.stdout.splitlines() if line.strip()]
|
| 30 |
+
return [f for f in files if f.endswith(".py") and Path(f).exists()]
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
def added_lines_for_file(base, head, repo_relative_path):
|
| 34 |
+
"""Return the set of 1-indexed line numbers introduced/modified in `head`."""
|
| 35 |
+
result = run(["git", "diff", "--no-color", "--unified=0", f"{base}", f"{head}", "--", repo_relative_path])
|
| 36 |
+
if result.returncode != 0:
|
| 37 |
+
print(result.stderr, file=sys.stderr)
|
| 38 |
+
sys.exit(2)
|
| 39 |
+
lines = set()
|
| 40 |
+
for line in result.stdout.splitlines():
|
| 41 |
+
match = HUNK_RE.match(line)
|
| 42 |
+
if not match:
|
| 43 |
+
continue
|
| 44 |
+
new_start = int(match.group(1))
|
| 45 |
+
new_count = int(match.group(2)) if match.group(2) is not None else 1
|
| 46 |
+
if new_count == 0:
|
| 47 |
+
# Pure deletion at this point in the file; nothing was added.
|
| 48 |
+
continue
|
| 49 |
+
lines.update(range(new_start, new_start + new_count))
|
| 50 |
+
return lines
|
| 51 |
+
|
| 52 |
+
|
| 53 |
+
def main():
|
| 54 |
+
parser = argparse.ArgumentParser(description=__doc__)
|
| 55 |
+
parser.add_argument("--package-dir", required=True, help="Repo-relative package directory, e.g. OmniGibson")
|
| 56 |
+
parser.add_argument("--base", required=True, help="Base git ref/sha to diff against")
|
| 57 |
+
parser.add_argument("--head", required=True, help="Head git ref/sha being checked")
|
| 58 |
+
args = parser.parse_args()
|
| 59 |
+
|
| 60 |
+
package_dir = args.package_dir.rstrip("/")
|
| 61 |
+
changed_files = changed_python_files(args.base, args.head, package_dir)
|
| 62 |
+
|
| 63 |
+
if not changed_files:
|
| 64 |
+
print(f"No changed Python files under {package_dir}/ — skipping type check.")
|
| 65 |
+
return 0
|
| 66 |
+
|
| 67 |
+
print(f"Type-checking {len(changed_files)} changed file(s) under {package_dir}/:")
|
| 68 |
+
for f in changed_files:
|
| 69 |
+
print(f" {f}")
|
| 70 |
+
|
| 71 |
+
relative_files = [str(Path(f).relative_to(package_dir)) for f in changed_files]
|
| 72 |
+
pyright_result = run(["pyright", "--outputjson", *relative_files], cwd=package_dir)
|
| 73 |
+
|
| 74 |
+
try:
|
| 75 |
+
report = json.loads(pyright_result.stdout)
|
| 76 |
+
except json.JSONDecodeError:
|
| 77 |
+
print("Failed to parse pyright output as JSON:", file=sys.stderr)
|
| 78 |
+
print(pyright_result.stdout, file=sys.stderr)
|
| 79 |
+
print(pyright_result.stderr, file=sys.stderr)
|
| 80 |
+
return 2
|
| 81 |
+
|
| 82 |
+
added_lines = {f: added_lines_for_file(args.base, args.head, f) for f in changed_files}
|
| 83 |
+
|
| 84 |
+
blocking, pre_existing = [], []
|
| 85 |
+
for diag in report.get("generalDiagnostics", []):
|
| 86 |
+
if diag.get("severity") != "error":
|
| 87 |
+
continue
|
| 88 |
+
diag_file = str(Path(package_dir) / Path(diag["file"]).relative_to(Path(package_dir).resolve()))
|
| 89 |
+
line = diag["range"]["start"]["line"] + 1
|
| 90 |
+
entry = f"{diag_file}:{line}: {diag['message'].splitlines()[0]}"
|
| 91 |
+
if line in added_lines.get(diag_file, ()):
|
| 92 |
+
blocking.append(entry)
|
| 93 |
+
else:
|
| 94 |
+
pre_existing.append(entry)
|
| 95 |
+
|
| 96 |
+
if pre_existing:
|
| 97 |
+
print(f"\n{len(pre_existing)} pre-existing type error(s) in touched files (not blocking):")
|
| 98 |
+
for entry in pre_existing:
|
| 99 |
+
print(f" {entry}")
|
| 100 |
+
|
| 101 |
+
if blocking:
|
| 102 |
+
print(f"\n{len(blocking)} new type error(s) on lines you touched (blocking):")
|
| 103 |
+
for entry in blocking:
|
| 104 |
+
print(f" {entry}")
|
| 105 |
+
return 1
|
| 106 |
+
|
| 107 |
+
print("\nNo new type errors on touched lines.")
|
| 108 |
+
return 0
|
| 109 |
+
|
| 110 |
+
|
| 111 |
+
if __name__ == "__main__":
|
| 112 |
+
sys.exit(main())
|
source_data/pinned/behavior-1k-bddl/v3.9.3-post2/.github/scripts/cprofile_to_html.py
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""Convert a cProfile .prof file into an HTML summary.
|
| 3 |
+
|
| 4 |
+
This uses snakeviz to parse profile stats and render function tables inspired by
|
| 5 |
+
https://gist.github.com/MSSandroid/6402e2e99e31633386a312b283839e0d.
|
| 6 |
+
"""
|
| 7 |
+
|
| 8 |
+
import argparse
|
| 9 |
+
import html
|
| 10 |
+
import os
|
| 11 |
+
from pstats import Stats
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
def _format_time(seconds):
|
| 15 |
+
return f"{seconds:.6f}"
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
def main():
|
| 19 |
+
parser = argparse.ArgumentParser()
|
| 20 |
+
parser.add_argument("--profile", required=True, help="Path to .prof file")
|
| 21 |
+
parser.add_argument("--output", required=True, help="Output html path")
|
| 22 |
+
parser.add_argument("--limit", type=int, default=200, help="Number of functions to include")
|
| 23 |
+
args = parser.parse_args()
|
| 24 |
+
|
| 25 |
+
import snakeviz.stats as snakeviz_stats
|
| 26 |
+
|
| 27 |
+
stats = Stats(args.profile)
|
| 28 |
+
snake_stats = snakeviz_stats.json_stats(stats)
|
| 29 |
+
|
| 30 |
+
rows = []
|
| 31 |
+
for idx, (func_name, data) in enumerate(sorted(snake_stats.items(), key=lambda item: item[1]["stats"][3], reverse=True)):
|
| 32 |
+
if idx >= args.limit:
|
| 33 |
+
break
|
| 34 |
+
ccalls, ncalls, tottime, cumtime = data["stats"]
|
| 35 |
+
rows.append(
|
| 36 |
+
"<tr>"
|
| 37 |
+
f"<td>{idx + 1}</td>"
|
| 38 |
+
f"<td><code>{html.escape(func_name)}</code></td>"
|
| 39 |
+
f"<td>{ncalls}</td>"
|
| 40 |
+
f"<td>{ccalls}</td>"
|
| 41 |
+
f"<td>{_format_time(tottime)}</td>"
|
| 42 |
+
f"<td>{_format_time(cumtime)}</td>"
|
| 43 |
+
"</tr>"
|
| 44 |
+
)
|
| 45 |
+
|
| 46 |
+
total_calls = stats.total_calls
|
| 47 |
+
primitive_calls = stats.prim_calls
|
| 48 |
+
total_time = stats.total_tt
|
| 49 |
+
|
| 50 |
+
os.makedirs(os.path.dirname(os.path.abspath(args.output)), exist_ok=True)
|
| 51 |
+
with open(args.output, "w", encoding="utf-8") as f:
|
| 52 |
+
f.write(
|
| 53 |
+
"""<!doctype html>
|
| 54 |
+
<html lang=\"en\">
|
| 55 |
+
<head>
|
| 56 |
+
<meta charset=\"utf-8\" />
|
| 57 |
+
<title>cProfile report</title>
|
| 58 |
+
<style>
|
| 59 |
+
body { font-family: system-ui, sans-serif; margin: 24px; }
|
| 60 |
+
table { border-collapse: collapse; width: 100%; }
|
| 61 |
+
th, td { border: 1px solid #ddd; padding: 6px 8px; font-size: 13px; }
|
| 62 |
+
th { background: #f5f5f5; text-align: left; }
|
| 63 |
+
code { font-size: 12px; }
|
| 64 |
+
</style>
|
| 65 |
+
</head>
|
| 66 |
+
<body>
|
| 67 |
+
"""
|
| 68 |
+
)
|
| 69 |
+
f.write(f"<h1>cProfile report: {html.escape(os.path.basename(args.profile))}</h1>\n")
|
| 70 |
+
f.write("<p>Generated with <code>snakeviz.stats.json_stats</code> and <code>pstats.Stats</code>.</p>\n")
|
| 71 |
+
f.write(
|
| 72 |
+
f"<ul><li>Total calls: {total_calls}</li><li>Primitive calls: {primitive_calls}</li><li>Total time (s): {total_time:.6f}</li></ul>\n"
|
| 73 |
+
)
|
| 74 |
+
f.write(
|
| 75 |
+
"<table><thead><tr><th>#</th><th>Function</th><th>Calls</th><th>Primitive Calls</th><th>Total Time (s)</th><th>Cumulative Time (s)</th></tr></thead><tbody>"
|
| 76 |
+
)
|
| 77 |
+
f.write("\n".join(rows))
|
| 78 |
+
f.write("</tbody></table>\n</body></html>\n")
|
| 79 |
+
|
| 80 |
+
|
| 81 |
+
if __name__ == "__main__":
|
| 82 |
+
main()
|
source_data/pinned/behavior-1k-bddl/v3.9.3-post2/.github/scripts/resolve_diff_range.sh
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env bash
|
| 2 |
+
# Determines the base commit to diff against for diff-scoped type checking,
|
| 3 |
+
# and writes it to $GITHUB_OUTPUT as `base_sha`.
|
| 4 |
+
set -euo pipefail
|
| 5 |
+
|
| 6 |
+
if [ "$EVENT_NAME" = "pull_request" ]; then
|
| 7 |
+
git fetch --depth=1 origin "$BASE_REF"
|
| 8 |
+
base_sha=$(git merge-base "origin/$BASE_REF" HEAD)
|
| 9 |
+
else
|
| 10 |
+
base_sha="$BEFORE_SHA"
|
| 11 |
+
if [ -z "$base_sha" ] || [ "$base_sha" = "0000000000000000000000000000000000000000" ]; then
|
| 12 |
+
base_sha=$(git rev-parse HEAD~1)
|
| 13 |
+
fi
|
| 14 |
+
fi
|
| 15 |
+
|
| 16 |
+
echo "base_sha=$base_sha" >> "$GITHUB_OUTPUT"
|
source_data/pinned/behavior-1k-bddl/v3.9.3-post2/.github/workflows/build-push-containers.yml
ADDED
|
@@ -0,0 +1,157 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: build-push-containers
|
| 2 |
+
|
| 3 |
+
on:
|
| 4 |
+
release:
|
| 5 |
+
types: [published]
|
| 6 |
+
push:
|
| 7 |
+
branches:
|
| 8 |
+
- 'main'
|
| 9 |
+
workflow_dispatch:
|
| 10 |
+
inputs:
|
| 11 |
+
image_tag:
|
| 12 |
+
description: >
|
| 13 |
+
Tag to publish the manually-built behavior-dev/behavior-gha images under (e.g. the branch
|
| 14 |
+
name).
|
| 15 |
+
required: true
|
| 16 |
+
type: string
|
| 17 |
+
|
| 18 |
+
jobs:
|
| 19 |
+
docker:
|
| 20 |
+
runs-on: docker-builder # This is a larger runner with more disk space.
|
| 21 |
+
steps:
|
| 22 |
+
-
|
| 23 |
+
name: Check disk space
|
| 24 |
+
run: df . -h
|
| 25 |
+
-
|
| 26 |
+
name: Free disk space
|
| 27 |
+
run: |
|
| 28 |
+
sudo docker rmi $(docker image ls -aq) >/dev/null 2>&1 || true
|
| 29 |
+
sudo rm -rf \
|
| 30 |
+
/usr/share/dotnet /usr/local/lib/android /opt/ghc \
|
| 31 |
+
/usr/local/share/powershell /usr/share/swift /usr/local/.ghcup \
|
| 32 |
+
/usr/lib/jvm /opt/hostedtoolcache/CodeQL || true
|
| 33 |
+
echo "some directories deleted"
|
| 34 |
+
sudo apt-get update >/dev/null 2>&1
|
| 35 |
+
sudo apt install aptitude -y >/dev/null 2>&1
|
| 36 |
+
sudo aptitude purge aria2 ansible azure-cli shellcheck rpm xorriso zsync \
|
| 37 |
+
esl-erlang firefox gfortran-8 gfortran-9 google-chrome-stable \
|
| 38 |
+
google-cloud-sdk imagemagick \
|
| 39 |
+
libmagickcore-dev libmagickwand-dev libmagic-dev ant ant-optional kubectl \
|
| 40 |
+
mercurial apt-transport-https mono-complete libmysqlclient \
|
| 41 |
+
unixodbc-dev yarn chrpath libssl-dev libxft-dev \
|
| 42 |
+
libfreetype6 libfreetype6-dev libfontconfig1 libfontconfig1-dev \
|
| 43 |
+
snmp pollinate libpq-dev postgresql-client powershell ruby-full \
|
| 44 |
+
sphinxsearch subversion mongodb-org azure-cli microsoft-edge-stable \
|
| 45 |
+
-y -f >/dev/null 2>&1 || true
|
| 46 |
+
sudo aptitude purge google-cloud-sdk -f -y >/dev/null 2>&1 || true
|
| 47 |
+
sudo aptitude purge microsoft-edge-stable -f -y >/dev/null 2>&1 || true
|
| 48 |
+
sudo apt purge microsoft-edge-stable -f -y >/dev/null 2>&1 || true
|
| 49 |
+
sudo aptitude purge '~n ^mysql' -f -y >/dev/null 2>&1 || true
|
| 50 |
+
sudo aptitude purge '~n ^php' -f -y >/dev/null 2>&1 || true
|
| 51 |
+
sudo aptitude purge '~n ^dotnet' -f -y >/dev/null 2>&1 || true
|
| 52 |
+
sudo apt-get autoremove -y >/dev/null 2>&1
|
| 53 |
+
sudo apt-get autoclean -y >/dev/null 2>&1
|
| 54 |
+
echo "some packages purged"
|
| 55 |
+
-
|
| 56 |
+
name: Check disk space
|
| 57 |
+
run: |
|
| 58 |
+
df . -h
|
| 59 |
+
-
|
| 60 |
+
name: Checkout
|
| 61 |
+
uses: actions/checkout@v4
|
| 62 |
+
-
|
| 63 |
+
name: Set up Docker Buildx
|
| 64 |
+
uses: docker/setup-buildx-action@v3
|
| 65 |
+
-
|
| 66 |
+
name: Login to NVCR
|
| 67 |
+
uses: docker/login-action@v3
|
| 68 |
+
with:
|
| 69 |
+
registry: nvcr.io
|
| 70 |
+
username: ${{ secrets.NVCR_USERNAME }}
|
| 71 |
+
password: ${{ secrets.NVCR_PASSWORD }}
|
| 72 |
+
-
|
| 73 |
+
name: Login to Docker Hub
|
| 74 |
+
uses: docker/login-action@v3
|
| 75 |
+
with:
|
| 76 |
+
username: ${{ secrets.DOCKER_HUB_USERNAME }}
|
| 77 |
+
password: ${{ secrets.DOCKER_HUB_PASSWORD }}
|
| 78 |
+
-
|
| 79 |
+
name: Metadata for prod Image
|
| 80 |
+
id: meta-prod
|
| 81 |
+
if: github.event_name != 'workflow_dispatch'
|
| 82 |
+
uses: docker/metadata-action@v5
|
| 83 |
+
with:
|
| 84 |
+
images: |
|
| 85 |
+
stanfordvl/behavior
|
| 86 |
+
tags: |
|
| 87 |
+
type=ref,event=branch
|
| 88 |
+
type=semver,pattern={{version}}
|
| 89 |
+
-
|
| 90 |
+
name: Metadata for dev Image
|
| 91 |
+
id: meta-dev
|
| 92 |
+
uses: docker/metadata-action@v5
|
| 93 |
+
with:
|
| 94 |
+
images: |
|
| 95 |
+
stanfordvl/behavior-dev
|
| 96 |
+
tags: |
|
| 97 |
+
type=ref,event=branch
|
| 98 |
+
type=semver,pattern={{version}}
|
| 99 |
+
type=raw,value=${{ github.event.inputs.image_tag }},enable=${{ github.event_name == 'workflow_dispatch' }}
|
| 100 |
+
-
|
| 101 |
+
name: Metadata for actions Image
|
| 102 |
+
id: meta-actions
|
| 103 |
+
uses: docker/metadata-action@v5
|
| 104 |
+
with:
|
| 105 |
+
images: |
|
| 106 |
+
stanfordvl/behavior-gha
|
| 107 |
+
tags: |
|
| 108 |
+
type=raw,value=latest,enable=${{ github.event_name != 'workflow_dispatch' }}
|
| 109 |
+
type=raw,value=${{ github.event.inputs.image_tag }},enable=${{ github.event_name == 'workflow_dispatch' }}
|
| 110 |
+
-
|
| 111 |
+
name: Build and push prod image
|
| 112 |
+
id: build-prod
|
| 113 |
+
if: github.event_name != 'workflow_dispatch'
|
| 114 |
+
uses: docker/build-push-action@v5
|
| 115 |
+
with:
|
| 116 |
+
context: .
|
| 117 |
+
push: true
|
| 118 |
+
provenance: false
|
| 119 |
+
tags: ${{ steps.meta-prod.outputs.tags }}
|
| 120 |
+
labels: ${{ steps.meta-prod.outputs.labels }}
|
| 121 |
+
file: docker/Dockerfile
|
| 122 |
+
cache-from: type=registry,ref=stanfordvl/behavior:build-cache
|
| 123 |
+
cache-to: type=registry,ref=stanfordvl/behavior:build-cache,mode=max
|
| 124 |
+
|
| 125 |
+
-
|
| 126 |
+
name: Build and push dev image
|
| 127 |
+
id: build-dev
|
| 128 |
+
uses: docker/build-push-action@v5
|
| 129 |
+
with:
|
| 130 |
+
context: .
|
| 131 |
+
build-args: "DEV_MODE=1"
|
| 132 |
+
push: true
|
| 133 |
+
provenance: false
|
| 134 |
+
tags: ${{ steps.meta-dev.outputs.tags }}
|
| 135 |
+
labels: ${{ steps.meta-dev.outputs.labels }}
|
| 136 |
+
file: docker/Dockerfile
|
| 137 |
+
# Manual workflow_dispatch builds read from the shared cache for speed but never write to
|
| 138 |
+
# it, so a broken branch build can never poison the cache used by the real main/release
|
| 139 |
+
# builds.
|
| 140 |
+
cache-from: type=registry,ref=stanfordvl/behavior:build-cache
|
| 141 |
+
cache-to: ${{ github.event_name != 'workflow_dispatch' && 'type=registry,ref=stanfordvl/behavior:build-cache,mode=max' || '' }}
|
| 142 |
+
|
| 143 |
+
- name: Update actions image Dockerfile with dev image tag
|
| 144 |
+
run: |
|
| 145 |
+
sed -i "s/behavior-dev:latest/behavior-dev@${{ steps.build-dev.outputs.digest }}/g" docker/gh-actions/Dockerfile && cat docker/gh-actions/Dockerfile
|
| 146 |
+
-
|
| 147 |
+
name: Build and push actions image
|
| 148 |
+
id: build-actions
|
| 149 |
+
uses: docker/build-push-action@v5
|
| 150 |
+
with:
|
| 151 |
+
context: docker/gh-actions
|
| 152 |
+
push: true
|
| 153 |
+
tags: ${{ steps.meta-actions.outputs.tags }}
|
| 154 |
+
labels: ${{ steps.meta-actions.outputs.labels }}
|
| 155 |
+
file: docker/gh-actions/Dockerfile
|
| 156 |
+
cache-from: type=registry,ref=stanfordvl/behavior:build-cache
|
| 157 |
+
cache-to: ${{ github.event_name != 'workflow_dispatch' && 'type=registry,ref=stanfordvl/behavior:build-cache,mode=max' || '' }}
|
source_data/pinned/behavior-1k-bddl/v3.9.3-post2/.github/workflows/build-website.yml
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: Build and deploy BEHAVIOR website
|
| 2 |
+
|
| 3 |
+
on:
|
| 4 |
+
schedule:
|
| 5 |
+
- cron: "0 10 * * *" # Every day at 10am
|
| 6 |
+
workflow_dispatch:
|
| 7 |
+
push:
|
| 8 |
+
branches:
|
| 9 |
+
- main
|
| 10 |
+
|
| 11 |
+
permissions:
|
| 12 |
+
contents: read
|
| 13 |
+
pages: write
|
| 14 |
+
id-token: write
|
| 15 |
+
|
| 16 |
+
concurrency:
|
| 17 |
+
group: "pages"
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
jobs:
|
| 21 |
+
build:
|
| 22 |
+
runs-on: [self-hosted, linux]
|
| 23 |
+
|
| 24 |
+
steps:
|
| 25 |
+
- name: Fix home
|
| 26 |
+
run: echo "HOME=/root" >> $GITHUB_ENV
|
| 27 |
+
|
| 28 |
+
- name: Checkout source
|
| 29 |
+
uses: actions/checkout@v4
|
| 30 |
+
|
| 31 |
+
- name: Install BDDL
|
| 32 |
+
working-directory: bddl3
|
| 33 |
+
run: pip install -e .
|
| 34 |
+
|
| 35 |
+
- name: Install
|
| 36 |
+
working-directory: OmniGibson
|
| 37 |
+
run: pip install -e .[dev]
|
| 38 |
+
|
| 39 |
+
- name: Build docs
|
| 40 |
+
run: mkdocs build # TODO: Shouldn't we copy over the src directory here?
|
| 41 |
+
|
| 42 |
+
# # See if we need to rebuild the whole thing
|
| 43 |
+
# - name: Get BDDL hash
|
| 44 |
+
# id: bddl-hash
|
| 45 |
+
# working-directory: bddl3
|
| 46 |
+
# run: echo hash=$(git rev-parse HEAD) >> "$GITHUB_OUTPUT"
|
| 47 |
+
|
| 48 |
+
# - name: Get knowledgebase hash
|
| 49 |
+
# id: website-hash
|
| 50 |
+
# working-directory: knowledgebase
|
| 51 |
+
# run: echo hash=$(git rev-parse HEAD) >> "$GITHUB_OUTPUT"
|
| 52 |
+
|
| 53 |
+
# - name: Check cache for overall data
|
| 54 |
+
# id: cache-knowledgebase
|
| 55 |
+
# uses: actions/cache@v3
|
| 56 |
+
# with:
|
| 57 |
+
# key: knowledgebase-${{ steps.website-hash.outputs.hash }}-${{ steps.bddl-hash.outputs.hash }}
|
| 58 |
+
# path: README.md
|
| 59 |
+
# lookup-only: true
|
| 60 |
+
|
| 61 |
+
# - if: ${{ steps.cache-knowledgebase.outputs.cache-hit != 'true' }}
|
| 62 |
+
- name: Install other dependencies
|
| 63 |
+
working-directory: knowledgebase
|
| 64 |
+
run: pip install -r requirements.txt
|
| 65 |
+
|
| 66 |
+
# - if: ${{ steps.cache-knowledgebase.outputs.cache-hit != 'true' }}
|
| 67 |
+
- name: Generate static knowledgebase site
|
| 68 |
+
working-directory: knowledgebase
|
| 69 |
+
run: python build_static_site.py
|
| 70 |
+
|
| 71 |
+
- name: Move knowledgebase to combined site
|
| 72 |
+
run: cp -R knowledgebase/build/knowledgebase site
|
| 73 |
+
|
| 74 |
+
- name: Upload pages artifact
|
| 75 |
+
uses: actions/upload-pages-artifact@v3
|
| 76 |
+
with:
|
| 77 |
+
path: site/
|
| 78 |
+
|
| 79 |
+
# Deploy on github pages
|
| 80 |
+
deploy:
|
| 81 |
+
environment:
|
| 82 |
+
name: github-pages
|
| 83 |
+
url: ${{ steps.deployment.outputs.page_url }}
|
| 84 |
+
runs-on: ubuntu-latest
|
| 85 |
+
needs: build
|
| 86 |
+
steps:
|
| 87 |
+
- name: Deploy to GitHub Pages
|
| 88 |
+
id: deployment
|
| 89 |
+
uses: actions/deploy-pages@v4
|
source_data/pinned/behavior-1k-bddl/v3.9.3-post2/.github/workflows/profiling.yml
ADDED
|
@@ -0,0 +1,305 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: Profiling
|
| 2 |
+
|
| 3 |
+
on:
|
| 4 |
+
pull_request:
|
| 5 |
+
push:
|
| 6 |
+
branches:
|
| 7 |
+
- main
|
| 8 |
+
workflow_dispatch:
|
| 9 |
+
|
| 10 |
+
permissions:
|
| 11 |
+
pull-requests: write
|
| 12 |
+
contents: read
|
| 13 |
+
|
| 14 |
+
concurrency:
|
| 15 |
+
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }}
|
| 16 |
+
cancel-in-progress: true
|
| 17 |
+
|
| 18 |
+
jobs:
|
| 19 |
+
profile:
|
| 20 |
+
name: "Profile: ${{ matrix.label }}"
|
| 21 |
+
runs-on: [self-hosted, linux, gpu, dataset-enabled]
|
| 22 |
+
|
| 23 |
+
strategy:
|
| 24 |
+
fail-fast: false
|
| 25 |
+
matrix:
|
| 26 |
+
include:
|
| 27 |
+
# Baselines (GPU dynamics)
|
| 28 |
+
- name: baseline-empty
|
| 29 |
+
args: "-g"
|
| 30 |
+
label: "Empty scene"
|
| 31 |
+
- name: baseline-empty-1robot
|
| 32 |
+
args: "-g -r 1"
|
| 33 |
+
label: "Empty scene + 1 Robot"
|
| 34 |
+
- name: baseline-rs-int
|
| 35 |
+
args: "-g -s Rs_int"
|
| 36 |
+
label: "Rs_int"
|
| 37 |
+
- name: baseline-rs-int-1robot
|
| 38 |
+
args: "-g -s Rs_int -r 1"
|
| 39 |
+
label: "Rs_int + 1 Robot"
|
| 40 |
+
- name: deep-rs-int-1robot
|
| 41 |
+
args: "-g -s Rs_int -r 1 -d"
|
| 42 |
+
label: "Rs_int + 1 Robot (deep profile)"
|
| 43 |
+
deep_profile: true
|
| 44 |
+
# Scenes
|
| 45 |
+
- name: scene-house
|
| 46 |
+
args: "-r 1 -s house_single_floor"
|
| 47 |
+
label: "house_single_floor + 1 Robot"
|
| 48 |
+
# Non-physics features (GPU dynamics)
|
| 49 |
+
- name: feature-fluids
|
| 50 |
+
args: "-g -r 1 -w"
|
| 51 |
+
label: "1 Robot + fluids"
|
| 52 |
+
- name: feature-cloth
|
| 53 |
+
args: "-g -r 1 -c"
|
| 54 |
+
label: "1 Robot + cloth"
|
| 55 |
+
- name: feature-particles
|
| 56 |
+
args: "-g -r 1 -p"
|
| 57 |
+
label: "1 Robot + macro particles"
|
| 58 |
+
|
| 59 |
+
defaults:
|
| 60 |
+
run:
|
| 61 |
+
working-directory: ${{ github.workspace }}/OmniGibson
|
| 62 |
+
|
| 63 |
+
steps:
|
| 64 |
+
- name: Checkout source
|
| 65 |
+
uses: actions/checkout@v4
|
| 66 |
+
with:
|
| 67 |
+
submodules: true
|
| 68 |
+
|
| 69 |
+
- name: Install BDDL
|
| 70 |
+
run: pip install -e .
|
| 71 |
+
working-directory: ${{ github.workspace }}/bddl3
|
| 72 |
+
|
| 73 |
+
- name: Install OmniGibson
|
| 74 |
+
run: pip install -e .[dev,primitives,eval] --no-build-isolation
|
| 75 |
+
|
| 76 |
+
- name: Install deep profiling dependencies
|
| 77 |
+
if: matrix.deep_profile
|
| 78 |
+
run: pip install snakeviz
|
| 79 |
+
|
| 80 |
+
- name: Run profiling
|
| 81 |
+
run: |
|
| 82 |
+
rm -f output.json
|
| 83 |
+
python tests/benchmark/profiling.py ${{ matrix.args }}
|
| 84 |
+
|
| 85 |
+
- name: Convert deep profile to HTML
|
| 86 |
+
if: matrix.deep_profile
|
| 87 |
+
run: |
|
| 88 |
+
for prof in load.prof step.prof pre_physics_step.prof post_physics_step.prof non_physics_step.prof; do
|
| 89 |
+
python ../.github/scripts/cprofile_to_html.py \
|
| 90 |
+
--profile "$prof" \
|
| 91 |
+
--output "${prof%.prof}.html"
|
| 92 |
+
done
|
| 93 |
+
|
| 94 |
+
- name: Upload results
|
| 95 |
+
uses: actions/upload-artifact@v4
|
| 96 |
+
if: always()
|
| 97 |
+
with:
|
| 98 |
+
name: profiling-${{ matrix.name }}
|
| 99 |
+
path: OmniGibson/output.json
|
| 100 |
+
if-no-files-found: warn
|
| 101 |
+
|
| 102 |
+
- name: Upload deep profile outputs
|
| 103 |
+
uses: actions/upload-artifact@v4
|
| 104 |
+
if: always() && matrix.deep_profile
|
| 105 |
+
with:
|
| 106 |
+
name: profiling-deep-${{ matrix.name }}
|
| 107 |
+
path: |
|
| 108 |
+
OmniGibson/load.prof
|
| 109 |
+
OmniGibson/load.html
|
| 110 |
+
OmniGibson/step.prof
|
| 111 |
+
OmniGibson/step.html
|
| 112 |
+
OmniGibson/pre_physics_step.prof
|
| 113 |
+
OmniGibson/pre_physics_step.html
|
| 114 |
+
OmniGibson/post_physics_step.prof
|
| 115 |
+
OmniGibson/post_physics_step.html
|
| 116 |
+
OmniGibson/non_physics_step.prof
|
| 117 |
+
OmniGibson/non_physics_step.html
|
| 118 |
+
if-no-files-found: warn
|
| 119 |
+
|
| 120 |
+
report:
|
| 121 |
+
name: Compile Profiling Report
|
| 122 |
+
runs-on: ubuntu-latest
|
| 123 |
+
needs: [profile]
|
| 124 |
+
if: always() && github.event_name == 'pull_request'
|
| 125 |
+
permissions:
|
| 126 |
+
pull-requests: write
|
| 127 |
+
steps:
|
| 128 |
+
- name: Download PR profiling results
|
| 129 |
+
uses: actions/download-artifact@v4
|
| 130 |
+
continue-on-error: true
|
| 131 |
+
with:
|
| 132 |
+
path: pr-results
|
| 133 |
+
pattern: profiling-*
|
| 134 |
+
|
| 135 |
+
- name: Restore baseline from main
|
| 136 |
+
uses: actions/cache/restore@v4
|
| 137 |
+
continue-on-error: true
|
| 138 |
+
with:
|
| 139 |
+
path: baseline
|
| 140 |
+
key: profiling-baseline-${{ github.event.pull_request.base.sha }}
|
| 141 |
+
restore-keys: |
|
| 142 |
+
profiling-baseline-
|
| 143 |
+
|
| 144 |
+
- name: Generate report
|
| 145 |
+
run: |
|
| 146 |
+
python3 << 'PYEOF'
|
| 147 |
+
import json, os
|
| 148 |
+
|
| 149 |
+
SCENARIOS = [
|
| 150 |
+
("profiling-baseline-empty", "Empty scene", "Baselines (GPU dynamics)"),
|
| 151 |
+
("profiling-baseline-empty-1robot", "Empty scene + 1 Robot", "Baselines (GPU dynamics)"),
|
| 152 |
+
("profiling-baseline-rs-int", "Rs_int", "Baselines (GPU dynamics)"),
|
| 153 |
+
("profiling-baseline-rs-int-1robot", "Rs_int + 1 Robot", "Baselines (GPU dynamics)"),
|
| 154 |
+
("profiling-scene-house", "house_single_floor + 1 Robot", "Scenes"),
|
| 155 |
+
("profiling-feature-fluids", "1 Robot + fluids", "Non-physics features (GPU dynamics)"),
|
| 156 |
+
("profiling-feature-cloth", "1 Robot + cloth", "Non-physics features (GPU dynamics)"),
|
| 157 |
+
("profiling-feature-particles", "1 Robot + macro particles", "Non-physics features (GPU dynamics)"),
|
| 158 |
+
]
|
| 159 |
+
|
| 160 |
+
METRICS = ["FPS", "Loading time", "Isaac step time", "Non-Isaac step time", "Memory usage", "Vram usage"]
|
| 161 |
+
HEADERS = {
|
| 162 |
+
"FPS": "FPS",
|
| 163 |
+
"Loading time": "Load (s)",
|
| 164 |
+
"Isaac step time": "Isaac (ms)",
|
| 165 |
+
"Non-Isaac step time": "Non-Isaac (ms)",
|
| 166 |
+
"Memory usage": "Mem (GB)",
|
| 167 |
+
"Vram usage": "VRAM (GB)",
|
| 168 |
+
}
|
| 169 |
+
HIGHER_IS_BETTER = {"FPS"}
|
| 170 |
+
|
| 171 |
+
def load_results(base_path):
|
| 172 |
+
results = {}
|
| 173 |
+
if not os.path.isdir(base_path):
|
| 174 |
+
return results
|
| 175 |
+
for dir_name, _, _ in SCENARIOS:
|
| 176 |
+
json_path = os.path.join(base_path, dir_name, "output.json")
|
| 177 |
+
if not os.path.exists(json_path):
|
| 178 |
+
continue
|
| 179 |
+
with open(json_path) as f:
|
| 180 |
+
data = json.load(f)
|
| 181 |
+
metrics = {}
|
| 182 |
+
for entry in data:
|
| 183 |
+
metrics[entry["extra"][0]] = entry["value"]
|
| 184 |
+
results[dir_name] = metrics
|
| 185 |
+
return results
|
| 186 |
+
|
| 187 |
+
def fmt(metric, value):
|
| 188 |
+
if value is None:
|
| 189 |
+
return "N/A"
|
| 190 |
+
return f"{value:.1f}" if metric in ("FPS", "Loading time") else f"{value:.2f}"
|
| 191 |
+
|
| 192 |
+
def delta(metric, pr_val, base_val):
|
| 193 |
+
if pr_val is None or base_val is None or base_val == 0:
|
| 194 |
+
return ""
|
| 195 |
+
pct = ((pr_val - base_val) / abs(base_val)) * 100
|
| 196 |
+
is_better = (pct > 0) if metric in HIGHER_IS_BETTER else (pct < 0)
|
| 197 |
+
if abs(pct) < 5:
|
| 198 |
+
emoji = "⚪"
|
| 199 |
+
elif is_better:
|
| 200 |
+
emoji = "🟢"
|
| 201 |
+
else:
|
| 202 |
+
emoji = "🔴"
|
| 203 |
+
sign = "+" if pct > 0 else ""
|
| 204 |
+
return f" ({sign}{pct:.1f}% {emoji})"
|
| 205 |
+
|
| 206 |
+
pr = load_results("pr-results")
|
| 207 |
+
base = load_results("baseline")
|
| 208 |
+
has_base = len(base) > 0
|
| 209 |
+
|
| 210 |
+
lines = ["## Profiling Report\n"]
|
| 211 |
+
if not has_base:
|
| 212 |
+
lines.append("> **Note:** No baseline found from `main`. Showing absolute values only.\n")
|
| 213 |
+
|
| 214 |
+
current_group = None
|
| 215 |
+
for dir_name, label, group in SCENARIOS:
|
| 216 |
+
if group != current_group:
|
| 217 |
+
current_group = group
|
| 218 |
+
lines.append(f"\n### {group}\n")
|
| 219 |
+
hdr = "| Scenario |" + "".join(f" {HEADERS[m]} |" for m in METRICS)
|
| 220 |
+
sep = "|---|" + "---|" * len(METRICS)
|
| 221 |
+
lines.append(hdr)
|
| 222 |
+
lines.append(sep)
|
| 223 |
+
|
| 224 |
+
pr_m = pr.get(dir_name, {})
|
| 225 |
+
if not pr_m:
|
| 226 |
+
lines.append(f"| {label} |" + " N/A |" * len(METRICS))
|
| 227 |
+
continue
|
| 228 |
+
|
| 229 |
+
base_m = base.get(dir_name, {})
|
| 230 |
+
row = f"| {label}"
|
| 231 |
+
for m in METRICS:
|
| 232 |
+
pv, bv = pr_m.get(m), base_m.get(m)
|
| 233 |
+
cell = fmt(m, pv)
|
| 234 |
+
if has_base and pv is not None:
|
| 235 |
+
cell += delta(m, pv, bv)
|
| 236 |
+
row += f" | {cell}"
|
| 237 |
+
lines.append(row + " |")
|
| 238 |
+
|
| 239 |
+
lines.append("")
|
| 240 |
+
lines.append("### Deep profile artifacts")
|
| 241 |
+
lines.append(
|
| 242 |
+
f"Download deep profile HTML reports and raw .prof files from the "
|
| 243 |
+
f"[Actions artifacts](https://github.com/{os.environ['GITHUB_REPOSITORY']}/actions/runs/{os.environ['GITHUB_RUN_ID']}#artifacts) "
|
| 244 |
+
f"(artifact prefix: `profiling-deep-`). Includes:"
|
| 245 |
+
)
|
| 246 |
+
lines.append("- `load` — environment loading")
|
| 247 |
+
lines.append("- `step` — full simulation step")
|
| 248 |
+
lines.append("- `pre_physics_step` — pre-physics step processing")
|
| 249 |
+
lines.append("- `post_physics_step` — post-physics step processing")
|
| 250 |
+
lines.append("- `non_physics_step` — non-physics step processing")
|
| 251 |
+
|
| 252 |
+
lines.append("")
|
| 253 |
+
lines.append("<details><summary>Legend</summary>\n")
|
| 254 |
+
lines.append("- 🟢 Improvement >= 5%")
|
| 255 |
+
lines.append("- 🔴 Regression >= 5%")
|
| 256 |
+
lines.append("- ⚪ Change < 5%")
|
| 257 |
+
lines.append("- For **FPS**, higher is better. For all other metrics, lower is better.")
|
| 258 |
+
lines.append("\n</details>")
|
| 259 |
+
|
| 260 |
+
report = "\n".join(lines)
|
| 261 |
+
with open("profiling-report.md", "w") as f:
|
| 262 |
+
f.write(report)
|
| 263 |
+
print(report)
|
| 264 |
+
PYEOF
|
| 265 |
+
|
| 266 |
+
- name: Post PR comment
|
| 267 |
+
uses: marocchino/sticky-pull-request-comment@v2
|
| 268 |
+
with:
|
| 269 |
+
header: profiling-report
|
| 270 |
+
path: profiling-report.md
|
| 271 |
+
|
| 272 |
+
save_baseline:
|
| 273 |
+
name: Save Baseline
|
| 274 |
+
runs-on: ubuntu-latest
|
| 275 |
+
needs: [profile]
|
| 276 |
+
if: always() && github.event_name == 'push' && github.ref == 'refs/heads/main'
|
| 277 |
+
steps:
|
| 278 |
+
- name: Restore previous baseline
|
| 279 |
+
uses: actions/cache/restore@v4
|
| 280 |
+
continue-on-error: true
|
| 281 |
+
with:
|
| 282 |
+
path: baseline
|
| 283 |
+
key: profiling-baseline-do-not-match
|
| 284 |
+
restore-keys: |
|
| 285 |
+
profiling-baseline-
|
| 286 |
+
|
| 287 |
+
- name: Download new profiling results
|
| 288 |
+
uses: actions/download-artifact@v4
|
| 289 |
+
continue-on-error: true
|
| 290 |
+
with:
|
| 291 |
+
path: new-results
|
| 292 |
+
pattern: profiling-*
|
| 293 |
+
|
| 294 |
+
- name: Merge into baseline
|
| 295 |
+
run: |
|
| 296 |
+
mkdir -p baseline
|
| 297 |
+
if [ -d new-results ]; then
|
| 298 |
+
cp -r new-results/* baseline/
|
| 299 |
+
fi
|
| 300 |
+
|
| 301 |
+
- name: Save baseline cache
|
| 302 |
+
uses: actions/cache/save@v4
|
| 303 |
+
with:
|
| 304 |
+
path: baseline
|
| 305 |
+
key: profiling-baseline-${{ github.sha }}
|
source_data/pinned/behavior-1k-bddl/v3.9.3-post2/.github/workflows/profiling_vector.yml
ADDED
|
@@ -0,0 +1,306 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: Vector Profiling
|
| 2 |
+
|
| 3 |
+
on:
|
| 4 |
+
pull_request:
|
| 5 |
+
branches:
|
| 6 |
+
- vec/merge-vector-into-main
|
| 7 |
+
- main
|
| 8 |
+
push:
|
| 9 |
+
branches:
|
| 10 |
+
- main
|
| 11 |
+
workflow_dispatch:
|
| 12 |
+
|
| 13 |
+
permissions:
|
| 14 |
+
pull-requests: write
|
| 15 |
+
contents: read
|
| 16 |
+
|
| 17 |
+
concurrency:
|
| 18 |
+
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.ref }}
|
| 19 |
+
cancel-in-progress: true
|
| 20 |
+
|
| 21 |
+
jobs:
|
| 22 |
+
profile:
|
| 23 |
+
name: "VecProfile: ${{ matrix.label }}"
|
| 24 |
+
runs-on: [self-hosted, linux, gpu, dataset-enabled, titanrtx]
|
| 25 |
+
|
| 26 |
+
strategy:
|
| 27 |
+
fail-fast: false
|
| 28 |
+
matrix:
|
| 29 |
+
include:
|
| 30 |
+
# 1 env
|
| 31 |
+
- name: "1env-norender-simple-nostates"
|
| 32 |
+
args: "--n-envs 1"
|
| 33 |
+
label: "1 env, no render, simple, states off"
|
| 34 |
+
- name: "1env-norender-simple-states"
|
| 35 |
+
args: "--n-envs 1 --object-states"
|
| 36 |
+
label: "1 env, no render, simple, states on"
|
| 37 |
+
- name: "1env-norender-behavior-states"
|
| 38 |
+
args: "--n-envs 1 --task-type behavior --object-states"
|
| 39 |
+
label: "1 env, no render, behavior, states on"
|
| 40 |
+
- name: "1env-render-simple-nostates"
|
| 41 |
+
args: "--n-envs 1 --rendering"
|
| 42 |
+
label: "1 env, render, simple, states off"
|
| 43 |
+
- name: "1env-render-simple-states"
|
| 44 |
+
args: "--n-envs 1 --rendering --object-states"
|
| 45 |
+
label: "1 env, render, simple, states on"
|
| 46 |
+
- name: "1env-render-behavior-states"
|
| 47 |
+
args: "--n-envs 1 --rendering --task-type behavior --object-states"
|
| 48 |
+
label: "1 env, render, behavior, states on"
|
| 49 |
+
- name: "1env-norender-navigation-nostates"
|
| 50 |
+
args: "--n-envs 1 --task-type navigation"
|
| 51 |
+
label: "1 env, no render, navigation, states off"
|
| 52 |
+
- name: "1env-norender-navigation-states"
|
| 53 |
+
args: "--n-envs 1 --task-type navigation --object-states"
|
| 54 |
+
label: "1 env, no render, navigation, states on"
|
| 55 |
+
- name: "1env-render-navigation-nostates"
|
| 56 |
+
args: "--n-envs 1 --rendering --task-type navigation"
|
| 57 |
+
label: "1 env, render, navigation, states off"
|
| 58 |
+
- name: "1env-render-navigation-states"
|
| 59 |
+
args: "--n-envs 1 --rendering --task-type navigation --object-states"
|
| 60 |
+
label: "1 env, render, navigation, states on"
|
| 61 |
+
# 10 envs
|
| 62 |
+
- name: "10env-norender-simple-nostates"
|
| 63 |
+
args: "--n-envs 10"
|
| 64 |
+
label: "10 envs, no render, simple, states off"
|
| 65 |
+
- name: "10env-norender-simple-states"
|
| 66 |
+
args: "--n-envs 10 --object-states"
|
| 67 |
+
label: "10 envs, no render, simple, states on"
|
| 68 |
+
- name: "10env-norender-behavior-states"
|
| 69 |
+
args: "--n-envs 10 --task-type behavior --object-states"
|
| 70 |
+
label: "10 envs, no render, behavior, states on"
|
| 71 |
+
- name: "10env-render-simple-nostates"
|
| 72 |
+
args: "--n-envs 10 --rendering"
|
| 73 |
+
label: "10 envs, render, simple, states off"
|
| 74 |
+
- name: "10env-render-simple-states"
|
| 75 |
+
args: "--n-envs 10 --rendering --object-states"
|
| 76 |
+
label: "10 envs, render, simple, states on"
|
| 77 |
+
- name: "10env-render-behavior-states"
|
| 78 |
+
args: "--n-envs 10 --rendering --task-type behavior --object-states"
|
| 79 |
+
label: "10 envs, render, behavior, states on"
|
| 80 |
+
- name: "10env-norender-navigation-nostates"
|
| 81 |
+
args: "--n-envs 10 --task-type navigation"
|
| 82 |
+
label: "10 envs, no render, navigation, states off"
|
| 83 |
+
- name: "10env-norender-navigation-states"
|
| 84 |
+
args: "--n-envs 10 --task-type navigation --object-states"
|
| 85 |
+
label: "10 envs, no render, navigation, states on"
|
| 86 |
+
- name: "10env-render-navigation-nostates"
|
| 87 |
+
args: "--n-envs 10 --rendering --task-type navigation"
|
| 88 |
+
label: "10 envs, render, navigation, states off"
|
| 89 |
+
- name: "10env-render-navigation-states"
|
| 90 |
+
args: "--n-envs 10 --rendering --task-type navigation --object-states"
|
| 91 |
+
label: "10 envs, render, navigation, states on"
|
| 92 |
+
|
| 93 |
+
defaults:
|
| 94 |
+
run:
|
| 95 |
+
working-directory: ${{ github.workspace }}/OmniGibson
|
| 96 |
+
|
| 97 |
+
steps:
|
| 98 |
+
- name: Checkout source
|
| 99 |
+
uses: actions/checkout@v4
|
| 100 |
+
with:
|
| 101 |
+
submodules: true
|
| 102 |
+
|
| 103 |
+
- name: Install BDDL
|
| 104 |
+
run: pip install -e .
|
| 105 |
+
working-directory: ${{ github.workspace }}/bddl3
|
| 106 |
+
|
| 107 |
+
- name: Install OmniGibson
|
| 108 |
+
run: pip install -e .[dev,primitives,eval] --no-build-isolation
|
| 109 |
+
|
| 110 |
+
- name: Run vector profiling
|
| 111 |
+
env:
|
| 112 |
+
OMNIGIBSON_HEADLESS: "1"
|
| 113 |
+
run: |
|
| 114 |
+
rm -f vector_output.json
|
| 115 |
+
python tests/benchmark/vector_profiling.py -g ${{ matrix.args }}
|
| 116 |
+
|
| 117 |
+
- name: Upload results
|
| 118 |
+
uses: actions/upload-artifact@v4
|
| 119 |
+
if: always()
|
| 120 |
+
with:
|
| 121 |
+
name: vec-profiling-${{ matrix.name }}
|
| 122 |
+
path: OmniGibson/vector_output.json
|
| 123 |
+
if-no-files-found: warn
|
| 124 |
+
|
| 125 |
+
report:
|
| 126 |
+
name: Compile Vector Profiling Report
|
| 127 |
+
runs-on: ubuntu-latest
|
| 128 |
+
needs: [profile]
|
| 129 |
+
if: always() && github.event_name == 'pull_request'
|
| 130 |
+
permissions:
|
| 131 |
+
pull-requests: write
|
| 132 |
+
|
| 133 |
+
steps:
|
| 134 |
+
- name: Download PR profiling results
|
| 135 |
+
uses: actions/download-artifact@v4
|
| 136 |
+
continue-on-error: true
|
| 137 |
+
with:
|
| 138 |
+
path: pr-results
|
| 139 |
+
pattern: vec-profiling-*
|
| 140 |
+
|
| 141 |
+
- name: Restore baseline from vector
|
| 142 |
+
uses: actions/cache/restore@v4
|
| 143 |
+
continue-on-error: true
|
| 144 |
+
with:
|
| 145 |
+
path: baseline
|
| 146 |
+
key: vec-profiling-baseline-${{ github.event.pull_request.base.sha }}
|
| 147 |
+
restore-keys: |
|
| 148 |
+
vec-profiling-baseline-
|
| 149 |
+
|
| 150 |
+
- name: Merge results and build comparison report
|
| 151 |
+
run: |
|
| 152 |
+
python3 << 'PYEOF'
|
| 153 |
+
import json, os
|
| 154 |
+
|
| 155 |
+
# Walk a directory of downloaded artifacts and concatenate every vector_output.json found.
|
| 156 |
+
def collect(results_dir):
|
| 157 |
+
merged = []
|
| 158 |
+
if os.path.isdir(results_dir):
|
| 159 |
+
for dirpath, _, filenames in os.walk(results_dir):
|
| 160 |
+
for fname in filenames:
|
| 161 |
+
if fname == "vector_output.json":
|
| 162 |
+
with open(os.path.join(dirpath, fname)) as f:
|
| 163 |
+
merged.extend(json.load(f))
|
| 164 |
+
return merged
|
| 165 |
+
|
| 166 |
+
# Build lookup: label -> metric -> value
|
| 167 |
+
def build_lookup(entries):
|
| 168 |
+
result = {}
|
| 169 |
+
for e in entries:
|
| 170 |
+
label = e["name"]
|
| 171 |
+
metric = e["extra"][0]
|
| 172 |
+
if label not in result:
|
| 173 |
+
result[label] = {}
|
| 174 |
+
result[label][metric] = e["value"]
|
| 175 |
+
return result
|
| 176 |
+
|
| 177 |
+
pr = build_lookup(collect("pr-results"))
|
| 178 |
+
base = build_lookup(collect("baseline"))
|
| 179 |
+
has_base = len(base) > 0
|
| 180 |
+
|
| 181 |
+
METRICS = ["FPS", "Loading time", "Isaac step time", "Non-Isaac step time", "Memory usage", "Vram usage"]
|
| 182 |
+
HEADERS = {
|
| 183 |
+
"FPS": "FPS",
|
| 184 |
+
"Loading time": "Load (s)",
|
| 185 |
+
"Isaac step time": "Isaac (ms)",
|
| 186 |
+
"Non-Isaac step time": "Non-Isaac (ms)",
|
| 187 |
+
"Memory usage": "Mem (GB)",
|
| 188 |
+
"Vram usage": "VRAM (GB)",
|
| 189 |
+
}
|
| 190 |
+
HIGHER_IS_BETTER = {"FPS"}
|
| 191 |
+
N_ENV_GROUPS = ["1 env", "10 envs"]
|
| 192 |
+
REFERENCE_GROUP = N_ENV_GROUPS[0]
|
| 193 |
+
|
| 194 |
+
def fmt(metric, value):
|
| 195 |
+
if value is None:
|
| 196 |
+
return "N/A"
|
| 197 |
+
return f"{value:.1f}" if metric in ("FPS", "Loading time") else f"{value:.2f}"
|
| 198 |
+
|
| 199 |
+
def delta(metric, pr_val, base_val):
|
| 200 |
+
if pr_val is None or base_val is None or base_val == 0:
|
| 201 |
+
return ""
|
| 202 |
+
pct = ((pr_val - base_val) / abs(base_val)) * 100
|
| 203 |
+
is_better = (pct > 0) if metric in HIGHER_IS_BETTER else (pct < 0)
|
| 204 |
+
emoji = "⚪" if abs(pct) < 5 else ("🟢" if is_better else "🔴")
|
| 205 |
+
sign = "+" if pct > 0 else ""
|
| 206 |
+
return f" ({sign}{pct:.1f}% {emoji})"
|
| 207 |
+
|
| 208 |
+
# Ratio of this scenario against the same scenario at REFERENCE_GROUP env count, so the
|
| 209 |
+
# multi-env rows show how each metric scales with n_envs (e.g. "x4.2" load, "x9.0" FPS).
|
| 210 |
+
def scaling(label, metric, value):
|
| 211 |
+
if value is None or ", " not in label:
|
| 212 |
+
return ""
|
| 213 |
+
ref_label = REFERENCE_GROUP + ", " + label.split(", ", 1)[1]
|
| 214 |
+
ref_val = pr.get(ref_label, {}).get(metric)
|
| 215 |
+
if ref_val is None or ref_val == 0:
|
| 216 |
+
return ""
|
| 217 |
+
return f" [x{value / ref_val:.1f}]"
|
| 218 |
+
|
| 219 |
+
lines = ["## Vector Profiling Report\n"]
|
| 220 |
+
if not has_base:
|
| 221 |
+
lines.append("> **Note:** No baseline found. Showing absolute values only.\n")
|
| 222 |
+
|
| 223 |
+
all_labels = sorted(pr.keys())
|
| 224 |
+
|
| 225 |
+
for group in N_ENV_GROUPS:
|
| 226 |
+
group_labels = [l for l in all_labels if l.startswith(group + ",")]
|
| 227 |
+
if not group_labels:
|
| 228 |
+
continue
|
| 229 |
+
lines.append(f"\n### {group}\n")
|
| 230 |
+
hdr = "| Scenario |" + "".join(f" {HEADERS[m]} |" for m in METRICS)
|
| 231 |
+
sep = "|---|" + "---|" * len(METRICS)
|
| 232 |
+
lines.append(hdr)
|
| 233 |
+
lines.append(sep)
|
| 234 |
+
for label in sorted(group_labels):
|
| 235 |
+
pr_m = pr.get(label, {})
|
| 236 |
+
base_m = base.get(label, {})
|
| 237 |
+
row = f"| {label.split(', ', 1)[1] if ', ' in label else label}"
|
| 238 |
+
for m in METRICS:
|
| 239 |
+
pv = pr_m.get(m)
|
| 240 |
+
bv = base_m.get(m)
|
| 241 |
+
cell = fmt(m, pv)
|
| 242 |
+
if has_base and pv is not None:
|
| 243 |
+
cell += delta(m, pv, bv)
|
| 244 |
+
if group != REFERENCE_GROUP:
|
| 245 |
+
cell += scaling(label, m, pv)
|
| 246 |
+
row += f" | {cell}"
|
| 247 |
+
lines.append(row + " |")
|
| 248 |
+
|
| 249 |
+
lines.append("")
|
| 250 |
+
lines.append("<details><summary>Legend</summary>\n")
|
| 251 |
+
lines.append("- 🟢 Improvement >= 5%")
|
| 252 |
+
lines.append("- 🔴 Regression >= 5%")
|
| 253 |
+
lines.append("- ⚪ Change < 5%")
|
| 254 |
+
lines.append("- **FPS**: higher is better. All other metrics: lower is better.")
|
| 255 |
+
lines.append("- FPS = total throughput across all envs (n_envs × per-env FPS)")
|
| 256 |
+
lines.append(f"- `[xN.N]` = ratio against the same scenario at {REFERENCE_GROUP}. "
|
| 257 |
+
"For FPS this is the throughput speed-up (higher is better); "
|
| 258 |
+
"for every other metric it is the growth factor (lower is better).")
|
| 259 |
+
lines.append("\n</details>")
|
| 260 |
+
|
| 261 |
+
report = "\n".join(lines)
|
| 262 |
+
with open("profiling-vector-report.md", "w") as f:
|
| 263 |
+
f.write(report)
|
| 264 |
+
print(report)
|
| 265 |
+
PYEOF
|
| 266 |
+
|
| 267 |
+
- name: Post PR comment
|
| 268 |
+
uses: marocchino/sticky-pull-request-comment@v2
|
| 269 |
+
with:
|
| 270 |
+
header: vector-profiling-report
|
| 271 |
+
path: profiling-vector-report.md
|
| 272 |
+
|
| 273 |
+
save_baseline:
|
| 274 |
+
name: Save Vector Profiling Baseline
|
| 275 |
+
runs-on: ubuntu-latest
|
| 276 |
+
needs: [profile]
|
| 277 |
+
if: always() && github.event_name == 'push' && github.ref == 'refs/heads/main'
|
| 278 |
+
steps:
|
| 279 |
+
- name: Restore previous baseline
|
| 280 |
+
uses: actions/cache/restore@v4
|
| 281 |
+
continue-on-error: true
|
| 282 |
+
with:
|
| 283 |
+
path: baseline
|
| 284 |
+
key: vec-profiling-baseline-do-not-match
|
| 285 |
+
restore-keys: |
|
| 286 |
+
vec-profiling-baseline-
|
| 287 |
+
|
| 288 |
+
- name: Download new profiling results
|
| 289 |
+
uses: actions/download-artifact@v4
|
| 290 |
+
continue-on-error: true
|
| 291 |
+
with:
|
| 292 |
+
path: new-results
|
| 293 |
+
pattern: vec-profiling-*
|
| 294 |
+
|
| 295 |
+
- name: Merge into baseline
|
| 296 |
+
run: |
|
| 297 |
+
mkdir -p baseline
|
| 298 |
+
if [ -d new-results ]; then
|
| 299 |
+
cp -r new-results/* baseline/
|
| 300 |
+
fi
|
| 301 |
+
|
| 302 |
+
- name: Save baseline cache
|
| 303 |
+
uses: actions/cache/save@v4
|
| 304 |
+
with:
|
| 305 |
+
path: baseline
|
| 306 |
+
key: vec-profiling-baseline-${{ github.sha }}
|
source_data/pinned/behavior-1k-bddl/v3.9.3-post2/.github/workflows/publish-pypi.yml
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# This workflow will upload a Python Package using Twine when a release is created
|
| 2 |
+
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries
|
| 3 |
+
|
| 4 |
+
# This workflow uses actions that are not certified by GitHub.
|
| 5 |
+
# They are provided by a third-party and are governed by
|
| 6 |
+
# separate terms of service, privacy policy, and support
|
| 7 |
+
# documentation.
|
| 8 |
+
|
| 9 |
+
name: Upload Python Package
|
| 10 |
+
|
| 11 |
+
on:
|
| 12 |
+
release:
|
| 13 |
+
types: [published]
|
| 14 |
+
|
| 15 |
+
jobs:
|
| 16 |
+
pypi-publish:
|
| 17 |
+
name: Upload release to PyPI
|
| 18 |
+
runs-on: ubuntu-latest
|
| 19 |
+
environment:
|
| 20 |
+
name: pypi
|
| 21 |
+
url: https://pypi.org/p/omnigibson
|
| 22 |
+
permissions:
|
| 23 |
+
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
|
| 24 |
+
contents: read
|
| 25 |
+
steps:
|
| 26 |
+
- uses: actions/checkout@v4
|
| 27 |
+
- name: Set up Python
|
| 28 |
+
uses: actions/setup-python@v3
|
| 29 |
+
with:
|
| 30 |
+
python-version: '3.x'
|
| 31 |
+
- name: Install dependencies
|
| 32 |
+
run: |
|
| 33 |
+
python -m pip install --upgrade pip
|
| 34 |
+
pip install setuptools wheel twine
|
| 35 |
+
- name: Build package
|
| 36 |
+
run: python setup.py sdist
|
| 37 |
+
- name: Publish package distributions to PyPI
|
| 38 |
+
uses: pypa/gh-action-pypi-publish@v1.10.2
|
source_data/pinned/behavior-1k-bddl/v3.9.3-post2/.github/workflows/pull-sheets-bddl.yml
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: Sync bddl Google Sheets data
|
| 2 |
+
|
| 3 |
+
on:
|
| 4 |
+
schedule:
|
| 5 |
+
- cron: "0 9 * * *" # Every day at 9am
|
| 6 |
+
workflow_dispatch:
|
| 7 |
+
# push:
|
| 8 |
+
# branches:
|
| 9 |
+
# - main
|
| 10 |
+
|
| 11 |
+
jobs:
|
| 12 |
+
pull-sheets:
|
| 13 |
+
name: Sync Google Sheets data
|
| 14 |
+
runs-on: ubuntu-latest
|
| 15 |
+
|
| 16 |
+
steps:
|
| 17 |
+
- name: Checkout code
|
| 18 |
+
uses: actions/checkout@v3
|
| 19 |
+
|
| 20 |
+
- name: Setup python
|
| 21 |
+
uses: actions/setup-python@v2
|
| 22 |
+
with:
|
| 23 |
+
python-version: "3.10"
|
| 24 |
+
architecture: x64
|
| 25 |
+
|
| 26 |
+
- name: Authenticate on Google Cloud
|
| 27 |
+
uses: 'google-github-actions/auth@v1'
|
| 28 |
+
with:
|
| 29 |
+
credentials_json: '${{ secrets.GCP_CREDENTIALS }}'
|
| 30 |
+
|
| 31 |
+
- uses: webfactory/ssh-agent@v0.9.0
|
| 32 |
+
with:
|
| 33 |
+
ssh-private-key: ${{ secrets.SHEETS_DEPLOY_KEY }}
|
| 34 |
+
|
| 35 |
+
# See if we need to re-pull any asset_pipeline data from DVC.
|
| 36 |
+
- name: Check cache for pipeline data
|
| 37 |
+
id: cache-pipeline
|
| 38 |
+
uses: actions/cache@v3
|
| 39 |
+
with:
|
| 40 |
+
key: asset_pipeline-${{ hashFiles('asset_pipeline/dvc.lock') }}
|
| 41 |
+
path: |
|
| 42 |
+
asset_pipeline/artifacts/pipeline/combined_room_object_list.json
|
| 43 |
+
asset_pipeline/artifacts/pipeline/object_inventory.json
|
| 44 |
+
|
| 45 |
+
- if: ${{ steps.cache-pipeline.outputs.cache-hit != 'true' }}
|
| 46 |
+
name: Install dvc
|
| 47 |
+
run: pip install dvc[gs]
|
| 48 |
+
|
| 49 |
+
- if: ${{ steps.cache-pipeline.outputs.cache-hit != 'true' }}
|
| 50 |
+
name: Pull dvc data
|
| 51 |
+
working-directory: asset_pipeline
|
| 52 |
+
run: dvc pull combined_room_object_list object_inventory
|
| 53 |
+
|
| 54 |
+
- if: ${{ steps.cache-pipeline.outputs.cache-hit != 'true' }}
|
| 55 |
+
name: Unprotect data
|
| 56 |
+
working-directory: asset_pipeline
|
| 57 |
+
run: dvc unprotect artifacts/pipeline/combined_room_object_list.json artifacts/pipeline/object_inventory.json
|
| 58 |
+
|
| 59 |
+
- name: Copy over pipeline files
|
| 60 |
+
run: cp asset_pipeline/artifacts/pipeline/{combined_room_object_list,object_inventory}.json bddl3/bddl/generated_data
|
| 61 |
+
|
| 62 |
+
- name: Combine complaint files from asset_pipeline
|
| 63 |
+
run: |
|
| 64 |
+
python3 -c "
|
| 65 |
+
import glob, json
|
| 66 |
+
files = glob.glob('asset_pipeline/cad/*/*/complaints.json')
|
| 67 |
+
combined = []
|
| 68 |
+
for file in files:
|
| 69 |
+
with open(file) as f:
|
| 70 |
+
combined.extend(json.load(f))
|
| 71 |
+
combined.sort(key=lambda x: (x['object'], x['type'], x['additional_info'], x['complaint'], x['processed']))
|
| 72 |
+
with open('bddl3/bddl/generated_data/complaints.json', 'w') as f:
|
| 73 |
+
json.dump(combined, f, indent=2)
|
| 74 |
+
"
|
| 75 |
+
|
| 76 |
+
- name: Install BDDL
|
| 77 |
+
working-directory: bddl3
|
| 78 |
+
run: pip install -e .
|
| 79 |
+
|
| 80 |
+
- name: Install dev requirements
|
| 81 |
+
working-directory: bddl3
|
| 82 |
+
run: pip install -r requirements-dev.txt
|
| 83 |
+
|
| 84 |
+
- name: Refresh sheets data
|
| 85 |
+
working-directory: bddl3
|
| 86 |
+
run: python -m bddl.data_generation.pull_sheets
|
| 87 |
+
|
| 88 |
+
- name: Refresh derivative data
|
| 89 |
+
working-directory: bddl3
|
| 90 |
+
run: python -m bddl.data_generation.generate_datafiles
|
| 91 |
+
|
| 92 |
+
# Validate that the generated knowledgebase still builds before auto-committing these refreshed files.
|
| 93 |
+
# If this step fails, the workflow stops and does not auto-commit/push a broken knowledgebase that
|
| 94 |
+
# would block sampling and the website. load_wordnet=True enables deeper WordNet-based synset validation.
|
| 95 |
+
- name: Test if knowledgebase builds OK
|
| 96 |
+
run: python -c "from bddl.knowledge_base import KnowledgeBase; KnowledgeBase(verbose=False, load_wordnet=True)"
|
| 97 |
+
|
| 98 |
+
- uses: stefanzweifel/git-auto-commit-action@v4
|
| 99 |
+
with:
|
| 100 |
+
commit_message: "Sync bddl Google Sheets data"
|
source_data/pinned/behavior-1k-bddl/v3.9.3-post2/.github/workflows/pull-sheets.yml
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: Sync asset pipeline Google Sheets data
|
| 2 |
+
|
| 3 |
+
on:
|
| 4 |
+
schedule:
|
| 5 |
+
- cron: "0 10 * * *" # Every day at 10am
|
| 6 |
+
workflow_dispatch:
|
| 7 |
+
# push:
|
| 8 |
+
# branches:
|
| 9 |
+
# - main
|
| 10 |
+
|
| 11 |
+
jobs:
|
| 12 |
+
pull-sheets:
|
| 13 |
+
name: Sync Google Sheets data
|
| 14 |
+
runs-on: ubuntu-latest
|
| 15 |
+
|
| 16 |
+
steps:
|
| 17 |
+
- name: Checkout code
|
| 18 |
+
uses: actions/checkout@v3
|
| 19 |
+
|
| 20 |
+
- name: Setup python
|
| 21 |
+
uses: actions/setup-python@v2
|
| 22 |
+
with:
|
| 23 |
+
python-version: "3.8"
|
| 24 |
+
architecture: x64
|
| 25 |
+
|
| 26 |
+
- name: Install requirements
|
| 27 |
+
run: pip install gspread pandas
|
| 28 |
+
|
| 29 |
+
- name: Authenticate on Google Cloud
|
| 30 |
+
uses: 'google-github-actions/auth@v1'
|
| 31 |
+
with:
|
| 32 |
+
credentials_json: '${{ secrets.GCP_CREDENTIALS }}'
|
| 33 |
+
|
| 34 |
+
- uses: webfactory/ssh-agent@v0.9.0
|
| 35 |
+
with:
|
| 36 |
+
ssh-private-key: ${{ secrets.SHEETS_DEPLOY_KEY }}
|
| 37 |
+
|
| 38 |
+
- name: Refresh sheets data
|
| 39 |
+
run: python -m b1k_pipeline.sync_sheets
|
| 40 |
+
working-directory: asset_pipeline
|
| 41 |
+
|
| 42 |
+
- uses: stefanzweifel/git-auto-commit-action@v4
|
| 43 |
+
with:
|
| 44 |
+
commit_message: "Sync Google Sheets data"
|
source_data/pinned/behavior-1k-bddl/v3.9.3-post2/.github/workflows/tests.yml
ADDED
|
@@ -0,0 +1,249 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: Tests
|
| 2 |
+
|
| 3 |
+
on:
|
| 4 |
+
pull_request:
|
| 5 |
+
push:
|
| 6 |
+
branches:
|
| 7 |
+
- main
|
| 8 |
+
|
| 9 |
+
concurrency:
|
| 10 |
+
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }}
|
| 11 |
+
cancel-in-progress: true
|
| 12 |
+
|
| 13 |
+
jobs:
|
| 14 |
+
bddl_tests:
|
| 15 |
+
name: BDDL Tests
|
| 16 |
+
runs-on: [self-hosted, linux, gpu]
|
| 17 |
+
|
| 18 |
+
steps:
|
| 19 |
+
- name: Checkout source
|
| 20 |
+
uses: actions/checkout@v4
|
| 21 |
+
with:
|
| 22 |
+
submodules: true
|
| 23 |
+
|
| 24 |
+
- name: Install BDDL
|
| 25 |
+
run: pip install -e .
|
| 26 |
+
working-directory: ${{ github.workspace }}/bddl3
|
| 27 |
+
|
| 28 |
+
- name: Run BDDL tests
|
| 29 |
+
run: pytest tests/test_knowledgebase.py -v --junitxml=bddl_tests.xml -o junit_family=xunit1
|
| 30 |
+
working-directory: ${{ github.workspace }}/bddl3
|
| 31 |
+
|
| 32 |
+
- name: Deploy artifact
|
| 33 |
+
if: always()
|
| 34 |
+
uses: actions/upload-artifact@v4
|
| 35 |
+
with:
|
| 36 |
+
name: ${{ github.run_id }}-tests-bddl
|
| 37 |
+
path: bddl3/bddl_tests.xml
|
| 38 |
+
overwrite: true
|
| 39 |
+
|
| 40 |
+
check_example_list:
|
| 41 |
+
name: Check Example List Up To Date
|
| 42 |
+
runs-on: [self-hosted, linux, gpu]
|
| 43 |
+
defaults:
|
| 44 |
+
run:
|
| 45 |
+
working-directory: ${{ github.workspace }}/OmniGibson
|
| 46 |
+
|
| 47 |
+
steps:
|
| 48 |
+
- name: Checkout source
|
| 49 |
+
uses: actions/checkout@v4
|
| 50 |
+
with:
|
| 51 |
+
submodules: true
|
| 52 |
+
|
| 53 |
+
- name: Install BDDL
|
| 54 |
+
run: pip install -e .
|
| 55 |
+
working-directory: ${{ github.workspace }}/bddl3
|
| 56 |
+
|
| 57 |
+
- name: Install OmniGibson
|
| 58 |
+
run: pip install -e .[dev,primitives,eval] --no-build-isolation
|
| 59 |
+
- name: Check example lists are up to date
|
| 60 |
+
run: python tests/update_example_tests.py --check
|
| 61 |
+
|
| 62 |
+
run_test:
|
| 63 |
+
name: Run Tests
|
| 64 |
+
runs-on: [self-hosted, linux, gpu, dataset-enabled]
|
| 65 |
+
|
| 66 |
+
strategy:
|
| 67 |
+
fail-fast: false
|
| 68 |
+
matrix:
|
| 69 |
+
test_file:
|
| 70 |
+
- test_controllers
|
| 71 |
+
# - test_curobo
|
| 72 |
+
# - test_data_collection # TODO: https://github.com/StanfordVL/BEHAVIOR-1K/issues/2016
|
| 73 |
+
- test_dump_load_states
|
| 74 |
+
- test_envs
|
| 75 |
+
- test_multiple_envs_dummy_api
|
| 76 |
+
- test_multiple_envs_dummy_scene
|
| 77 |
+
- test_multiple_envs_heat_narrow_phase
|
| 78 |
+
- test_multiple_envs_heat_states
|
| 79 |
+
- test_multiple_envs_transition_rules
|
| 80 |
+
- test_object_removal
|
| 81 |
+
- test_object_states
|
| 82 |
+
# - test_primitives
|
| 83 |
+
- test_robot_states_flatcache
|
| 84 |
+
- test_robot_teleoperation
|
| 85 |
+
- test_scene_graph
|
| 86 |
+
- test_sensors
|
| 87 |
+
- test_symbolic_primitives
|
| 88 |
+
- test_systems
|
| 89 |
+
- test_transform_utils
|
| 90 |
+
- test_snapshots
|
| 91 |
+
- test_transition_rules
|
| 92 |
+
include:
|
| 93 |
+
# The three BehaviorTask multi-env suites share one env (see the `behavior_env` fixture in
|
| 94 |
+
# tests/conftest.py), so running them in a single job loads house_double_floor_lower once
|
| 95 |
+
# instead of once per file. They stay separate files; only the job is shared.
|
| 96 |
+
- test_file: test_multiple_envs_behavior_scene
|
| 97 |
+
extra_files: >-
|
| 98 |
+
tests/test_multiple_envs_behavior_task.py
|
| 99 |
+
# The task-type suites share the same gm macros, so one job pays the Isaac startup cost once.
|
| 100 |
+
- test_file: test_multiple_envs_task_tensors
|
| 101 |
+
extra_files: >-
|
| 102 |
+
tests/test_multiple_envs_grasp.py
|
| 103 |
+
tests/test_multiple_envs_point_tasks.py
|
| 104 |
+
# --- BEGIN AUTO-GENERATED EXAMPLE INCLUDES ---
|
| 105 |
+
- {test_file: test_examples, example: "environments.navigation_env_demo"}
|
| 106 |
+
- {test_file: test_examples, example: "environments.vector_env_demo"}
|
| 107 |
+
- {test_file: test_examples, example: "object_states.attachment_demo"}
|
| 108 |
+
- {test_file: test_examples, example: "object_states.dicing_demo"}
|
| 109 |
+
- {test_file: test_examples, example: "object_states.heated_state_demo"}
|
| 110 |
+
- {test_file: test_examples, example: "object_states.onfire_demo"}
|
| 111 |
+
- {test_file: test_examples, example: "object_states.overlaid_demo"}
|
| 112 |
+
- {test_file: test_examples, example: "object_states.particle_applier_remover_demo"}
|
| 113 |
+
- {test_file: test_examples, example: "object_states.sample_kinematics_demo"}
|
| 114 |
+
- {test_file: test_examples, example: "object_states.slicing_demo"}
|
| 115 |
+
- {test_file: test_examples, example: "object_states.temperature_demo"}
|
| 116 |
+
- {test_file: test_examples, example: "objects.draw_bounding_box"}
|
| 117 |
+
- {test_file: test_examples, example: "objects.highlight_objects"}
|
| 118 |
+
- {test_file: test_examples, example: "objects.load_object_selector"}
|
| 119 |
+
- {test_file: test_examples, example: "objects.visualize_object"}
|
| 120 |
+
- {test_file: test_examples, example: "robots.all_robots_visualizer"}
|
| 121 |
+
- {test_file: test_examples, example: "robots.grasping_mode_example"}
|
| 122 |
+
- {test_file: test_examples, example: "robots.import_custom_robot", args: "--config tests/data/r1_pro_source_config.yaml"}
|
| 123 |
+
- {test_file: test_examples, example: "robots.robot_control_example"}
|
| 124 |
+
- {test_file: test_examples, example: "scenes.scene_selector"}
|
| 125 |
+
- {test_file: test_examples, example: "scenes.scene_tour_demo"}
|
| 126 |
+
- {test_file: test_examples, example: "scenes.traversability_map_example"}
|
| 127 |
+
- {test_file: test_examples, example: "simulator.sim_save_load_example"}
|
| 128 |
+
# --- END AUTO-GENERATED EXAMPLE INCLUDES ---
|
| 129 |
+
|
| 130 |
+
defaults:
|
| 131 |
+
run:
|
| 132 |
+
working-directory: ${{ github.workspace }}/OmniGibson
|
| 133 |
+
|
| 134 |
+
steps:
|
| 135 |
+
- name: Checkout source
|
| 136 |
+
uses: actions/checkout@v4
|
| 137 |
+
with:
|
| 138 |
+
submodules: true
|
| 139 |
+
|
| 140 |
+
- name: Install BDDL
|
| 141 |
+
run: pip install -e .
|
| 142 |
+
working-directory: ${{ github.workspace }}/bddl3
|
| 143 |
+
|
| 144 |
+
- name: Install OmniGibson
|
| 145 |
+
run: pip install -e .[dev,primitives,eval] --no-build-isolation
|
| 146 |
+
|
| 147 |
+
- name: Print env
|
| 148 |
+
run: printenv
|
| 149 |
+
|
| 150 |
+
- name: Run tests
|
| 151 |
+
run: >
|
| 152 |
+
pytest -s tests/${{ matrix.test_file }}.py ${{ matrix.extra_files || '' }}
|
| 153 |
+
${{ matrix.example && format('-k "{0}"', matrix.example) || '' }}
|
| 154 |
+
${{ matrix.args && format('--test-args={0}', matrix.args) || '' }}
|
| 155 |
+
--junitxml=${{ matrix.test_file }}${{ matrix.example && format('_{0}', matrix.example) || '' }}.xml
|
| 156 |
+
-o junit_family=xunit1
|
| 157 |
+
continue-on-error: true
|
| 158 |
+
timeout-minutes: 30
|
| 159 |
+
|
| 160 |
+
- name: Check for failures, errors, or missing XML
|
| 161 |
+
if: always()
|
| 162 |
+
run: |
|
| 163 |
+
xml=${{ matrix.test_file }}${{ matrix.example && format('_{0}', matrix.example) || '' }}.xml
|
| 164 |
+
if [ ! -f "$xml" ]; then
|
| 165 |
+
cat > "$xml" << 'EOF'
|
| 166 |
+
<?xml version="1.0"?>
|
| 167 |
+
<testsuite name="${{ matrix.test_file }}" errors="1" failures="0" tests="1">
|
| 168 |
+
<testcase name="${{ matrix.test_file }}" classname="${{ matrix.test_file }}">
|
| 169 |
+
<error message="Test did not produce output, likely due to segfault or timeout"/>
|
| 170 |
+
</testcase>
|
| 171 |
+
</testsuite>
|
| 172 |
+
EOF
|
| 173 |
+
echo "Error: XML file not found, probably due to segfault or timeout"
|
| 174 |
+
exit 1
|
| 175 |
+
elif grep -Eq 'failures="[1-9][0-9]*"|errors="[1-9][0-9]*"' "$xml"; then
|
| 176 |
+
echo "Error: Test failures or errors found"
|
| 177 |
+
exit 1
|
| 178 |
+
else
|
| 179 |
+
echo "All tests passed successfully"
|
| 180 |
+
fi
|
| 181 |
+
|
| 182 |
+
- name: Deploy snapshot artifacts
|
| 183 |
+
if: always() && matrix.test_file == 'test_snapshots'
|
| 184 |
+
uses: actions/upload-artifact@v4
|
| 185 |
+
with:
|
| 186 |
+
name: ${{ github.run_id }}-snapshots
|
| 187 |
+
path: OmniGibson/tests/snapshots/actual/
|
| 188 |
+
overwrite: true
|
| 189 |
+
|
| 190 |
+
- name: Deploy artifact
|
| 191 |
+
if: always()
|
| 192 |
+
uses: actions/upload-artifact@v4
|
| 193 |
+
with:
|
| 194 |
+
name: ${{ github.run_id }}-tests-${{ matrix.test_file }}${{ matrix.example && format('-{0}', matrix.example) || '' }}
|
| 195 |
+
path: OmniGibson/${{ matrix.test_file }}${{ matrix.example && format('_{0}', matrix.example) || '' }}.xml
|
| 196 |
+
overwrite: true
|
| 197 |
+
|
| 198 |
+
upload_report:
|
| 199 |
+
name: Test Report
|
| 200 |
+
runs-on: ubuntu-latest
|
| 201 |
+
needs: [bddl_tests, check_example_list, run_test]
|
| 202 |
+
if: always()
|
| 203 |
+
permissions:
|
| 204 |
+
pull-requests: write
|
| 205 |
+
steps:
|
| 206 |
+
- name: Checkout source
|
| 207 |
+
uses: actions/checkout@v4
|
| 208 |
+
|
| 209 |
+
- name: Pull reports
|
| 210 |
+
uses: actions/download-artifact@v4
|
| 211 |
+
with:
|
| 212 |
+
path: test-results
|
| 213 |
+
merge-multiple: true
|
| 214 |
+
- name: Upload test results to Trunk
|
| 215 |
+
if: ${{ !cancelled() }}
|
| 216 |
+
continue-on-error: true
|
| 217 |
+
uses: trunk-io/analytics-uploader@v1
|
| 218 |
+
with:
|
| 219 |
+
junit-paths: test-results/**/*.xml
|
| 220 |
+
org-slug: stanfordvl-behavior
|
| 221 |
+
token: ${{ secrets.TRUNK_API_TOKEN }}
|
| 222 |
+
|
| 223 |
+
- name: Convert JUnit XML to CTRF
|
| 224 |
+
run: npx --yes junit-to-ctrf "test-results/**/test_*.xml" -o ctrf-report.json
|
| 225 |
+
|
| 226 |
+
- name: Publish PR comment
|
| 227 |
+
uses: ctrf-io/github-test-reporter@v1
|
| 228 |
+
with:
|
| 229 |
+
report-path: ctrf-report.json
|
| 230 |
+
pull-request-report: true
|
| 231 |
+
overwrite-comment: true
|
| 232 |
+
env:
|
| 233 |
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
| 234 |
+
|
| 235 |
+
- name: Fail if any tests failed or were cancelled
|
| 236 |
+
run: |
|
| 237 |
+
if [[ "${{ needs.run_test.result }}" == "cancelled" || "${{ needs.bddl_tests.result }}" == "cancelled" || "${{ needs.check_example_list.result }}" == "cancelled" ]]; then
|
| 238 |
+
echo "One or more test jobs were cancelled"
|
| 239 |
+
exit 1
|
| 240 |
+
fi
|
| 241 |
+
if grep -rqE 'failures="[1-9][0-9]*"|errors="[1-9][0-9]*"' test-results/; then
|
| 242 |
+
echo "Test failures or errors found"
|
| 243 |
+
exit 1
|
| 244 |
+
fi
|
| 245 |
+
|
| 246 |
+
# - name: Upload coverage to Codecov
|
| 247 |
+
# uses: codecov/codecov-action@v2.1.0
|
| 248 |
+
# with:
|
| 249 |
+
# token: ${{ secrets.CODECOV_TOKEN }}
|
source_data/pinned/behavior-1k-bddl/v3.9.3-post2/.github/workflows/type-check.yml
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: Type Check
|
| 2 |
+
|
| 3 |
+
on:
|
| 4 |
+
pull_request:
|
| 5 |
+
push:
|
| 6 |
+
branches:
|
| 7 |
+
- main
|
| 8 |
+
|
| 9 |
+
concurrency:
|
| 10 |
+
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }}
|
| 11 |
+
cancel-in-progress: true
|
| 12 |
+
|
| 13 |
+
jobs:
|
| 14 |
+
typecheck_bddl:
|
| 15 |
+
name: Type Check (bddl3)
|
| 16 |
+
runs-on: [self-hosted, linux, gpu]
|
| 17 |
+
steps:
|
| 18 |
+
- name: Checkout source
|
| 19 |
+
uses: actions/checkout@v4
|
| 20 |
+
with:
|
| 21 |
+
fetch-depth: 0
|
| 22 |
+
|
| 23 |
+
- name: Determine diff range
|
| 24 |
+
id: range
|
| 25 |
+
env:
|
| 26 |
+
EVENT_NAME: ${{ github.event_name }}
|
| 27 |
+
BASE_REF: ${{ github.base_ref }}
|
| 28 |
+
BEFORE_SHA: ${{ github.event.before }}
|
| 29 |
+
run: .github/scripts/resolve_diff_range.sh
|
| 30 |
+
|
| 31 |
+
- name: Install BDDL
|
| 32 |
+
run: pip install -e .[dev]
|
| 33 |
+
working-directory: bddl3
|
| 34 |
+
|
| 35 |
+
- name: Check types on changed files
|
| 36 |
+
continue-on-error: true # TODO: make blocking once the existing backlog is cleaned up
|
| 37 |
+
run: >
|
| 38 |
+
python .github/scripts/check_types_diff.py
|
| 39 |
+
--package-dir bddl3
|
| 40 |
+
--base ${{ steps.range.outputs.base_sha }}
|
| 41 |
+
--head ${{ github.sha }}
|
| 42 |
+
|
| 43 |
+
typecheck_omnigibson:
|
| 44 |
+
name: Type Check (OmniGibson)
|
| 45 |
+
runs-on: [self-hosted, linux, gpu]
|
| 46 |
+
steps:
|
| 47 |
+
- name: Checkout source
|
| 48 |
+
uses: actions/checkout@v4
|
| 49 |
+
with:
|
| 50 |
+
fetch-depth: 0
|
| 51 |
+
submodules: true
|
| 52 |
+
|
| 53 |
+
- name: Determine diff range
|
| 54 |
+
id: range
|
| 55 |
+
env:
|
| 56 |
+
EVENT_NAME: ${{ github.event_name }}
|
| 57 |
+
BASE_REF: ${{ github.base_ref }}
|
| 58 |
+
BEFORE_SHA: ${{ github.event.before }}
|
| 59 |
+
run: .github/scripts/resolve_diff_range.sh
|
| 60 |
+
|
| 61 |
+
- name: Install BDDL
|
| 62 |
+
run: pip install -e .
|
| 63 |
+
working-directory: bddl3
|
| 64 |
+
|
| 65 |
+
- name: Install OmniGibson
|
| 66 |
+
run: pip install -e .[dev,primitives,eval] --no-build-isolation
|
| 67 |
+
working-directory: OmniGibson
|
| 68 |
+
|
| 69 |
+
- name: Check types on changed files
|
| 70 |
+
continue-on-error: true # TODO: make blocking once the existing backlog is cleaned up
|
| 71 |
+
run: >
|
| 72 |
+
python .github/scripts/check_types_diff.py
|
| 73 |
+
--package-dir OmniGibson
|
| 74 |
+
--base ${{ steps.range.outputs.base_sha }}
|
| 75 |
+
--head ${{ github.sha }}
|
| 76 |
+
|
| 77 |
+
typecheck_joylo:
|
| 78 |
+
name: Type Check (joylo)
|
| 79 |
+
runs-on: [self-hosted, linux, gpu]
|
| 80 |
+
steps:
|
| 81 |
+
- name: Checkout source
|
| 82 |
+
uses: actions/checkout@v4
|
| 83 |
+
with:
|
| 84 |
+
fetch-depth: 0
|
| 85 |
+
|
| 86 |
+
- name: Determine diff range
|
| 87 |
+
id: range
|
| 88 |
+
env:
|
| 89 |
+
EVENT_NAME: ${{ github.event_name }}
|
| 90 |
+
BASE_REF: ${{ github.base_ref }}
|
| 91 |
+
BEFORE_SHA: ${{ github.event.before }}
|
| 92 |
+
run: .github/scripts/resolve_diff_range.sh
|
| 93 |
+
|
| 94 |
+
- name: Install joylo
|
| 95 |
+
run: pip install -e .[dev]
|
| 96 |
+
working-directory: joylo
|
| 97 |
+
|
| 98 |
+
- name: Check types on changed files
|
| 99 |
+
continue-on-error: true # TODO: make blocking once the existing backlog is cleaned up
|
| 100 |
+
run: >
|
| 101 |
+
python .github/scripts/check_types_diff.py
|
| 102 |
+
--package-dir joylo
|
| 103 |
+
--base ${{ steps.range.outputs.base_sha }}
|
| 104 |
+
--head ${{ github.sha }}
|
source_data/pinned/behavior-1k-bddl/v3.9.3-post2/.gitignore
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
gha-creds-*.json
|
| 2 |
+
/site
|
| 3 |
+
.vscode
|
| 4 |
+
.DS_Store
|
| 5 |
+
|
| 6 |
+
# training
|
| 7 |
+
outputs/
|
| 8 |
+
/*.ipynb
|
| 9 |
+
|
| 10 |
+
__pycache__/
|
| 11 |
+
.codex
|
source_data/pinned/behavior-1k-bddl/v3.9.3-post2/.pre-commit-config.yaml
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
repos:
|
| 2 |
+
- repo: https://github.com/astral-sh/ruff-pre-commit
|
| 3 |
+
# Ruff version.
|
| 4 |
+
rev: v0.8.4
|
| 5 |
+
hooks:
|
| 6 |
+
# Run the linter.
|
| 7 |
+
- id: ruff
|
| 8 |
+
args: ["--fix"]
|
| 9 |
+
files: ^OmniGibson/
|
| 10 |
+
# Run the formatter.
|
| 11 |
+
- id: ruff-format
|
| 12 |
+
files: ^OmniGibson/
|
source_data/pinned/behavior-1k-bddl/v3.9.3-post2/AGENTS.md
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# AGENTS.md
|
| 2 |
+
|
| 3 |
+
This file provides guidance to AI coding agents when working with code in this repository.
|
| 4 |
+
|
| 5 |
+
## General Guidelines
|
| 6 |
+
|
| 7 |
+
- **Use `behavior` conda environment by default** when running Python commands, unless explicitly told otherwise. You can do this by using the `conda run` command. The conda binary is usually available as ~/miniconda3/condabin/conda.
|
| 8 |
+
- **Make minimal changes** - prefer small, targeted edits over large rewrites. Avoid unnecessary stylistic changes (e.g., reformatting code that isn't relevant to the task).
|
| 9 |
+
|
| 10 |
+
## Project Overview
|
| 11 |
+
|
| 12 |
+
BEHAVIOR-1K is a monorepo for a simulation benchmark testing embodied AI agents on 1,000+ household activities. It contains three main packages plus supporting tooling:
|
| 13 |
+
|
| 14 |
+
- **OmniGibson** (`OmniGibson/`) - Physics simulation engine built on NVIDIA Omniverse/Isaac Sim. Provides environments, robots, objects, sensors, controllers, and tasks as a Gymnasium-compatible interface.
|
| 15 |
+
- **BDDL3** (`bddl3/`) - Behavior Domain Definition Language. Defines a symbolic knowledge base with 1,000+ activity definitions, object taxonomy/ontology, and condition evaluation logic.
|
| 16 |
+
- **JoyLo** (`joylo/`) - Teleoperation framework for robot control using physical hardware (GELLO devices).
|
| 17 |
+
|
| 18 |
+
Supporting components: `asset_pipeline/` (3D asset conversion), `knowledgebase/` (Flask web app for browsing BDDL data), `docs/` (MkDocs site), `eval-jobqueue/` (evaluation infrastructure).
|
| 19 |
+
|
| 20 |
+
## Commands
|
| 21 |
+
|
| 22 |
+
### Installation
|
| 23 |
+
You should not have to install any part of this project, the user should have a pre-installed conda env for you. If that's not the case, refuse running things and ask them to install first. But for general reference, the below are the installation commands.
|
| 24 |
+
|
| 25 |
+
```bash
|
| 26 |
+
# Modular install via setup script (conda env creation + component selection)
|
| 27 |
+
bash setup.sh --new-env behavior --omnigibson --bddl
|
| 28 |
+
# Individual packages (editable installs)
|
| 29 |
+
cd bddl3 && pip install -e .
|
| 30 |
+
cd OmniGibson && pip install -e .[dev] # dev dependencies (pytest, mkdocs)
|
| 31 |
+
cd OmniGibson && pip install -e .[dev,primitives] # + motion planning (curobo)
|
| 32 |
+
cd OmniGibson && pip install -e .[dev,eval] # + evaluation dependencies
|
| 33 |
+
```
|
| 34 |
+
|
| 35 |
+
### Testing (OmniGibson)
|
| 36 |
+
Tests require an NVIDIA RTX GPU (2080Ti+) and Isaac Sim runtime. Whenever running any tests, you should set the OMNIGIBSON_HEADLESS=1 environment flag so that a DISPLAY is not needed. Run from the `OmniGibson/` directory:
|
| 37 |
+
```bash
|
| 38 |
+
pytest tests/ # all tests
|
| 39 |
+
pytest tests/test_object_states.py # single test file
|
| 40 |
+
pytest tests/test_envs.py -k "test_name" # single test by name
|
| 41 |
+
```
|
| 42 |
+
|
| 43 |
+
### Linting
|
| 44 |
+
Pre-commit hooks run Ruff on `OmniGibson/` only (not joylo, bddl3):
|
| 45 |
+
```bash
|
| 46 |
+
ruff check OmniGibson/ # lint
|
| 47 |
+
ruff format OmniGibson/ # format
|
| 48 |
+
pre-commit run --all-files # run pre-commit hooks
|
| 49 |
+
```
|
| 50 |
+
|
| 51 |
+
### Documentation
|
| 52 |
+
```bash
|
| 53 |
+
mkdocs serve # local docs server (from repo root, uses mkdocs.yml)
|
| 54 |
+
```
|
| 55 |
+
|
| 56 |
+
## Architecture
|
| 57 |
+
|
| 58 |
+
### OmniGibson Core (`OmniGibson/omnigibson/`)
|
| 59 |
+
The simulation engine follows a registry pattern — robots, objects, scenes, tasks, controllers, and sensors each have a `REGISTERED_*` dict populated via class decorators.
|
| 60 |
+
|
| 61 |
+
Key module relationships:
|
| 62 |
+
- **`simulator.py`** — Singleton wrapper around Isaac Sim. All physics stepping goes through here.
|
| 63 |
+
- **`envs/`** — Gymnasium environments. `env_base.py` is the core env; `vec_env_base.py` for vectorized; wrappers in `env_wrapper.py` and `data_wrapper.py`.
|
| 64 |
+
- **`robots/`** — Robot definitions in `definitions/` (YAML-configured). `robot.py` is the base class.
|
| 65 |
+
- **`objects/`** — Simulated objects with state tracking (temperature, wetness, etc.).
|
| 66 |
+
- **`object_states/`** — State logic (e.g., `Cooked`, `Sliced`, `OnTop`). These implement BDDL predicates in simulation.
|
| 67 |
+
- **`scenes/`** — Scene loading and management.
|
| 68 |
+
- **`tasks/`** — Task definitions that pair with BDDL activity specs.
|
| 69 |
+
- **`controllers/`** — Low-level robot control (joint, IK, operational space).
|
| 70 |
+
- **`sensors/`** — Vision, scan, and other sensor modalities.
|
| 71 |
+
- **`transition_rules.py`** — Rules for state transitions (e.g., cooking, mixing).
|
| 72 |
+
- **`systems/`** — Particle systems (water, dust, etc.) and material systems.
|
| 73 |
+
- **`macros.py`** — Global configuration via `gm` (global macros) object.
|
| 74 |
+
- **`action_primitives/`** — High-level action abstractions (pick, place, navigate).
|
| 75 |
+
- **`learning/`** — RL training utilities.
|
| 76 |
+
|
| 77 |
+
OmniGibson is based on Isaac Sim, which will be installed in the `behavior` conda env. You can expect to find Isaac Sim source files in the conda env's site packages directory,
|
| 78 |
+
under the `isaacsim` package. Everything from isaacsim needs to be imported using the `omnigibson.lazy` module since these imports are only available after the app has launched
|
| 79 |
+
(e.g. through simulator.py's launch_app). You can follow most of these imports to the source code by finding the appropriate extension inside the isaacsim directory. Especially
|
| 80 |
+
relevant extensions' names start with isaacsim.core.
|
| 81 |
+
|
| 82 |
+
OmniGibson currently uses [Isaac Sim 5.1](https://docs.isaacsim.omniverse.nvidia.com/5.1.0/) and [Omniverse Kit 107.3.1](https://docs.omniverse.nvidia.com/kit/docs/kit-manual/107.3.1/). This [documentation for USDRT](https://docs.omniverse.nvidia.com/kit/docs/usdrt.scenegraph/7.6.1/index.html#usdrt-scenegraph-module) may also be especially useful for understanding Fabric and USD syncing. When following the links, make sure not to add an extra "docs/" to the href.
|
| 83 |
+
|
| 84 |
+
### BDDL3 (`bddl3/bddl/`)
|
| 85 |
+
- **`activity_definitions/`** — One file per activity with symbolic pre/post conditions.
|
| 86 |
+
- **`object_taxonomy.py`** — Hierarchical object ontology.
|
| 87 |
+
- **`condition_evaluation.py`** — Evaluates symbolic conditions against simulation state.
|
| 88 |
+
- **`backend_abc.py`** — Abstract interface that OmniGibson implements to connect simulation to BDDL logic.
|
| 89 |
+
- **`knowledge_base/`** — Structured data about objects, scenes, and their properties.
|
| 90 |
+
|
| 91 |
+
### Config-Driven Design
|
| 92 |
+
OmniGibson uses YAML configs extensively (`OmniGibson/omnigibson/configs/`). Environment creation typically loads a config specifying scene, task, robot, and controller parameters.
|
| 93 |
+
|
| 94 |
+
## Code Style
|
| 95 |
+
|
| 96 |
+
- **Python 3.10+**, line length 120, indent 4 spaces
|
| 97 |
+
- **Ruff** for linting and formatting (rules: E4, E7, E9, F; ignores: E731, E722, E741)
|
| 98 |
+
- Ruff config is split: root `ruff.toml` (excludes joylo) and `OmniGibson/pyproject.toml` (detailed rules)
|
| 99 |
+
- Pre-commit hooks only apply to `OmniGibson/` directory
|
| 100 |
+
- Type checking via Pyright (configured in `OmniGibson/pyproject.toml`)
|
| 101 |
+
|
| 102 |
+
## CI/CD
|
| 103 |
+
|
| 104 |
+
GitHub Actions workflows (`.github/workflows/`):
|
| 105 |
+
- **tests.yml** — Runs pytest matrix across test files on self-hosted GPU runners. Also checks example list is up to date.
|
| 106 |
+
- **build-push-containers.yml** — Docker image builds
|
| 107 |
+
- **build-website.yml** — MkDocs documentation deployment
|
| 108 |
+
- **publish-pypi.yml** — PyPI releases
|
| 109 |
+
- **profiling.yml** — Performance benchmarking
|
source_data/pinned/behavior-1k-bddl/v3.9.3-post2/CLAUDE.md
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# CLAUDE.md
|
| 2 |
+
|
| 3 |
+
@AGENTS.md
|
source_data/pinned/behavior-1k-bddl/v3.9.3-post2/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
MIT License
|
| 2 |
+
|
| 3 |
+
Copyright (c) 2023 Stanford Vision and Learning Group
|
| 4 |
+
|
| 5 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
| 6 |
+
of this software and associated documentation files (the "Software"), to deal
|
| 7 |
+
in the Software without restriction, including without limitation the rights
|
| 8 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 9 |
+
copies of the Software, and to permit persons to whom the Software is
|
| 10 |
+
furnished to do so, subject to the following conditions:
|
| 11 |
+
|
| 12 |
+
The above copyright notice and this permission notice shall be included in all
|
| 13 |
+
copies or substantial portions of the Software.
|
| 14 |
+
|
| 15 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
| 16 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
| 17 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
| 18 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
| 19 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
| 20 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
| 21 |
+
SOFTWARE.
|
source_data/pinned/behavior-1k-bddl/v3.9.3-post2/OmniGibson/.gitignore
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
*.pyc
|
| 2 |
+
*.pyd
|
| 3 |
+
*.pkl
|
| 4 |
+
*.so
|
| 5 |
+
*.egg-info/
|
| 6 |
+
.DS_Store
|
| 7 |
+
*.pth
|
| 8 |
+
src/
|
| 9 |
+
pw
|
| 10 |
+
*.o
|
| 11 |
+
*.ipynb
|
| 12 |
+
*.ipynb_checkpoints/
|
| 13 |
+
*.out
|
| 14 |
+
npz/
|
| 15 |
+
*.npy
|
| 16 |
+
dev/transfer.c
|
| 17 |
+
*.jpg
|
| 18 |
+
*.png
|
| 19 |
+
*.bmp
|
| 20 |
+
*.bak
|
| 21 |
+
*.zip
|
| 22 |
+
.*.swp
|
| 23 |
+
|
| 24 |
+
docs/apidoc
|
| 25 |
+
|
| 26 |
+
# vscode
|
| 27 |
+
.vscode/
|
| 28 |
+
|
| 29 |
+
# Physics
|
| 30 |
+
physics/*.txt
|
| 31 |
+
physics/*.json
|
| 32 |
+
# Physics assets
|
| 33 |
+
physics/models
|
| 34 |
+
|
| 35 |
+
*/events*
|
| 36 |
+
0_VRDemoSettings.txt
|
| 37 |
+
|
| 38 |
+
# VR
|
| 39 |
+
# This is the folder where the pyd files get put after setup.py builds gibson
|
| 40 |
+
Release
|
| 41 |
+
|
| 42 |
+
cnn_policy*
|
| 43 |
+
*ppo_policy*
|
| 44 |
+
checkpoint
|
| 45 |
+
*.log
|
| 46 |
+
*.log.*
|
| 47 |
+
*.model.*
|
| 48 |
+
examples/train/models/
|
| 49 |
+
|
| 50 |
+
log_*/
|
| 51 |
+
baselines/
|
| 52 |
+
aws/
|
| 53 |
+
monitor_*
|
| 54 |
+
comparison/
|
| 55 |
+
0.monitor.csvpaper/
|
| 56 |
+
0.monitor.csv
|
| 57 |
+
|
| 58 |
+
cvpr/
|
| 59 |
+
gibson/cpp-household
|
| 60 |
+
|
| 61 |
+
*.idea*
|
| 62 |
+
|
| 63 |
+
# Plotting
|
| 64 |
+
examples/scripts/plot*
|
| 65 |
+
|
| 66 |
+
# Models
|
| 67 |
+
nav_models
|
| 68 |
+
|
| 69 |
+
gibson/assets
|
| 70 |
+
*.pdf
|
| 71 |
+
.cache
|
| 72 |
+
notebook
|
| 73 |
+
build
|
| 74 |
+
dist
|
| 75 |
+
omnigibson.egg-info
|
| 76 |
+
|
| 77 |
+
# Directories used for QC pipeline
|
| 78 |
+
omnigibson/utils/data_utils/mesh_decimation/collision
|
| 79 |
+
omnigibson/utils/data_utils/mesh_decimation/visual
|
| 80 |
+
omnigibson/utils/data_utils/mesh_decimation/final_videos
|
| 81 |
+
|
| 82 |
+
# libcryptopp
|
| 83 |
+
omnigibson/render/mesh_renderer/libcryptopp.so.8.6
|
| 84 |
+
|
| 85 |
+
# Coverage
|
| 86 |
+
.coverage
|
| 87 |
+
coverage.xml
|
| 88 |
+
|
| 89 |
+
# Doc
|
| 90 |
+
docs/reference
|
| 91 |
+
site/
|
| 92 |
+
|
| 93 |
+
# Tests of examples
|
| 94 |
+
tests/tests_of_examples
|
| 95 |
+
|
| 96 |
+
# Appdata directory generated by Omniverse
|
| 97 |
+
appdata/
|
source_data/pinned/behavior-1k-bddl/v3.9.3-post2/OmniGibson/.gitmodules
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[submodule "omnigibson/render/pybind11"]
|
| 2 |
+
path = omnigibson/render/pybind11
|
| 3 |
+
url = https://github.com/pybind/pybind11.git
|
| 4 |
+
[submodule "omnigibson/render/glfw"]
|
| 5 |
+
path = omnigibson/render/glfw
|
| 6 |
+
url = https://github.com/glfw/glfw
|
| 7 |
+
[submodule "omnigibson/render/glm"]
|
| 8 |
+
path = omnigibson/render/glm
|
| 9 |
+
url = https://github.com/g-truc/glm
|
| 10 |
+
[submodule "omnigibson/render/openvr"]
|
| 11 |
+
path = omnigibson/render/openvr
|
| 12 |
+
url = https://github.com/ValveSoftware/openvr
|
| 13 |
+
[submodule "omnigibson/render/cryptopp"]
|
| 14 |
+
path = omnigibson/render/cryptopp
|
| 15 |
+
url = https://github.com/fxia22/cryptopp
|
source_data/pinned/behavior-1k-bddl/v3.9.3-post2/OmniGibson/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
MIT License
|
| 2 |
+
|
| 3 |
+
Copyright (c) 2023 Stanford Vision and Learning Group
|
| 4 |
+
|
| 5 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
| 6 |
+
of this software and associated documentation files (the "Software"), to deal
|
| 7 |
+
in the Software without restriction, including without limitation the rights
|
| 8 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 9 |
+
copies of the Software, and to permit persons to whom the Software is
|
| 10 |
+
furnished to do so, subject to the following conditions:
|
| 11 |
+
|
| 12 |
+
The above copyright notice and this permission notice shall be included in all
|
| 13 |
+
copies or substantial portions of the Software.
|
| 14 |
+
|
| 15 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
| 16 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
| 17 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
| 18 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
| 19 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
| 20 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
| 21 |
+
SOFTWARE.
|
source_data/pinned/behavior-1k-bddl/v3.9.3-post2/OmniGibson/MANIFEST.in
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
include LICENSE
|
| 2 |
+
|
| 3 |
+
graft omnigibson
|
| 4 |
+
prune omnigibson/data
|
| 5 |
+
|
| 6 |
+
global-exclude *.py[co]
|
source_data/pinned/behavior-1k-bddl/v3.9.3-post2/OmniGibson/README.md
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+

|
| 2 |
+
|
| 3 |
+
# <h1><img height="40" src="./docs/assets/OmniGibson_logo.png" style="float:left;padding-right:10px"> OmniGibson</h1>
|
| 4 |
+
[](https://github.com/StanfordVL/OmniGibson/actions/workflows/tests.yml)
|
| 5 |
+
[](https://hub.docker.com/r/stanfordvl/omnigibson)
|
| 6 |
+
[](https://stanfordvl.github.io/OmniGibson/profiling/)
|
| 7 |
+
|
| 8 |
+
-------
|
| 9 |
+
|
| 10 |
+
### Need support? Join our Discord!
|
| 11 |
+
<a href="https://discord.gg/bccR5vGFEx"><img src="https://discordapp.com/api/guilds/1166422812160966707/widget.png?style=banner3"></a>
|
| 12 |
+
|
| 13 |
+
-------
|
| 14 |
+
|
| 15 |
+
### Latest Updates
|
| 16 |
+
- [10/01/24] **v1.1.0**: Major improvements, stability fixes, pip installation, and much more! [[release notes]](https://github.com/StanfordVL/OmniGibson/releases/tag/v1.1.0)
|
| 17 |
+
|
| 18 |
+
- [03/17/24] **v1.0.0**: First full release with 1,004 pre-sampled tasks, all 50 scenes, and many new objects! [[release notes]](https://github.com/StanfordVL/OmniGibson/releases/tag/v1.0.0)
|
| 19 |
+
|
| 20 |
+
- [08/04/23] **v0.2.0**: More assets! 600 pre-sampled tasks, 7 new scenes, and many new objects 📈 [[release notes]](https://github.com/StanfordVL/OmniGibson/releases/tag/v0.2.0)
|
| 21 |
+
|
| 22 |
+
- [04/10/23] **v0.1.0**: Significantly improved stability, performance, and ease of installation :wrench: [[release notes]](https://github.com/StanfordVL/OmniGibson/releases/tag/v0.1.0)
|
| 23 |
+
|
| 24 |
+
-------
|
| 25 |
+
|
| 26 |
+
**`OmniGibson`** is a platform for accelerating Embodied AI research built upon NVIDIA's [Omniverse](https://www.nvidia.com/en-us/omniverse/) platform, featuring:
|
| 27 |
+
|
| 28 |
+
* 📸 Photorealistic Visuals and 📐 Physical Realism
|
| 29 |
+
* 🌊 Fluid and 👕 Soft Body Support
|
| 30 |
+
* 🏔️ Large-Scale, High-Quality Scenes and 🎾 Objects
|
| 31 |
+
* 🌡️ Dynamic Kinematic and Semantic Object States
|
| 32 |
+
* 🤖 Mobile Manipulator Robots with Modular ⚙️ Controllers
|
| 33 |
+
* 🌎 OpenAI Gym Interface
|
| 34 |
+
|
| 35 |
+
Check out [**`OmniGibson`**'s documentation](https://behavior.stanford.edu/omnigibson/getting_started/installation.html) to get started!
|
| 36 |
+
|
| 37 |
+
### Citation
|
| 38 |
+
If you use **`OmniGibson`** or its assets and models, please cite:
|
| 39 |
+
|
| 40 |
+
```
|
| 41 |
+
@inproceedings{
|
| 42 |
+
li2022behavior,
|
| 43 |
+
title={{BEHAVIOR}-1K: A Benchmark for Embodied {AI} with 1,000 Everyday Activities and Realistic Simulation},
|
| 44 |
+
author={Chengshu Li and Ruohan Zhang and Josiah Wong and Cem Gokmen and Sanjana Srivastava and Roberto Mart{\'\i}n-Mart{\'\i}n and Chen Wang and Gabrael Levine and Michael Lingelbach and Jiankai Sun and Mona Anvari and Minjune Hwang and Manasi Sharma and Arman Aydin and Dhruva Bansal and Samuel Hunter and Kyu-Young Kim and Alan Lou and Caleb R Matthews and Ivan Villa-Renteria and Jerry Huayang Tang and Claire Tang and Fei Xia and Silvio Savarese and Hyowon Gweon and Karen Liu and Jiajun Wu and Li Fei-Fei},
|
| 45 |
+
booktitle={6th Annual Conference on Robot Learning},
|
| 46 |
+
year={2022},
|
| 47 |
+
url={https://openreview.net/forum?id=_8DoIe8G3t}
|
| 48 |
+
}
|
| 49 |
+
```
|
| 50 |
+
|
| 51 |
+
### Profiling
|
| 52 |
+
Click on the plot to access our profiling page with more examples.
|
| 53 |
+
|
| 54 |
+
[](https://stanfordvl.github.io/OmniGibson/profiling/)
|
source_data/pinned/behavior-1k-bddl/v3.9.3-post2/OmniGibson/omnigibson/.gitignore
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
*.tar.gz'
|
| 2 |
+
data
|
| 3 |
+
render/coord.npy
|
| 4 |
+
render/model.pth
|
source_data/pinned/behavior-1k-bddl/v3.9.3-post2/OmniGibson/omnigibson/__init__.py
ADDED
|
@@ -0,0 +1,199 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
| 1 |
+
import builtins
|
| 2 |
+
import logging
|
| 3 |
+
import os
|
| 4 |
+
import shutil
|
| 5 |
+
import signal
|
| 6 |
+
import tempfile
|
| 7 |
+
|
| 8 |
+
from omnigibson.controllers import REGISTERED_CONTROLLERS
|
| 9 |
+
from omnigibson.envs import Environment
|
| 10 |
+
from omnigibson.macros import gm
|
| 11 |
+
from omnigibson.objects import REGISTERED_OBJECTS
|
| 12 |
+
from omnigibson.robots import REGISTERED_ROBOTS
|
| 13 |
+
from omnigibson.scenes import REGISTERED_SCENES
|
| 14 |
+
from omnigibson.sensors import ALL_SENSOR_MODALITIES
|
| 15 |
+
from omnigibson.simulator import _launch_simulator as launch
|
| 16 |
+
from omnigibson.tasks import REGISTERED_TASKS
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
# Create logger
|
| 20 |
+
RESET = "\033[0m"
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
class LogFormatter(logging.Formatter):
|
| 24 |
+
COLORS = {
|
| 25 |
+
logging.DEBUG: "\033[32m", # green
|
| 26 |
+
logging.INFO: RESET,
|
| 27 |
+
logging.WARNING: "\033[33m", # yellow
|
| 28 |
+
logging.ERROR: "\033[31m", # red
|
| 29 |
+
logging.CRITICAL: "\033[31m" + "\033[1m", # bold red
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
def format(self, record):
|
| 33 |
+
color = self.COLORS.get(record.levelno, RESET)
|
| 34 |
+
total_seconds = record.relativeCreated / 1000.0
|
| 35 |
+
hours = int(total_seconds // 3600)
|
| 36 |
+
minutes = int((total_seconds % 3600) // 60)
|
| 37 |
+
seconds = total_seconds % 60
|
| 38 |
+
# Format as HH:MM:SS.sss, with leading zeros
|
| 39 |
+
record.relativeCreated_hms = f"{hours:02d}:{minutes:02d}:{seconds:06.3f}"
|
| 40 |
+
return f"{color}{super().format(record)}{RESET}"
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
formatter = LogFormatter("[%(relativeCreated_hms)s] [%(levelname)s] [%(name)s] %(message)s")
|
| 44 |
+
_og_handler = logging.StreamHandler()
|
| 45 |
+
_og_handler.setFormatter(formatter)
|
| 46 |
+
_og_logger = logging.getLogger("omnigibson")
|
| 47 |
+
_og_logger.addHandler(_og_handler)
|
| 48 |
+
_og_logger.propagate = False # prevent Isaac Sim's Carbonite handler from double-printing
|
| 49 |
+
log = logging.getLogger(__name__)
|
| 50 |
+
|
| 51 |
+
builtins.ISAAC_LAUNCHED_FROM_JUPYTER = (
|
| 52 |
+
os.getenv("ISAAC_JUPYTER_KERNEL") is not None
|
| 53 |
+
) # We set this in the kernel.json file
|
| 54 |
+
|
| 55 |
+
__version__ = "3.9.3"
|
| 56 |
+
|
| 57 |
+
root_path = os.path.dirname(os.path.realpath(__file__))
|
| 58 |
+
|
| 59 |
+
# Store paths to example configs
|
| 60 |
+
# TODO: Move this elsewhere.
|
| 61 |
+
example_config_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), "configs")
|
| 62 |
+
|
| 63 |
+
# Initialize global variables
|
| 64 |
+
app = None # (this is a singleton so it's okay that it's global)
|
| 65 |
+
sim = None # (this is a singleton so it's okay that it's global)
|
| 66 |
+
|
| 67 |
+
|
| 68 |
+
# Create and expose a temporary directory for any use cases. It will get destroyed upon omni
|
| 69 |
+
# shutdown by the shutdown function.
|
| 70 |
+
tempdir = tempfile.mkdtemp()
|
| 71 |
+
|
| 72 |
+
|
| 73 |
+
def clear(
|
| 74 |
+
gravity=None,
|
| 75 |
+
physics_dt=None,
|
| 76 |
+
rendering_dt=None,
|
| 77 |
+
sim_step_dt=None,
|
| 78 |
+
viewer_width=None,
|
| 79 |
+
viewer_height=None,
|
| 80 |
+
device=None,
|
| 81 |
+
):
|
| 82 |
+
"""
|
| 83 |
+
Clear the stage and then call launch again to make og.sim point to a new simulator instance
|
| 84 |
+
|
| 85 |
+
Args:
|
| 86 |
+
gravity (None or float): gravity on z direction.
|
| 87 |
+
physics_dt (None or float): dt between physics steps.
|
| 88 |
+
If None, will use the current simulator value
|
| 89 |
+
rendering_dt (None or float): dt between rendering steps. Note: rendering means rendering a frame of the
|
| 90 |
+
current application and not only rendering a frame to the viewports/ cameras. So UI elements of
|
| 91 |
+
Isaac Sim will be refreshed with this dt as well if running non-headless.
|
| 92 |
+
If None, will use the current simulator value
|
| 93 |
+
sim_step_dt (None or float): dt between self.step() calls. This is the amount of simulation time that
|
| 94 |
+
passes every time step() is called. Note: This must be a multiple of @rendering_dt. If None, will
|
| 95 |
+
use the current simulator value
|
| 96 |
+
viewer_width (None or int): width of the camera image, in pixels
|
| 97 |
+
If None, will use the current simulator value
|
| 98 |
+
viewer_height (None or int): height of the camera image, in pixels
|
| 99 |
+
If None, will use the current simulator value
|
| 100 |
+
device (None or str): specifies the device to be used if running on the gpu with torch backend
|
| 101 |
+
If None, will use the current simulator value
|
| 102 |
+
|
| 103 |
+
"""
|
| 104 |
+
global sim
|
| 105 |
+
|
| 106 |
+
import omnigibson.lazy as lazy
|
| 107 |
+
|
| 108 |
+
# First save important simulator settings
|
| 109 |
+
init_kwargs = dict(
|
| 110 |
+
gravity=sim.gravity if gravity is None else gravity,
|
| 111 |
+
physics_dt=sim.get_physics_dt() if physics_dt is None else physics_dt,
|
| 112 |
+
rendering_dt=sim.get_rendering_dt() if rendering_dt is None else rendering_dt,
|
| 113 |
+
sim_step_dt=sim.get_sim_step_dt() if sim_step_dt is None else sim_step_dt,
|
| 114 |
+
viewer_width=sim.viewer_width if viewer_width is None else viewer_width,
|
| 115 |
+
viewer_height=sim.viewer_height if viewer_height is None else viewer_height,
|
| 116 |
+
device=sim.device if device is None else device,
|
| 117 |
+
)
|
| 118 |
+
|
| 119 |
+
# Stop the viewport menubar USD watcher before teardown. This revokes the TfNotice
|
| 120 |
+
# listener so that prim deletions during _partial_clear() don't queue deferred
|
| 121 |
+
# callbacks that later fire on an invalid stage and corrupt CUDA/PhysX state.
|
| 122 |
+
usd_watcher = lazy.omni.kit.viewport.menubar.core.utils.usd_watch
|
| 123 |
+
usd_watcher.stop()
|
| 124 |
+
|
| 125 |
+
# First let the simulator clear everything it owns.
|
| 126 |
+
sim._partial_clear()
|
| 127 |
+
|
| 128 |
+
usd_watcher.start()
|
| 129 |
+
|
| 130 |
+
# Then close the stage and remove pointers to the simulator object.
|
| 131 |
+
assert lazy.isaacsim.core.utils.stage.close_stage()
|
| 132 |
+
sim = None
|
| 133 |
+
lazy.isaacsim.core.api.SimulationContext.clear_instance()
|
| 134 |
+
|
| 135 |
+
# Then relaunch the simulator.
|
| 136 |
+
launch(**init_kwargs)
|
| 137 |
+
|
| 138 |
+
# Check that the device remains the same
|
| 139 |
+
assert (
|
| 140 |
+
sim.device == init_kwargs["device"]
|
| 141 |
+
), f"Device changed from {init_kwargs['device']} to {sim.device} after clear."
|
| 142 |
+
|
| 143 |
+
|
| 144 |
+
def cleanup(*args, **kwargs):
|
| 145 |
+
# TODO: Currently tempfile removal will fail due to CopyPrim command (for example, GranularSystem in dicing_apple example.)
|
| 146 |
+
try:
|
| 147 |
+
shutil.rmtree(tempdir)
|
| 148 |
+
except PermissionError:
|
| 149 |
+
log.info("Permission error when removing temp files. Ignoring")
|
| 150 |
+
from omnigibson.simulator import logo_small
|
| 151 |
+
|
| 152 |
+
log.info(f"{'-' * 10} Shutting Down {logo_small()} {'-' * 10}")
|
| 153 |
+
|
| 154 |
+
|
| 155 |
+
def shutdown(due_to_signal=False):
|
| 156 |
+
if app is not None:
|
| 157 |
+
# If Isaac is running, we do the cleanup in its shutdown callback to avoid open handles.
|
| 158 |
+
# TODO: Automated cleanup in callback doesn't work for some reason. Need to investigate.
|
| 159 |
+
# Manually call cleanup for now.
|
| 160 |
+
cleanup()
|
| 161 |
+
if sim is not None:
|
| 162 |
+
sim._disable_usd_guard()
|
| 163 |
+
app.close()
|
| 164 |
+
else:
|
| 165 |
+
# Otherwise, we do the cleanup here.
|
| 166 |
+
cleanup()
|
| 167 |
+
|
| 168 |
+
# If we're not shutting down due to a signal, we need to manually exit
|
| 169 |
+
if not due_to_signal:
|
| 170 |
+
exit(0)
|
| 171 |
+
|
| 172 |
+
|
| 173 |
+
def shutdown_handler(*args, **kwargs):
|
| 174 |
+
shutdown(due_to_signal=True)
|
| 175 |
+
return signal.default_int_handler(*args, **kwargs)
|
| 176 |
+
|
| 177 |
+
|
| 178 |
+
# Something somewhere disables the default SIGINT handler, so we need to re-enable it
|
| 179 |
+
signal.signal(signal.SIGINT, shutdown_handler)
|
| 180 |
+
|
| 181 |
+
__all__ = [
|
| 182 |
+
"ALL_SENSOR_MODALITIES",
|
| 183 |
+
"app",
|
| 184 |
+
"cleanup",
|
| 185 |
+
"clear",
|
| 186 |
+
"Environment",
|
| 187 |
+
"example_config_path",
|
| 188 |
+
"gm",
|
| 189 |
+
"launch",
|
| 190 |
+
"log",
|
| 191 |
+
"REGISTERED_CONTROLLERS",
|
| 192 |
+
"REGISTERED_OBJECTS",
|
| 193 |
+
"REGISTERED_ROBOTS",
|
| 194 |
+
"REGISTERED_SCENES",
|
| 195 |
+
"REGISTERED_TASKS",
|
| 196 |
+
"shutdown",
|
| 197 |
+
"sim",
|
| 198 |
+
"tempdir",
|
| 199 |
+
]
|
source_data/pinned/behavior-1k-bddl/v3.9.3-post2/OmniGibson/omnigibson/action_primitives/action_primitive_set_base.py
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import inspect
|
| 2 |
+
from abc import ABCMeta, abstractmethod
|
| 3 |
+
from enum import IntEnum
|
| 4 |
+
from typing import List
|
| 5 |
+
|
| 6 |
+
from future.utils import with_metaclass
|
| 7 |
+
|
| 8 |
+
REGISTERED_PRIMITIVE_SETS = {}
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
class ActionPrimitiveError(ValueError):
|
| 12 |
+
class Reason(IntEnum):
|
| 13 |
+
# A primitive could not be executed because a precondition was not satisfied, e.g. PLACE was called without an
|
| 14 |
+
# object currently in hand.
|
| 15 |
+
PRE_CONDITION_ERROR = 0
|
| 16 |
+
|
| 17 |
+
# A sampling error occurred: e.g. a position to place an object could not be found, or the robot could not
|
| 18 |
+
# find a pose near the object to navigate to.
|
| 19 |
+
SAMPLING_ERROR = 1
|
| 20 |
+
|
| 21 |
+
# The planning for a primitive failed possibly due to not being able to find a path.
|
| 22 |
+
PLANNING_ERROR = 2
|
| 23 |
+
|
| 24 |
+
# The planning for a primitive was successfully completed, but an error occurred during execution.
|
| 25 |
+
EXECUTION_ERROR = 3
|
| 26 |
+
|
| 27 |
+
# The execution of the primitive happened correctly, but while checking post-conditions, an error was found.
|
| 28 |
+
POST_CONDITION_ERROR = 4
|
| 29 |
+
|
| 30 |
+
def __init__(self, reason: Reason, message, metadata=None):
|
| 31 |
+
self.reason = reason
|
| 32 |
+
self.metadata = metadata if metadata is not None else {}
|
| 33 |
+
super().__init__(f"{reason.name}: {message}. Additional info: {metadata}")
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
class ActionPrimitiveErrorGroup(ValueError):
|
| 37 |
+
def __init__(self, exceptions: List[ActionPrimitiveError]) -> None:
|
| 38 |
+
self._exceptions = tuple(exceptions)
|
| 39 |
+
submessages = [f"Attempt {i}: {e}" for i, e in enumerate(exceptions)]
|
| 40 |
+
submessages = "\n\n".join(submessages)
|
| 41 |
+
message = "An error occurred during each attempt of this action.\n\n" + submessages
|
| 42 |
+
super().__init__(message)
|
| 43 |
+
|
| 44 |
+
@property
|
| 45 |
+
def exceptions(self):
|
| 46 |
+
return self._exceptions
|
| 47 |
+
|
| 48 |
+
|
| 49 |
+
class BaseActionPrimitiveSet(with_metaclass(ABCMeta, object)):
|
| 50 |
+
def __init_subclass__(cls, **kwargs):
|
| 51 |
+
"""
|
| 52 |
+
Registers all subclasses as part of this registry. This is useful to decouple internal codebase from external
|
| 53 |
+
user additions. This way, users can add their custom primitive set by simply extending this class,
|
| 54 |
+
and it will automatically be registered internally. This allows users to then specify their primitive set
|
| 55 |
+
directly in string-from in e.g., their config files, without having to manually set the str-to-class mapping
|
| 56 |
+
in our code.
|
| 57 |
+
"""
|
| 58 |
+
if not inspect.isabstract(cls):
|
| 59 |
+
REGISTERED_PRIMITIVE_SETS[cls.__name__] = cls
|
| 60 |
+
|
| 61 |
+
def __init__(self, env, robot):
|
| 62 |
+
self.env = env
|
| 63 |
+
self.robot = robot
|
| 64 |
+
|
| 65 |
+
@abstractmethod
|
| 66 |
+
def get_action_space(self):
|
| 67 |
+
"""Get the higher-level action space as an OpenAI Gym Space object."""
|
| 68 |
+
pass
|
| 69 |
+
|
| 70 |
+
@abstractmethod
|
| 71 |
+
def apply(self, action):
|
| 72 |
+
"""
|
| 73 |
+
Apply a primitive action.
|
| 74 |
+
|
| 75 |
+
Given a higher-level action in the same format as the action space (e.g. as a number),
|
| 76 |
+
generates a sequence of lower level actions (or raise ActionPrimitiveError). The action
|
| 77 |
+
will get resolved and passed into apply_ref.
|
| 78 |
+
"""
|
| 79 |
+
pass
|
| 80 |
+
|
| 81 |
+
@abstractmethod
|
| 82 |
+
def apply_ref(self, primitive, *args):
|
| 83 |
+
"""
|
| 84 |
+
Apply a primitive action by reference.
|
| 85 |
+
|
| 86 |
+
Given a higher-level action from the corresponding action set enum and any necessary arguments,
|
| 87 |
+
generates a sequence of lower level actions (or raise ActionPrimitiveError)
|
| 88 |
+
"""
|
| 89 |
+
pass
|
source_data/pinned/behavior-1k-bddl/v3.9.3-post2/OmniGibson/omnigibson/action_primitives/curobo.py
ADDED
|
@@ -0,0 +1,1006 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import math
|
| 2 |
+
from enum import Enum
|
| 3 |
+
from typing import Dict, Any, Optional
|
| 4 |
+
|
| 5 |
+
import torch as th # MUST come before importing omni!!!
|
| 6 |
+
|
| 7 |
+
import omnigibson as og
|
| 8 |
+
import omnigibson.lazy as lazy
|
| 9 |
+
import omnigibson.utils.transform_utils as T
|
| 10 |
+
from omnigibson.macros import create_module_macros
|
| 11 |
+
from omnigibson.prims.rigid_dynamic_prim import RigidDynamicPrim
|
| 12 |
+
from omnigibson.utils.constants import JointType
|
| 13 |
+
from omnigibson.utils.python_utils import multi_dim_linspace
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
# Gives 1 - 5% better speedup, according to https://github.com/NVlabs/curobo/discussions/245#discussioncomment-9265692
|
| 17 |
+
th.backends.cudnn.benchmark = True
|
| 18 |
+
th.backends.cuda.matmul.allow_tf32 = True
|
| 19 |
+
th.backends.cudnn.allow_tf32 = True
|
| 20 |
+
|
| 21 |
+
# Create settings for this module
|
| 22 |
+
m = create_module_macros(module_path=__file__)
|
| 23 |
+
|
| 24 |
+
m.HOLONOMIC_BASE_PRISMATIC_JOINT_LIMIT = 5.0 # meters
|
| 25 |
+
m.HOLONOMIC_BASE_REVOLUTE_JOINT_LIMIT = math.pi * 2 # radians
|
| 26 |
+
|
| 27 |
+
m.DEFAULT_COLLISION_ACTIVATION_DISTANCE = 0.005
|
| 28 |
+
m.DEFAULT_ATTACHED_OBJECT_SCALE = 0.8
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
class CuRoboEmbodimentSelection(str, Enum):
|
| 32 |
+
BASE = "base"
|
| 33 |
+
ARM = "arm"
|
| 34 |
+
DEFAULT = "default"
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
def create_world_mesh_collision(tensor_args, obb_cache_size=10, mesh_cache_size=2048, max_distance=0.05):
|
| 38 |
+
"""
|
| 39 |
+
Creates a CuRobo WorldMeshCollision to use for collision checking
|
| 40 |
+
|
| 41 |
+
Args:
|
| 42 |
+
tensor_args (TensorDeviceType): Tensor device information
|
| 43 |
+
obb_cache_size (int): Cache size for number of oriented bounding boxes supported in the collision world
|
| 44 |
+
mesh_cache_size (int): Cache size for number of meshes supported in the collision world
|
| 45 |
+
max_distance (float): maximum distance when checking collisions (see curobo source code)
|
| 46 |
+
|
| 47 |
+
Returns:
|
| 48 |
+
MeshCollisionWorld: collision world used to check against for collisions
|
| 49 |
+
"""
|
| 50 |
+
world_cfg = lazy.curobo.geom.sdf.world.WorldCollisionConfig.load_from_dict(
|
| 51 |
+
dict(
|
| 52 |
+
cache={"obb": obb_cache_size, "mesh": mesh_cache_size},
|
| 53 |
+
n_envs=1,
|
| 54 |
+
checker_type=lazy.curobo.geom.sdf.world.CollisionCheckerType.MESH,
|
| 55 |
+
max_distance=max_distance,
|
| 56 |
+
),
|
| 57 |
+
tensor_args=tensor_args,
|
| 58 |
+
)
|
| 59 |
+
|
| 60 |
+
# To update, run world_coll_checker.load_collision_model(obstacles)
|
| 61 |
+
return lazy.curobo.geom.sdf.utils.create_collision_checker(world_cfg)
|
| 62 |
+
|
| 63 |
+
|
| 64 |
+
class CuRoboMotionGenerator:
|
| 65 |
+
"""
|
| 66 |
+
Class for motion generator using CuRobo backend
|
| 67 |
+
"""
|
| 68 |
+
|
| 69 |
+
def __init__(
|
| 70 |
+
self,
|
| 71 |
+
robot,
|
| 72 |
+
robot_cfg_path=None,
|
| 73 |
+
robot_usd_path=None,
|
| 74 |
+
device="cuda:0",
|
| 75 |
+
motion_cfg_kwargs=None,
|
| 76 |
+
batch_size=2,
|
| 77 |
+
use_cuda_graph=True,
|
| 78 |
+
debug=False,
|
| 79 |
+
use_default_embodiment_only=False,
|
| 80 |
+
collision_activation_distance=m.DEFAULT_COLLISION_ACTIVATION_DISTANCE,
|
| 81 |
+
):
|
| 82 |
+
"""
|
| 83 |
+
Args:
|
| 84 |
+
robot (BaseRobot): Robot for which to generate motion plans
|
| 85 |
+
robot_cfg_path (None or str): If specified, the path to the robot configuration to use. If None, will
|
| 86 |
+
try to use a pre-configured one directly from curobo based on the robot class of @robot
|
| 87 |
+
robot_usd_path (None or str): If specified, the path to the robot USD file to use. If None, will
|
| 88 |
+
try to use a pre-configured one directly from curobo based on the robot class of @robot
|
| 89 |
+
device (str): Which device to use for curobo
|
| 90 |
+
motion_cfg_kwargs (None or dict): If specified, keyward arguments to pass to
|
| 91 |
+
MotionGenConfig.load_from_robot_config(...)
|
| 92 |
+
batch_size (int): Size of batches for computing trajectories. This must be FIXED
|
| 93 |
+
use_cuda_graph (bool): Whether to use CUDA graph for motion generation or not
|
| 94 |
+
debug (bool): Whether to debug generation or not, setting this True will set use_cuda_graph to False implicitly
|
| 95 |
+
use_default_embodiment_only (bool): Whether to use only the default embodiment for the robot or not
|
| 96 |
+
collision_activation_distance (float): Distance threshold at which a collision with the world is detected.
|
| 97 |
+
Increasing this value will make the motion planner more conservative in its planning with respect
|
| 98 |
+
to the underlying sphere representation of the robot. Note that this does not affect self-collisions detection.
|
| 99 |
+
"""
|
| 100 |
+
# Store internal variables
|
| 101 |
+
self._tensor_args = lazy.curobo.types.base.TensorDeviceType(device=th.device(device))
|
| 102 |
+
self.debug = debug
|
| 103 |
+
self.robot = robot
|
| 104 |
+
self.robot_joint_names = list(robot.joints.keys())
|
| 105 |
+
self.batch_size = batch_size
|
| 106 |
+
|
| 107 |
+
# Load robot config and usd paths and make sure paths point correctly
|
| 108 |
+
robot_cfg_path_dict = robot.curobo_path if robot_cfg_path is None else robot_cfg_path
|
| 109 |
+
if not isinstance(robot_cfg_path_dict, dict):
|
| 110 |
+
robot_cfg_path_dict = {CuRoboEmbodimentSelection.DEFAULT: robot_cfg_path_dict}
|
| 111 |
+
if use_default_embodiment_only:
|
| 112 |
+
robot_cfg_path_dict = {
|
| 113 |
+
CuRoboEmbodimentSelection.DEFAULT: robot_cfg_path_dict[CuRoboEmbodimentSelection.DEFAULT]
|
| 114 |
+
}
|
| 115 |
+
print("!" * 100)
|
| 116 |
+
# TODO [Wensi]: Check whether this is still true for future releases.
|
| 117 |
+
print(
|
| 118 |
+
"""
|
| 119 |
+
NOTE: Currently (v3.9.3), for cuda architecture 12.0 (e.g. RTX 50-series), using Default embodiment for Tiago or non-DEFAULT embodiment for R1Pro
|
| 120 |
+
will raise CUDA illegal memory access error during mg.warmup() due to cuRobo compatibility issues.
|
| 121 |
+
Therefore, we automatically exclude these incompatible embodiments when we detect such GPU is being used.
|
| 122 |
+
"""
|
| 123 |
+
)
|
| 124 |
+
if th.cuda.get_device_capability(device) == (12, 0):
|
| 125 |
+
if robot.model == "tiago":
|
| 126 |
+
print("Detected you are using Tiago with cuda architecture 12.0 GPU: excluding non-DEFAULT embodiment.")
|
| 127 |
+
robot_cfg_path_dict = {
|
| 128 |
+
CuRoboEmbodimentSelection.DEFAULT: robot_cfg_path_dict[CuRoboEmbodimentSelection.DEFAULT]
|
| 129 |
+
}
|
| 130 |
+
elif robot.model == "r1pro":
|
| 131 |
+
print("Detected you are using R1Pro with cuda architecture 12.0 GPU: excluding DEFAULT embodiment.")
|
| 132 |
+
robot_cfg_path_dict = {
|
| 133 |
+
k: v for k, v in robot_cfg_path_dict.items() if k != CuRoboEmbodimentSelection.DEFAULT
|
| 134 |
+
}
|
| 135 |
+
print("!" * 100)
|
| 136 |
+
robot_usd_path = robot.usd_path if robot_usd_path is None else robot_usd_path
|
| 137 |
+
|
| 138 |
+
# This will be shared across all MotionGen instances
|
| 139 |
+
world_coll_checker = create_world_mesh_collision(
|
| 140 |
+
self._tensor_args, obb_cache_size=10, mesh_cache_size=2048, max_distance=0.05
|
| 141 |
+
)
|
| 142 |
+
|
| 143 |
+
usd_help = lazy.curobo.util.usd_helper.UsdHelper()
|
| 144 |
+
usd_help.stage = og.sim.stage
|
| 145 |
+
self.usd_help = usd_help
|
| 146 |
+
|
| 147 |
+
self.mg = dict()
|
| 148 |
+
self.ee_link = dict()
|
| 149 |
+
self.additional_links = dict()
|
| 150 |
+
self.base_link = dict()
|
| 151 |
+
|
| 152 |
+
# Grab mapping from robot joint name to index
|
| 153 |
+
reset_qpos = self.robot.reset_joint_pos
|
| 154 |
+
joint_idx_mapping = {joint.joint_name: i for i, joint in enumerate(self.robot.joints.values())}
|
| 155 |
+
for emb_sel, robot_cfg_path in robot_cfg_path_dict.items():
|
| 156 |
+
content_path = lazy.curobo.types.file_path.ContentPath(
|
| 157 |
+
robot_config_absolute_path=robot_cfg_path, robot_usd_absolute_path=robot_usd_path
|
| 158 |
+
)
|
| 159 |
+
robot_cfg_dict = lazy.curobo.cuda_robot_model.util.load_robot_yaml(content_path)["robot_cfg"]
|
| 160 |
+
robot_cfg_dict["kinematics"]["use_usd_kinematics"] = True
|
| 161 |
+
|
| 162 |
+
# Automatically populate the locked joints and retract config from the robot values
|
| 163 |
+
for joint_name, lock_val in robot_cfg_dict["kinematics"]["lock_joints"].items():
|
| 164 |
+
if lock_val is None:
|
| 165 |
+
joint_idx = joint_idx_mapping[joint_name]
|
| 166 |
+
robot_cfg_dict["kinematics"]["lock_joints"][joint_name] = reset_qpos[joint_idx]
|
| 167 |
+
if robot_cfg_dict["kinematics"]["cspace"]["retract_config"] is None:
|
| 168 |
+
robot_cfg_dict["kinematics"]["cspace"]["retract_config"] = [
|
| 169 |
+
reset_qpos[joint_idx_mapping[joint_name]]
|
| 170 |
+
for joint_name in robot_cfg_dict["kinematics"]["cspace"]["joint_names"]
|
| 171 |
+
]
|
| 172 |
+
|
| 173 |
+
self.ee_link[emb_sel] = robot_cfg_dict["kinematics"]["ee_link"]
|
| 174 |
+
# RobotConfig.from_dict will append ee_link to link_names, so we make a copy here.
|
| 175 |
+
self.additional_links[emb_sel] = robot_cfg_dict["kinematics"]["link_names"].copy()
|
| 176 |
+
self.base_link[emb_sel] = robot_cfg_dict["kinematics"]["base_link"]
|
| 177 |
+
|
| 178 |
+
robot_cfg_obj = lazy.curobo.types.robot.RobotConfig.from_dict(robot_cfg_dict, self._tensor_args)
|
| 179 |
+
|
| 180 |
+
if robot.is_holonomic_base:
|
| 181 |
+
self.update_joint_limits(robot_cfg_obj, emb_sel)
|
| 182 |
+
|
| 183 |
+
motion_kwargs = dict(
|
| 184 |
+
trajopt_tsteps=32,
|
| 185 |
+
collision_checker_type=lazy.curobo.geom.sdf.world.CollisionCheckerType.MESH,
|
| 186 |
+
use_cuda_graph=use_cuda_graph,
|
| 187 |
+
num_ik_seeds=128,
|
| 188 |
+
num_batch_ik_seeds=128,
|
| 189 |
+
num_batch_trajopt_seeds=1,
|
| 190 |
+
num_trajopt_noisy_seeds=1,
|
| 191 |
+
ik_opt_iters=100,
|
| 192 |
+
optimize_dt=True,
|
| 193 |
+
num_trajopt_seeds=4,
|
| 194 |
+
num_graph_seeds=4,
|
| 195 |
+
interpolation_dt=og.sim.get_sim_step_dt(),
|
| 196 |
+
collision_activation_distance=collision_activation_distance,
|
| 197 |
+
self_collision_check=True,
|
| 198 |
+
maximum_trajectory_dt=None,
|
| 199 |
+
fixed_iters_trajopt=True,
|
| 200 |
+
finetune_trajopt_iters=100,
|
| 201 |
+
finetune_dt_scale=1.05,
|
| 202 |
+
)
|
| 203 |
+
if motion_cfg_kwargs is not None:
|
| 204 |
+
motion_kwargs.update(motion_cfg_kwargs)
|
| 205 |
+
|
| 206 |
+
motion_gen_config = lazy.curobo.wrap.reacher.motion_gen.MotionGenConfig.load_from_robot_config(
|
| 207 |
+
robot_cfg=robot_cfg_obj,
|
| 208 |
+
world_model=None,
|
| 209 |
+
world_coll_checker=world_coll_checker,
|
| 210 |
+
tensor_args=self._tensor_args,
|
| 211 |
+
store_trajopt_debug=self.debug,
|
| 212 |
+
**motion_kwargs,
|
| 213 |
+
)
|
| 214 |
+
self.mg[emb_sel] = lazy.curobo.wrap.reacher.motion_gen.MotionGen(motion_gen_config)
|
| 215 |
+
|
| 216 |
+
for mg in self.mg.values():
|
| 217 |
+
mg.warmup(
|
| 218 |
+
enable_graph=False,
|
| 219 |
+
warmup_js_trajopt=False,
|
| 220 |
+
batch=batch_size,
|
| 221 |
+
warmup_joint_delta=0.0,
|
| 222 |
+
)
|
| 223 |
+
|
| 224 |
+
# Make sure all cuda graphs have been warmed up
|
| 225 |
+
for solver in [mg.ik_solver, mg.trajopt_solver, mg.finetune_trajopt_solver]:
|
| 226 |
+
if solver.solver.use_cuda_graph_metrics:
|
| 227 |
+
assert solver.solver.safety_rollout._metrics_cuda_graph_init
|
| 228 |
+
if isinstance(solver, lazy.curobo.wrap.reacher.trajopt.TrajOptSolver):
|
| 229 |
+
assert solver.interpolate_rollout._metrics_cuda_graph_init
|
| 230 |
+
for opt in solver.solver.optimizers:
|
| 231 |
+
if opt.use_cuda_graph:
|
| 232 |
+
assert opt.cu_opt_init
|
| 233 |
+
|
| 234 |
+
def update_joint_limits(self, robot_cfg_obj, emb_sel):
|
| 235 |
+
joint_limits = robot_cfg_obj.kinematics.kinematics_config.joint_limits
|
| 236 |
+
for joint_name in self.robot.base_joint_names:
|
| 237 |
+
if joint_name in joint_limits.joint_names:
|
| 238 |
+
joint_idx = joint_limits.joint_names.index(joint_name)
|
| 239 |
+
# Manually specify joint limits for the base_footprint_x/y/rz
|
| 240 |
+
if self.robot.joints[joint_name].joint_type == JointType.JOINT_PRISMATIC:
|
| 241 |
+
joint_limits.position[0][joint_idx] = -m.HOLONOMIC_BASE_PRISMATIC_JOINT_LIMIT
|
| 242 |
+
else:
|
| 243 |
+
# Needs to be -2pi to 2pi, instead of -pi to pi, otherwise the planning success rate is much lower
|
| 244 |
+
joint_limits.position[0][joint_idx] = -m.HOLONOMIC_BASE_REVOLUTE_JOINT_LIMIT
|
| 245 |
+
|
| 246 |
+
joint_limits.position[1][joint_idx] = -joint_limits.position[0][joint_idx]
|
| 247 |
+
|
| 248 |
+
def save_visualization(self, q, file_path, emb_sel=CuRoboEmbodimentSelection.DEFAULT):
|
| 249 |
+
# Update obstacles
|
| 250 |
+
self.update_obstacles()
|
| 251 |
+
|
| 252 |
+
# Get robot collision spheres
|
| 253 |
+
cu_js = lazy.curobo.types.state.JointState(
|
| 254 |
+
position=self.tensor_args.to_device(q),
|
| 255 |
+
joint_names=self.robot_joint_names,
|
| 256 |
+
).get_ordered_joint_state(self.mg[emb_sel].kinematics.joint_names)
|
| 257 |
+
sph = self.mg[emb_sel].kinematics.get_robot_as_spheres(cu_js.position)
|
| 258 |
+
robot_world = lazy.curobo.geom.types.WorldConfig(sphere=sph[0])
|
| 259 |
+
|
| 260 |
+
# Combine all obstacles into a single mesh
|
| 261 |
+
mesh_world = self.mg[emb_sel].world_model.get_mesh_world(merge_meshes=True)
|
| 262 |
+
robot_world.add_obstacle(mesh_world.mesh[0])
|
| 263 |
+
robot_world.save_world_as_mesh(file_path)
|
| 264 |
+
|
| 265 |
+
def update_obstacles(self, ignore_objects=None):
|
| 266 |
+
"""
|
| 267 |
+
Updates internal world collision cache representation based on sim state
|
| 268 |
+
|
| 269 |
+
Args:
|
| 270 |
+
ignore_objects (None or list of DatasetObject): If specified, objects that should
|
| 271 |
+
be ignored when updating obstacles
|
| 272 |
+
"""
|
| 273 |
+
obstacles = {"cuboid": None, "sphere": None, "mesh": [], "cylinder": None, "capsule": None}
|
| 274 |
+
robot_transform = T.pose_inv(T.pose2mat(self.robot.root_link.get_position_orientation()))
|
| 275 |
+
|
| 276 |
+
if og.sim.floor_plane is not None:
|
| 277 |
+
prim = og.sim.floor_plane.prim.GetChildren()[0]
|
| 278 |
+
m = lazy.curobo.util.usd_helper.get_mesh_attrs(
|
| 279 |
+
prim, cache=self.usd_help._xform_cache, transform=robot_transform.numpy()
|
| 280 |
+
)
|
| 281 |
+
obstacles["mesh"].append(m)
|
| 282 |
+
|
| 283 |
+
for obj in self.robot.scene.objects:
|
| 284 |
+
if obj == self.robot:
|
| 285 |
+
continue
|
| 286 |
+
if obj.visual_only:
|
| 287 |
+
continue
|
| 288 |
+
if ignore_objects is not None and obj in ignore_objects:
|
| 289 |
+
continue
|
| 290 |
+
for link in obj.links.values():
|
| 291 |
+
for collision_mesh in link.collision_meshes.values():
|
| 292 |
+
assert (
|
| 293 |
+
collision_mesh.geom_type == "Mesh"
|
| 294 |
+
), f"collision_mesh {collision_mesh.prim_path} is not a mesh, but a {collision_mesh.geom_type}"
|
| 295 |
+
obj_pose = T.pose2mat(collision_mesh.get_position_orientation())
|
| 296 |
+
pose = robot_transform @ obj_pose
|
| 297 |
+
pos, orn = T.mat2pose(pose)
|
| 298 |
+
# xyzw -> wxyz
|
| 299 |
+
orn = orn[[3, 0, 1, 2]]
|
| 300 |
+
m = lazy.curobo.geom.types.Mesh(
|
| 301 |
+
name=collision_mesh.prim_path,
|
| 302 |
+
pose=th.cat([pos, orn]).tolist(),
|
| 303 |
+
vertices=collision_mesh.points.numpy(),
|
| 304 |
+
faces=collision_mesh.faces.numpy(),
|
| 305 |
+
scale=collision_mesh.get_world_scale().numpy(),
|
| 306 |
+
)
|
| 307 |
+
obstacles["mesh"].append(m)
|
| 308 |
+
|
| 309 |
+
world = lazy.curobo.geom.types.WorldConfig(**obstacles)
|
| 310 |
+
world = world.get_collision_check_world()
|
| 311 |
+
self.mg[CuRoboEmbodimentSelection.DEFAULT].update_world(world)
|
| 312 |
+
|
| 313 |
+
def check_collisions(
|
| 314 |
+
self,
|
| 315 |
+
q,
|
| 316 |
+
initial_joint_pos=None,
|
| 317 |
+
self_collision_check=True,
|
| 318 |
+
skip_obstacle_update=False,
|
| 319 |
+
attached_obj=None,
|
| 320 |
+
attached_obj_scale=None,
|
| 321 |
+
):
|
| 322 |
+
"""
|
| 323 |
+
Checks collisions between the sphere representation of the robot and the rest of the current scene
|
| 324 |
+
|
| 325 |
+
Args:
|
| 326 |
+
q (th.tensor): (N, D)-shaped tensor, representing N-total different joint configurations to check
|
| 327 |
+
collisions against the world
|
| 328 |
+
initial_joint_pos (None or th.tensor): If specified, the initial joint positions to set the locked joints.
|
| 329 |
+
Default is the current joint positions of the robot
|
| 330 |
+
self_collision_check (bool): Whether to check self-collisions or not
|
| 331 |
+
skip_obstacle_update (bool): Whether to skip updating the obstacles in the world collision checker
|
| 332 |
+
attached_obj (None or Dict[str, USDObject]): If specified, a dictionary where the keys are the end-effector
|
| 333 |
+
link names and the values are the corresponding USDObject instances to attach to that link
|
| 334 |
+
attached_obj_scale (None or Dict[str, float]): If specified, a dictionary where the keys are the end-effector
|
| 335 |
+
link names and the values are the corresponding scale to apply to the attached object
|
| 336 |
+
|
| 337 |
+
Returns:
|
| 338 |
+
th.tensor: (N,)-shaped tensor, where each value is True if in collision, else False
|
| 339 |
+
"""
|
| 340 |
+
# check_collisions only makes sense for the default embodiment where all the joints are actuated
|
| 341 |
+
emb_sel = CuRoboEmbodimentSelection.DEFAULT
|
| 342 |
+
|
| 343 |
+
# Update obstacles
|
| 344 |
+
if not skip_obstacle_update:
|
| 345 |
+
self.update_obstacles()
|
| 346 |
+
|
| 347 |
+
q_pos = self.robot.get_joint_positions() if initial_joint_pos is None else initial_joint_pos
|
| 348 |
+
q_pos = q_pos.unsqueeze(0)
|
| 349 |
+
cu_joint_state = lazy.curobo.types.state.JointState(
|
| 350 |
+
position=self._tensor_args.to_device(q_pos),
|
| 351 |
+
joint_names=self.robot_joint_names,
|
| 352 |
+
)
|
| 353 |
+
|
| 354 |
+
# Update the locked joints with the current joint positions
|
| 355 |
+
self.update_locked_joints(cu_joint_state, emb_sel)
|
| 356 |
+
|
| 357 |
+
# Compute kinematics to get corresponding sphere representation
|
| 358 |
+
cu_js = lazy.curobo.types.state.JointState(
|
| 359 |
+
position=self.tensor_args.to_device(q),
|
| 360 |
+
joint_names=self.robot_joint_names,
|
| 361 |
+
).get_ordered_joint_state(self.mg[emb_sel].kinematics.joint_names)
|
| 362 |
+
|
| 363 |
+
# Attach objects if specified
|
| 364 |
+
attached_info = self._attach_objects_to_robot(
|
| 365 |
+
attached_obj=attached_obj,
|
| 366 |
+
attached_obj_scale=attached_obj_scale,
|
| 367 |
+
cu_js_batch=cu_js,
|
| 368 |
+
emb_sel=emb_sel,
|
| 369 |
+
)
|
| 370 |
+
|
| 371 |
+
robot_spheres = self.mg[emb_sel].compute_kinematics(cu_js).robot_spheres
|
| 372 |
+
# (N_samples, n_spheres, 4) --> (N_samples, 1, n_spheres, 4)
|
| 373 |
+
robot_spheres = robot_spheres.unsqueeze(dim=1)
|
| 374 |
+
|
| 375 |
+
with th.no_grad():
|
| 376 |
+
collision_dist = (
|
| 377 |
+
self.mg[emb_sel].rollout_fn.primitive_collision_constraint.forward(robot_spheres).squeeze(1)
|
| 378 |
+
)
|
| 379 |
+
collision_results = collision_dist > 0.0
|
| 380 |
+
if self_collision_check:
|
| 381 |
+
self_collision_dist = (
|
| 382 |
+
self.mg[emb_sel].rollout_fn.robot_self_collision_constraint.forward(robot_spheres).squeeze(1)
|
| 383 |
+
)
|
| 384 |
+
self_collision_results = self_collision_dist > 0.0
|
| 385 |
+
collision_results = collision_results | self_collision_results
|
| 386 |
+
|
| 387 |
+
# Detach objects before returning
|
| 388 |
+
self._detach_objects_from_robot(attached_info, emb_sel)
|
| 389 |
+
|
| 390 |
+
# Return results
|
| 391 |
+
return collision_results # shape (B,)
|
| 392 |
+
|
| 393 |
+
def update_locked_joints(self, cu_joint_state, emb_sel):
|
| 394 |
+
"""
|
| 395 |
+
Updates the locked joints and fixed transforms for the given embodiment selection
|
| 396 |
+
This is needed to update curobo robot model about the current joint positions from Isaac.
|
| 397 |
+
|
| 398 |
+
Args:
|
| 399 |
+
cu_joint_state (JointState): JointState object representing the current joint positions
|
| 400 |
+
emb_sel (CuRoboEmbodimentSelection): Which embodiment selection to use for updating locked joints
|
| 401 |
+
"""
|
| 402 |
+
kc = self.mg[emb_sel].kinematics.kinematics_config
|
| 403 |
+
# Update the lock joint state position
|
| 404 |
+
kc.lock_jointstate.position = cu_joint_state.get_ordered_joint_state(kc.lock_jointstate.joint_names).position[0]
|
| 405 |
+
# Update all the fixed transforms between the parent links and the child links of these joints
|
| 406 |
+
for i, joint_name in enumerate(kc.lock_jointstate.joint_names):
|
| 407 |
+
joint = self.robot.joints[joint_name]
|
| 408 |
+
joint_pos = kc.lock_jointstate.position[i]
|
| 409 |
+
child_link_name = joint.body1.split("/")[-1]
|
| 410 |
+
|
| 411 |
+
# Compute the fixed transform between the parent link and the child link
|
| 412 |
+
# Note that we cannot directly query the parent and child link poses from OG
|
| 413 |
+
# because the cu_joint_state might not represent the current joint position in OG
|
| 414 |
+
|
| 415 |
+
jf_to_cf_pose = joint.local_position_1, joint.local_orientation_1
|
| 416 |
+
# Compute the transform from child frame to joint frame
|
| 417 |
+
cf_to_jf_pose = T.invert_pose_transform(*jf_to_cf_pose)
|
| 418 |
+
|
| 419 |
+
# Compute the transform from the joint frame to the joint frame moved by the joint position
|
| 420 |
+
if joint.joint_type == JointType.JOINT_FIXED:
|
| 421 |
+
jf_to_jf_moved_pos = th.zeros(3)
|
| 422 |
+
jf_to_jf_moved_quat = th.tensor([0.0, 0.0, 0.0, 1.0])
|
| 423 |
+
elif joint.joint_type == JointType.JOINT_PRISMATIC:
|
| 424 |
+
jf_to_jf_moved_pos = th.tensor([0.0, 0.0, 0.0])
|
| 425 |
+
jf_to_jf_moved_pos[["X", "Y", "Z"].index(joint.axis)] = joint_pos
|
| 426 |
+
jf_to_jf_moved_quat = th.tensor([0.0, 0.0, 0.0, 1.0])
|
| 427 |
+
elif joint.joint_type == JointType.JOINT_REVOLUTE:
|
| 428 |
+
jf_to_jf_moved_pos = th.zeros(3)
|
| 429 |
+
axis = th.zeros(3)
|
| 430 |
+
axis[["X", "Y", "Z"].index(joint.axis)] = 1.0
|
| 431 |
+
jf_to_jf_moved_quat = T.axisangle2quat(axis * joint_pos.cpu())
|
| 432 |
+
else:
|
| 433 |
+
raise NotImplementedError(f"Joint type {joint.joint_type} not supported")
|
| 434 |
+
|
| 435 |
+
# Compute the transform from the child frame to the joint frame moved by the joint position
|
| 436 |
+
cf_to_jf_moved_pose = T.pose_transform(jf_to_jf_moved_pos, jf_to_jf_moved_quat, *cf_to_jf_pose)
|
| 437 |
+
|
| 438 |
+
# Compute the transform from the joint frame moved by the joint position to the parent frame
|
| 439 |
+
jf_moved_to_pf_pose = joint.local_position_0, joint.local_orientation_0
|
| 440 |
+
|
| 441 |
+
# Compute the transform from the child frame to the parent frame
|
| 442 |
+
cf_to_pf_pose = T.pose_transform(*jf_moved_to_pf_pose, *cf_to_jf_moved_pose)
|
| 443 |
+
cf_to_pf_pose = T.pose2mat(cf_to_pf_pose)
|
| 444 |
+
|
| 445 |
+
link_idx = kc.link_name_to_idx_map[child_link_name]
|
| 446 |
+
kc.fixed_transforms[link_idx] = cf_to_pf_pose
|
| 447 |
+
|
| 448 |
+
def solve_ik_batch(
|
| 449 |
+
self,
|
| 450 |
+
start_state: Any,
|
| 451 |
+
goal_pose: Any,
|
| 452 |
+
plan_config: Any,
|
| 453 |
+
link_poses: Optional[Any] = None,
|
| 454 |
+
emb_sel=CuRoboEmbodimentSelection.DEFAULT,
|
| 455 |
+
):
|
| 456 |
+
"""Find IK solutions to reach a batch of goal poses from a batch of start joint states.
|
| 457 |
+
|
| 458 |
+
Args:
|
| 459 |
+
start_state: Start joint states of the robot. When planning from a non-static state,
|
| 460 |
+
i.e, when velocity or acceleration is non-zero, set :attr:`MotionGen.optimize_dt`
|
| 461 |
+
to False.
|
| 462 |
+
goal_pose: Goal poses for the end-effector.ik_
|
| 463 |
+
plan_config: Planning parameters for motion generation.
|
| 464 |
+
link_poses: Goal poses for each link in the robot when planning for multiple links.
|
| 465 |
+
|
| 466 |
+
Returns:
|
| 467 |
+
IKResult: Result of IK solution. Check :attr:`IKResult.success`
|
| 468 |
+
attribute to check which indices of the batch were successful.
|
| 469 |
+
bool: Whether the IK solution was successful for the batch.
|
| 470 |
+
JointState: Joint state of the robot at the goal pose.
|
| 471 |
+
"""
|
| 472 |
+
solve_state = self.mg[emb_sel]._get_solve_state(
|
| 473 |
+
lazy.curobo.wrap.reacher.types.ReacherSolveType.BATCH, plan_config, goal_pose, start_state
|
| 474 |
+
)
|
| 475 |
+
result = self.mg[emb_sel]._solve_ik_from_solve_state(
|
| 476 |
+
goal_pose,
|
| 477 |
+
solve_state,
|
| 478 |
+
start_state,
|
| 479 |
+
plan_config.use_nn_ik_seed,
|
| 480 |
+
plan_config.partial_ik_opt,
|
| 481 |
+
link_poses,
|
| 482 |
+
)
|
| 483 |
+
# If any of the IK seeds is successful
|
| 484 |
+
success = result.success.any(dim=1)
|
| 485 |
+
# Set non-successful error to infinity
|
| 486 |
+
result.error[~result.success].fill_(float("inf"))
|
| 487 |
+
# Get the index of the minimum error
|
| 488 |
+
min_error_idx = result.error.argmin(dim=1)
|
| 489 |
+
# Get the joint state with the minimum error
|
| 490 |
+
joint_state = result.js_solution[range(result.js_solution.shape[0]), min_error_idx]
|
| 491 |
+
joint_state = [joint_state[i] for i in range(joint_state.shape[0])]
|
| 492 |
+
return result, success, joint_state
|
| 493 |
+
|
| 494 |
+
def plan_batch(
|
| 495 |
+
self,
|
| 496 |
+
start_state: Any,
|
| 497 |
+
goal_pose: Any,
|
| 498 |
+
plan_config: Any,
|
| 499 |
+
link_poses: Optional[Any] = None,
|
| 500 |
+
emb_sel=CuRoboEmbodimentSelection.DEFAULT,
|
| 501 |
+
):
|
| 502 |
+
"""Plan a batch of trajectories from a batch of start joint states to a batch of goal poses.
|
| 503 |
+
|
| 504 |
+
Args:
|
| 505 |
+
start_state: Start joint states of the robot. When planning from a non-static state,
|
| 506 |
+
i.e, when velocity or acceleration is non-zero, set :attr:`MotionGen.optimize_dt`
|
| 507 |
+
to False.
|
| 508 |
+
goal_pose: Goal poses for the end-effector.
|
| 509 |
+
plan_config: Planning parameters for motion generation.
|
| 510 |
+
link_poses: Goal poses for each link in the robot when planning for multiple links.
|
| 511 |
+
|
| 512 |
+
Returns:
|
| 513 |
+
MotionGenResult: Result of IK solution. Check :attr:`MotionGenResult.success`
|
| 514 |
+
attribute to check which indices of the batch were successful.
|
| 515 |
+
bool: Whether the IK solution was successful for the batch.
|
| 516 |
+
JointState: Joint state of the robot at the goal pose.
|
| 517 |
+
"""
|
| 518 |
+
result = self.mg[emb_sel].plan_batch(start_state, goal_pose, plan_config, link_poses=link_poses)
|
| 519 |
+
success = result.success
|
| 520 |
+
if result.interpolated_plan is None:
|
| 521 |
+
joint_state = [None] * goal_pose.batch
|
| 522 |
+
else:
|
| 523 |
+
joint_state = result.get_paths()
|
| 524 |
+
|
| 525 |
+
return result, success, joint_state
|
| 526 |
+
|
| 527 |
+
def compute_trajectories(
|
| 528 |
+
self,
|
| 529 |
+
target_pos,
|
| 530 |
+
target_quat,
|
| 531 |
+
initial_joint_pos=None,
|
| 532 |
+
is_local=False,
|
| 533 |
+
max_attempts=5,
|
| 534 |
+
timeout=2.0,
|
| 535 |
+
ik_fail_return=5,
|
| 536 |
+
enable_finetune_trajopt=True,
|
| 537 |
+
finetune_attempts=1,
|
| 538 |
+
return_full_result=False,
|
| 539 |
+
success_ratio=None,
|
| 540 |
+
attached_obj=None,
|
| 541 |
+
attached_obj_scale=None,
|
| 542 |
+
motion_constraint=None,
|
| 543 |
+
skip_obstacle_update=False,
|
| 544 |
+
ik_only=False,
|
| 545 |
+
ik_world_collision_check=True,
|
| 546 |
+
emb_sel=CuRoboEmbodimentSelection.DEFAULT,
|
| 547 |
+
):
|
| 548 |
+
"""
|
| 549 |
+
Computes the robot joint trajectory to reach the desired @target_pos and @target_quat
|
| 550 |
+
|
| 551 |
+
Args:
|
| 552 |
+
target_pos (Dict[str, th.Tensor] or th.Tensor): The torch tensor shape is either (3,) or (N, 3)
|
| 553 |
+
where each entry is an individual (x,y,z) position to reach with the default end-effector link specified
|
| 554 |
+
@self.ee_link[emb_sel]. If a dictionary is given, the keys should be the end-effector links and
|
| 555 |
+
the values should be the corresponding (N, 3) tensors
|
| 556 |
+
target_quat (Dict[str, th.Tensor] or th.Tensor): The torch tensor shape is either (4,) or (N, 4)
|
| 557 |
+
where each entry is an individual (x,y,z,w) quaternion to reach with the default end-effector link specified
|
| 558 |
+
@self.ee_link[emb_sel]. If a dictionary is given, the keys should be the end-effector links and
|
| 559 |
+
the values should be the corresponding (N, 4) tensors
|
| 560 |
+
initial_joint_pos (None or th.Tensor): If specified, the initial joint positions to start the trajectory.
|
| 561 |
+
Default is the current joint positions of the robot
|
| 562 |
+
is_local (bool): Whether @target_pos and @target_quat are specified in the robot's local frame or the world
|
| 563 |
+
global frame
|
| 564 |
+
max_attempts (int): Maximum number of attempts for trying to compute a valid trajectory
|
| 565 |
+
timeout (float): Maximum time in seconds allowed to solve the motion generation problem
|
| 566 |
+
ik_fail_return (None or int): Number of IK attempts allowed before returning a failure. Set this to a
|
| 567 |
+
low value (5) to save compute time when an unreachable goal is given
|
| 568 |
+
enable_finetune_trajopt (bool): Whether to enable timing reparameterization for a smoother trajectory
|
| 569 |
+
finetune_attempts (int): Number of attempts to run finetuning trajectory optimization. Every attempt will
|
| 570 |
+
increase the `MotionGenPlanConfig.finetune_dt_scale` by `MotionGenPlanConfig.finetune_dt_decay` as a
|
| 571 |
+
path couldn't be found with the previous smaller dt
|
| 572 |
+
return_full_result (bool): Whether to return a list of raw MotionGenResult object(s) or a 2-tuple of
|
| 573 |
+
(success, results); the default is the latter
|
| 574 |
+
success_ratio (None or float): If set, specifies the fraction of successes necessary given self.batch_size.
|
| 575 |
+
If None, will automatically be the smallest ratio (1 / self.batch_size), i.e: any nonzero number of
|
| 576 |
+
successes
|
| 577 |
+
attached_obj (None or Dict[str, USDObject]): If specified, a dictionary where the keys are the end-effector
|
| 578 |
+
link names and the values are the corresponding USDObject instances to attach to that link
|
| 579 |
+
attached_obj_scale (None or Dict[str, float]): If specified, a dictionary where the keys are the end-effector
|
| 580 |
+
link names and the values are the corresponding scale to apply to the attached object
|
| 581 |
+
motion_constraint (None or List[float]): If specified, the motion constraint vector is a 6D vector controlling
|
| 582 |
+
end-effector movement (angular first, linear next): [qx, qy, qz, x, y, z]. Setting any component to 1.0
|
| 583 |
+
locks that axis, forcing the planner to reach the target using only the remaining unlocked axes.
|
| 584 |
+
Details can be found here: https://curobo.org/advanced_examples/3_constrained_planning.html
|
| 585 |
+
skip_obstacle_update (bool): Whether to skip updating the obstacles in the world collision checker
|
| 586 |
+
ik_only (bool): Whether to only run the IK solver and not the trajectory optimization
|
| 587 |
+
ik_world_collision_check (bool): Whether to check for collisions in the world when running the IK solver for ik_only mode
|
| 588 |
+
emb_sel (CuRoboEmbodimentSelection): Which embodiment selection to use for computing trajectories
|
| 589 |
+
Returns:
|
| 590 |
+
2-tuple or list of MotionGenResult: If @return_full_result is True, will return a list of raw MotionGenResult
|
| 591 |
+
object(s) computed from internal batch trajectory computations. If it is False, will return 2-tuple
|
| 592 |
+
(success, results), where success is a (N,)-shaped boolean tensor representing whether each requested
|
| 593 |
+
target pos / quat successfully generated a motion plan, and results is a (N,)-shaped array of
|
| 594 |
+
corresponding JointState objects.
|
| 595 |
+
"""
|
| 596 |
+
# Previously, this would silently fail so we explicitly check for out-of-range joint limits here
|
| 597 |
+
# This may be fixed in a recent version of CuRobo? See https://github.com/NVlabs/curobo/discussions/288
|
| 598 |
+
# relevant_joint_positions_normalized = (
|
| 599 |
+
# lazy.curobo.types.state.JointState(
|
| 600 |
+
# position=self.tensor_args.to_device(self.robot.get_joint_positions(normalized=True)),
|
| 601 |
+
# joint_names=self.robot_joint_names,
|
| 602 |
+
# )
|
| 603 |
+
# .get_ordered_joint_state(self.mg[emb_sel].kinematics.joint_names)
|
| 604 |
+
# .position
|
| 605 |
+
# )
|
| 606 |
+
|
| 607 |
+
# if not th.all(th.abs(relevant_joint_positions_normalized) < 0.99):
|
| 608 |
+
# print("Robot is near joint limits! No trajectory will be computed")
|
| 609 |
+
# return None, None if not return_full_result else None
|
| 610 |
+
|
| 611 |
+
if not skip_obstacle_update:
|
| 612 |
+
self.update_obstacles()
|
| 613 |
+
|
| 614 |
+
# If target_pos and target_quat are torch tensors, it's assumed that they correspond to the default ee_link
|
| 615 |
+
if isinstance(target_pos, th.Tensor):
|
| 616 |
+
target_pos = {self.ee_link[emb_sel]: target_pos}
|
| 617 |
+
if isinstance(target_quat, th.Tensor):
|
| 618 |
+
target_quat = {self.ee_link[emb_sel]: target_quat}
|
| 619 |
+
|
| 620 |
+
assert target_pos.keys() == target_quat.keys(), "Expected target_pos and target_quat to have the same keys!"
|
| 621 |
+
|
| 622 |
+
# Make sure tensor shapes are (N, 3) and (N, 4)
|
| 623 |
+
target_pos = {k: v if len(v.shape) == 2 else v.unsqueeze(0) for k, v in target_pos.items()}
|
| 624 |
+
target_quat = {k: v if len(v.shape) == 2 else v.unsqueeze(0) for k, v in target_quat.items()}
|
| 625 |
+
|
| 626 |
+
for link_name in target_pos.keys():
|
| 627 |
+
target_pos_link = target_pos[link_name]
|
| 628 |
+
target_quat_link = target_quat[link_name]
|
| 629 |
+
if not is_local:
|
| 630 |
+
# Convert target pose to base link *in the eyes of curobo*.
|
| 631 |
+
# For stationary arms (e.g. Franka), it is @robot.root_link / @robot.base_footprint_link_name ("base_link")
|
| 632 |
+
# For holonomic robots (e.g. Tiago, R1), it is @robot.root_link ("base_footprint_x"), not @robot.base_footprint_link_name ("base_link")
|
| 633 |
+
curobo_base_link_name = self.base_link[emb_sel]
|
| 634 |
+
robot_pos, robot_quat = self.robot.links[curobo_base_link_name].get_position_orientation()
|
| 635 |
+
target_pose = th.zeros((target_pos_link.shape[0], 4, 4))
|
| 636 |
+
target_pose[:, 3, 3] = 1.0
|
| 637 |
+
target_pose[:, :3, :3] = T.quat2mat(target_quat_link)
|
| 638 |
+
target_pose[:, :3, 3] = target_pos_link
|
| 639 |
+
inv_robot_pose = T.pose_inv(T.pose2mat((robot_pos, robot_quat)))
|
| 640 |
+
target_pose = inv_robot_pose.view(1, 4, 4) @ target_pose
|
| 641 |
+
target_pos_link = target_pose[:, :3, 3]
|
| 642 |
+
target_quat_link = T.mat2quat(target_pose[:, :3, :3])
|
| 643 |
+
|
| 644 |
+
# Map xyzw -> wxyz quat
|
| 645 |
+
target_quat_link = target_quat_link[:, [3, 0, 1, 2]]
|
| 646 |
+
|
| 647 |
+
# Make sure tensors are on device and contiguous
|
| 648 |
+
target_pos_link = self._tensor_args.to_device(target_pos_link).contiguous()
|
| 649 |
+
target_quat_link = self._tensor_args.to_device(target_quat_link).contiguous()
|
| 650 |
+
|
| 651 |
+
target_pos[link_name] = target_pos_link
|
| 652 |
+
target_quat[link_name] = target_quat_link
|
| 653 |
+
|
| 654 |
+
# Define the plan config
|
| 655 |
+
plan_cfg = lazy.curobo.wrap.reacher.motion_gen.MotionGenPlanConfig(
|
| 656 |
+
enable_graph=False,
|
| 657 |
+
max_attempts=max_attempts,
|
| 658 |
+
timeout=timeout,
|
| 659 |
+
enable_graph_attempt=None,
|
| 660 |
+
ik_fail_return=ik_fail_return,
|
| 661 |
+
enable_finetune_trajopt=enable_finetune_trajopt,
|
| 662 |
+
finetune_attempts=finetune_attempts,
|
| 663 |
+
success_ratio=1.0 / self.batch_size if success_ratio is None else success_ratio,
|
| 664 |
+
)
|
| 665 |
+
|
| 666 |
+
# Add the pose cost metric
|
| 667 |
+
if self.ee_link[emb_sel] in target_pos and motion_constraint is not None:
|
| 668 |
+
plan_cfg.pose_cost_metric = lazy.curobo.wrap.reacher.motion_gen.PoseCostMetric(
|
| 669 |
+
hold_partial_pose=True, hold_vec_weight=self._tensor_args.to_device(motion_constraint)
|
| 670 |
+
)
|
| 671 |
+
|
| 672 |
+
# Construct initial state
|
| 673 |
+
if initial_joint_pos is None:
|
| 674 |
+
q_pos = th.stack([self.robot.get_joint_positions()] * self.batch_size, axis=0)
|
| 675 |
+
q_vel = th.stack([self.robot.get_joint_velocities()] * self.batch_size, axis=0)
|
| 676 |
+
q_eff = th.stack([self.robot.get_joint_efforts()] * self.batch_size, axis=0)
|
| 677 |
+
else:
|
| 678 |
+
q_pos = th.stack([initial_joint_pos] * self.batch_size, axis=0)
|
| 679 |
+
q_vel = th.zeros_like(q_pos)
|
| 680 |
+
q_eff = th.zeros_like(q_pos)
|
| 681 |
+
|
| 682 |
+
cu_joint_state = lazy.curobo.types.state.JointState(
|
| 683 |
+
position=self._tensor_args.to_device(q_pos),
|
| 684 |
+
# TODO: Ideally these should be nonzero, but curobo fails to compute a solution if so
|
| 685 |
+
# See this note from https://curobo.org/get_started/2b_isaacsim_examples.html
|
| 686 |
+
# Motion generation only generates motions when the robot is static.
|
| 687 |
+
# cuRobo has an experimental mode to optimize from non-static states.
|
| 688 |
+
# You can try this by passing --reactive to motion_gen_reacher.py.
|
| 689 |
+
# This mode will have lower success than the static mode as now the optimization
|
| 690 |
+
# has to account for the robot’s current velocity and acceleration.
|
| 691 |
+
# The weights have also not been tuned for reactive mode.
|
| 692 |
+
velocity=self._tensor_args.to_device(q_vel) * 0.0,
|
| 693 |
+
acceleration=self._tensor_args.to_device(q_eff) * 0.0,
|
| 694 |
+
jerk=self._tensor_args.to_device(q_eff) * 0.0,
|
| 695 |
+
joint_names=self.robot_joint_names,
|
| 696 |
+
)
|
| 697 |
+
|
| 698 |
+
# Update the locked joints with the current joint positions
|
| 699 |
+
self.update_locked_joints(cu_joint_state, emb_sel)
|
| 700 |
+
|
| 701 |
+
cu_js_batch = cu_joint_state.get_ordered_joint_state(self.mg[emb_sel].kinematics.joint_names)
|
| 702 |
+
|
| 703 |
+
# Attach object to robot if requested
|
| 704 |
+
attached_info = self._attach_objects_to_robot(
|
| 705 |
+
attached_obj=attached_obj,
|
| 706 |
+
attached_obj_scale=attached_obj_scale,
|
| 707 |
+
cu_js_batch=cu_js_batch,
|
| 708 |
+
emb_sel=emb_sel,
|
| 709 |
+
)
|
| 710 |
+
|
| 711 |
+
all_rollout_fns = [
|
| 712 |
+
fn
|
| 713 |
+
for fn in self.mg[emb_sel].get_all_rollout_instances()
|
| 714 |
+
if isinstance(fn, lazy.curobo.rollout.arm_reacher.ArmReacher)
|
| 715 |
+
]
|
| 716 |
+
|
| 717 |
+
# Enable/disable costs based on whether the end-effector is in the target position
|
| 718 |
+
for rollout_fn in all_rollout_fns:
|
| 719 |
+
(
|
| 720 |
+
rollout_fn.goal_cost.enable_cost()
|
| 721 |
+
if self.ee_link[emb_sel] in target_pos
|
| 722 |
+
else rollout_fn.goal_cost.disable_cost()
|
| 723 |
+
)
|
| 724 |
+
(
|
| 725 |
+
rollout_fn.pose_convergence.enable_cost()
|
| 726 |
+
if self.ee_link[emb_sel] in target_pos
|
| 727 |
+
else rollout_fn.pose_convergence.disable_cost()
|
| 728 |
+
)
|
| 729 |
+
for additional_link in self.additional_links[emb_sel]:
|
| 730 |
+
(
|
| 731 |
+
rollout_fn._link_pose_costs[additional_link].enable_cost()
|
| 732 |
+
if additional_link in target_pos
|
| 733 |
+
else rollout_fn._link_pose_costs[additional_link].disable_cost()
|
| 734 |
+
)
|
| 735 |
+
(
|
| 736 |
+
rollout_fn._link_pose_convergence[additional_link].enable_cost()
|
| 737 |
+
if additional_link in target_pos
|
| 738 |
+
else rollout_fn._link_pose_convergence[additional_link].disable_cost()
|
| 739 |
+
)
|
| 740 |
+
|
| 741 |
+
if ik_only:
|
| 742 |
+
for rollout_fn in self.mg[emb_sel].ik_solver.get_all_rollout_instances():
|
| 743 |
+
(
|
| 744 |
+
rollout_fn.primitive_collision_cost.enable_cost()
|
| 745 |
+
if ik_world_collision_check
|
| 746 |
+
else rollout_fn.primitive_collision_cost.disable_cost()
|
| 747 |
+
)
|
| 748 |
+
(
|
| 749 |
+
rollout_fn.primitive_collision_constraint.enable_cost()
|
| 750 |
+
if ik_world_collision_check
|
| 751 |
+
else rollout_fn.primitive_collision_constraint.disable_cost()
|
| 752 |
+
)
|
| 753 |
+
|
| 754 |
+
# Determine how many internal batches we need to run based on submitted size
|
| 755 |
+
num_targets = next(iter(target_pos.values())).shape[0]
|
| 756 |
+
remainder = num_targets % self.batch_size
|
| 757 |
+
n_batches = math.ceil(num_targets / self.batch_size)
|
| 758 |
+
|
| 759 |
+
# If ee_link is not in target_pos, add trivial target poses to avoid errors
|
| 760 |
+
if self.ee_link[emb_sel] not in target_pos:
|
| 761 |
+
target_pos[self.ee_link[emb_sel]] = self._tensor_args.to_device(th.zeros((num_targets, 3)))
|
| 762 |
+
target_quat[self.ee_link[emb_sel]] = self._tensor_args.to_device(th.zeros((num_targets, 4)))
|
| 763 |
+
target_quat[self.ee_link[emb_sel]][..., 0] = 1.0
|
| 764 |
+
|
| 765 |
+
# Run internal batched calls
|
| 766 |
+
results, successes, paths = [], self._tensor_args.to_device(th.tensor([], dtype=th.bool)), []
|
| 767 |
+
for i in range(n_batches):
|
| 768 |
+
# We're using a remainder if we're on the final batch and our remainder is nonzero
|
| 769 |
+
using_remainder = (i == n_batches - 1) and remainder > 0
|
| 770 |
+
offset_idx = self.batch_size * i
|
| 771 |
+
end_idx = remainder if using_remainder else self.batch_size
|
| 772 |
+
|
| 773 |
+
ik_goal_batch_by_link = dict()
|
| 774 |
+
for link_name in target_pos.keys():
|
| 775 |
+
target_pos_link = target_pos[link_name]
|
| 776 |
+
target_quat_link = target_quat[link_name]
|
| 777 |
+
|
| 778 |
+
batch_target_pos = target_pos_link[offset_idx : offset_idx + end_idx]
|
| 779 |
+
batch_target_quat = target_quat_link[offset_idx : offset_idx + end_idx]
|
| 780 |
+
|
| 781 |
+
# Pad the goal if we're in our final batch
|
| 782 |
+
if using_remainder:
|
| 783 |
+
new_batch_target_pos = self._tensor_args.to_device(th.zeros((self.batch_size, 3)))
|
| 784 |
+
new_batch_target_pos[:end_idx] = batch_target_pos
|
| 785 |
+
new_batch_target_pos[end_idx:] = batch_target_pos[-1]
|
| 786 |
+
batch_target_pos = new_batch_target_pos
|
| 787 |
+
new_batch_target_quat = self._tensor_args.to_device(th.zeros((self.batch_size, 4)))
|
| 788 |
+
new_batch_target_quat[:end_idx] = batch_target_quat
|
| 789 |
+
new_batch_target_quat[end_idx:] = batch_target_quat[-1]
|
| 790 |
+
batch_target_quat = new_batch_target_quat
|
| 791 |
+
|
| 792 |
+
# Create IK goal
|
| 793 |
+
ik_goal_batch = lazy.curobo.types.math.Pose(
|
| 794 |
+
position=batch_target_pos,
|
| 795 |
+
quaternion=batch_target_quat,
|
| 796 |
+
name=link_name,
|
| 797 |
+
)
|
| 798 |
+
|
| 799 |
+
ik_goal_batch_by_link[link_name] = ik_goal_batch
|
| 800 |
+
|
| 801 |
+
# Run batched planning
|
| 802 |
+
if self.debug:
|
| 803 |
+
self.mg[emb_sel].store_debug_in_result = True
|
| 804 |
+
|
| 805 |
+
# Pop the main ee_link goal
|
| 806 |
+
main_ik_goal_batch = ik_goal_batch_by_link.pop(self.ee_link[emb_sel])
|
| 807 |
+
|
| 808 |
+
# If no other goals (e.g. no second end-effector), set to None
|
| 809 |
+
if len(ik_goal_batch_by_link) == 0:
|
| 810 |
+
ik_goal_batch_by_link = None
|
| 811 |
+
|
| 812 |
+
plan_fn = self.plan_batch if not ik_only else self.solve_ik_batch
|
| 813 |
+
result, success, joint_state = plan_fn(
|
| 814 |
+
cu_js_batch, main_ik_goal_batch, plan_cfg, link_poses=ik_goal_batch_by_link, emb_sel=emb_sel
|
| 815 |
+
)
|
| 816 |
+
if self.debug:
|
| 817 |
+
breakpoint()
|
| 818 |
+
|
| 819 |
+
# Append results
|
| 820 |
+
results.append(result)
|
| 821 |
+
successes = th.concatenate([successes, success[:end_idx]])
|
| 822 |
+
paths += joint_state[:end_idx]
|
| 823 |
+
|
| 824 |
+
# Detach attached object if it was attached
|
| 825 |
+
self._detach_objects_from_robot(attached_info, emb_sel)
|
| 826 |
+
|
| 827 |
+
if return_full_result:
|
| 828 |
+
return results
|
| 829 |
+
else:
|
| 830 |
+
return successes, paths
|
| 831 |
+
|
| 832 |
+
def path_to_joint_trajectory(self, path, get_full_js=True, emb_sel=CuRoboEmbodimentSelection.DEFAULT):
|
| 833 |
+
"""
|
| 834 |
+
Converts raw path from motion generator into joint trajectory sequence
|
| 835 |
+
|
| 836 |
+
Args:
|
| 837 |
+
path (JointState): Joint state path to convert into joint trajectory
|
| 838 |
+
get_full_js (bool): Whether to get the full joint state
|
| 839 |
+
emb_sel (CuRoboEmbodimentSelection): Which embodiment to use for the robot
|
| 840 |
+
|
| 841 |
+
Returns:
|
| 842 |
+
torch.tensor: (T, D) tensor representing the interpolated joint trajectory
|
| 843 |
+
to reach the desired @target_pos, @target_quat configuration, where T is the number of interpolated
|
| 844 |
+
steps and D is the number of robot joints.
|
| 845 |
+
"""
|
| 846 |
+
cmd_plan = self.mg[emb_sel].get_full_js(path) if get_full_js else path
|
| 847 |
+
return cmd_plan.get_ordered_joint_state(self.robot_joint_names).position
|
| 848 |
+
|
| 849 |
+
def add_linearly_interpolated_waypoints(self, traj: th.Tensor, max_inter_dist=0.01):
|
| 850 |
+
"""
|
| 851 |
+
Adds waypoints to the joint trajectory so that the joint position distance
|
| 852 |
+
between each pairs of neighboring waypoints is less than @max_inter_dist
|
| 853 |
+
|
| 854 |
+
Args:
|
| 855 |
+
traj: (T, D) tensor representing the joint trajectory
|
| 856 |
+
max_inter_dist (float): Maximum joint position distance between two neighboring waypoints
|
| 857 |
+
|
| 858 |
+
Returns:
|
| 859 |
+
torch.tensor: (T', D) tensor representing the interpolated joint trajectory
|
| 860 |
+
"""
|
| 861 |
+
assert len(traj) > 1, "Plan must have at least 2 waypoints to interpolate"
|
| 862 |
+
interpolated_plan = []
|
| 863 |
+
for i in range(len(traj) - 1):
|
| 864 |
+
# Calculate maximum difference across all dimensions
|
| 865 |
+
max_diff = (traj[i + 1] - traj[i]).abs().max()
|
| 866 |
+
num_intervals = math.ceil(max_diff.item() / max_inter_dist)
|
| 867 |
+
interpolated_plan += multi_dim_linspace(traj[i], traj[i + 1], num_intervals, endpoint=False)
|
| 868 |
+
|
| 869 |
+
interpolated_plan.append(traj[-1])
|
| 870 |
+
return th.stack(interpolated_plan)
|
| 871 |
+
|
| 872 |
+
def path_to_eef_trajectory(
|
| 873 |
+
self, path, return_axisangle=False, emb_sel=CuRoboEmbodimentSelection.DEFAULT
|
| 874 |
+
) -> Dict[str, th.Tensor]:
|
| 875 |
+
"""
|
| 876 |
+
Converts raw path from motion generator into end-effector trajectory sequence in the robot frame.
|
| 877 |
+
This trajectory sequence can be executed by an IKController, although there is no guaranteee that
|
| 878 |
+
the controller will output the same joint trajectory as the one computed by cuRobo.
|
| 879 |
+
|
| 880 |
+
Args:
|
| 881 |
+
path (JointState): Joint state path to convert into joint trajectory
|
| 882 |
+
return_axisangle (bool): Whether to return the interpolated orientations in quaternion or axis-angle representation
|
| 883 |
+
emb_sel (CuRoboEmbodimentSelection): Which embodiment to use for the robot
|
| 884 |
+
|
| 885 |
+
Returns:
|
| 886 |
+
Dict[str, torch.Tensor]: Mapping eef link names to (T, [6, 7])-shaped array where each entry is is the (x,y,z) position
|
| 887 |
+
and (x,y,z,w) quaternion (if @return_axisangle is False) or (ax, ay, az) axis-angle orientation, specified in the robot frame.
|
| 888 |
+
"""
|
| 889 |
+
# If the base-only embodiment is selected, the eef links stay the same, return the current eef poses in the robot frame
|
| 890 |
+
if emb_sel == CuRoboEmbodimentSelection.BASE:
|
| 891 |
+
link_poses = dict()
|
| 892 |
+
for arm_name in self.robot.arm_names:
|
| 893 |
+
link_name = self.robot.eef_link_names[arm_name]
|
| 894 |
+
position, orientation = self.robot.get_relative_eef_pose(arm_name)
|
| 895 |
+
if return_axisangle:
|
| 896 |
+
orientation = T.quat2axisangle(orientation)
|
| 897 |
+
link_poses[link_name] = th.cat([position, orientation], dim=-1)
|
| 898 |
+
return link_poses
|
| 899 |
+
|
| 900 |
+
cmd_plan = self.mg[emb_sel].get_full_js(path)
|
| 901 |
+
robot_state = self.mg[emb_sel].kinematics.compute_kinematics(path)
|
| 902 |
+
|
| 903 |
+
link_poses = dict()
|
| 904 |
+
|
| 905 |
+
for link_name, poses in robot_state.link_poses.items():
|
| 906 |
+
position = poses.position
|
| 907 |
+
# wxyz -> xyzw
|
| 908 |
+
orientation = poses.quaternion[:, [1, 2, 3, 0]]
|
| 909 |
+
|
| 910 |
+
# If the robot is holonomic, we need to transform the poses to the base link frame
|
| 911 |
+
if self.robot.is_holonomic_base:
|
| 912 |
+
base_link_position = th.zeros_like(position)
|
| 913 |
+
base_link_position[:, 0] = cmd_plan.position[:, cmd_plan.joint_names.index("base_footprint_x_joint")]
|
| 914 |
+
base_link_position[:, 1] = cmd_plan.position[:, cmd_plan.joint_names.index("base_footprint_y_joint")]
|
| 915 |
+
base_link_euler = th.zeros_like(position)
|
| 916 |
+
base_link_euler[:, 2] = cmd_plan.position[:, cmd_plan.joint_names.index("base_footprint_rz_joint")]
|
| 917 |
+
base_link_orientation = T.euler2quat(base_link_euler)
|
| 918 |
+
position, orientation = T.relative_pose_transform(
|
| 919 |
+
position, orientation, base_link_position, base_link_orientation
|
| 920 |
+
)
|
| 921 |
+
|
| 922 |
+
if return_axisangle:
|
| 923 |
+
orientation = T.quat2axisangle(orientation)
|
| 924 |
+
link_poses[link_name] = th.cat([position, orientation], dim=-1)
|
| 925 |
+
|
| 926 |
+
return link_poses
|
| 927 |
+
|
| 928 |
+
@property
|
| 929 |
+
def tensor_args(self):
|
| 930 |
+
"""
|
| 931 |
+
Returns:
|
| 932 |
+
TensorDeviceType: tensor arguments used by this CuRobo instance
|
| 933 |
+
"""
|
| 934 |
+
return self._tensor_args
|
| 935 |
+
|
| 936 |
+
def _attach_objects_to_robot(
|
| 937 |
+
self,
|
| 938 |
+
attached_obj,
|
| 939 |
+
attached_obj_scale,
|
| 940 |
+
cu_js_batch,
|
| 941 |
+
emb_sel,
|
| 942 |
+
):
|
| 943 |
+
"""
|
| 944 |
+
Helper function to attach objects to the robot.
|
| 945 |
+
|
| 946 |
+
Args:
|
| 947 |
+
attached_obj (None or Dict[str, USDObject]): Dictionary mapping end-effector
|
| 948 |
+
link names to corresponding USDObject instances
|
| 949 |
+
attached_obj_scale (None or Dict[str, float]): Dictionary mapping end-effector
|
| 950 |
+
link names to corresponding scale values
|
| 951 |
+
cu_js_batch (JointState): CuRobo joint state object ordered according to kinematics
|
| 952 |
+
emb_sel (CuRoboEmbodimentSelection): Which embodiment selection to use
|
| 953 |
+
|
| 954 |
+
Returns:
|
| 955 |
+
list: List of attached object information for detachment
|
| 956 |
+
"""
|
| 957 |
+
if attached_obj is None:
|
| 958 |
+
return []
|
| 959 |
+
|
| 960 |
+
attached_info = []
|
| 961 |
+
for ee_link_name, obj in attached_obj.items():
|
| 962 |
+
assert isinstance(obj, RigidDynamicPrim), "attached_object should be a RigidDynamicPrim object"
|
| 963 |
+
obj_paths = [geom.prim_path for geom in obj.collision_meshes.values()]
|
| 964 |
+
assert len(obj_paths) <= 32, f"Expected obj_paths to be at most 32, got: {len(obj_paths)}"
|
| 965 |
+
|
| 966 |
+
position, quaternion = self.robot.links[ee_link_name].get_position_orientation()
|
| 967 |
+
# xyzw to wxyz
|
| 968 |
+
quaternion = quaternion[[3, 0, 1, 2]]
|
| 969 |
+
ee_pose = lazy.curobo.types.math.Pose(position=position, quaternion=quaternion).to(self._tensor_args)
|
| 970 |
+
|
| 971 |
+
scale = m.DEFAULT_ATTACHED_OBJECT_SCALE if attached_obj_scale is None else attached_obj_scale[ee_link_name]
|
| 972 |
+
|
| 973 |
+
self.mg[emb_sel].attach_objects_to_robot(
|
| 974 |
+
joint_state=cu_js_batch,
|
| 975 |
+
object_names=obj_paths,
|
| 976 |
+
ee_pose=ee_pose,
|
| 977 |
+
link_name=self.robot.curobo_attached_object_link_names[ee_link_name],
|
| 978 |
+
scale=scale,
|
| 979 |
+
pitch_scale=1.0,
|
| 980 |
+
merge_meshes=True,
|
| 981 |
+
)
|
| 982 |
+
|
| 983 |
+
attached_info.append(
|
| 984 |
+
{"obj_paths": obj_paths, "link_name": self.robot.curobo_attached_object_link_names[ee_link_name]}
|
| 985 |
+
)
|
| 986 |
+
|
| 987 |
+
return attached_info
|
| 988 |
+
|
| 989 |
+
def _detach_objects_from_robot(
|
| 990 |
+
self,
|
| 991 |
+
attached_info,
|
| 992 |
+
emb_sel,
|
| 993 |
+
):
|
| 994 |
+
"""
|
| 995 |
+
Helper function to detach previously attached objects from the robot.
|
| 996 |
+
|
| 997 |
+
Args:
|
| 998 |
+
attached_info (list): List of dictionaries containing object paths and link names
|
| 999 |
+
returned by _attach_objects_to_robot
|
| 1000 |
+
emb_sel (CuRoboEmbodimentSelection): Which embodiment selection to use
|
| 1001 |
+
"""
|
| 1002 |
+
for info in attached_info:
|
| 1003 |
+
self.mg[emb_sel].detach_object_from_robot(
|
| 1004 |
+
object_names=info["obj_paths"],
|
| 1005 |
+
link_name=info["link_name"],
|
| 1006 |
+
)
|
source_data/pinned/behavior-1k-bddl/v3.9.3-post2/OmniGibson/omnigibson/action_primitives/starter_semantic_action_primitives.py
ADDED
|
@@ -0,0 +1,2093 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
WARNING!
|
| 3 |
+
The StarterSemanticActionPrimitive is a work-in-progress and is only provided as an example.
|
| 4 |
+
It currently only works with Tiago and R1 with their JointControllers set to absolute position mode.
|
| 5 |
+
See provided tiago_primitives.yaml config file for an example. See examples/action_primitives for
|
| 6 |
+
runnable examples.
|
| 7 |
+
"""
|
| 8 |
+
|
| 9 |
+
import inspect
|
| 10 |
+
import math
|
| 11 |
+
import random
|
| 12 |
+
from typing import Any
|
| 13 |
+
|
| 14 |
+
import cv2
|
| 15 |
+
import gymnasium as gym
|
| 16 |
+
import torch as th
|
| 17 |
+
from aenum import IntEnum, auto
|
| 18 |
+
from matplotlib import pyplot as plt
|
| 19 |
+
|
| 20 |
+
import omnigibson as og
|
| 21 |
+
import omnigibson.utils.transform_utils as T
|
| 22 |
+
from omnigibson import object_states
|
| 23 |
+
from omnigibson.action_primitives.action_primitive_set_base import (
|
| 24 |
+
ActionPrimitiveError,
|
| 25 |
+
ActionPrimitiveErrorGroup,
|
| 26 |
+
BaseActionPrimitiveSet,
|
| 27 |
+
)
|
| 28 |
+
from omnigibson.action_primitives.curobo import (
|
| 29 |
+
CuRoboEmbodimentSelection,
|
| 30 |
+
CuRoboMotionGenerator,
|
| 31 |
+
)
|
| 32 |
+
from omnigibson.controllers import (
|
| 33 |
+
ControllerView,
|
| 34 |
+
InverseKinematicsController,
|
| 35 |
+
HolonomicBaseJointController,
|
| 36 |
+
DifferentialDriveController,
|
| 37 |
+
)
|
| 38 |
+
from omnigibson.macros import create_module_macros
|
| 39 |
+
from omnigibson.macros import macros
|
| 40 |
+
from omnigibson.objects.usd_object import USDObject
|
| 41 |
+
from omnigibson.robots import Robot
|
| 42 |
+
from omnigibson.tasks.behavior_task import BehaviorTask
|
| 43 |
+
from omnigibson.utils.geometry_utils import wrap_angle
|
| 44 |
+
from omnigibson.utils.grasping_planning_utils import get_grasp_poses_for_object_sticky, get_grasp_position_for_open
|
| 45 |
+
from omnigibson.utils.motion_planning_utils import detect_robot_collision_in_sim
|
| 46 |
+
from omnigibson.utils.object_state_utils import sample_cuboid_for_predicate
|
| 47 |
+
from omnigibson.utils.python_utils import multi_dim_linspace
|
| 48 |
+
from omnigibson.utils.ui_utils import create_module_logger
|
| 49 |
+
|
| 50 |
+
m = create_module_macros(module_path=__file__)
|
| 51 |
+
|
| 52 |
+
m.DEFAULT_COLLISION_ACTIVATION_DISTANCE = 0.02
|
| 53 |
+
m.MAX_PLANNING_ATTEMPTS = 100
|
| 54 |
+
m.MAX_IK_FAILURES_BEFORE_RETURN = 50
|
| 55 |
+
|
| 56 |
+
m.MAX_STEPS_FOR_SETTLING = 500
|
| 57 |
+
|
| 58 |
+
m.MAX_STEPS_FOR_JOINT_MOTION = 10
|
| 59 |
+
|
| 60 |
+
m.MAX_CARTESIAN_HAND_STEP = 0.002
|
| 61 |
+
m.MAX_STEPS_FOR_HAND_MOVE_JOINT = 500
|
| 62 |
+
m.MAX_STEPS_FOR_HAND_MOVE_IK = 1000
|
| 63 |
+
m.MAX_STEPS_FOR_GRASP_OR_RELEASE = 250
|
| 64 |
+
m.MAX_STEPS_FOR_WAYPOINT_NAVIGATION = 500
|
| 65 |
+
m.MAX_ATTEMPTS_FOR_OPEN_CLOSE = 20
|
| 66 |
+
|
| 67 |
+
m.MAX_ATTEMPTS_FOR_SAMPLING_POSE_WITH_OBJECT_AND_PREDICATE = 20
|
| 68 |
+
m.MAX_ATTEMPTS_FOR_SAMPLING_POSE_NEAR_OBJECT = 200
|
| 69 |
+
m.MAX_ATTEMPTS_FOR_SAMPLING_POSE_FOR_CORRECT_ROOM = 20
|
| 70 |
+
m.MAX_ATTEMPTS_FOR_SAMPLING_POSE_IN_ROOM = 60
|
| 71 |
+
m.MAX_ATTEMPTS_FOR_SAMPLING_PLACE_POSE = 50
|
| 72 |
+
m.PREDICATE_SAMPLING_Z_OFFSET = 0.02
|
| 73 |
+
m.BASE_POSE_SAMPLING_LOWER_BOUND = 0.0
|
| 74 |
+
m.BASE_POSE_SAMPLING_UPPER_BOUND = 1.5
|
| 75 |
+
|
| 76 |
+
m.GRASP_APPROACH_DISTANCE = 0.01
|
| 77 |
+
m.OPEN_GRASP_APPROACH_DISTANCE = 0.4
|
| 78 |
+
|
| 79 |
+
m.HAND_DIST_THRESHOLD = 0.002
|
| 80 |
+
m.DEFAULT_DIST_THRESHOLD = 0.005
|
| 81 |
+
m.DEFAULT_ANGLE_THRESHOLD = 0.03
|
| 82 |
+
m.LOW_PRECISION_DIST_THRESHOLD = 0.1
|
| 83 |
+
m.LOW_PRECISION_ANGLE_THRESHOLD = 0.2
|
| 84 |
+
|
| 85 |
+
m.JOINT_POS_DIFF_THRESHOLD = 0.005
|
| 86 |
+
m.LOW_PRECISION_JOINT_POS_DIFF_THRESHOLD = 0.05
|
| 87 |
+
m.JOINT_CONTROL_MIN_ACTION = 0.0
|
| 88 |
+
m.MAX_ALLOWED_JOINT_ERROR_FOR_LINEAR_MOTION = math.radians(45)
|
| 89 |
+
m.TIME_BEFORE_JOINT_STUCK_CHECK = 1.0
|
| 90 |
+
|
| 91 |
+
log = create_module_logger(module_name=__name__)
|
| 92 |
+
|
| 93 |
+
|
| 94 |
+
def indented_print(msg, *args, **kwargs):
|
| 95 |
+
print(" " * len(inspect.stack()) + str(msg), *args, **kwargs)
|
| 96 |
+
|
| 97 |
+
|
| 98 |
+
class StarterSemanticActionPrimitiveSet(IntEnum):
|
| 99 |
+
_init_ = "value __doc__"
|
| 100 |
+
GRASP = auto(), "Grasp an object"
|
| 101 |
+
PLACE_ON_TOP = auto(), "Place the currently grasped object on top of another object"
|
| 102 |
+
PLACE_INSIDE = auto(), "Place the currently grasped object inside another object"
|
| 103 |
+
OPEN = auto(), "Open an object"
|
| 104 |
+
CLOSE = auto(), "Close an object"
|
| 105 |
+
NAVIGATE_TO = auto(), "Navigate to an object (mostly for debugging purposes - other primitives also navigate first)"
|
| 106 |
+
RELEASE = (
|
| 107 |
+
auto(),
|
| 108 |
+
"Release an object, letting it fall to the ground. You can then grasp it again, as a way of reorienting your grasp of the object.",
|
| 109 |
+
)
|
| 110 |
+
TOGGLE_ON = auto(), "Toggle an object on"
|
| 111 |
+
TOGGLE_OFF = auto(), "Toggle an object off"
|
| 112 |
+
|
| 113 |
+
|
| 114 |
+
# (TODO) execution failure: overwrite_head_action might move the head that causes self-collision with curobo-generated motion plans (at the time of curobo planning, it assumes the head doesn't move).
|
| 115 |
+
# (TODO) R1 improvement: create a new CuRoboEmbodimentSelection type that only allows for arm movement, and not torso movement.
|
| 116 |
+
|
| 117 |
+
|
| 118 |
+
class StarterSemanticActionPrimitives(BaseActionPrimitiveSet):
|
| 119 |
+
def __init__(
|
| 120 |
+
self,
|
| 121 |
+
env,
|
| 122 |
+
robot,
|
| 123 |
+
enable_head_tracking=True,
|
| 124 |
+
always_track_eef=False,
|
| 125 |
+
task_relevant_objects_only=False,
|
| 126 |
+
curobo_batch_size=3,
|
| 127 |
+
debug_visual_marker=None,
|
| 128 |
+
skip_curobo_initilization=False,
|
| 129 |
+
):
|
| 130 |
+
"""
|
| 131 |
+
Initializes a StarterSemanticActionPrimitives generator.
|
| 132 |
+
|
| 133 |
+
Args:
|
| 134 |
+
env (Environment): The environment that the primitives will run on.
|
| 135 |
+
robot (BaseRobot): The robot that the primitives will run on.
|
| 136 |
+
enable_head_tracking (bool): Whether to enable head tracking. Defaults to True.
|
| 137 |
+
always_track_eef (bool, optional): Whether to always track the end effector, as opposed
|
| 138 |
+
to switching between target object and end effector based on context. Defaults to False.
|
| 139 |
+
task_relevant_objects_only (bool): Whether to only consider objects relevant to the task
|
| 140 |
+
when computing the action space. Defaults to False.
|
| 141 |
+
curobo_batch_size (int): The batch size for curobo motion planning and collision checking. Defaults to 3.
|
| 142 |
+
debug_visual_marker (PrimitiveObject): The object to use for debug visual markers. Defaults to None.
|
| 143 |
+
skip_curobo_initilization (bool): Whether to skip curobo initialization. Defaults to False.
|
| 144 |
+
"""
|
| 145 |
+
log.warning(
|
| 146 |
+
"The StarterSemanticActionPrimitive is a work-in-progress and is only provided as an example. "
|
| 147 |
+
"It currently only works with Tiago and R1 with their HolonomicBaseJointController/JointControllers set to absolute position mode."
|
| 148 |
+
)
|
| 149 |
+
super().__init__(env, robot)
|
| 150 |
+
# Resolve which env this primitive controller is bound to, based on the robot's scene.
|
| 151 |
+
# Used by get_action_space() to pick the right per-env BehaviorTask object_scope.
|
| 152 |
+
self._env_idx = next(i for i, s in enumerate(env.scenes) if s is robot.scene)
|
| 153 |
+
self.controller_functions = {
|
| 154 |
+
StarterSemanticActionPrimitiveSet.GRASP: self._grasp,
|
| 155 |
+
StarterSemanticActionPrimitiveSet.PLACE_ON_TOP: self._place_on_top,
|
| 156 |
+
StarterSemanticActionPrimitiveSet.PLACE_INSIDE: self._place_inside,
|
| 157 |
+
StarterSemanticActionPrimitiveSet.OPEN: self._open,
|
| 158 |
+
StarterSemanticActionPrimitiveSet.CLOSE: self._close,
|
| 159 |
+
StarterSemanticActionPrimitiveSet.NAVIGATE_TO: self._navigate_to_obj,
|
| 160 |
+
StarterSemanticActionPrimitiveSet.RELEASE: self._execute_release,
|
| 161 |
+
StarterSemanticActionPrimitiveSet.TOGGLE_ON: self._toggle_on,
|
| 162 |
+
StarterSemanticActionPrimitiveSet.TOGGLE_OFF: self._toggle_off,
|
| 163 |
+
}
|
| 164 |
+
self._motion_generator = (
|
| 165 |
+
None
|
| 166 |
+
if skip_curobo_initilization
|
| 167 |
+
else CuRoboMotionGenerator(
|
| 168 |
+
robot=self.robot,
|
| 169 |
+
batch_size=curobo_batch_size,
|
| 170 |
+
collision_activation_distance=m.DEFAULT_COLLISION_ACTIVATION_DISTANCE,
|
| 171 |
+
)
|
| 172 |
+
)
|
| 173 |
+
|
| 174 |
+
self._task_relevant_objects_only = task_relevant_objects_only
|
| 175 |
+
|
| 176 |
+
self._enable_head_tracking = enable_head_tracking
|
| 177 |
+
self._always_track_eef = always_track_eef
|
| 178 |
+
self._tracking_object = None
|
| 179 |
+
|
| 180 |
+
# Store the current position of the arm as the arm target
|
| 181 |
+
self._arm_targets = {}
|
| 182 |
+
self._reset_eef_pose = {}
|
| 183 |
+
if self.robot.is_manipulation:
|
| 184 |
+
# Batched read of joint positions for all controllers
|
| 185 |
+
joint_positions = self.robot.get_joint_positions()
|
| 186 |
+
for arm_name in self.robot.arm_names:
|
| 187 |
+
arm = f"arm_{arm_name}"
|
| 188 |
+
arm_group_key, _ = self.robot.controllers[arm]
|
| 189 |
+
if ControllerView.is_controller_type(arm_group_key, InverseKinematicsController):
|
| 190 |
+
# Use the current relative end-effector pose as the IK target
|
| 191 |
+
pos_relative_np, quat_relative_np = self.robot.get_relative_eef_pose(arm_name)
|
| 192 |
+
pos_relative = pos_relative_np
|
| 193 |
+
quat_relative = quat_relative_np
|
| 194 |
+
quat_relative_axis_angle = T.quat2axisangle(quat_relative)
|
| 195 |
+
self._arm_targets[arm] = (pos_relative, quat_relative_axis_angle)
|
| 196 |
+
else:
|
| 197 |
+
# Use the current joint positions for this arm as the target
|
| 198 |
+
arm_target = joint_positions[ControllerView.get_dof_idx(arm_group_key)]
|
| 199 |
+
self._arm_targets[arm] = arm_target
|
| 200 |
+
|
| 201 |
+
self._reset_eef_pose[arm_name] = self.robot.get_relative_eef_pose(arm_name)
|
| 202 |
+
|
| 203 |
+
self._curobo_batch_size = curobo_batch_size
|
| 204 |
+
self.debug_visual_marker = debug_visual_marker
|
| 205 |
+
|
| 206 |
+
# Action primitives uses assisted grasping; we ignore delayed AG here
|
| 207 |
+
with macros.unlocked():
|
| 208 |
+
macros.robots.manipulation_robot.GRASP_WINDOW = 0.0
|
| 209 |
+
|
| 210 |
+
@property
|
| 211 |
+
def arm(self):
|
| 212 |
+
assert self.robot.is_manipulation, "Cannot use arm for non-manipulation robot"
|
| 213 |
+
return self.robot.default_arm
|
| 214 |
+
|
| 215 |
+
def _postprocess_action(self, action):
|
| 216 |
+
"""Postprocesses action by applying head tracking."""
|
| 217 |
+
if self._enable_head_tracking:
|
| 218 |
+
action = self._overwrite_head_action(action)
|
| 219 |
+
return action
|
| 220 |
+
|
| 221 |
+
def get_action_space(self):
|
| 222 |
+
# TODO: Figure out how to implement what happens when the set of objects in scene changes.
|
| 223 |
+
if self._task_relevant_objects_only:
|
| 224 |
+
assert isinstance(
|
| 225 |
+
self.env.task, BehaviorTask
|
| 226 |
+
), "Activity relevant objects can only be used for BEHAVIOR tasks"
|
| 227 |
+
self.addressable_objects = sorted(
|
| 228 |
+
set(self.env.task.object_scopes[self._env_idx].values()), key=lambda obj: obj.name
|
| 229 |
+
)
|
| 230 |
+
else:
|
| 231 |
+
self.addressable_objects = sorted(set(self.env.scene.objects_by_name.values()), key=lambda obj: obj.name)
|
| 232 |
+
|
| 233 |
+
# Filter out the robots.
|
| 234 |
+
self.addressable_objects = [obj for obj in self.addressable_objects if not isinstance(obj, Robot)]
|
| 235 |
+
|
| 236 |
+
self.num_objects = len(self.addressable_objects)
|
| 237 |
+
return gym.spaces.Tuple(
|
| 238 |
+
[gym.spaces.Discrete(self.num_objects), gym.spaces.Discrete(len(StarterSemanticActionPrimitiveSet))]
|
| 239 |
+
)
|
| 240 |
+
|
| 241 |
+
def get_action_from_primitive_and_object(self, primitive: StarterSemanticActionPrimitiveSet, obj: USDObject):
|
| 242 |
+
assert obj in self.addressable_objects
|
| 243 |
+
primitive_int = int(primitive)
|
| 244 |
+
return primitive_int, self.addressable_objects.index(obj)
|
| 245 |
+
|
| 246 |
+
def _get_obj_in_hand(self):
|
| 247 |
+
"""
|
| 248 |
+
Get object in the robot's hand
|
| 249 |
+
|
| 250 |
+
Returns:
|
| 251 |
+
StatefulObject or None: Object if robot is holding something or None if it is not
|
| 252 |
+
"""
|
| 253 |
+
obj_in_hand = self.robot._ag_obj_in_hand[self.arm] # TODO(MP): Expose this interface.
|
| 254 |
+
return obj_in_hand
|
| 255 |
+
|
| 256 |
+
def apply(self, action):
|
| 257 |
+
# Decompose the tuple
|
| 258 |
+
action_idx, obj_idx = action
|
| 259 |
+
|
| 260 |
+
# Find the target object.
|
| 261 |
+
target_obj = self.addressable_objects[obj_idx]
|
| 262 |
+
|
| 263 |
+
# Find the appropriate action generator.
|
| 264 |
+
action = StarterSemanticActionPrimitiveSet(action_idx)
|
| 265 |
+
return self.apply_ref(action, target_obj)
|
| 266 |
+
|
| 267 |
+
def apply_ref(self, primitive, *args: Any, attempts=5):
|
| 268 |
+
"""
|
| 269 |
+
Yields action for robot to execute the primitive with the given arguments.
|
| 270 |
+
|
| 271 |
+
Args:
|
| 272 |
+
primitive (StarterSemanticActionPrimitiveSet): Primitive to execute
|
| 273 |
+
args: Arguments for the primitive
|
| 274 |
+
attempts (int): Number of attempts to make before raising an error
|
| 275 |
+
|
| 276 |
+
Yields:
|
| 277 |
+
th.tensor or None: Action array for one step for the robot to execute the primitve or None if primitive completed
|
| 278 |
+
|
| 279 |
+
Raises:
|
| 280 |
+
ActionPrimitiveError: If primitive fails to execute
|
| 281 |
+
"""
|
| 282 |
+
ctrl = self.controller_functions[primitive]
|
| 283 |
+
|
| 284 |
+
errors = []
|
| 285 |
+
for _ in range(attempts):
|
| 286 |
+
# Attempt
|
| 287 |
+
success = False
|
| 288 |
+
try:
|
| 289 |
+
yield from ctrl(*args)
|
| 290 |
+
success = True
|
| 291 |
+
except ActionPrimitiveError as e:
|
| 292 |
+
errors.append(e)
|
| 293 |
+
|
| 294 |
+
try:
|
| 295 |
+
# If we're not holding anything, release the hand so it doesn't stick to anything else.
|
| 296 |
+
if not self._get_obj_in_hand():
|
| 297 |
+
yield from self._execute_release()
|
| 298 |
+
except ActionPrimitiveError:
|
| 299 |
+
pass
|
| 300 |
+
|
| 301 |
+
try:
|
| 302 |
+
# Make sure we retract the arms after every step
|
| 303 |
+
yield from self._reset_robot()
|
| 304 |
+
except ActionPrimitiveError:
|
| 305 |
+
pass
|
| 306 |
+
|
| 307 |
+
try:
|
| 308 |
+
# Settle before returning.
|
| 309 |
+
yield from self._settle_robot()
|
| 310 |
+
except ActionPrimitiveError:
|
| 311 |
+
pass
|
| 312 |
+
|
| 313 |
+
# Stop on success
|
| 314 |
+
if success:
|
| 315 |
+
return
|
| 316 |
+
|
| 317 |
+
raise ActionPrimitiveErrorGroup(errors)
|
| 318 |
+
|
| 319 |
+
# # One-attempt debug version
|
| 320 |
+
# ctrl = self.controller_functions[primitive]
|
| 321 |
+
# yield from ctrl(*args)
|
| 322 |
+
# if not self._get_obj_in_hand():
|
| 323 |
+
# yield from self._execute_release()
|
| 324 |
+
# yield from self._reset_robot()
|
| 325 |
+
# yield from self._settle_robot()
|
| 326 |
+
|
| 327 |
+
def _open(self, obj):
|
| 328 |
+
yield from self._open_or_close(obj, True)
|
| 329 |
+
|
| 330 |
+
def _close(self, obj):
|
| 331 |
+
yield from self._open_or_close(obj, False)
|
| 332 |
+
|
| 333 |
+
def _open_or_close(self, obj, should_open):
|
| 334 |
+
raise NotImplementedError("Open/close is not implemented correctly yet.")
|
| 335 |
+
|
| 336 |
+
# Update the tracking to track the eef.
|
| 337 |
+
self._tracking_object = self.robot
|
| 338 |
+
|
| 339 |
+
if self._get_obj_in_hand():
|
| 340 |
+
raise ActionPrimitiveError(
|
| 341 |
+
ActionPrimitiveError.Reason.PRE_CONDITION_ERROR,
|
| 342 |
+
"Cannot open or close an object while holding an object",
|
| 343 |
+
{"object in hand": self._get_obj_in_hand().name},
|
| 344 |
+
)
|
| 345 |
+
|
| 346 |
+
# Open the hand first
|
| 347 |
+
yield from self._execute_release()
|
| 348 |
+
|
| 349 |
+
for _ in range(m.MAX_ATTEMPTS_FOR_OPEN_CLOSE):
|
| 350 |
+
try:
|
| 351 |
+
# TODO: This needs to be fixed. Many assumptions (None relevant joint, 3 waypoints, etc.)
|
| 352 |
+
if should_open:
|
| 353 |
+
grasp_data = get_grasp_position_for_open(self.robot, obj, should_open, None)
|
| 354 |
+
else:
|
| 355 |
+
grasp_data = get_grasp_position_for_open(self.robot, obj, should_open, None, num_waypoints=3)
|
| 356 |
+
|
| 357 |
+
if grasp_data is None:
|
| 358 |
+
# We were trying to do something but didn't have the data.
|
| 359 |
+
raise ActionPrimitiveError(
|
| 360 |
+
ActionPrimitiveError.Reason.SAMPLING_ERROR,
|
| 361 |
+
"Could not sample grasp position for target object",
|
| 362 |
+
{"target object": obj.name},
|
| 363 |
+
)
|
| 364 |
+
|
| 365 |
+
relevant_joint, grasp_pose, target_poses, object_direction, grasp_required, pos_change = grasp_data
|
| 366 |
+
if abs(pos_change) < 0.1:
|
| 367 |
+
indented_print("Yaw change is small and done,", pos_change)
|
| 368 |
+
return
|
| 369 |
+
|
| 370 |
+
# Prepare data for the approach later.
|
| 371 |
+
approach_pos = grasp_pose[0] + object_direction * m.OPEN_GRASP_APPROACH_DISTANCE
|
| 372 |
+
approach_pose = (approach_pos, grasp_pose[1])
|
| 373 |
+
|
| 374 |
+
# If the grasp pose is too far, navigate
|
| 375 |
+
yield from self._navigate_if_needed(obj, eef_pose=grasp_pose)
|
| 376 |
+
|
| 377 |
+
yield from self._move_hand(grasp_pose, stop_if_stuck=True)
|
| 378 |
+
|
| 379 |
+
# We can pre-grasp in sticky grasping mode only for opening
|
| 380 |
+
if should_open:
|
| 381 |
+
yield from self._execute_grasp()
|
| 382 |
+
|
| 383 |
+
# Since the grasp pose is slightly off the object, we want to move towards the object, around 5cm.
|
| 384 |
+
# It's okay if we can't go all the way because we run into the object.
|
| 385 |
+
yield from self._navigate_if_needed(obj, eef_pose=approach_pose)
|
| 386 |
+
|
| 387 |
+
if should_open:
|
| 388 |
+
yield from self._move_hand_linearly_cartesian(
|
| 389 |
+
approach_pose, ignore_failure=False, stop_on_contact=True, stop_if_stuck=True
|
| 390 |
+
)
|
| 391 |
+
else:
|
| 392 |
+
yield from self._move_hand_linearly_cartesian(
|
| 393 |
+
approach_pose, ignore_failure=False, stop_if_stuck=True
|
| 394 |
+
)
|
| 395 |
+
|
| 396 |
+
# Step once to update
|
| 397 |
+
empty_action = self._empty_action()
|
| 398 |
+
yield self._postprocess_action(empty_action)
|
| 399 |
+
|
| 400 |
+
for i, target_pose in enumerate(target_poses):
|
| 401 |
+
yield from self._move_hand_linearly_cartesian(target_pose, ignore_failure=False, stop_if_stuck=True)
|
| 402 |
+
|
| 403 |
+
# Moving to target pose often fails. This might leave the robot's motors with torques that
|
| 404 |
+
# try to get to a far-away position thus applying large torques, but unable to move due to
|
| 405 |
+
# the sticky grasp joint. Thus if we release the joint, the robot might suddenly launch in an
|
| 406 |
+
# arbitrary direction. To avoid this, we command the hand to apply torques with its current
|
| 407 |
+
# position as its target. This prevents the hand from jerking into some other position when we do a release.
|
| 408 |
+
yield from self._move_hand_linearly_cartesian(
|
| 409 |
+
self.robot.eef_links[self.arm].get_position_orientation(), ignore_failure=True, stop_if_stuck=True
|
| 410 |
+
)
|
| 411 |
+
|
| 412 |
+
if should_open:
|
| 413 |
+
yield from self._execute_release()
|
| 414 |
+
yield from self._move_base_backward()
|
| 415 |
+
|
| 416 |
+
except ActionPrimitiveError as e:
|
| 417 |
+
indented_print(e)
|
| 418 |
+
if should_open:
|
| 419 |
+
yield from self._execute_release()
|
| 420 |
+
yield from self._move_base_backward()
|
| 421 |
+
else:
|
| 422 |
+
yield from self._move_hand_backward()
|
| 423 |
+
|
| 424 |
+
if obj.states[object_states.Open].get_value() != should_open:
|
| 425 |
+
raise ActionPrimitiveError(
|
| 426 |
+
ActionPrimitiveError.Reason.POST_CONDITION_ERROR,
|
| 427 |
+
"Despite executing the planned trajectory, the object did not open or close as expected. Maybe try again",
|
| 428 |
+
{"target object": obj.name, "is it currently open": obj.states[object_states.Open].get_value()},
|
| 429 |
+
)
|
| 430 |
+
|
| 431 |
+
# TODO: Figure out how to generalize out of this "backing out" behavior.
|
| 432 |
+
def _move_base_backward(self, steps=5, speed=0.2):
|
| 433 |
+
"""
|
| 434 |
+
Yields action for the robot to move base so the eef is in the target pose using the planner
|
| 435 |
+
|
| 436 |
+
Args:
|
| 437 |
+
steps (int): steps to move base
|
| 438 |
+
speed (float): base speed
|
| 439 |
+
|
| 440 |
+
Returns:
|
| 441 |
+
th.tensor or None: Action array for one step for the robot to move base or None if its at the target pose
|
| 442 |
+
"""
|
| 443 |
+
for _ in range(steps):
|
| 444 |
+
action = self._empty_action()
|
| 445 |
+
action[self.robot.controller_action_idx["gripper_{}".format(self.arm)]] = 1.0
|
| 446 |
+
action[self.robot.base_control_idx[0]] = -speed
|
| 447 |
+
yield self._postprocess_action(action)
|
| 448 |
+
|
| 449 |
+
def _move_hand_backward(self, steps=5, speed=0.2):
|
| 450 |
+
"""
|
| 451 |
+
Yields action for the robot to move its base backwards.
|
| 452 |
+
|
| 453 |
+
Args:
|
| 454 |
+
steps (int): steps to move eef
|
| 455 |
+
speed (float): eef speed
|
| 456 |
+
|
| 457 |
+
Returns:
|
| 458 |
+
th.tensor or None: Action array for one step for the robot to move hand or None if its at the target pose
|
| 459 |
+
"""
|
| 460 |
+
for _ in range(steps):
|
| 461 |
+
action = self._empty_action()
|
| 462 |
+
action[self.robot.controller_action_idx["gripper_{}".format(self.arm)]] = 1.0
|
| 463 |
+
action[self.robot.controller_action_idx["arm_{}".format(self.arm)][0]] = -speed
|
| 464 |
+
yield self._postprocess_action(action)
|
| 465 |
+
|
| 466 |
+
def _move_hand_upward(self, steps=5, speed=0.1):
|
| 467 |
+
"""
|
| 468 |
+
Yields action for the robot to move hand upward.
|
| 469 |
+
|
| 470 |
+
Args:
|
| 471 |
+
steps (int): steps to move eef
|
| 472 |
+
speed (float): eef speed
|
| 473 |
+
|
| 474 |
+
Returns:
|
| 475 |
+
th.tensor or None: Action array for one step for the robot to move hand or None if its at the target pose
|
| 476 |
+
"""
|
| 477 |
+
# TODO: Combine these movement functions.
|
| 478 |
+
for _ in range(steps):
|
| 479 |
+
action = self._empty_action()
|
| 480 |
+
action[self.robot.controller_action_idx["gripper_{}".format(self.arm)]] = 1.0
|
| 481 |
+
action[self.robot.controller_action_idx["arm_{}".format(self.arm)][2]] = speed
|
| 482 |
+
yield self._postprocess_action(action)
|
| 483 |
+
|
| 484 |
+
def _sample_grasp_pose(self, obj):
|
| 485 |
+
"""
|
| 486 |
+
Samples an eef grasp pose for the object
|
| 487 |
+
|
| 488 |
+
Args:
|
| 489 |
+
obj (USDObject): Object to sample grasp pose for
|
| 490 |
+
|
| 491 |
+
Returns:
|
| 492 |
+
Tuple[th.tensor, th.tensor]: Pregrasp pose and grasp pose of the robot eef in the world frame
|
| 493 |
+
"""
|
| 494 |
+
indented_print("Sampling grasp pose")
|
| 495 |
+
grasp_poses = get_grasp_poses_for_object_sticky(obj)
|
| 496 |
+
grasp_pos, grasp_quat = random.choice(grasp_poses)
|
| 497 |
+
|
| 498 |
+
# Identity quaternion for top-down grasping (x-forward, y-right, z-down)
|
| 499 |
+
approach_dir = T.quat2mat(grasp_quat) @ th.tensor([0.0, 0.0, -1.0])
|
| 500 |
+
|
| 501 |
+
avg_finger_offset = th.mean(
|
| 502 |
+
th.tensor([length for length in self.robot.eef_to_fingertip_lengths[self.arm].values()])
|
| 503 |
+
)
|
| 504 |
+
pregrasp_offset = avg_finger_offset + m.GRASP_APPROACH_DISTANCE
|
| 505 |
+
|
| 506 |
+
pregrasp_pos = grasp_pos - approach_dir * pregrasp_offset
|
| 507 |
+
|
| 508 |
+
# The sampled grasp pose is robot-agnostic
|
| 509 |
+
# We need to multiply by the quaternion of the robot's eef frame of top-down grasping (x-forward, y-right, z-down)
|
| 510 |
+
grasp_quat = T.quat_multiply(grasp_quat, th.tensor([1.0, 0.0, 0.0, 0.0]))
|
| 511 |
+
|
| 512 |
+
pregrasp_pose = (pregrasp_pos, grasp_quat)
|
| 513 |
+
grasp_pose = (grasp_pos, grasp_quat)
|
| 514 |
+
|
| 515 |
+
return pregrasp_pose, grasp_pose
|
| 516 |
+
|
| 517 |
+
def _grasp(self, obj):
|
| 518 |
+
"""
|
| 519 |
+
Yields action for the robot to navigate to object if needed, then to grasp it
|
| 520 |
+
|
| 521 |
+
Args:
|
| 522 |
+
StatefulObject: Object for robot to grasp
|
| 523 |
+
|
| 524 |
+
Returns:
|
| 525 |
+
th.tensor or None: Action array for one step for the robot to grasp or None if grasp completed
|
| 526 |
+
"""
|
| 527 |
+
if obj is None or not isinstance(obj, USDObject):
|
| 528 |
+
raise ActionPrimitiveError(
|
| 529 |
+
ActionPrimitiveError.Reason.PRE_CONDITION_ERROR,
|
| 530 |
+
"You need to provide an object to grasp",
|
| 531 |
+
{"provided object": obj},
|
| 532 |
+
)
|
| 533 |
+
if self.robot.grasping_mode not in ["sticky", "assisted"]:
|
| 534 |
+
raise ActionPrimitiveError(
|
| 535 |
+
ActionPrimitiveError.Reason.PRE_CONDITION_ERROR,
|
| 536 |
+
"Grasping mode not supported",
|
| 537 |
+
{"grasping mode": self.robot.grasping_mode},
|
| 538 |
+
)
|
| 539 |
+
|
| 540 |
+
# Update the tracking to track the object.
|
| 541 |
+
self._tracking_object = obj
|
| 542 |
+
|
| 543 |
+
# Don't do anything if the object is already grasped.
|
| 544 |
+
obj_in_hand = self._get_obj_in_hand()
|
| 545 |
+
if obj_in_hand is not None:
|
| 546 |
+
if obj_in_hand == obj:
|
| 547 |
+
return
|
| 548 |
+
else:
|
| 549 |
+
raise ActionPrimitiveError(
|
| 550 |
+
ActionPrimitiveError.Reason.PRE_CONDITION_ERROR,
|
| 551 |
+
"Cannot grasp when your hand is already full",
|
| 552 |
+
{"target object": obj.name, "object currently in hand": obj_in_hand.name},
|
| 553 |
+
)
|
| 554 |
+
|
| 555 |
+
# Open the hand first
|
| 556 |
+
indented_print("Opening hand before grasping")
|
| 557 |
+
yield from self._execute_release()
|
| 558 |
+
|
| 559 |
+
pregrasp_pose, grasp_pose = self._sample_grasp_pose(obj)
|
| 560 |
+
|
| 561 |
+
# If the pre-grasp pose is too far, navigate.
|
| 562 |
+
indented_print("Navigating to grasp pose if needed")
|
| 563 |
+
yield from self._navigate_if_needed(obj, eef_pose=pregrasp_pose)
|
| 564 |
+
|
| 565 |
+
indented_print("Moving hand to grasp pose")
|
| 566 |
+
yield from self._move_hand(pregrasp_pose)
|
| 567 |
+
|
| 568 |
+
if self.robot.grasping_mode == "sticky":
|
| 569 |
+
indented_print("Sticky grasping: close gripper")
|
| 570 |
+
# Close the gripper
|
| 571 |
+
yield from self._execute_grasp()
|
| 572 |
+
|
| 573 |
+
indented_print("Sticky grasping: approach")
|
| 574 |
+
# Only translate in the z-axis of the goal frame (assuming z-axis points out of the gripper)
|
| 575 |
+
# This is the same as requesting the end-effector to move along the approach_dir direction.
|
| 576 |
+
# By default, it's NOT the z-axis of the world frame unless `project_pose_to_goal_frame=False` is set in curobo.
|
| 577 |
+
# For sticky grasping, we also need to ignore the object during motion planning because the fingers are already closed.
|
| 578 |
+
yield from self._move_hand(
|
| 579 |
+
grasp_pose, motion_constraint=[1, 1, 1, 1, 1, 0], stop_on_ag=True, ignore_objects=[obj]
|
| 580 |
+
)
|
| 581 |
+
elif self.robot.grasping_mode == "assisted":
|
| 582 |
+
indented_print("Assisted grasping: approach")
|
| 583 |
+
# Same as above in terms of moving along the approach_dir direction, but we don't ignore the object.
|
| 584 |
+
# For this approach motion, we expect the fingers to move towards and eventually "wrap" around the object without collisions.
|
| 585 |
+
yield from self._move_hand(grasp_pose, motion_constraint=[1, 1, 1, 1, 1, 0])
|
| 586 |
+
|
| 587 |
+
# Now we close the fingers to grasp the object with AG.
|
| 588 |
+
indented_print("Assisted grasping: close gripper")
|
| 589 |
+
yield from self._execute_grasp()
|
| 590 |
+
|
| 591 |
+
# Step a few times to update
|
| 592 |
+
yield from self._settle_robot()
|
| 593 |
+
|
| 594 |
+
indented_print("Checking grasp")
|
| 595 |
+
obj_in_hand = self._get_obj_in_hand()
|
| 596 |
+
if obj_in_hand is None:
|
| 597 |
+
raise ActionPrimitiveError(
|
| 598 |
+
ActionPrimitiveError.Reason.POST_CONDITION_ERROR,
|
| 599 |
+
"Grasp completed, but no object detected in hand after executing grasp",
|
| 600 |
+
{"target object": obj.name},
|
| 601 |
+
)
|
| 602 |
+
|
| 603 |
+
indented_print("Done with grasp")
|
| 604 |
+
|
| 605 |
+
if self._get_obj_in_hand() != obj:
|
| 606 |
+
raise ActionPrimitiveError(
|
| 607 |
+
ActionPrimitiveError.Reason.POST_CONDITION_ERROR,
|
| 608 |
+
"An unexpected object was detected in hand after executing grasp. Consider releasing it",
|
| 609 |
+
{"expected object": obj.name, "actual object": self._get_obj_in_hand().name},
|
| 610 |
+
)
|
| 611 |
+
|
| 612 |
+
def _place_on_top(self, obj):
|
| 613 |
+
"""
|
| 614 |
+
Yields action for the robot to navigate to the object if needed, then to place an object on it
|
| 615 |
+
|
| 616 |
+
Args:
|
| 617 |
+
obj (StatefulObject): Object for robot to place the object in its hand on
|
| 618 |
+
|
| 619 |
+
Returns:
|
| 620 |
+
th.tensor or None: Action array for one step for the robot to place or None if place completed
|
| 621 |
+
"""
|
| 622 |
+
yield from self._place_with_predicate(obj, object_states.OnTop)
|
| 623 |
+
|
| 624 |
+
def _place_inside(self, obj):
|
| 625 |
+
"""
|
| 626 |
+
Yields action for the robot to navigate to the object if needed, then to place an object in it
|
| 627 |
+
|
| 628 |
+
Args:
|
| 629 |
+
obj (StatefulObject): Object for robot to place the object in its hand on
|
| 630 |
+
|
| 631 |
+
Returns:
|
| 632 |
+
th.tensor or None: Action array for one step for the robot to place or None if place completed
|
| 633 |
+
"""
|
| 634 |
+
yield from self._place_with_predicate(obj, object_states.Inside)
|
| 635 |
+
|
| 636 |
+
def _toggle_on(self, obj):
|
| 637 |
+
yield from self._toggle(obj, True)
|
| 638 |
+
|
| 639 |
+
def _toggle_off(self, obj):
|
| 640 |
+
yield from self._toggle(obj, False)
|
| 641 |
+
|
| 642 |
+
def _toggle(self, obj, value):
|
| 643 |
+
raise NotImplementedError("Toggle is not implemented correctly yet.")
|
| 644 |
+
|
| 645 |
+
if obj.states[object_states.ToggledOn].get_value() == value:
|
| 646 |
+
return
|
| 647 |
+
|
| 648 |
+
# Put the hand in the toggle marker.
|
| 649 |
+
toggle_state = obj.states[object_states.ToggledOn]
|
| 650 |
+
toggle_position = toggle_state.get_link_position()
|
| 651 |
+
yield from self._navigate_if_needed(obj, toggle_position)
|
| 652 |
+
|
| 653 |
+
# Just keep the current hand orientation.
|
| 654 |
+
hand_orientation = self.robot.eef_links[self.arm].get_position_orientation()[1]
|
| 655 |
+
desired_hand_pose = (toggle_position, hand_orientation)
|
| 656 |
+
|
| 657 |
+
yield from self._move_hand(desired_hand_pose)
|
| 658 |
+
|
| 659 |
+
if obj.states[object_states.ToggledOn].get_value() != value:
|
| 660 |
+
raise ActionPrimitiveError(
|
| 661 |
+
ActionPrimitiveError.Reason.POST_CONDITION_ERROR,
|
| 662 |
+
"The object did not toggle as expected - maybe try again",
|
| 663 |
+
{
|
| 664 |
+
"target object": obj.name,
|
| 665 |
+
"is it currently toggled on": obj.states[object_states.ToggledOn].get_value(),
|
| 666 |
+
},
|
| 667 |
+
)
|
| 668 |
+
|
| 669 |
+
def _place_with_predicate(self, obj, predicate):
|
| 670 |
+
"""
|
| 671 |
+
Yields action for the robot to navigate to the object if needed, then to place it
|
| 672 |
+
|
| 673 |
+
Args:
|
| 674 |
+
obj (StatefulObject): Object for robot to place the object in its hand on
|
| 675 |
+
predicate (object_states.OnTop or object_states.Inside): Determines whether to place on top or inside
|
| 676 |
+
|
| 677 |
+
Returns:
|
| 678 |
+
th.tensor or None: Action array for one step for the robot to place or None if place completed
|
| 679 |
+
"""
|
| 680 |
+
if obj is None or not isinstance(obj, USDObject):
|
| 681 |
+
raise ActionPrimitiveError(
|
| 682 |
+
ActionPrimitiveError.Reason.PRE_CONDITION_ERROR,
|
| 683 |
+
"You need to provide an object to place the object in your hand on",
|
| 684 |
+
{"provided object": obj},
|
| 685 |
+
)
|
| 686 |
+
# Update the tracking to track the object.
|
| 687 |
+
self._tracking_object = obj
|
| 688 |
+
|
| 689 |
+
obj_in_hand = self._get_obj_in_hand()
|
| 690 |
+
if obj_in_hand is None:
|
| 691 |
+
raise ActionPrimitiveError(
|
| 692 |
+
ActionPrimitiveError.Reason.PRE_CONDITION_ERROR,
|
| 693 |
+
"You need to be grasping an object first to place it somewhere.",
|
| 694 |
+
)
|
| 695 |
+
|
| 696 |
+
self._motion_generator.update_obstacles()
|
| 697 |
+
target_in_reach = False
|
| 698 |
+
valid_navigation_pose = None
|
| 699 |
+
for _ in range(m.MAX_ATTEMPTS_FOR_SAMPLING_PLACE_POSE):
|
| 700 |
+
# Sample one pose at a time
|
| 701 |
+
obj_pose = self._sample_pose_with_object_and_predicate(predicate, obj_in_hand, obj, world_aligned=True)
|
| 702 |
+
hand_pose = self._get_hand_pose_for_object_pose(obj_pose)
|
| 703 |
+
|
| 704 |
+
# First check if we can directly move the hand there
|
| 705 |
+
# We want to plan with the fingers at their upper (open) limits to avoid collisions
|
| 706 |
+
# because later we will open-loop open the gripper with _execute_release after placing.
|
| 707 |
+
initial_joint_pos = self._get_joint_position_with_fingers_at_limit("upper")
|
| 708 |
+
target_in_reach = self._target_in_reach_of_robot(
|
| 709 |
+
hand_pose, initial_joint_pos=initial_joint_pos, skip_obstacle_update=True
|
| 710 |
+
)
|
| 711 |
+
if target_in_reach:
|
| 712 |
+
yield from self._move_hand(hand_pose)
|
| 713 |
+
break
|
| 714 |
+
|
| 715 |
+
# If not, try to find a valid navigation pose for this hand pose
|
| 716 |
+
valid_navigation_pose = self._sample_pose_near_object(
|
| 717 |
+
obj, eef_pose=hand_pose, plan_with_open_gripper=True, sampling_attempts=10, skip_obstacle_update=True
|
| 718 |
+
)
|
| 719 |
+
|
| 720 |
+
if valid_navigation_pose is not None:
|
| 721 |
+
yield from self._navigate_to_pose(valid_navigation_pose, skip_obstacle_update=True)
|
| 722 |
+
yield from self._move_hand(hand_pose)
|
| 723 |
+
break
|
| 724 |
+
|
| 725 |
+
if not target_in_reach and valid_navigation_pose is None:
|
| 726 |
+
raise ActionPrimitiveError(
|
| 727 |
+
ActionPrimitiveError.Reason.PLANNING_ERROR,
|
| 728 |
+
"Could not find a valid pose to place the object",
|
| 729 |
+
{"target object": obj.name},
|
| 730 |
+
)
|
| 731 |
+
|
| 732 |
+
yield from self._execute_release()
|
| 733 |
+
|
| 734 |
+
if self._get_obj_in_hand() is not None:
|
| 735 |
+
raise ActionPrimitiveError(
|
| 736 |
+
ActionPrimitiveError.Reason.EXECUTION_ERROR,
|
| 737 |
+
"Could not release object - the object is still in your hand",
|
| 738 |
+
{"object": self._get_obj_in_hand().name},
|
| 739 |
+
)
|
| 740 |
+
|
| 741 |
+
if not obj_in_hand.states[predicate].get_value(obj):
|
| 742 |
+
raise ActionPrimitiveError(
|
| 743 |
+
ActionPrimitiveError.Reason.EXECUTION_ERROR,
|
| 744 |
+
"Failed to place object at the desired place (probably dropped). The object was still released, so you need to grasp it again to continue",
|
| 745 |
+
{"dropped object": obj_in_hand.name, "target object": obj.name},
|
| 746 |
+
)
|
| 747 |
+
|
| 748 |
+
def _convert_cartesian_to_joint_space(self, target_pose):
|
| 749 |
+
"""
|
| 750 |
+
Gets joint positions for the arm so eef is at the target pose
|
| 751 |
+
|
| 752 |
+
Args:
|
| 753 |
+
target_pose (Tuple[th.tensor, th.tensor]): target pose to reach for the default end-effector in the world frame
|
| 754 |
+
|
| 755 |
+
Returns:
|
| 756 |
+
2-tuple
|
| 757 |
+
- th.tensor or None: Joint positions to reach target pose or None if impossible to reach target pose
|
| 758 |
+
- th.tensor: Indices for joints in the robot
|
| 759 |
+
"""
|
| 760 |
+
joint_pos = self._ik_solver_cartesian_to_joint_space(target_pose)
|
| 761 |
+
if joint_pos is None:
|
| 762 |
+
raise ActionPrimitiveError(
|
| 763 |
+
ActionPrimitiveError.Reason.PLANNING_ERROR,
|
| 764 |
+
"Could not find joint positions for target pose. You cannot reach it. Try again for a new pose",
|
| 765 |
+
)
|
| 766 |
+
return joint_pos
|
| 767 |
+
|
| 768 |
+
def _target_in_reach_of_robot(self, target_pose, initial_joint_pos=None, skip_obstacle_update=False):
|
| 769 |
+
"""
|
| 770 |
+
Determines whether the eef for the robot can reach the target pose in the world frame
|
| 771 |
+
|
| 772 |
+
Args:
|
| 773 |
+
target_pose (Tuple[th.tensor, th.tensor]): target pose to reach for the default end-effector in the world frame
|
| 774 |
+
skip_obstacle_update (bool): Whether to skip updating obstacles
|
| 775 |
+
|
| 776 |
+
Returns:
|
| 777 |
+
bool: Whether the default eef can reach the target pose
|
| 778 |
+
"""
|
| 779 |
+
return (
|
| 780 |
+
self._ik_solver_cartesian_to_joint_space(
|
| 781 |
+
target_pose,
|
| 782 |
+
initial_joint_pos=initial_joint_pos,
|
| 783 |
+
skip_obstacle_update=skip_obstacle_update,
|
| 784 |
+
)
|
| 785 |
+
is not None
|
| 786 |
+
)
|
| 787 |
+
|
| 788 |
+
def _manipulation_control_idx(self):
|
| 789 |
+
"""The appropriate manipulation control idx for the current settings."""
|
| 790 |
+
return th.cat([self.robot.trunk_control_idx, self.robot.arm_control_idx[self.arm]])
|
| 791 |
+
|
| 792 |
+
def _ik_solver_cartesian_to_joint_space(self, target_pose, initial_joint_pos=None, skip_obstacle_update=False):
|
| 793 |
+
"""
|
| 794 |
+
Get joint positions for the arm so eef is at the target pose in the world frame
|
| 795 |
+
|
| 796 |
+
Args:
|
| 797 |
+
target_pose (Tuple[th.tensor, th.tensor]): target pose to reach for the default end-effector in the world frame
|
| 798 |
+
initial_joint_pos (None or th.tensor): If specified, the initial joint positions to set the locked joints.
|
| 799 |
+
Default is the current joint positions of the robot
|
| 800 |
+
skip_obstacle_update (bool): Whether to skip updating obstacles
|
| 801 |
+
|
| 802 |
+
Returns:
|
| 803 |
+
2-tuple
|
| 804 |
+
- th.tensor or None: Joint positions to reach target pose or None if impossible to reach the target pose
|
| 805 |
+
- th.tensor: Indices for joints in the robot
|
| 806 |
+
"""
|
| 807 |
+
target_pos = {self.robot.eef_link_names[self.arm]: target_pose[0]}
|
| 808 |
+
target_quat = {self.robot.eef_link_names[self.arm]: target_pose[1]}
|
| 809 |
+
|
| 810 |
+
target_pos = {k: th.stack([v for _ in range(self._motion_generator.batch_size)]) for k, v in target_pos.items()}
|
| 811 |
+
target_quat = {
|
| 812 |
+
k: th.stack([v for _ in range(self._motion_generator.batch_size)]) for k, v in target_quat.items()
|
| 813 |
+
}
|
| 814 |
+
|
| 815 |
+
successes, joint_states = self._motion_generator.compute_trajectories(
|
| 816 |
+
target_pos=target_pos,
|
| 817 |
+
target_quat=target_quat,
|
| 818 |
+
initial_joint_pos=initial_joint_pos,
|
| 819 |
+
is_local=False,
|
| 820 |
+
max_attempts=math.ceil(m.MAX_PLANNING_ATTEMPTS / self._motion_generator.batch_size),
|
| 821 |
+
timeout=60.0,
|
| 822 |
+
ik_fail_return=m.MAX_IK_FAILURES_BEFORE_RETURN,
|
| 823 |
+
enable_finetune_trajopt=False,
|
| 824 |
+
finetune_attempts=0,
|
| 825 |
+
return_full_result=False,
|
| 826 |
+
success_ratio=1.0 / self._motion_generator.batch_size,
|
| 827 |
+
attached_obj=None,
|
| 828 |
+
attached_obj_scale=None,
|
| 829 |
+
motion_constraint=None,
|
| 830 |
+
skip_obstacle_update=skip_obstacle_update,
|
| 831 |
+
ik_only=True,
|
| 832 |
+
ik_world_collision_check=True,
|
| 833 |
+
emb_sel=CuRoboEmbodimentSelection.ARM,
|
| 834 |
+
)
|
| 835 |
+
|
| 836 |
+
# Grab the first successful joint state if found
|
| 837 |
+
success_idx = th.where(successes)[0].cpu()
|
| 838 |
+
if len(success_idx) == 0:
|
| 839 |
+
return None
|
| 840 |
+
|
| 841 |
+
joint_state = joint_states[success_idx[0]]
|
| 842 |
+
joint_pos = self._motion_generator.path_to_joint_trajectory(
|
| 843 |
+
joint_state, get_full_js=False, emb_sel=CuRoboEmbodimentSelection.ARM
|
| 844 |
+
)
|
| 845 |
+
return joint_pos[self._manipulation_control_idx()].cpu()
|
| 846 |
+
|
| 847 |
+
def _move_hand(
|
| 848 |
+
self,
|
| 849 |
+
target_pose,
|
| 850 |
+
stop_on_contact=False,
|
| 851 |
+
stop_on_ag=False,
|
| 852 |
+
motion_constraint=None,
|
| 853 |
+
low_precision=False,
|
| 854 |
+
lock_auxiliary_arm=False,
|
| 855 |
+
ignore_objects=None,
|
| 856 |
+
):
|
| 857 |
+
"""
|
| 858 |
+
Yields action for the robot to move hand so the eef is in the target pose using the planner
|
| 859 |
+
|
| 860 |
+
Args:
|
| 861 |
+
target_pose (Tuple[th.tensor, th.tensor]): target pose to reach for the default end-effector in the world frame
|
| 862 |
+
stop_on_contact (bool): Whether to stop executing motion plan if contact is detected
|
| 863 |
+
stop_on_ag (bool): Whether to stop executing motion plan if assisted grasping is activated
|
| 864 |
+
motion_constraint (MotionConstraint): Motion constraint for the motion
|
| 865 |
+
low_precision (bool): Whether to use low precision for the motion
|
| 866 |
+
lock_auxiliary_arm (bool): Whether to lock the other arm in place
|
| 867 |
+
ignore_objects (None or list of str): If specified, objects that should be ignored when planning
|
| 868 |
+
|
| 869 |
+
Returns:
|
| 870 |
+
th.tensor or None: Action array for one step for the robot to move hand or None if its at the target pose
|
| 871 |
+
"""
|
| 872 |
+
if self.debug_visual_marker is not None:
|
| 873 |
+
self.debug_visual_marker.set_position_orientation(*target_pose)
|
| 874 |
+
|
| 875 |
+
yield from self._settle_robot()
|
| 876 |
+
# curobo motion generator takes a pose but outputs joint positions
|
| 877 |
+
if not lock_auxiliary_arm:
|
| 878 |
+
target_pos = {
|
| 879 |
+
self.robot.eef_link_names[self.arm]: target_pose[0],
|
| 880 |
+
}
|
| 881 |
+
target_quat = {
|
| 882 |
+
self.robot.eef_link_names[self.arm]: target_pose[1],
|
| 883 |
+
}
|
| 884 |
+
else:
|
| 885 |
+
left_hand_pos, left_hand_quat = target_pose if self.arm == "left" else self.robot.get_eef_pose(arm="left")
|
| 886 |
+
right_hand_pos, right_hand_quat = (
|
| 887 |
+
target_pose if self.arm == "right" else self.robot.get_eef_pose(arm="right")
|
| 888 |
+
)
|
| 889 |
+
target_pos = {
|
| 890 |
+
self.robot.eef_link_names["left"]: left_hand_pos,
|
| 891 |
+
self.robot.eef_link_names["right"]: right_hand_pos,
|
| 892 |
+
}
|
| 893 |
+
target_quat = {
|
| 894 |
+
self.robot.eef_link_names["left"]: left_hand_quat,
|
| 895 |
+
self.robot.eef_link_names["right"]: right_hand_quat,
|
| 896 |
+
}
|
| 897 |
+
q_traj = self._plan_joint_motion(
|
| 898 |
+
target_pos=target_pos,
|
| 899 |
+
target_quat=target_quat,
|
| 900 |
+
embodiment_selection=CuRoboEmbodimentSelection.ARM,
|
| 901 |
+
motion_constraint=motion_constraint,
|
| 902 |
+
ignore_objects=ignore_objects,
|
| 903 |
+
)
|
| 904 |
+
|
| 905 |
+
indented_print(f"Plan has {len(q_traj)} steps")
|
| 906 |
+
yield from self._execute_motion_plan(
|
| 907 |
+
q_traj, stop_on_contact=stop_on_contact, stop_on_ag=stop_on_ag, low_precision=low_precision
|
| 908 |
+
)
|
| 909 |
+
|
| 910 |
+
def _plan_joint_motion(
|
| 911 |
+
self,
|
| 912 |
+
target_pos,
|
| 913 |
+
target_quat,
|
| 914 |
+
embodiment_selection=CuRoboEmbodimentSelection.DEFAULT,
|
| 915 |
+
motion_constraint=None,
|
| 916 |
+
skip_obstacle_update=False,
|
| 917 |
+
ignore_objects=None,
|
| 918 |
+
):
|
| 919 |
+
# If an object is grasped, we need to pass it to the motion planner
|
| 920 |
+
obj_in_hand = self._get_obj_in_hand()
|
| 921 |
+
attached_obj = {self.robot.eef_link_names[self.arm]: obj_in_hand.root_link} if obj_in_hand is not None else None
|
| 922 |
+
|
| 923 |
+
# Aggregate target_pos and target_quat to match batch_size
|
| 924 |
+
target_pos = {k: th.stack([v for _ in range(self._motion_generator.batch_size)]) for k, v in target_pos.items()}
|
| 925 |
+
target_quat = {
|
| 926 |
+
k: th.stack([v for _ in range(self._motion_generator.batch_size)]) for k, v in target_quat.items()
|
| 927 |
+
}
|
| 928 |
+
|
| 929 |
+
if not skip_obstacle_update:
|
| 930 |
+
self._motion_generator.update_obstacles(ignore_objects=ignore_objects)
|
| 931 |
+
|
| 932 |
+
successes, traj_paths = self._motion_generator.compute_trajectories(
|
| 933 |
+
target_pos=target_pos,
|
| 934 |
+
target_quat=target_quat,
|
| 935 |
+
initial_joint_pos=None,
|
| 936 |
+
is_local=False,
|
| 937 |
+
max_attempts=math.ceil(m.MAX_PLANNING_ATTEMPTS / self._motion_generator.batch_size),
|
| 938 |
+
timeout=60.0,
|
| 939 |
+
ik_fail_return=m.MAX_IK_FAILURES_BEFORE_RETURN,
|
| 940 |
+
enable_finetune_trajopt=True,
|
| 941 |
+
finetune_attempts=1,
|
| 942 |
+
return_full_result=False,
|
| 943 |
+
success_ratio=1.0 / self._motion_generator.batch_size,
|
| 944 |
+
attached_obj=attached_obj,
|
| 945 |
+
attached_obj_scale=None,
|
| 946 |
+
motion_constraint=motion_constraint,
|
| 947 |
+
skip_obstacle_update=True,
|
| 948 |
+
ik_only=False,
|
| 949 |
+
ik_world_collision_check=True,
|
| 950 |
+
emb_sel=embodiment_selection,
|
| 951 |
+
)
|
| 952 |
+
# Grab the first successful trajectory if found
|
| 953 |
+
success_idx = th.where(successes)[0].cpu()
|
| 954 |
+
if len(success_idx) == 0:
|
| 955 |
+
raise ActionPrimitiveError(
|
| 956 |
+
ActionPrimitiveError.Reason.PLANNING_ERROR,
|
| 957 |
+
"There is no accessible path from where you are to the desired pose. Try again",
|
| 958 |
+
)
|
| 959 |
+
|
| 960 |
+
traj_path = traj_paths[success_idx[0]]
|
| 961 |
+
q_traj = (
|
| 962 |
+
self._motion_generator.path_to_joint_trajectory(traj_path, get_full_js=True, emb_sel=embodiment_selection)
|
| 963 |
+
.cpu()
|
| 964 |
+
.float()
|
| 965 |
+
)
|
| 966 |
+
q_traj = self._motion_generator.add_linearly_interpolated_waypoints(traj=q_traj, max_inter_dist=0.01)
|
| 967 |
+
|
| 968 |
+
return q_traj
|
| 969 |
+
|
| 970 |
+
def _execute_motion_plan(
|
| 971 |
+
self,
|
| 972 |
+
q_traj,
|
| 973 |
+
stop_on_contact=False,
|
| 974 |
+
stop_on_ag=False,
|
| 975 |
+
ignore_failure=False,
|
| 976 |
+
low_precision=False,
|
| 977 |
+
ignore_physics=False,
|
| 978 |
+
):
|
| 979 |
+
for joint_pos in q_traj:
|
| 980 |
+
if ignore_physics:
|
| 981 |
+
self.robot.set_joint_positions(joint_pos)
|
| 982 |
+
og.sim.step()
|
| 983 |
+
if stop_on_contact and detect_robot_collision_in_sim(self.robot):
|
| 984 |
+
return
|
| 985 |
+
else:
|
| 986 |
+
# Convert target joint positions to command
|
| 987 |
+
base_target_reached = False
|
| 988 |
+
articulation_target_reached = False
|
| 989 |
+
collision_detected = False
|
| 990 |
+
articulation_control_idx = [self.robot.trunk_control_idx]
|
| 991 |
+
for arm in self.robot.arm_names:
|
| 992 |
+
articulation_control_idx.append(self.robot.arm_control_idx[arm])
|
| 993 |
+
articulation_control_idx = th.cat(articulation_control_idx)
|
| 994 |
+
for _ in range(m.MAX_STEPS_FOR_JOINT_MOTION):
|
| 995 |
+
# We need to call @q_to_action for every step because as the robot base moves, the same base joint_pos will be
|
| 996 |
+
# converted to different actions, since HolonomicBaseJointController accepts an action in the robot local frame.
|
| 997 |
+
action = self.robot.q_to_action(joint_pos)
|
| 998 |
+
yield self._postprocess_action(action)
|
| 999 |
+
|
| 1000 |
+
current_joint_pos = self.robot.get_joint_positions()
|
| 1001 |
+
joint_pos_diff = joint_pos - current_joint_pos
|
| 1002 |
+
base_joint_diff = joint_pos_diff[self.robot.base_control_idx]
|
| 1003 |
+
articulation_joint_diff = joint_pos_diff[articulation_control_idx] # Gets all non-base joints
|
| 1004 |
+
articulation_threshold = (
|
| 1005 |
+
m.JOINT_POS_DIFF_THRESHOLD if not low_precision else m.LOW_PRECISION_JOINT_POS_DIFF_THRESHOLD
|
| 1006 |
+
)
|
| 1007 |
+
max_articulation_joint_diff = th.max(th.abs(articulation_joint_diff)).item()
|
| 1008 |
+
if max_articulation_joint_diff < articulation_threshold:
|
| 1009 |
+
articulation_target_reached = True
|
| 1010 |
+
|
| 1011 |
+
max_base_pos_diff = th.max(th.abs(base_joint_diff[:2])).item()
|
| 1012 |
+
max_base_orn_diff = th.abs(wrap_angle(base_joint_diff[2]))
|
| 1013 |
+
if max_base_pos_diff < m.DEFAULT_DIST_THRESHOLD and max_base_orn_diff < m.DEFAULT_ANGLE_THRESHOLD:
|
| 1014 |
+
base_target_reached = True
|
| 1015 |
+
|
| 1016 |
+
# Early stopping if the base, trunk and arm joints are at the target positions
|
| 1017 |
+
if base_target_reached and articulation_target_reached:
|
| 1018 |
+
break
|
| 1019 |
+
|
| 1020 |
+
collision_detected = detect_robot_collision_in_sim(self.robot)
|
| 1021 |
+
if stop_on_contact and collision_detected:
|
| 1022 |
+
return
|
| 1023 |
+
|
| 1024 |
+
if stop_on_ag and self._get_obj_in_hand() is not None:
|
| 1025 |
+
return
|
| 1026 |
+
|
| 1027 |
+
if not ignore_failure:
|
| 1028 |
+
if not base_target_reached:
|
| 1029 |
+
indented_print(f"max base pos diff: {max_base_pos_diff}")
|
| 1030 |
+
indented_print(f"max base angle diff: {max_base_orn_diff}")
|
| 1031 |
+
# breakpoint()
|
| 1032 |
+
raise ActionPrimitiveError(
|
| 1033 |
+
ActionPrimitiveError.Reason.EXECUTION_ERROR,
|
| 1034 |
+
"Could not reach the target base joint positions. Try again",
|
| 1035 |
+
)
|
| 1036 |
+
if not articulation_target_reached:
|
| 1037 |
+
indented_print(f"max articulation joint diff: {max_articulation_joint_diff}")
|
| 1038 |
+
# breakpoint()
|
| 1039 |
+
raise ActionPrimitiveError(
|
| 1040 |
+
ActionPrimitiveError.Reason.EXECUTION_ERROR,
|
| 1041 |
+
"Could not reach the target articulation joint positions. Try again",
|
| 1042 |
+
)
|
| 1043 |
+
|
| 1044 |
+
def _move_hand_direct_joint(self, joint_pos, stop_on_contact=False, ignore_failure=False):
|
| 1045 |
+
"""
|
| 1046 |
+
Yields action for the robot to move its arm to reach the specified joint positions by directly actuating with no planner
|
| 1047 |
+
|
| 1048 |
+
Args:
|
| 1049 |
+
joint_pos (th.tensor): Array of joint positions for the arm
|
| 1050 |
+
stop_on_contact (boolean): Determines whether to stop move once an object is hit
|
| 1051 |
+
ignore_failure (boolean): Determines whether to throw error for not reaching final joint positions
|
| 1052 |
+
|
| 1053 |
+
Returns:
|
| 1054 |
+
th.tensor or None: Action array for one step for the robot to move arm or None if its at the joint positions
|
| 1055 |
+
"""
|
| 1056 |
+
|
| 1057 |
+
# Store the previous eef pose for checking if we got stuck
|
| 1058 |
+
prev_eef_pos = th.zeros(3)
|
| 1059 |
+
|
| 1060 |
+
# All we need to do here is save the target joint position so that empty action takes us towards it
|
| 1061 |
+
controller_name = f"arm_{self.arm}"
|
| 1062 |
+
self._arm_targets[controller_name] = joint_pos
|
| 1063 |
+
|
| 1064 |
+
for i in range(m.MAX_STEPS_FOR_HAND_MOVE_JOINT):
|
| 1065 |
+
current_joint_pos = self.robot.get_joint_positions()[self._manipulation_control_idx()]
|
| 1066 |
+
diff_joint_pos = joint_pos - current_joint_pos
|
| 1067 |
+
if th.max(th.abs(diff_joint_pos)).item() < m.JOINT_POS_DIFF_THRESHOLD:
|
| 1068 |
+
return
|
| 1069 |
+
if stop_on_contact and detect_robot_collision_in_sim(self.robot):
|
| 1070 |
+
return
|
| 1071 |
+
# check if the eef stayed in the same pose for sufficiently long
|
| 1072 |
+
if (
|
| 1073 |
+
og.sim.get_sim_step_dt() * i > m.TIME_BEFORE_JOINT_STUCK_CHECK
|
| 1074 |
+
and th.max(th.abs(self.robot.get_eef_position(self.arm) - prev_eef_pos)).item() < 0.0001
|
| 1075 |
+
):
|
| 1076 |
+
# We're stuck!
|
| 1077 |
+
break
|
| 1078 |
+
|
| 1079 |
+
# Since we set the new joint target as the arm_target, the empty action will take us towards it.
|
| 1080 |
+
action = self._empty_action()
|
| 1081 |
+
|
| 1082 |
+
prev_eef_pos = self.robot.get_eef_position(self.arm)
|
| 1083 |
+
yield self._postprocess_action(action)
|
| 1084 |
+
|
| 1085 |
+
if not ignore_failure:
|
| 1086 |
+
raise ActionPrimitiveError(
|
| 1087 |
+
ActionPrimitiveError.Reason.EXECUTION_ERROR,
|
| 1088 |
+
"Your hand was obstructed from moving to the desired joint position",
|
| 1089 |
+
)
|
| 1090 |
+
|
| 1091 |
+
def _move_hand_direct_ik(
|
| 1092 |
+
self,
|
| 1093 |
+
target_pose,
|
| 1094 |
+
stop_on_contact=False,
|
| 1095 |
+
ignore_failure=False,
|
| 1096 |
+
pos_thresh=0.02,
|
| 1097 |
+
ori_thresh=0.4,
|
| 1098 |
+
in_world_frame=True,
|
| 1099 |
+
stop_if_stuck=False,
|
| 1100 |
+
):
|
| 1101 |
+
"""
|
| 1102 |
+
Moves the hand to a target pose using inverse kinematics.
|
| 1103 |
+
|
| 1104 |
+
Args:
|
| 1105 |
+
target_pose (tuple): A tuple of two elements, representing the target pose of the hand as a position and a quaternion.
|
| 1106 |
+
stop_on_contact (bool, optional): Whether to stop the movement if the hand collides with an object. Defaults to False.
|
| 1107 |
+
ignore_failure (bool, optional): Whether to raise an exception if the movement fails. Defaults to False.
|
| 1108 |
+
pos_thresh (float, optional): The position threshold for considering the target pose reached. Defaults to 0.04.
|
| 1109 |
+
ori_thresh (float, optional): The orientation threshold for considering the target pose reached. Defaults to 0.4.
|
| 1110 |
+
in_world_frame (bool, optional): Whether the target pose is given in the world frame. Defaults to True.
|
| 1111 |
+
stop_if_stuck (bool, optional): Whether to stop the movement if the hand is stuck. Defaults to False.
|
| 1112 |
+
|
| 1113 |
+
Yields:
|
| 1114 |
+
numpy.ndarray: The action to be executed by the robot controller.
|
| 1115 |
+
|
| 1116 |
+
Raises:
|
| 1117 |
+
ActionPrimitiveError: If the movement fails and ignore_failure is False.
|
| 1118 |
+
"""
|
| 1119 |
+
# make sure controller is InverseKinematicsController and in expected mode
|
| 1120 |
+
controller_config = self.robot._controller_config["arm_" + self.arm]
|
| 1121 |
+
assert (
|
| 1122 |
+
controller_config["name"] == "InverseKinematicsController"
|
| 1123 |
+
), "Controller must be InverseKinematicsController"
|
| 1124 |
+
assert controller_config["mode"] == "pose_absolute_ori", "Controller must be in pose_absolute_ori mode"
|
| 1125 |
+
if in_world_frame:
|
| 1126 |
+
target_pose = self._world_pose_to_robot_pose(target_pose)
|
| 1127 |
+
target_pos = target_pose[0]
|
| 1128 |
+
target_orn = target_pose[1]
|
| 1129 |
+
target_orn_axisangle = T.quat2axisangle(target_pose[1])
|
| 1130 |
+
prev_pos = prev_orn = None
|
| 1131 |
+
|
| 1132 |
+
# All we need to do here is save the target IK position so that empty action takes us towards it
|
| 1133 |
+
controller_name = f"arm_{self.arm}"
|
| 1134 |
+
self._arm_targets[controller_name] = (target_pos, target_orn_axisangle)
|
| 1135 |
+
|
| 1136 |
+
for i in range(m.MAX_STEPS_FOR_HAND_MOVE_IK):
|
| 1137 |
+
current_pose = self._world_pose_to_robot_pose(
|
| 1138 |
+
(self.robot.get_eef_position(self.arm), self.robot.get_eef_orientation(self.arm))
|
| 1139 |
+
)
|
| 1140 |
+
current_pos = current_pose[0]
|
| 1141 |
+
current_orn = current_pose[1]
|
| 1142 |
+
|
| 1143 |
+
delta_pos = target_pos - current_pos
|
| 1144 |
+
target_pos_diff = th.norm(delta_pos)
|
| 1145 |
+
target_orn_diff = T.get_orientation_diff_in_radian(current_orn, target_orn)
|
| 1146 |
+
reached_goal = target_pos_diff < pos_thresh and target_orn_diff < ori_thresh
|
| 1147 |
+
if reached_goal:
|
| 1148 |
+
return
|
| 1149 |
+
|
| 1150 |
+
if stop_on_contact and detect_robot_collision_in_sim(self.robot):
|
| 1151 |
+
return
|
| 1152 |
+
|
| 1153 |
+
# if i > 0 and stop_if_stuck and detect_robot_collision_in_sim(self.robot):
|
| 1154 |
+
if i > 0 and stop_if_stuck:
|
| 1155 |
+
pos_diff = th.norm(prev_pos - current_pos)
|
| 1156 |
+
orn_diff = T.get_orientation_diff_in_radian(current_orn, prev_orn)
|
| 1157 |
+
if pos_diff < 0.0003 and orn_diff < 0.01:
|
| 1158 |
+
raise ActionPrimitiveError(ActionPrimitiveError.Reason.EXECUTION_ERROR, "Hand is stuck")
|
| 1159 |
+
|
| 1160 |
+
prev_pos = current_pos
|
| 1161 |
+
prev_orn = current_orn
|
| 1162 |
+
|
| 1163 |
+
# Since we set the new IK target as the arm_target, the empty action will take us towards it.
|
| 1164 |
+
action = self._empty_action()
|
| 1165 |
+
yield self._postprocess_action(action)
|
| 1166 |
+
|
| 1167 |
+
if not ignore_failure:
|
| 1168 |
+
raise ActionPrimitiveError(
|
| 1169 |
+
ActionPrimitiveError.Reason.EXECUTION_ERROR,
|
| 1170 |
+
"Your hand was obstructed from moving to the desired joint position",
|
| 1171 |
+
)
|
| 1172 |
+
|
| 1173 |
+
def _move_hand_linearly_cartesian(
|
| 1174 |
+
self, target_pose, stop_on_contact=False, ignore_failure=False, stop_if_stuck=False
|
| 1175 |
+
):
|
| 1176 |
+
"""
|
| 1177 |
+
Yields action for the robot to move its arm to reach the specified target pose by moving the eef along a line in cartesian
|
| 1178 |
+
space from its current pose
|
| 1179 |
+
|
| 1180 |
+
Args:
|
| 1181 |
+
target_pose (Tuple[th.tensor, th.tensor]): target pose to reach for the default end-effector in the world frame
|
| 1182 |
+
stop_on_contact (boolean): Determines whether to stop move once an object is hit
|
| 1183 |
+
ignore_failure (boolean): Determines whether to throw error for not reaching final joint positions
|
| 1184 |
+
|
| 1185 |
+
Returns:
|
| 1186 |
+
th.tensor or None: Action array for one step for the robot to move arm or None if its at the target pose
|
| 1187 |
+
"""
|
| 1188 |
+
# To make sure that this happens in a roughly linear fashion, we will divide the trajectory
|
| 1189 |
+
# into 1cm-long pieces
|
| 1190 |
+
start_pos, start_orn = self.robot.eef_links[self.arm].get_position_orientation()
|
| 1191 |
+
travel_distance = th.norm(target_pose[0] - start_pos)
|
| 1192 |
+
num_poses = int(
|
| 1193 |
+
th.max(th.tensor([2, int(travel_distance / m.MAX_CARTESIAN_HAND_STEP) + 1], dtype=th.float32)).item()
|
| 1194 |
+
)
|
| 1195 |
+
pos_waypoints = multi_dim_linspace(start_pos, target_pose[0], num_poses)
|
| 1196 |
+
|
| 1197 |
+
# Also interpolate the rotations
|
| 1198 |
+
t_values = th.linspace(0, 1, num_poses)
|
| 1199 |
+
quat_waypoints = [T.quat_slerp(start_orn, target_pose[1], t) for t in t_values]
|
| 1200 |
+
|
| 1201 |
+
controller_config = self.robot._controller_config["arm_" + self.arm]
|
| 1202 |
+
if controller_config["name"] == "InverseKinematicsController":
|
| 1203 |
+
waypoints = list(zip(pos_waypoints, quat_waypoints))
|
| 1204 |
+
|
| 1205 |
+
for i, waypoint in enumerate(waypoints):
|
| 1206 |
+
if i < len(waypoints) - 1:
|
| 1207 |
+
yield from self._move_hand_direct_ik(
|
| 1208 |
+
waypoint,
|
| 1209 |
+
stop_on_contact=stop_on_contact,
|
| 1210 |
+
ignore_failure=ignore_failure,
|
| 1211 |
+
stop_if_stuck=stop_if_stuck,
|
| 1212 |
+
)
|
| 1213 |
+
else:
|
| 1214 |
+
yield from self._move_hand_direct_ik(
|
| 1215 |
+
waypoints[-1],
|
| 1216 |
+
pos_thresh=0.01,
|
| 1217 |
+
ori_thresh=0.1,
|
| 1218 |
+
stop_on_contact=stop_on_contact,
|
| 1219 |
+
ignore_failure=ignore_failure,
|
| 1220 |
+
stop_if_stuck=stop_if_stuck,
|
| 1221 |
+
)
|
| 1222 |
+
|
| 1223 |
+
# Also decide if we can stop early.
|
| 1224 |
+
current_pos, current_orn = self.robot.eef_links[self.arm].get_position_orientation()
|
| 1225 |
+
pos_diff = th.norm(current_pos - target_pose[0])
|
| 1226 |
+
orn_diff = T.get_orientation_diff_in_radian(target_pose[1], current_orn).item()
|
| 1227 |
+
if pos_diff < m.HAND_DIST_THRESHOLD and orn_diff < th.deg2rad(th.tensor([0.1])).item():
|
| 1228 |
+
return
|
| 1229 |
+
|
| 1230 |
+
if stop_on_contact and detect_robot_collision_in_sim(self.robot):
|
| 1231 |
+
return
|
| 1232 |
+
|
| 1233 |
+
if not ignore_failure:
|
| 1234 |
+
raise ActionPrimitiveError(
|
| 1235 |
+
ActionPrimitiveError.Reason.EXECUTION_ERROR,
|
| 1236 |
+
"Your hand was obstructed from moving to the desired world position",
|
| 1237 |
+
)
|
| 1238 |
+
else:
|
| 1239 |
+
# Use joint positions
|
| 1240 |
+
joint_space_data = [
|
| 1241 |
+
self._convert_cartesian_to_joint_space(waypoint) for waypoint in zip(pos_waypoints, quat_waypoints)
|
| 1242 |
+
]
|
| 1243 |
+
joints = list(self.robot.joints.values())
|
| 1244 |
+
|
| 1245 |
+
for joint_pos in joint_space_data:
|
| 1246 |
+
# Check if the movement can be done roughly linearly.
|
| 1247 |
+
current_joint_positions = self.robot.get_joint_positions()[self._manipulation_control_idx()]
|
| 1248 |
+
|
| 1249 |
+
failed_joints = []
|
| 1250 |
+
for joint_idx, target_joint_pos, current_joint_pos in zip(
|
| 1251 |
+
self._manipulation_control_idx(), joint_pos, current_joint_positions
|
| 1252 |
+
):
|
| 1253 |
+
if th.abs(target_joint_pos - current_joint_pos) > m.MAX_ALLOWED_JOINT_ERROR_FOR_LINEAR_MOTION:
|
| 1254 |
+
failed_joints.append(joints[joint_idx].joint_name)
|
| 1255 |
+
|
| 1256 |
+
if failed_joints:
|
| 1257 |
+
raise ActionPrimitiveError(
|
| 1258 |
+
ActionPrimitiveError.Reason.EXECUTION_ERROR,
|
| 1259 |
+
"You cannot reach the target position in a straight line - it requires rotating your arm which might cause collisions. You might need to get closer and retry",
|
| 1260 |
+
{"failed joints": failed_joints},
|
| 1261 |
+
)
|
| 1262 |
+
|
| 1263 |
+
# Otherwise, move the joint
|
| 1264 |
+
yield from self._move_hand_direct_joint(
|
| 1265 |
+
joint_pos, stop_on_contact=stop_on_contact, ignore_failure=ignore_failure
|
| 1266 |
+
)
|
| 1267 |
+
|
| 1268 |
+
# Also decide if we can stop early.
|
| 1269 |
+
current_pos, current_orn = self.robot.eef_links[self.arm].get_position_orientation()
|
| 1270 |
+
pos_diff = th.norm(current_pos - target_pose[0])
|
| 1271 |
+
orn_diff = T.get_orientation_diff_in_radian(target_pose[1], current_orn)
|
| 1272 |
+
if pos_diff < 0.001 and orn_diff < th.deg2rad(th.tensor([0.1])).item():
|
| 1273 |
+
return
|
| 1274 |
+
|
| 1275 |
+
if stop_on_contact and detect_robot_collision_in_sim(self.robot):
|
| 1276 |
+
return
|
| 1277 |
+
|
| 1278 |
+
if not ignore_failure:
|
| 1279 |
+
raise ActionPrimitiveError(
|
| 1280 |
+
ActionPrimitiveError.Reason.EXECUTION_ERROR,
|
| 1281 |
+
"Your hand was obstructed from moving to the desired world position",
|
| 1282 |
+
)
|
| 1283 |
+
|
| 1284 |
+
def _get_joint_position_with_fingers_at_limit(self, limit_type):
|
| 1285 |
+
"""
|
| 1286 |
+
Helper function to get the joint positions when the robot's fingers are at their limit positions.
|
| 1287 |
+
|
| 1288 |
+
Args:
|
| 1289 |
+
limit_type (str): Either 'lower' for grasping or 'upper' for releasing.
|
| 1290 |
+
|
| 1291 |
+
Yields:
|
| 1292 |
+
th.tensor: Joint positions for the robot with fingers at their limit positions.
|
| 1293 |
+
"""
|
| 1294 |
+
target_joint_positions = self.robot.get_joint_positions()
|
| 1295 |
+
gripper_ctrl_idx = self.robot.gripper_control_idx[self.arm]
|
| 1296 |
+
if limit_type == self.robot._grasping_direction:
|
| 1297 |
+
finger_joint_limits = self.robot.joint_lower_limits[gripper_ctrl_idx]
|
| 1298 |
+
else:
|
| 1299 |
+
finger_joint_limits = self.robot.joint_upper_limits[gripper_ctrl_idx]
|
| 1300 |
+
target_joint_positions[gripper_ctrl_idx] = finger_joint_limits
|
| 1301 |
+
return target_joint_positions
|
| 1302 |
+
|
| 1303 |
+
def _move_fingers_to_limit(self, limit_type):
|
| 1304 |
+
"""
|
| 1305 |
+
Helper function to move the robot's fingers to their limit positions.
|
| 1306 |
+
|
| 1307 |
+
Args:
|
| 1308 |
+
limit_type (str): Either 'lower' for grasping or 'upper' for releasing.
|
| 1309 |
+
|
| 1310 |
+
Yields:
|
| 1311 |
+
th.tensor or None: Action array for one step for the robot to move fingers or None if done.
|
| 1312 |
+
"""
|
| 1313 |
+
target_joint_positions = self._get_joint_position_with_fingers_at_limit(limit_type)
|
| 1314 |
+
action = self.robot.q_to_action(target_joint_positions)
|
| 1315 |
+
for _ in range(m.MAX_STEPS_FOR_GRASP_OR_RELEASE):
|
| 1316 |
+
yield self._postprocess_action(action)
|
| 1317 |
+
current_joint_positions = self.robot.get_joint_positions()
|
| 1318 |
+
if th.allclose(current_joint_positions, target_joint_positions, atol=m.JOINT_POS_DIFF_THRESHOLD):
|
| 1319 |
+
break
|
| 1320 |
+
elif limit_type == "lower" and self._get_obj_in_hand() is not None:
|
| 1321 |
+
# If we are grasping an object, we should stop when object is detected in hand
|
| 1322 |
+
break
|
| 1323 |
+
|
| 1324 |
+
def _execute_grasp(self):
|
| 1325 |
+
"""
|
| 1326 |
+
Yields action for the robot to grasp.
|
| 1327 |
+
|
| 1328 |
+
Returns:
|
| 1329 |
+
th.tensor or None: Action array for one step for the robot to grasp or None if done grasping.
|
| 1330 |
+
"""
|
| 1331 |
+
yield from self._move_fingers_to_limit("lower")
|
| 1332 |
+
|
| 1333 |
+
def _execute_release(self):
|
| 1334 |
+
"""
|
| 1335 |
+
Yields action for the robot to release its grasp.
|
| 1336 |
+
|
| 1337 |
+
Returns:
|
| 1338 |
+
th.tensor or None: Action array for one step for the robot to release or None if done releasing.
|
| 1339 |
+
"""
|
| 1340 |
+
yield from self._move_fingers_to_limit("upper")
|
| 1341 |
+
|
| 1342 |
+
if self._get_obj_in_hand() is not None:
|
| 1343 |
+
raise ActionPrimitiveError(
|
| 1344 |
+
ActionPrimitiveError.Reason.EXECUTION_ERROR,
|
| 1345 |
+
"An object was still detected in your hand after executing release",
|
| 1346 |
+
{"object in hand": self._get_obj_in_hand().name},
|
| 1347 |
+
)
|
| 1348 |
+
|
| 1349 |
+
def _overwrite_head_action(self, action):
|
| 1350 |
+
"""
|
| 1351 |
+
Overwrites camera control actions to track an object of interest.
|
| 1352 |
+
If self._always_track_eef is true, always tracks the end effector of the robot.
|
| 1353 |
+
Otherwise, tracks the object of interest or the end effector as specified by the primitive.
|
| 1354 |
+
|
| 1355 |
+
Args:
|
| 1356 |
+
action (array) : action array to overwrite
|
| 1357 |
+
"""
|
| 1358 |
+
if self._always_track_eef:
|
| 1359 |
+
target_obj_pose = (self.robot.get_eef_position(self.arm), self.robot.get_eef_orientation(self.arm))
|
| 1360 |
+
else:
|
| 1361 |
+
if self._tracking_object is None:
|
| 1362 |
+
return action
|
| 1363 |
+
|
| 1364 |
+
if self._tracking_object == self.robot:
|
| 1365 |
+
target_obj_pose = (self.robot.get_eef_position(self.arm), self.robot.get_eef_orientation(self.arm))
|
| 1366 |
+
else:
|
| 1367 |
+
target_obj_pose = self._tracking_object.get_position_orientation()
|
| 1368 |
+
|
| 1369 |
+
assert self.robot.model == "tiago", "Tracking object with camera is currently only supported for Tiago"
|
| 1370 |
+
|
| 1371 |
+
head_q = self._get_head_goal_q(target_obj_pose)
|
| 1372 |
+
head_idx = self.robot.controller_action_idx["camera"]
|
| 1373 |
+
|
| 1374 |
+
config = self.robot._controller_config["camera"]
|
| 1375 |
+
assert config["name"] == "JointController", "Camera controller must be JointController"
|
| 1376 |
+
assert config["motor_type"] == "position", "Camera controller must be in position control mode"
|
| 1377 |
+
use_delta = config["use_delta_commands"]
|
| 1378 |
+
|
| 1379 |
+
if use_delta:
|
| 1380 |
+
cur_head_q = self.robot.get_joint_positions()[self.robot.camera_control_idx]
|
| 1381 |
+
head_action = head_q - cur_head_q
|
| 1382 |
+
else:
|
| 1383 |
+
head_action = head_q
|
| 1384 |
+
action[head_idx] = head_action
|
| 1385 |
+
return action
|
| 1386 |
+
|
| 1387 |
+
def _get_head_goal_q(self, target_obj_pose):
|
| 1388 |
+
"""
|
| 1389 |
+
Get goal joint positions for head to look at an object of interest,
|
| 1390 |
+
If the object cannot be seen, return the reset (default) head joint positions.
|
| 1391 |
+
"""
|
| 1392 |
+
|
| 1393 |
+
# get current head joint positions
|
| 1394 |
+
head1_joint = self.robot.joints["head_1_joint"]
|
| 1395 |
+
head2_joint = self.robot.joints["head_2_joint"]
|
| 1396 |
+
head1_joint_limits = [head1_joint.lower_limit, head1_joint.upper_limit]
|
| 1397 |
+
head2_joint_limits = [head2_joint.lower_limit, head2_joint.upper_limit]
|
| 1398 |
+
head1_joint_goal = head1_joint.get_state()[0][0]
|
| 1399 |
+
head2_joint_goal = head2_joint.get_state()[0][0]
|
| 1400 |
+
|
| 1401 |
+
# grab robot and object poses
|
| 1402 |
+
robot_pose = self.robot.get_position_orientation()
|
| 1403 |
+
# obj_pose = obj.get_position_orientation()
|
| 1404 |
+
obj_in_base = T.relative_pose_transform(*target_obj_pose, *robot_pose)
|
| 1405 |
+
|
| 1406 |
+
# compute angle between base and object in xy plane (parallel to floor)
|
| 1407 |
+
theta = th.arctan2(obj_in_base[0][1], obj_in_base[0][0])
|
| 1408 |
+
|
| 1409 |
+
# if it is possible to get object in view, compute both head joint positions
|
| 1410 |
+
if head1_joint_limits[0] < theta < head1_joint_limits[1]:
|
| 1411 |
+
head1_joint_goal = theta
|
| 1412 |
+
|
| 1413 |
+
# compute angle between base and object in xz plane (perpendicular to floor)
|
| 1414 |
+
head2_pose = self.robot.links["head_2_link"].get_position_orientation()
|
| 1415 |
+
head2_in_base = T.relative_pose_transform(*head2_pose, *robot_pose)
|
| 1416 |
+
|
| 1417 |
+
phi = th.arctan2(obj_in_base[0][2] - head2_in_base[0][2], obj_in_base[0][0])
|
| 1418 |
+
if head2_joint_limits[0] < phi < head2_joint_limits[1]:
|
| 1419 |
+
head2_joint_goal = phi
|
| 1420 |
+
|
| 1421 |
+
# if not possible to look at object, return the reset (default) head joint positions
|
| 1422 |
+
else:
|
| 1423 |
+
default_head_pos = self.robot.reset_joint_pos[self.robot.controller_action_idx["camera"]]
|
| 1424 |
+
head1_joint_goal = default_head_pos[0]
|
| 1425 |
+
head2_joint_goal = default_head_pos[1]
|
| 1426 |
+
|
| 1427 |
+
return th.tensor([head1_joint_goal, head2_joint_goal])
|
| 1428 |
+
|
| 1429 |
+
def _empty_action(self, follow_arm_targets=True):
|
| 1430 |
+
"""
|
| 1431 |
+
Generate a no-op action that will keep the robot still but aim to move the arms to the saved pose targets, if possible
|
| 1432 |
+
|
| 1433 |
+
Args:
|
| 1434 |
+
follow_arm_targets (bool): Whether to move the arms to the saved pose targets or keep them still.
|
| 1435 |
+
|
| 1436 |
+
Returns:
|
| 1437 |
+
th.tensor or None: Action array for one step for the robot to do nothing
|
| 1438 |
+
"""
|
| 1439 |
+
action = th.zeros(self.robot.action_dim)
|
| 1440 |
+
for name, (group_key, controller_idx) in self.robot.controllers.items():
|
| 1441 |
+
# if desired arm targets are available, generate an action that moves the arms to the saved pose targets
|
| 1442 |
+
if follow_arm_targets and name in self._arm_targets:
|
| 1443 |
+
if ControllerView.is_controller_type(group_key, InverseKinematicsController):
|
| 1444 |
+
arm = name.replace("arm_", "")
|
| 1445 |
+
target_pos, target_orn_axisangle = self._arm_targets[name]
|
| 1446 |
+
current_pos, current_orn = self._world_pose_to_robot_pose(
|
| 1447 |
+
(self.robot.get_eef_position(arm), self.robot.get_eef_orientation(arm))
|
| 1448 |
+
)
|
| 1449 |
+
delta_pos = target_pos - current_pos
|
| 1450 |
+
mode = ControllerView.get_mode(group_key)
|
| 1451 |
+
if mode == "pose_delta_ori":
|
| 1452 |
+
delta_orn = T.orientation_error(
|
| 1453 |
+
T.quat2mat(T.axisangle2quat(target_orn_axisangle)), T.quat2mat(current_orn)
|
| 1454 |
+
)
|
| 1455 |
+
partial_action = th.cat((delta_pos, delta_orn))
|
| 1456 |
+
elif mode == "pose_absolute_ori":
|
| 1457 |
+
partial_action = th.cat((delta_pos, target_orn_axisangle))
|
| 1458 |
+
elif mode == "absolute_pose":
|
| 1459 |
+
partial_action = th.cat((target_pos, target_orn_axisangle))
|
| 1460 |
+
else:
|
| 1461 |
+
raise ValueError("Unexpected IK control mode")
|
| 1462 |
+
else:
|
| 1463 |
+
target_joint_pos = self._arm_targets[name]
|
| 1464 |
+
current_joint_pos = self.robot.get_joint_positions()[self._manipulation_control_idx()]
|
| 1465 |
+
if ControllerView.get_use_delta_commands(group_key):
|
| 1466 |
+
partial_action = target_joint_pos - current_joint_pos
|
| 1467 |
+
else:
|
| 1468 |
+
partial_action = target_joint_pos
|
| 1469 |
+
else:
|
| 1470 |
+
partial_action = ControllerView.compute_no_op_action(group_key, controller_idx)
|
| 1471 |
+
action_idx = self.robot.controller_action_idx[name]
|
| 1472 |
+
action[action_idx] = partial_action
|
| 1473 |
+
return action
|
| 1474 |
+
|
| 1475 |
+
def _reset_robot(self):
|
| 1476 |
+
"""
|
| 1477 |
+
Yields action to move both hands to the position optimal for executing subsequent action primitives
|
| 1478 |
+
|
| 1479 |
+
Returns:
|
| 1480 |
+
th.tensor or None: Action array for one step for the robot to reset its hands or None if it is done resetting
|
| 1481 |
+
"""
|
| 1482 |
+
indented_print("Resetting robot")
|
| 1483 |
+
target_pos = dict()
|
| 1484 |
+
target_quat = dict()
|
| 1485 |
+
for arm in self.robot.arm_names:
|
| 1486 |
+
reset_eef_pose = self._get_reset_eef_pose("world")[arm]
|
| 1487 |
+
target_pos[self.robot.eef_link_names[arm]] = reset_eef_pose[0]
|
| 1488 |
+
target_quat[self.robot.eef_link_names[arm]] = reset_eef_pose[1]
|
| 1489 |
+
q_traj = self._plan_joint_motion(
|
| 1490 |
+
target_pos=target_pos,
|
| 1491 |
+
target_quat=target_quat,
|
| 1492 |
+
embodiment_selection=CuRoboEmbodimentSelection.ARM,
|
| 1493 |
+
)
|
| 1494 |
+
indented_print(f"Plan has {len(q_traj)} steps")
|
| 1495 |
+
yield from self._execute_motion_plan(q_traj)
|
| 1496 |
+
|
| 1497 |
+
def _reset_hand(self):
|
| 1498 |
+
"""
|
| 1499 |
+
Yields action to move the hand to the position optimal for executing subsequent action primitives
|
| 1500 |
+
|
| 1501 |
+
Returns:
|
| 1502 |
+
th.tensor or None: Action array for one step for the robot to reset its hand or None if it is done resetting
|
| 1503 |
+
"""
|
| 1504 |
+
indented_print("Resetting hand")
|
| 1505 |
+
# TODO: make this work with both hands
|
| 1506 |
+
reset_eef_pose = self._get_reset_eef_pose("world")[self.arm]
|
| 1507 |
+
if self.debug_visual_marker is not None:
|
| 1508 |
+
self.debug_visual_marker.set_position_orientation(*reset_eef_pose)
|
| 1509 |
+
yield from self._move_hand(reset_eef_pose)
|
| 1510 |
+
|
| 1511 |
+
def _get_reset_eef_pose(self, frame="robot"):
|
| 1512 |
+
"""
|
| 1513 |
+
Get the reset eef pose for the robot
|
| 1514 |
+
|
| 1515 |
+
Args:
|
| 1516 |
+
frame (str): The frame in which the reset eef pose is specified, one of "robot" or "world"
|
| 1517 |
+
|
| 1518 |
+
Returns:
|
| 1519 |
+
dict of th.tensor: The reset eef pose for each robot arm
|
| 1520 |
+
"""
|
| 1521 |
+
pose = self._reset_eef_pose
|
| 1522 |
+
if frame == "robot":
|
| 1523 |
+
return pose
|
| 1524 |
+
elif frame == "world":
|
| 1525 |
+
return {arm: self._robot_pose_to_world_pose(pose[arm]) for arm in pose}
|
| 1526 |
+
else:
|
| 1527 |
+
raise ValueError(f"Unsupported frame: {frame}")
|
| 1528 |
+
|
| 1529 |
+
def _navigate_to_pose(self, pose_2d, skip_obstacle_update=False):
|
| 1530 |
+
"""
|
| 1531 |
+
Yields the action to navigate robot to the specified 2d pose
|
| 1532 |
+
|
| 1533 |
+
Args:
|
| 1534 |
+
pose_2d (Iterable): (x, y, yaw) 2d pose
|
| 1535 |
+
skip_obstacle_update (bool): Determines whether to skip updating the obstacles in the scene
|
| 1536 |
+
|
| 1537 |
+
Returns:
|
| 1538 |
+
th.tensor or None: Action array for one step for the robot to navigate or None if it is done navigating
|
| 1539 |
+
"""
|
| 1540 |
+
pose_3d = self._get_robot_pose_from_2d_pose(pose_2d)
|
| 1541 |
+
if self.debug_visual_marker is not None:
|
| 1542 |
+
self.debug_visual_marker.set_position_orientation(*pose_3d)
|
| 1543 |
+
target_pos = {self.robot.base_footprint_link_name: pose_3d[0]}
|
| 1544 |
+
target_quat = {self.robot.base_footprint_link_name: pose_3d[1]}
|
| 1545 |
+
q_traj = self._plan_joint_motion(
|
| 1546 |
+
target_pos,
|
| 1547 |
+
target_quat,
|
| 1548 |
+
embodiment_selection=CuRoboEmbodimentSelection.BASE,
|
| 1549 |
+
skip_obstacle_update=skip_obstacle_update,
|
| 1550 |
+
)
|
| 1551 |
+
yield from self._execute_motion_plan(q_traj)
|
| 1552 |
+
|
| 1553 |
+
# (TODO) add a function to draw curobo-generated plans.
|
| 1554 |
+
def _draw_plan(self, plan):
|
| 1555 |
+
SEARCHED = []
|
| 1556 |
+
trav_map = self.robot.scene._trav_map
|
| 1557 |
+
for q in plan:
|
| 1558 |
+
# The below code is useful for plotting the RRT tree.
|
| 1559 |
+
map_point = trav_map.world_to_map((q[0], q[1]))
|
| 1560 |
+
SEARCHED.append(th.flip(map_point, dims=tuple(range(map_point.dim()))))
|
| 1561 |
+
|
| 1562 |
+
fig = plt.figure()
|
| 1563 |
+
plt.imshow(trav_map.floor_map[0])
|
| 1564 |
+
plt.scatter(*zip(*SEARCHED), 5)
|
| 1565 |
+
fig.canvas.draw()
|
| 1566 |
+
|
| 1567 |
+
# Convert the canvas to image
|
| 1568 |
+
img = th.frombuffer(fig.canvas.tostring_rgb(), dtype=th.uint8)
|
| 1569 |
+
img = img.reshape(fig.canvas.get_width_height()[::-1] + (3,))
|
| 1570 |
+
plt.close(fig)
|
| 1571 |
+
|
| 1572 |
+
# Convert to BGR for cv2-based viewing.
|
| 1573 |
+
img = cv2.cvtColor(img, cv2.COLOR_RGB2BGR)
|
| 1574 |
+
|
| 1575 |
+
cv2.imshow("SceneGraph", img)
|
| 1576 |
+
cv2.waitKey(1)
|
| 1577 |
+
|
| 1578 |
+
def _navigate_if_needed(self, obj, eef_pose=None):
|
| 1579 |
+
"""
|
| 1580 |
+
Yields action to navigate the robot to be in range of the object if it not in the range
|
| 1581 |
+
|
| 1582 |
+
Args:
|
| 1583 |
+
obj (StatefulObject): Object for the robot to be in range of
|
| 1584 |
+
eef_pose (Tuple[th.tensor, th.tensor]): target pose to reach for the default end-effector in the world frame
|
| 1585 |
+
|
| 1586 |
+
Returns:
|
| 1587 |
+
th.tensor or None: Action array for one step for the robot to navigate or None if it is done navigating
|
| 1588 |
+
"""
|
| 1589 |
+
self._motion_generator.update_obstacles()
|
| 1590 |
+
|
| 1591 |
+
if eef_pose is None:
|
| 1592 |
+
eef_pose, _ = self._sample_grasp_pose(obj)
|
| 1593 |
+
|
| 1594 |
+
if self._target_in_reach_of_robot(eef_pose, skip_obstacle_update=True):
|
| 1595 |
+
# No need to navigate.
|
| 1596 |
+
return
|
| 1597 |
+
|
| 1598 |
+
yield from self._navigate_to_obj(obj, eef_pose=eef_pose, skip_obstacle_update=True)
|
| 1599 |
+
|
| 1600 |
+
def _navigate_to_obj(self, obj, eef_pose=None, skip_obstacle_update=False):
|
| 1601 |
+
"""
|
| 1602 |
+
Yields action to navigate the robot to be in range of the pose
|
| 1603 |
+
|
| 1604 |
+
Args:
|
| 1605 |
+
obj (StatefulObject or list of StatefulObject): object(s) to be in range of
|
| 1606 |
+
eef_pose (Tuple[th.tensor, th.tensor]): target pose to reach for the default end-effector in the world frame
|
| 1607 |
+
|
| 1608 |
+
Returns:
|
| 1609 |
+
th.tensor or None: Action array for one step for the robot to navigate in range or None if it is done navigating
|
| 1610 |
+
"""
|
| 1611 |
+
pose = self._sample_pose_near_object(obj, eef_pose=eef_pose, skip_obstacle_update=skip_obstacle_update)
|
| 1612 |
+
if pose is None:
|
| 1613 |
+
raise ActionPrimitiveError(
|
| 1614 |
+
ActionPrimitiveError.Reason.PLANNING_ERROR,
|
| 1615 |
+
"Could not find a valid pose near the object",
|
| 1616 |
+
{"object": obj.name},
|
| 1617 |
+
)
|
| 1618 |
+
yield from self._navigate_to_pose(pose, skip_obstacle_update=skip_obstacle_update)
|
| 1619 |
+
|
| 1620 |
+
def _navigate_to_pose_direct(self, pose_2d, low_precision=False):
|
| 1621 |
+
"""
|
| 1622 |
+
Yields action to navigate the robot to the 2d pose without planning
|
| 1623 |
+
|
| 1624 |
+
Args:
|
| 1625 |
+
pose_2d (Iterable): (x, y, yaw) 2d pose
|
| 1626 |
+
low_precision (bool): Determines whether to navigate to the pose within a large range (low precision) or small range (high precison)
|
| 1627 |
+
|
| 1628 |
+
Returns:
|
| 1629 |
+
th.tensor or None: Action array for one step for the robot to navigate or None if it is done navigating
|
| 1630 |
+
"""
|
| 1631 |
+
dist_threshold = m.LOW_PRECISION_DIST_THRESHOLD if low_precision else m.DEFAULT_DIST_THRESHOLD
|
| 1632 |
+
angle_threshold = m.LOW_PRECISION_ANGLE_THRESHOLD if low_precision else m.DEFAULT_ANGLE_THRESHOLD
|
| 1633 |
+
|
| 1634 |
+
end_pose = self._get_robot_pose_from_2d_pose(pose_2d)
|
| 1635 |
+
|
| 1636 |
+
for _ in range(m.MAX_STEPS_FOR_WAYPOINT_NAVIGATION):
|
| 1637 |
+
body_target_pose = self._world_pose_to_robot_pose(end_pose)
|
| 1638 |
+
if th.norm(body_target_pose[0][:2]) < dist_threshold:
|
| 1639 |
+
break
|
| 1640 |
+
|
| 1641 |
+
diff_pos = end_pose[0] - self.robot.get_position_orientation()[0]
|
| 1642 |
+
intermediate_pose = (
|
| 1643 |
+
end_pose[0],
|
| 1644 |
+
T.euler2quat(th.tensor([0, 0, math.atan2(diff_pos[1], diff_pos[0])], dtype=th.float32)),
|
| 1645 |
+
)
|
| 1646 |
+
body_intermediate_pose = self._world_pose_to_robot_pose(intermediate_pose)
|
| 1647 |
+
diff_yaw = T.quat2euler(body_intermediate_pose[1])[2].item()
|
| 1648 |
+
if abs(diff_yaw) > m.DEFAULT_ANGLE_THRESHOLD:
|
| 1649 |
+
yield from self._rotate_in_place(intermediate_pose, angle_threshold=m.DEFAULT_ANGLE_THRESHOLD)
|
| 1650 |
+
else:
|
| 1651 |
+
action = self._empty_action()
|
| 1652 |
+
base_group_key, _ = self.robot.controllers["base"]
|
| 1653 |
+
if ControllerView.is_controller_type(base_group_key, HolonomicBaseJointController):
|
| 1654 |
+
assert (
|
| 1655 |
+
ControllerView.get_motor_type(base_group_key) == "velocity"
|
| 1656 |
+
), "Holonomic base controller must be in velocity mode"
|
| 1657 |
+
direction_vec = (
|
| 1658 |
+
body_target_pose[0][:2]
|
| 1659 |
+
/ th.norm(body_target_pose[0][:2])
|
| 1660 |
+
* self.robot.linear_velocity_gain_for_primitives
|
| 1661 |
+
)
|
| 1662 |
+
base_action = th.tensor([direction_vec[0], direction_vec[1], 0.0], dtype=th.float32)
|
| 1663 |
+
action[self.robot.controller_action_idx["base"]] = base_action
|
| 1664 |
+
elif ControllerView.is_controller_type(base_group_key, DifferentialDriveController):
|
| 1665 |
+
base_action = th.tensor([self.robot.linear_velocity_gain_for_primitives, 0.0], dtype=th.float32)
|
| 1666 |
+
action[self.robot.controller_action_idx["base"]] = base_action
|
| 1667 |
+
else:
|
| 1668 |
+
raise ValueError(
|
| 1669 |
+
f"Unsupported base controller: {ControllerView.get_controller_type_str(base_group_key)}"
|
| 1670 |
+
)
|
| 1671 |
+
|
| 1672 |
+
yield self._postprocess_action(action)
|
| 1673 |
+
else:
|
| 1674 |
+
raise ActionPrimitiveError(
|
| 1675 |
+
ActionPrimitiveError.Reason.EXECUTION_ERROR,
|
| 1676 |
+
"Could not navigate to the target position",
|
| 1677 |
+
{"target pose": end_pose},
|
| 1678 |
+
)
|
| 1679 |
+
|
| 1680 |
+
# Rotate in place to final orientation once at location
|
| 1681 |
+
yield from self._rotate_in_place(end_pose, angle_threshold=angle_threshold)
|
| 1682 |
+
|
| 1683 |
+
def _rotate_in_place(self, end_pose, angle_threshold=m.DEFAULT_ANGLE_THRESHOLD):
|
| 1684 |
+
"""
|
| 1685 |
+
Yields action to rotate the robot to the 2d end pose
|
| 1686 |
+
|
| 1687 |
+
Args:
|
| 1688 |
+
end_pose (Iterable): (x, y, yaw) 2d pose
|
| 1689 |
+
angle_threshold (float): The angle difference between the robot's current and end pose that determines when the robot is done rotating
|
| 1690 |
+
|
| 1691 |
+
Returns:
|
| 1692 |
+
th.tensor or None: Action array for one step for the robot to rotate or None if it is done rotating
|
| 1693 |
+
"""
|
| 1694 |
+
for _ in range(m.MAX_STEPS_FOR_WAYPOINT_NAVIGATION):
|
| 1695 |
+
body_target_pose = self._world_pose_to_robot_pose(end_pose)
|
| 1696 |
+
diff_yaw = T.quat2euler(body_target_pose[1])[2].item()
|
| 1697 |
+
if abs(diff_yaw) < angle_threshold:
|
| 1698 |
+
break
|
| 1699 |
+
|
| 1700 |
+
action = self._empty_action()
|
| 1701 |
+
|
| 1702 |
+
direction = -1.0 if diff_yaw < 0.0 else 1.0
|
| 1703 |
+
ang_vel = self.robot.angular_velocity_gain_for_primitives * direction
|
| 1704 |
+
|
| 1705 |
+
base_action = action[self.robot.controller_action_idx["base"]]
|
| 1706 |
+
|
| 1707 |
+
base_group_key, _ = self.robot.controllers["base"]
|
| 1708 |
+
if ControllerView.is_controller_type(base_group_key, HolonomicBaseJointController):
|
| 1709 |
+
assert (
|
| 1710 |
+
ControllerView.get_motor_type(base_group_key) == "velocity"
|
| 1711 |
+
), "Holonomic base controller must be in velocity mode"
|
| 1712 |
+
base_action[0] = 0.0
|
| 1713 |
+
base_action[1] = 0.0
|
| 1714 |
+
base_action[2] = ang_vel
|
| 1715 |
+
elif ControllerView.is_controller_type(base_group_key, DifferentialDriveController):
|
| 1716 |
+
base_action[0] = 0.0
|
| 1717 |
+
base_action[1] = ang_vel
|
| 1718 |
+
else:
|
| 1719 |
+
raise ValueError(
|
| 1720 |
+
f"Unsupported base controller: {ControllerView.get_controller_type_str(base_group_key)}"
|
| 1721 |
+
)
|
| 1722 |
+
|
| 1723 |
+
action[self.robot.controller_action_idx["base"]] = base_action
|
| 1724 |
+
yield self._postprocess_action(action)
|
| 1725 |
+
else:
|
| 1726 |
+
raise ActionPrimitiveError(
|
| 1727 |
+
ActionPrimitiveError.Reason.EXECUTION_ERROR,
|
| 1728 |
+
"Could not rotate in place to the desired orientation",
|
| 1729 |
+
{"target pose": end_pose},
|
| 1730 |
+
)
|
| 1731 |
+
|
| 1732 |
+
empty_action = self._empty_action()
|
| 1733 |
+
yield self._postprocess_action(empty_action)
|
| 1734 |
+
|
| 1735 |
+
def _sample_pose_near_object(
|
| 1736 |
+
self,
|
| 1737 |
+
obj,
|
| 1738 |
+
eef_pose=None,
|
| 1739 |
+
plan_with_open_gripper=False,
|
| 1740 |
+
sampling_attempts=m.MAX_ATTEMPTS_FOR_SAMPLING_POSE_NEAR_OBJECT,
|
| 1741 |
+
skip_obstacle_update=False,
|
| 1742 |
+
):
|
| 1743 |
+
"""
|
| 1744 |
+
Returns a 2d pose for the robot within in the range of the object and where the robot is not in collision with anything
|
| 1745 |
+
|
| 1746 |
+
Args:
|
| 1747 |
+
obj (StatefulObject or list of StatefulObject): object(s) to sample a 2d pose near
|
| 1748 |
+
eef_pose (Tuple[th.tensor, th.tensor]): target pose to reach for the default end-effector in the world frame
|
| 1749 |
+
plan_with_open_gripper (bool): Determines whether to plan with the gripper open even though it might be closed now.
|
| 1750 |
+
This is useful for the placing primitive because we will open-loop open the gripper after placing
|
| 1751 |
+
sampling_attempts (int): Number of attempts to sample a valid pose
|
| 1752 |
+
skip_obstacle_update (bool): Determines whether to skip updating the obstacles in the scene
|
| 1753 |
+
Returns:
|
| 1754 |
+
2-tuple:
|
| 1755 |
+
- 3-array: (x,y,z) Position in the world frame
|
| 1756 |
+
- 4-array: (x,y,z,w) Quaternion orientation in the world frame
|
| 1757 |
+
"""
|
| 1758 |
+
distance_lo, distance_hi = m.BASE_POSE_SAMPLING_LOWER_BOUND, m.BASE_POSE_SAMPLING_UPPER_BOUND
|
| 1759 |
+
yaw_lo, yaw_hi = -math.pi, math.pi
|
| 1760 |
+
avg_arm_workspace_range = th.mean(self.robot.arm_workspace_range[self.arm])
|
| 1761 |
+
|
| 1762 |
+
if eef_pose is None:
|
| 1763 |
+
eef_pose, _ = self._sample_grasp_pose(obj)
|
| 1764 |
+
|
| 1765 |
+
target_pose = eef_pose
|
| 1766 |
+
|
| 1767 |
+
obj_rooms = (
|
| 1768 |
+
obj.in_rooms if obj.in_rooms else [self.robot.scene._seg_map.get_room_instance_by_point(target_pose[0][:2])]
|
| 1769 |
+
)
|
| 1770 |
+
|
| 1771 |
+
attempt = 0
|
| 1772 |
+
if not skip_obstacle_update:
|
| 1773 |
+
# Update obstacle once before sampling
|
| 1774 |
+
self._motion_generator.update_obstacles()
|
| 1775 |
+
while attempt < sampling_attempts:
|
| 1776 |
+
candidate_poses = []
|
| 1777 |
+
for _ in range(self._curobo_batch_size):
|
| 1778 |
+
for _ in range(m.MAX_ATTEMPTS_FOR_SAMPLING_POSE_FOR_CORRECT_ROOM):
|
| 1779 |
+
distance = (th.rand(1) * (distance_hi - distance_lo) + distance_lo).item()
|
| 1780 |
+
yaw = th.rand(1) * (yaw_hi - yaw_lo) + yaw_lo
|
| 1781 |
+
candidate_2d_pose = th.cat(
|
| 1782 |
+
[
|
| 1783 |
+
target_pose[0][0] + distance * th.cos(yaw),
|
| 1784 |
+
target_pose[0][1] + distance * th.sin(yaw),
|
| 1785 |
+
yaw + math.pi - avg_arm_workspace_range,
|
| 1786 |
+
]
|
| 1787 |
+
)
|
| 1788 |
+
|
| 1789 |
+
# Check room
|
| 1790 |
+
if self.robot.scene._seg_map.get_room_instance_by_point(candidate_2d_pose[:2]) in obj_rooms:
|
| 1791 |
+
break
|
| 1792 |
+
candidate_poses.append(candidate_2d_pose)
|
| 1793 |
+
|
| 1794 |
+
# Normally candidate_poses will have length equal to self._curobo_batch_size
|
| 1795 |
+
# In case we are unable to find a valid pose in the room, we will have less than self._curobo_batch_size.
|
| 1796 |
+
# We skip the following steps if the list is empty.
|
| 1797 |
+
if len(candidate_poses) > 0:
|
| 1798 |
+
result = self._validate_poses(
|
| 1799 |
+
candidate_poses,
|
| 1800 |
+
eef_pose=target_pose,
|
| 1801 |
+
plan_with_open_gripper=plan_with_open_gripper,
|
| 1802 |
+
skip_obstacle_update=True,
|
| 1803 |
+
)
|
| 1804 |
+
|
| 1805 |
+
# If anything in result is true, return the pose
|
| 1806 |
+
for i, res in enumerate(result):
|
| 1807 |
+
if res:
|
| 1808 |
+
indented_print("Found valid position near object.")
|
| 1809 |
+
return candidate_poses[i]
|
| 1810 |
+
|
| 1811 |
+
attempt += self._curobo_batch_size
|
| 1812 |
+
return None
|
| 1813 |
+
|
| 1814 |
+
@staticmethod
|
| 1815 |
+
def _sample_position_on_aabb_side(target_obj):
|
| 1816 |
+
"""
|
| 1817 |
+
Returns a position on one of the axis-aligned bounding box (AABB) side faces of the target object.
|
| 1818 |
+
|
| 1819 |
+
Args:
|
| 1820 |
+
target_obj (StatefulObject): Object to sample a position on
|
| 1821 |
+
|
| 1822 |
+
Returns:
|
| 1823 |
+
3-array: (x,y,z) Position in the world frame
|
| 1824 |
+
"""
|
| 1825 |
+
aabb_center, aabb_extent = target_obj.aabb_center, target_obj.aabb_extent
|
| 1826 |
+
# We want to sample only from the side-facing faces.
|
| 1827 |
+
face_normal_axis = random.choice([0, 1])
|
| 1828 |
+
face_normal_direction = random.choice([-1, 1])
|
| 1829 |
+
face_center = aabb_center + th.eye(3)[face_normal_axis] * aabb_extent * face_normal_direction
|
| 1830 |
+
face_lateral_axis = 0 if face_normal_axis == 1 else 1
|
| 1831 |
+
face_lateral_half_extent = th.eye(3)[face_lateral_axis] * aabb_extent / 2
|
| 1832 |
+
face_vertical_half_extent = th.eye(3)[2] * aabb_extent / 2
|
| 1833 |
+
face_min = face_center - face_vertical_half_extent - face_lateral_half_extent
|
| 1834 |
+
face_max = face_center + face_vertical_half_extent + face_lateral_half_extent
|
| 1835 |
+
return th.rand(face_min.size()) * (face_max - face_min) + face_min
|
| 1836 |
+
|
| 1837 |
+
# def _sample_pose_in_room(self, room: str):
|
| 1838 |
+
# """
|
| 1839 |
+
# Returns a pose for the robot within in the room where the robot is not in collision with anything
|
| 1840 |
+
|
| 1841 |
+
# Args:
|
| 1842 |
+
# room (str): Name of room
|
| 1843 |
+
|
| 1844 |
+
# Returns:
|
| 1845 |
+
# 2-tuple:
|
| 1846 |
+
# - 3-array: (x,y,z) Position in the world frame
|
| 1847 |
+
# - 4-array: (x,y,z,w) Quaternion orientation in the world frame
|
| 1848 |
+
# """
|
| 1849 |
+
# # TODO(MP): Bias the sampling near the agent.
|
| 1850 |
+
# for _ in range(m.MAX_ATTEMPTS_FOR_SAMPLING_POSE_IN_ROOM):
|
| 1851 |
+
# _, pos = self.env.scene.get_random_point_by_room_instance(room)
|
| 1852 |
+
# yaw_lo, yaw_hi = -math.pi, math.pi
|
| 1853 |
+
# yaw = (th.rand(1) * (yaw_hi - yaw_lo) + yaw_lo).item()
|
| 1854 |
+
# pose = (pos[0], pos[1], yaw)
|
| 1855 |
+
# if self._test_pose(pose):
|
| 1856 |
+
# return pose
|
| 1857 |
+
|
| 1858 |
+
# raise ActionPrimitiveError(
|
| 1859 |
+
# ActionPrimitiveError.Reason.SAMPLING_ERROR,
|
| 1860 |
+
# "Could not find valid position in the given room to travel to",
|
| 1861 |
+
# {"room": room}
|
| 1862 |
+
# )
|
| 1863 |
+
|
| 1864 |
+
def _sample_pose_with_object_and_predicate(
|
| 1865 |
+
self, predicate, held_obj, target_obj, world_aligned=False, near_poses=None, near_poses_threshold=None
|
| 1866 |
+
):
|
| 1867 |
+
"""
|
| 1868 |
+
Returns a pose for the held object relative to the target object that satisfies the predicate
|
| 1869 |
+
|
| 1870 |
+
Args:
|
| 1871 |
+
predicate (object_states.OnTop or object_states.Inside): Relation between held object and the target object
|
| 1872 |
+
held_obj (StatefulObject): Object held by the robot
|
| 1873 |
+
target_obj (StatefulObject): Object to sample a pose relative to
|
| 1874 |
+
world_aligned (bool): Whether to align the current world-aligned bbox to the sampled cuboid on the target_obj
|
| 1875 |
+
If True, align the current world-aligned bbox; if False, align the base-link aligned bbox
|
| 1876 |
+
near_poses (Iterable of arrays): Poses in the world frame to sample near
|
| 1877 |
+
near_poses_threshold (float): The distance threshold to check if the sampled pose is near the poses in near_poses
|
| 1878 |
+
|
| 1879 |
+
Returns:
|
| 1880 |
+
2-tuple:
|
| 1881 |
+
- 3-array: (x,y,z) Position in the world frame
|
| 1882 |
+
- 4-array: (x,y,z,w) Quaternion orientation in the world frame
|
| 1883 |
+
"""
|
| 1884 |
+
pred_map = {object_states.OnTop: "onTop", object_states.Inside: "inside"}
|
| 1885 |
+
|
| 1886 |
+
for _ in range(m.MAX_ATTEMPTS_FOR_SAMPLING_POSE_WITH_OBJECT_AND_PREDICATE):
|
| 1887 |
+
if world_aligned:
|
| 1888 |
+
# Take the bbox in the world frame because we want to keep the x-y component of the current orientation
|
| 1889 |
+
bb_extents = held_obj.aabb_extent
|
| 1890 |
+
bb_center = held_obj.aabb_center
|
| 1891 |
+
# Compute bbox pose in the object base link frame
|
| 1892 |
+
bb_pos_in_base, bb_orn_in_base = T.relative_pose_transform(
|
| 1893 |
+
bb_center, th.tensor([0, 0, 0, 1], dtype=th.float32), *held_obj.get_position_orientation()
|
| 1894 |
+
)
|
| 1895 |
+
else:
|
| 1896 |
+
_, _, bb_extents, bb_pos_in_base = held_obj.get_base_aligned_bbox()
|
| 1897 |
+
bb_orn_in_base = th.tensor([0, 0, 0, 1], dtype=th.float32)
|
| 1898 |
+
|
| 1899 |
+
sampling_results = sample_cuboid_for_predicate(pred_map[predicate], target_obj, bb_extents)
|
| 1900 |
+
if sampling_results[0][0] is None:
|
| 1901 |
+
continue
|
| 1902 |
+
sampled_bb_center = sampling_results[0][0] + th.tensor([0, 0, m.PREDICATE_SAMPLING_Z_OFFSET])
|
| 1903 |
+
sampled_bb_orn = sampling_results[0][2]
|
| 1904 |
+
|
| 1905 |
+
# Tobj_in_world @ Tbbox_in_obj = Tbbox_in_world
|
| 1906 |
+
# Tobj_in_world = Tbbox_in_world @ inv(Tbbox_in_obj)
|
| 1907 |
+
sampled_obj_pose = T.pose2mat((sampled_bb_center, sampled_bb_orn)) @ T.pose_inv(
|
| 1908 |
+
T.pose2mat((bb_pos_in_base, bb_orn_in_base))
|
| 1909 |
+
)
|
| 1910 |
+
|
| 1911 |
+
# Check that the pose is near one of the poses in the near_poses list if provided.
|
| 1912 |
+
if near_poses:
|
| 1913 |
+
sampled_pos = th.tensor([sampled_obj_pose[0]])
|
| 1914 |
+
if not th.any(th.norm(near_poses - sampled_pos, dim=1) < near_poses_threshold):
|
| 1915 |
+
continue
|
| 1916 |
+
|
| 1917 |
+
# Return the pose
|
| 1918 |
+
return T.mat2pose(sampled_obj_pose)
|
| 1919 |
+
|
| 1920 |
+
# If we get here, sampling failed.
|
| 1921 |
+
raise ActionPrimitiveError(
|
| 1922 |
+
ActionPrimitiveError.Reason.SAMPLING_ERROR,
|
| 1923 |
+
"Could not find a position to put this object in the desired relation to the target object",
|
| 1924 |
+
{"target object": target_obj.name, "object in hand": held_obj.name, "relation": pred_map[predicate]},
|
| 1925 |
+
)
|
| 1926 |
+
|
| 1927 |
+
def _validate_poses(self, candidate_poses, eef_pose=None, plan_with_open_gripper=False, skip_obstacle_update=False):
|
| 1928 |
+
"""
|
| 1929 |
+
Determines whether the robot can reach all poses on the objects and is not in collision at the specified 2d poses
|
| 1930 |
+
|
| 1931 |
+
Args:
|
| 1932 |
+
candidate_poses (list of arrays): Candidate 2d poses (x, y, yaw)
|
| 1933 |
+
eef_pose (Tuple[th.tensor, th.tensor]): target pose to reach for the default end-effector in the world frame
|
| 1934 |
+
plan_with_open_gripper (bool): Determines whether to plan with the gripper open even though it might be closed now.
|
| 1935 |
+
This is useful for the placing primitive because we will open-loop open the gripper after placing
|
| 1936 |
+
skip_obstacle_update (bool): Whether to skip updating the obstacles in the motion generator
|
| 1937 |
+
|
| 1938 |
+
Returns:
|
| 1939 |
+
list of bool: Whether the default arm can reach all poses on the objects and is not in collision
|
| 1940 |
+
at the specified 2d poses
|
| 1941 |
+
"""
|
| 1942 |
+
# First check collisions for all candidate poses
|
| 1943 |
+
candidate_joint_positions = []
|
| 1944 |
+
if plan_with_open_gripper:
|
| 1945 |
+
current_joint_pos = self._get_joint_position_with_fingers_at_limit("upper")
|
| 1946 |
+
else:
|
| 1947 |
+
current_joint_pos = self.robot.get_joint_positions()
|
| 1948 |
+
|
| 1949 |
+
# For holonomic robots, base joints are relative to root_link, but candidate
|
| 1950 |
+
# poses are in world frame. Convert (x, y) from world to root_link-relative.
|
| 1951 |
+
root_pos = self.robot.root_link.get_position_orientation()[0] if self.robot.is_holonomic_base else None
|
| 1952 |
+
|
| 1953 |
+
for pose in candidate_poses:
|
| 1954 |
+
joint_pos = current_joint_pos.clone()
|
| 1955 |
+
if root_pos is not None:
|
| 1956 |
+
joint_pos[self.robot.base_control_idx] = th.tensor(
|
| 1957 |
+
[pose[0] - root_pos[0], pose[1] - root_pos[1], pose[2]]
|
| 1958 |
+
)
|
| 1959 |
+
else:
|
| 1960 |
+
joint_pos[self.robot.base_control_idx] = pose
|
| 1961 |
+
candidate_joint_positions.append(joint_pos)
|
| 1962 |
+
|
| 1963 |
+
candidate_joint_positions = th.stack(candidate_joint_positions)
|
| 1964 |
+
|
| 1965 |
+
# If an object is grasped, we need to pass it to the collision checker
|
| 1966 |
+
obj_in_hand = self._get_obj_in_hand()
|
| 1967 |
+
attached_obj = {self.robot.eef_link_names[self.arm]: obj_in_hand.root_link} if obj_in_hand is not None else None
|
| 1968 |
+
|
| 1969 |
+
# No need to check for self-collision here because we are only testing for new base poses
|
| 1970 |
+
# This assumes the robot doesn't have self collisions currently.
|
| 1971 |
+
invalid_results = self._motion_generator.check_collisions(
|
| 1972 |
+
candidate_joint_positions,
|
| 1973 |
+
self_collision_check=False,
|
| 1974 |
+
skip_obstacle_update=skip_obstacle_update,
|
| 1975 |
+
attached_obj=attached_obj,
|
| 1976 |
+
).cpu()
|
| 1977 |
+
|
| 1978 |
+
# For each candidate that passed collision check, verify reachability
|
| 1979 |
+
for i in range(len(candidate_poses)):
|
| 1980 |
+
if invalid_results[i].item():
|
| 1981 |
+
continue
|
| 1982 |
+
|
| 1983 |
+
if eef_pose is not None:
|
| 1984 |
+
# Use the candidate joint position as the initial joint position to update the lock joints in curobo
|
| 1985 |
+
# This effectively moves the robot base in curobo when testing for arm reachability to the target eef_pose
|
| 1986 |
+
candidate_joint_position = candidate_joint_positions[i]
|
| 1987 |
+
if not self._target_in_reach_of_robot(
|
| 1988 |
+
eef_pose, initial_joint_pos=candidate_joint_position, skip_obstacle_update=skip_obstacle_update
|
| 1989 |
+
):
|
| 1990 |
+
invalid_results[i] = True
|
| 1991 |
+
|
| 1992 |
+
return ~invalid_results
|
| 1993 |
+
|
| 1994 |
+
def _get_robot_pose_from_2d_pose(self, pose_2d):
|
| 1995 |
+
"""
|
| 1996 |
+
Gets 3d pose from 2d pose
|
| 1997 |
+
|
| 1998 |
+
Args:
|
| 1999 |
+
pose_2d (Iterable): (x, y, yaw) 2d pose in the world frame
|
| 2000 |
+
|
| 2001 |
+
Returns:
|
| 2002 |
+
th.tensor: (x,y,z) Position in the world frame
|
| 2003 |
+
th.tensor: (x,y,z,w) Quaternion orientation in the world frame
|
| 2004 |
+
"""
|
| 2005 |
+
if self.robot.is_holonomic_base:
|
| 2006 |
+
base_joints = self.robot.get_joint_positions()[self.robot.base_idx]
|
| 2007 |
+
# base_joints[2] (z) is relative to root_link; convert to world frame
|
| 2008 |
+
root_pos = self.robot.root_link.get_position_orientation()[0]
|
| 2009 |
+
pos = th.tensor([pose_2d[0], pose_2d[1], root_pos[2] + base_joints[2]], dtype=th.float32)
|
| 2010 |
+
euler_intrinsic_xyz = th.tensor([base_joints[3], base_joints[4], pose_2d[2]], dtype=th.float32)
|
| 2011 |
+
mat = T.euler_intrinsic2mat(euler_intrinsic_xyz)
|
| 2012 |
+
orn = T.mat2quat(mat)
|
| 2013 |
+
else:
|
| 2014 |
+
pos = th.tensor([pose_2d[0], pose_2d[1], 0.0], dtype=th.float32)
|
| 2015 |
+
orn = T.euler2quat(th.tensor([0.0, 0.0, pose_2d[2]], dtype=th.float32))
|
| 2016 |
+
return pos, orn
|
| 2017 |
+
|
| 2018 |
+
def _world_pose_to_robot_pose(self, pose):
|
| 2019 |
+
"""
|
| 2020 |
+
Converts the pose in the world frame to the robot frame
|
| 2021 |
+
|
| 2022 |
+
Args:
|
| 2023 |
+
pose (Iterable): (pos, quat) Pose in the world frame
|
| 2024 |
+
|
| 2025 |
+
Returns:
|
| 2026 |
+
2-tuple:
|
| 2027 |
+
- 3-array: (x,y,z) Position in the world frame
|
| 2028 |
+
- 4-array: (x,y,z,w) Quaternion orientation in the world frame
|
| 2029 |
+
"""
|
| 2030 |
+
body_pose = self.robot.get_position_orientation()
|
| 2031 |
+
return T.relative_pose_transform(*pose, *body_pose)
|
| 2032 |
+
|
| 2033 |
+
def _robot_pose_to_world_pose(self, pose):
|
| 2034 |
+
"""
|
| 2035 |
+
Converts the pose in the robot frame to the world frame
|
| 2036 |
+
|
| 2037 |
+
Args:
|
| 2038 |
+
pose (Iterable): (pos, quat) Pose in the robot frame
|
| 2039 |
+
|
| 2040 |
+
Returns:
|
| 2041 |
+
2-tuple:
|
| 2042 |
+
- 3-array: (x,y,z) Position in the world frame
|
| 2043 |
+
- 4-array: (x,y,z,w) Quaternion orientation in the world frame
|
| 2044 |
+
"""
|
| 2045 |
+
body_pose = self.robot.get_position_orientation()
|
| 2046 |
+
inverse_body_pose = T.invert_pose_transform(body_pose[0], body_pose[1])
|
| 2047 |
+
return T.relative_pose_transform(*pose, *inverse_body_pose)
|
| 2048 |
+
|
| 2049 |
+
def _get_hand_pose_for_object_pose(self, desired_pose):
|
| 2050 |
+
"""
|
| 2051 |
+
Gets the pose of the hand for the desired object pose
|
| 2052 |
+
|
| 2053 |
+
Args:
|
| 2054 |
+
desired_pose (Iterable of arrays): Pose of the object in the world frame
|
| 2055 |
+
|
| 2056 |
+
Returns:
|
| 2057 |
+
2-tuple:
|
| 2058 |
+
- 3-array: (x,y,z) Position of the hand in the world frame
|
| 2059 |
+
- 4-array: (x,y,z,w) Quaternion orientation of the hand in the world frame
|
| 2060 |
+
"""
|
| 2061 |
+
obj_in_hand = self._get_obj_in_hand()
|
| 2062 |
+
|
| 2063 |
+
assert obj_in_hand is not None
|
| 2064 |
+
|
| 2065 |
+
# Get the object pose & the robot hand pose
|
| 2066 |
+
obj_in_world = obj_in_hand.get_position_orientation()
|
| 2067 |
+
hand_in_world = self.robot.eef_links[self.arm].get_position_orientation()
|
| 2068 |
+
|
| 2069 |
+
# Get the hand pose relative to the obj pose
|
| 2070 |
+
hand_in_obj = T.relative_pose_transform(*hand_in_world, *obj_in_world)
|
| 2071 |
+
|
| 2072 |
+
# Now apply desired obj pose.
|
| 2073 |
+
desired_hand_pose = T.pose_transform(*desired_pose, *hand_in_obj)
|
| 2074 |
+
|
| 2075 |
+
return desired_hand_pose
|
| 2076 |
+
|
| 2077 |
+
# Function that is particularly useful for Fetch, where it gives time for the base of robot to settle due to its uneven base.
|
| 2078 |
+
def _settle_robot(self):
|
| 2079 |
+
"""
|
| 2080 |
+
Yields a no op action for a few steps to allow the robot and physics to settle
|
| 2081 |
+
|
| 2082 |
+
Returns:
|
| 2083 |
+
th.tensor or None: Action array for one step for the robot to do nothing
|
| 2084 |
+
"""
|
| 2085 |
+
for _ in range(50):
|
| 2086 |
+
empty_action = self.robot.q_to_action(self.robot.get_joint_positions())
|
| 2087 |
+
yield self._postprocess_action(empty_action)
|
| 2088 |
+
|
| 2089 |
+
for _ in range(m.MAX_STEPS_FOR_SETTLING):
|
| 2090 |
+
if th.norm(self.robot.get_linear_velocity()) < 0.01:
|
| 2091 |
+
break
|
| 2092 |
+
empty_action = self.robot.q_to_action(self.robot.get_joint_positions())
|
| 2093 |
+
yield self._postprocess_action(empty_action)
|
source_data/pinned/behavior-1k-bddl/v3.9.3-post2/OmniGibson/omnigibson/action_primitives/symbolic_semantic_action_primitives.py
ADDED
|
@@ -0,0 +1,622 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
WARNING!
|
| 3 |
+
A set of action primitives that work without executing low-level physics but instead teleporting
|
| 4 |
+
objects directly into their post-condition states. Useful for learning high-level methods.
|
| 5 |
+
"""
|
| 6 |
+
|
| 7 |
+
import torch as th
|
| 8 |
+
from aenum import IntEnum, auto
|
| 9 |
+
from typing import Any
|
| 10 |
+
|
| 11 |
+
from omnigibson import object_states
|
| 12 |
+
from omnigibson.action_primitives.action_primitive_set_base import ActionPrimitiveError, ActionPrimitiveErrorGroup
|
| 13 |
+
from omnigibson.action_primitives.starter_semantic_action_primitives import StarterSemanticActionPrimitives
|
| 14 |
+
from omnigibson.objects import DatasetObject
|
| 15 |
+
from omnigibson.robots.robot import Robot
|
| 16 |
+
from omnigibson.transition_rules import SlicingRule
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
class SymbolicSemanticActionPrimitiveSet(IntEnum):
|
| 20 |
+
_init_ = "value __doc__"
|
| 21 |
+
GRASP = auto(), "Grasp an object"
|
| 22 |
+
PLACE_ON_TOP = auto(), "Place the currently grasped object on top of another object"
|
| 23 |
+
PLACE_INSIDE = auto(), "Place the currently grasped object inside another object"
|
| 24 |
+
OPEN = auto(), "Open an object"
|
| 25 |
+
CLOSE = auto(), "Close an object"
|
| 26 |
+
TOGGLE_ON = auto(), "Toggle an object on"
|
| 27 |
+
TOGGLE_OFF = auto(), "Toggle an object off"
|
| 28 |
+
SOAK_UNDER = auto(), "Soak the currently grasped object under a fluid source."
|
| 29 |
+
SOAK_INSIDE = auto(), "Soak the currently grasped object inside the fluid within a container."
|
| 30 |
+
WIPE = auto(), "Wipe the given object with the currently grasped object."
|
| 31 |
+
CUT = auto(), "Cut (slice or dice) the given object with the currently grasped object."
|
| 32 |
+
PLACE_NEAR_HEATING_ELEMENT = (
|
| 33 |
+
auto(),
|
| 34 |
+
"Place the currently grasped object near the heating element of another object.",
|
| 35 |
+
)
|
| 36 |
+
NAVIGATE_TO = auto(), "Navigate to an object"
|
| 37 |
+
RELEASE = (
|
| 38 |
+
auto(),
|
| 39 |
+
"Release an object, letting it fall to the ground. You can then grasp it again, as a way of reorienting your grasp of the object.",
|
| 40 |
+
)
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
class SymbolicSemanticActionPrimitives(StarterSemanticActionPrimitives):
|
| 44 |
+
def __init__(self, env, robot):
|
| 45 |
+
super().__init__(env, robot, skip_curobo_initilization=True)
|
| 46 |
+
self.controller_functions = {
|
| 47 |
+
SymbolicSemanticActionPrimitiveSet.GRASP: self._grasp,
|
| 48 |
+
SymbolicSemanticActionPrimitiveSet.PLACE_ON_TOP: self._place_on_top,
|
| 49 |
+
SymbolicSemanticActionPrimitiveSet.PLACE_INSIDE: self._place_inside,
|
| 50 |
+
SymbolicSemanticActionPrimitiveSet.OPEN: self._open,
|
| 51 |
+
SymbolicSemanticActionPrimitiveSet.CLOSE: self._close,
|
| 52 |
+
SymbolicSemanticActionPrimitiveSet.TOGGLE_ON: self._toggle_on,
|
| 53 |
+
SymbolicSemanticActionPrimitiveSet.TOGGLE_OFF: self._toggle_off,
|
| 54 |
+
SymbolicSemanticActionPrimitiveSet.SOAK_UNDER: self._soak_under,
|
| 55 |
+
SymbolicSemanticActionPrimitiveSet.SOAK_INSIDE: self._soak_inside,
|
| 56 |
+
SymbolicSemanticActionPrimitiveSet.WIPE: self._wipe,
|
| 57 |
+
SymbolicSemanticActionPrimitiveSet.CUT: self._cut,
|
| 58 |
+
SymbolicSemanticActionPrimitiveSet.PLACE_NEAR_HEATING_ELEMENT: self._place_near_heating_element,
|
| 59 |
+
SymbolicSemanticActionPrimitiveSet.NAVIGATE_TO: self._navigate_to_obj,
|
| 60 |
+
SymbolicSemanticActionPrimitiveSet.RELEASE: self._release,
|
| 61 |
+
}
|
| 62 |
+
|
| 63 |
+
def apply_ref(self, primitive, *args: Any, attempts=3):
|
| 64 |
+
"""
|
| 65 |
+
Yields action for robot to execute the primitive with the given arguments.
|
| 66 |
+
|
| 67 |
+
Args:
|
| 68 |
+
primitive (SymbolicSemanticActionPrimitiveSet): Primitive to execute
|
| 69 |
+
args: Arguments for the primitive
|
| 70 |
+
attempts (int): Number of attempts to make before raising an error
|
| 71 |
+
|
| 72 |
+
Returns:
|
| 73 |
+
th.tensor or None: Action array for one step for the robot tto execute the primitve or None if primitive completed
|
| 74 |
+
|
| 75 |
+
Raises:
|
| 76 |
+
ActionPrimitiveError: If primitive fails to execute
|
| 77 |
+
"""
|
| 78 |
+
assert attempts > 0, "Must make at least one attempt"
|
| 79 |
+
ctrl = self.controller_functions[primitive]
|
| 80 |
+
|
| 81 |
+
if any(isinstance(arg, Robot) for arg in args):
|
| 82 |
+
raise ActionPrimitiveErrorGroup(
|
| 83 |
+
[
|
| 84 |
+
ActionPrimitiveError(
|
| 85 |
+
ActionPrimitiveError.Reason.PRE_CONDITION_ERROR,
|
| 86 |
+
"Cannot call a symbolic semantic action primitive with a robot as an argument.",
|
| 87 |
+
)
|
| 88 |
+
]
|
| 89 |
+
)
|
| 90 |
+
|
| 91 |
+
errors = []
|
| 92 |
+
for _ in range(attempts):
|
| 93 |
+
# Attempt
|
| 94 |
+
success = False
|
| 95 |
+
try:
|
| 96 |
+
yield from ctrl(*args)
|
| 97 |
+
success = True
|
| 98 |
+
except ActionPrimitiveError as e:
|
| 99 |
+
errors.append(e)
|
| 100 |
+
|
| 101 |
+
try:
|
| 102 |
+
# Settle before returning.
|
| 103 |
+
yield from self._settle_robot()
|
| 104 |
+
except ActionPrimitiveError:
|
| 105 |
+
pass
|
| 106 |
+
|
| 107 |
+
# Stop on success
|
| 108 |
+
if success:
|
| 109 |
+
return
|
| 110 |
+
|
| 111 |
+
raise ActionPrimitiveErrorGroup(errors)
|
| 112 |
+
|
| 113 |
+
def _open_or_close(self, obj, should_open):
|
| 114 |
+
if self._get_obj_in_hand():
|
| 115 |
+
raise ActionPrimitiveError(
|
| 116 |
+
ActionPrimitiveError.Reason.PRE_CONDITION_ERROR,
|
| 117 |
+
"Cannot open or close an object while holding an object",
|
| 118 |
+
{"object in hand": self._get_obj_in_hand().name},
|
| 119 |
+
)
|
| 120 |
+
|
| 121 |
+
if object_states.Open not in obj.states:
|
| 122 |
+
raise ActionPrimitiveError(
|
| 123 |
+
ActionPrimitiveError.Reason.PRE_CONDITION_ERROR,
|
| 124 |
+
"The target object is not openable.",
|
| 125 |
+
{"target object": obj.name},
|
| 126 |
+
)
|
| 127 |
+
|
| 128 |
+
# Don't do anything if the object is already closed and we're trying to close.
|
| 129 |
+
if should_open == obj.states[object_states.Open].get_value():
|
| 130 |
+
return
|
| 131 |
+
|
| 132 |
+
# Set the value
|
| 133 |
+
obj.states[object_states.Open].set_value(should_open)
|
| 134 |
+
|
| 135 |
+
# Settle
|
| 136 |
+
yield from self._settle_robot()
|
| 137 |
+
|
| 138 |
+
if obj.states[object_states.Open].get_value() != should_open:
|
| 139 |
+
raise ActionPrimitiveError(
|
| 140 |
+
ActionPrimitiveError.Reason.POST_CONDITION_ERROR,
|
| 141 |
+
"The object did not open or close as expected. Maybe try again",
|
| 142 |
+
{"target object": obj.name, "is it currently open": obj.states[object_states.Open].get_value()},
|
| 143 |
+
)
|
| 144 |
+
|
| 145 |
+
def _grasp(self, obj: DatasetObject):
|
| 146 |
+
"""
|
| 147 |
+
Yields action for the robot to navigate to object if needed, then to grasp it
|
| 148 |
+
|
| 149 |
+
Args:
|
| 150 |
+
DatasetObject: Object for robot to grasp
|
| 151 |
+
|
| 152 |
+
Returns:
|
| 153 |
+
th.tensor or None: Action array for one step for the robot to grasp or None if grasp completed
|
| 154 |
+
"""
|
| 155 |
+
# Don't do anything if the object is already grasped.
|
| 156 |
+
obj_in_hand = self._get_obj_in_hand()
|
| 157 |
+
if obj_in_hand is not None:
|
| 158 |
+
if obj_in_hand == obj:
|
| 159 |
+
return
|
| 160 |
+
else:
|
| 161 |
+
raise ActionPrimitiveError(
|
| 162 |
+
ActionPrimitiveError.Reason.PRE_CONDITION_ERROR,
|
| 163 |
+
"Cannot grasp when your hand is already full",
|
| 164 |
+
{"target object": obj.name, "object currently in hand": obj_in_hand.name},
|
| 165 |
+
)
|
| 166 |
+
|
| 167 |
+
# Get close
|
| 168 |
+
# yield from self._navigate_if_needed(obj)
|
| 169 |
+
|
| 170 |
+
# Perform forced assisted grasp
|
| 171 |
+
eef_pos_world = self.robot.get_eef_position(self.arm)
|
| 172 |
+
obj.set_position_orientation(position=eef_pos_world)
|
| 173 |
+
self.robot._establish_grasp(obj, obj.root_link_name, self.arm, eef_pos_world, "FixedJoint")
|
| 174 |
+
|
| 175 |
+
# Execute for a moment
|
| 176 |
+
yield from self._settle_robot()
|
| 177 |
+
|
| 178 |
+
# Verify
|
| 179 |
+
if self._get_obj_in_hand() is None:
|
| 180 |
+
raise ActionPrimitiveError(
|
| 181 |
+
ActionPrimitiveError.Reason.POST_CONDITION_ERROR,
|
| 182 |
+
"Grasp completed, but no object detected in hand after executing grasp",
|
| 183 |
+
{"target object": obj.name},
|
| 184 |
+
)
|
| 185 |
+
|
| 186 |
+
if self._get_obj_in_hand() != obj:
|
| 187 |
+
raise ActionPrimitiveError(
|
| 188 |
+
ActionPrimitiveError.Reason.POST_CONDITION_ERROR,
|
| 189 |
+
"An unexpected object was detected in hand after executing grasp. Consider releasing it",
|
| 190 |
+
{"expected object": obj.name, "actual object": self._get_obj_in_hand().name},
|
| 191 |
+
)
|
| 192 |
+
|
| 193 |
+
def _release(self):
|
| 194 |
+
if not self._get_obj_in_hand():
|
| 195 |
+
raise ActionPrimitiveError(
|
| 196 |
+
ActionPrimitiveError.Reason.PRE_CONDITION_ERROR,
|
| 197 |
+
"Cannot release an object if you're not already holding an object",
|
| 198 |
+
)
|
| 199 |
+
|
| 200 |
+
for arm in self.robot.arm_names:
|
| 201 |
+
self.robot.release_grasp_immediately(arm=arm)
|
| 202 |
+
yield from self._settle_robot()
|
| 203 |
+
|
| 204 |
+
def _toggle(self, obj, value):
|
| 205 |
+
if self._get_obj_in_hand():
|
| 206 |
+
raise ActionPrimitiveError(
|
| 207 |
+
ActionPrimitiveError.Reason.PRE_CONDITION_ERROR,
|
| 208 |
+
"Cannot toggle an object while holding an object",
|
| 209 |
+
{"object in hand": self._get_obj_in_hand()},
|
| 210 |
+
)
|
| 211 |
+
|
| 212 |
+
if object_states.ToggledOn not in obj.states:
|
| 213 |
+
raise ActionPrimitiveError(
|
| 214 |
+
ActionPrimitiveError.Reason.PRE_CONDITION_ERROR,
|
| 215 |
+
"The target object is not toggleable.",
|
| 216 |
+
{"target object": obj.name},
|
| 217 |
+
)
|
| 218 |
+
|
| 219 |
+
if obj.states[object_states.ToggledOn].get_value() == value:
|
| 220 |
+
return
|
| 221 |
+
|
| 222 |
+
# Call the setter
|
| 223 |
+
obj.states[object_states.ToggledOn].set_value(value)
|
| 224 |
+
|
| 225 |
+
# Yield some actions
|
| 226 |
+
yield from self._settle_robot()
|
| 227 |
+
|
| 228 |
+
# Check that it actually happened
|
| 229 |
+
if obj.states[object_states.ToggledOn].get_value() != value:
|
| 230 |
+
raise ActionPrimitiveError(
|
| 231 |
+
ActionPrimitiveError.Reason.POST_CONDITION_ERROR,
|
| 232 |
+
"The object did not toggle as expected - maybe try again",
|
| 233 |
+
{
|
| 234 |
+
"target object": obj.name,
|
| 235 |
+
"is it currently toggled on": obj.states[object_states.ToggledOn].get_value(),
|
| 236 |
+
},
|
| 237 |
+
)
|
| 238 |
+
|
| 239 |
+
def _place_with_predicate(self, obj, predicate, near_poses=None, near_poses_threshold=None):
|
| 240 |
+
"""
|
| 241 |
+
Yields action for the robot to navigate to the object if needed, then to place it
|
| 242 |
+
|
| 243 |
+
Args:
|
| 244 |
+
obj (StatefulObject): Object for robot to place the object in its hand on
|
| 245 |
+
predicate (object_states.OnTop or object_states.Inside): Determines whether to place on top or inside
|
| 246 |
+
|
| 247 |
+
Returns:
|
| 248 |
+
th.tensor or None: Action array for one step for the robot to place or None if place completed
|
| 249 |
+
"""
|
| 250 |
+
obj_in_hand = self._get_obj_in_hand()
|
| 251 |
+
if obj_in_hand is None:
|
| 252 |
+
raise ActionPrimitiveError(
|
| 253 |
+
ActionPrimitiveError.Reason.PRE_CONDITION_ERROR,
|
| 254 |
+
"You need to be grasping an object first to place it somewhere.",
|
| 255 |
+
)
|
| 256 |
+
|
| 257 |
+
# Find a spot to put it
|
| 258 |
+
obj_pose = self._sample_pose_with_object_and_predicate(
|
| 259 |
+
predicate, obj_in_hand, obj, near_poses=near_poses, near_poses_threshold=near_poses_threshold
|
| 260 |
+
)
|
| 261 |
+
|
| 262 |
+
# Get close, release the object.
|
| 263 |
+
# yield from self._navigate_if_needed(obj, pose_on_obj=obj_pose)
|
| 264 |
+
yield from self._release()
|
| 265 |
+
|
| 266 |
+
# Actually move the object to the spot and step a bit to settle it.
|
| 267 |
+
obj_in_hand.set_position_orientation(*obj_pose)
|
| 268 |
+
yield from self._settle_robot()
|
| 269 |
+
|
| 270 |
+
if not obj_in_hand.states[predicate].get_value(obj):
|
| 271 |
+
raise ActionPrimitiveError(
|
| 272 |
+
ActionPrimitiveError.Reason.EXECUTION_ERROR,
|
| 273 |
+
"Failed to place object at the desired place (probably dropped). The object was still released, so you need to grasp it again to continue",
|
| 274 |
+
{"dropped object": obj_in_hand.name, "target object": obj.name},
|
| 275 |
+
)
|
| 276 |
+
|
| 277 |
+
def _soak_under(self, obj):
|
| 278 |
+
# Check that our current object is a particle remover
|
| 279 |
+
obj_in_hand = self._get_obj_in_hand()
|
| 280 |
+
if obj_in_hand is None:
|
| 281 |
+
raise ActionPrimitiveError(
|
| 282 |
+
ActionPrimitiveError.Reason.PRE_CONDITION_ERROR, "You need to be grasping a soakable object first."
|
| 283 |
+
)
|
| 284 |
+
|
| 285 |
+
# Check that the target object is a particle source
|
| 286 |
+
if object_states.ParticleSource not in obj.states:
|
| 287 |
+
raise ActionPrimitiveError(
|
| 288 |
+
ActionPrimitiveError.Reason.PRE_CONDITION_ERROR,
|
| 289 |
+
"The target object is not a particle source, so you can not soak anything under it.",
|
| 290 |
+
{"target object": obj.name},
|
| 291 |
+
)
|
| 292 |
+
|
| 293 |
+
# Check if the target object has any particles in it
|
| 294 |
+
producing_systems = {
|
| 295 |
+
ps
|
| 296 |
+
for ps in obj.scene.system_registry.objects
|
| 297 |
+
if obj.states[object_states.ParticleSource].check_conditions_for_system(ps.name)
|
| 298 |
+
}
|
| 299 |
+
if not producing_systems:
|
| 300 |
+
raise ActionPrimitiveError(
|
| 301 |
+
ActionPrimitiveError.Reason.PRE_CONDITION_ERROR,
|
| 302 |
+
"The target object currently is not producing any particles - try toggling it on.",
|
| 303 |
+
{"target object": obj.name},
|
| 304 |
+
)
|
| 305 |
+
|
| 306 |
+
# Check that the current object can remove those particles
|
| 307 |
+
if object_states.Saturated not in obj_in_hand.states:
|
| 308 |
+
raise ActionPrimitiveError(
|
| 309 |
+
ActionPrimitiveError.Reason.PRE_CONDITION_ERROR,
|
| 310 |
+
"The currently grasped object cannot soak particles.",
|
| 311 |
+
{"object in hand": obj_in_hand.name},
|
| 312 |
+
)
|
| 313 |
+
|
| 314 |
+
supported_systems = {
|
| 315 |
+
x for x in producing_systems if obj_in_hand.states[object_states.ParticleRemover].supports_system(x.name)
|
| 316 |
+
}
|
| 317 |
+
|
| 318 |
+
if not supported_systems:
|
| 319 |
+
raise ActionPrimitiveError(
|
| 320 |
+
ActionPrimitiveError.Reason.PRE_CONDITION_ERROR,
|
| 321 |
+
"The target object only contains particles that this object cannot soak.",
|
| 322 |
+
{
|
| 323 |
+
"target object": obj.name,
|
| 324 |
+
"cleaning tool": obj_in_hand.name,
|
| 325 |
+
"particles the target object is producing": sorted(x.name for x in producing_systems),
|
| 326 |
+
"particles the grasped object can remove": sorted(
|
| 327 |
+
[x for x in obj_in_hand.states[object_states.ParticleRemover].conditions.keys()]
|
| 328 |
+
),
|
| 329 |
+
},
|
| 330 |
+
)
|
| 331 |
+
|
| 332 |
+
currently_removable_systems = {
|
| 333 |
+
x
|
| 334 |
+
for x in supported_systems
|
| 335 |
+
if obj_in_hand.states[object_states.ParticleRemover].check_conditions_for_system(x.name)
|
| 336 |
+
}
|
| 337 |
+
if not currently_removable_systems:
|
| 338 |
+
# TODO: This needs to be far more descriptive.
|
| 339 |
+
raise ActionPrimitiveError(
|
| 340 |
+
ActionPrimitiveError.Reason.PRE_CONDITION_ERROR,
|
| 341 |
+
"The target object is covered by some particles that this object can normally soak, but needs to be in a different state to do so (e.g. toggled on, soaked by another fluid first, etc.).",
|
| 342 |
+
{
|
| 343 |
+
"target object": obj.name,
|
| 344 |
+
"cleaning tool": obj_in_hand.name,
|
| 345 |
+
"particles the target object is producing": sorted(x.name for x in producing_systems),
|
| 346 |
+
},
|
| 347 |
+
)
|
| 348 |
+
|
| 349 |
+
# If so, remove the particles.
|
| 350 |
+
for system in currently_removable_systems:
|
| 351 |
+
obj_in_hand.states[object_states.Saturated].set_value(system, True)
|
| 352 |
+
|
| 353 |
+
# Yield some actions
|
| 354 |
+
yield from self._settle_robot()
|
| 355 |
+
|
| 356 |
+
def _soak_inside(self, obj):
|
| 357 |
+
# Check that our current object is a particle remover
|
| 358 |
+
obj_in_hand = self._get_obj_in_hand()
|
| 359 |
+
if obj_in_hand is None:
|
| 360 |
+
raise ActionPrimitiveError(
|
| 361 |
+
ActionPrimitiveError.Reason.PRE_CONDITION_ERROR, "You need to be grasping a soakable object first."
|
| 362 |
+
)
|
| 363 |
+
|
| 364 |
+
# Check that the target object is fillable
|
| 365 |
+
if object_states.Contains not in obj.states:
|
| 366 |
+
raise ActionPrimitiveError(
|
| 367 |
+
ActionPrimitiveError.Reason.PRE_CONDITION_ERROR,
|
| 368 |
+
"The target object is not fillable by particles, so you can not soak anything in it.",
|
| 369 |
+
{"target object": obj.name},
|
| 370 |
+
)
|
| 371 |
+
|
| 372 |
+
# Check if the target object has any particles in it
|
| 373 |
+
contained_systems = {
|
| 374 |
+
ps for ps in obj.scene.system_registry.objects if obj.states[object_states.Contains].get_value(ps.states)
|
| 375 |
+
}
|
| 376 |
+
if not contained_systems:
|
| 377 |
+
raise ActionPrimitiveError(
|
| 378 |
+
ActionPrimitiveError.Reason.PRE_CONDITION_ERROR,
|
| 379 |
+
"The target object currently does not contain any particles.",
|
| 380 |
+
{"target object": obj.name},
|
| 381 |
+
)
|
| 382 |
+
|
| 383 |
+
# Check that the current object can remove those particles
|
| 384 |
+
if object_states.Saturated not in obj_in_hand.states:
|
| 385 |
+
raise ActionPrimitiveError(
|
| 386 |
+
ActionPrimitiveError.Reason.PRE_CONDITION_ERROR,
|
| 387 |
+
"The currently grasped object cannot soak particles.",
|
| 388 |
+
{"object in hand": obj_in_hand.name},
|
| 389 |
+
)
|
| 390 |
+
|
| 391 |
+
supported_systems = {
|
| 392 |
+
x for x in contained_systems if obj_in_hand.states[object_states.ParticleRemover].supports_system(x.name)
|
| 393 |
+
}
|
| 394 |
+
if not supported_systems:
|
| 395 |
+
raise ActionPrimitiveError(
|
| 396 |
+
ActionPrimitiveError.Reason.PRE_CONDITION_ERROR,
|
| 397 |
+
"The target object only contains particles that this object cannot soak.",
|
| 398 |
+
{
|
| 399 |
+
"target object": obj.name,
|
| 400 |
+
"cleaning tool": obj_in_hand.name,
|
| 401 |
+
"particles the target object contains": sorted(x.name for x in contained_systems),
|
| 402 |
+
"particles the grasped object can remove": sorted(
|
| 403 |
+
[x for x in obj_in_hand.states[object_states.ParticleRemover].conditions.keys()]
|
| 404 |
+
),
|
| 405 |
+
},
|
| 406 |
+
)
|
| 407 |
+
|
| 408 |
+
currently_removable_systems = {
|
| 409 |
+
x
|
| 410 |
+
for x in supported_systems
|
| 411 |
+
if obj_in_hand.states[object_states.ParticleRemover].check_conditions_for_system(x.name)
|
| 412 |
+
}
|
| 413 |
+
if not currently_removable_systems:
|
| 414 |
+
# TODO: This needs to be far more descriptive.
|
| 415 |
+
raise ActionPrimitiveError(
|
| 416 |
+
ActionPrimitiveError.Reason.PRE_CONDITION_ERROR,
|
| 417 |
+
"The target object is covered by some particles that this object can normally soak, but needs to be in a different state to do so (e.g. toggled on, soaked by another fluid first, etc.).",
|
| 418 |
+
{
|
| 419 |
+
"target object": obj.name,
|
| 420 |
+
"cleaning tool": obj_in_hand.name,
|
| 421 |
+
"particles the target object contains": sorted(x.name for x in contained_systems),
|
| 422 |
+
},
|
| 423 |
+
)
|
| 424 |
+
|
| 425 |
+
# If so, remove the particles.
|
| 426 |
+
for system in currently_removable_systems:
|
| 427 |
+
obj_in_hand.states[object_states.Saturated].set_value(system, True)
|
| 428 |
+
|
| 429 |
+
# Yield some actions
|
| 430 |
+
yield from self._settle_robot()
|
| 431 |
+
|
| 432 |
+
def _wipe(self, obj):
|
| 433 |
+
# Check that our current object is a particle remover
|
| 434 |
+
obj_in_hand = self._get_obj_in_hand()
|
| 435 |
+
if obj_in_hand is None:
|
| 436 |
+
raise ActionPrimitiveError(
|
| 437 |
+
ActionPrimitiveError.Reason.PRE_CONDITION_ERROR,
|
| 438 |
+
"You need to be grasping a wiping tool (particle remover) first to wipe an object.",
|
| 439 |
+
)
|
| 440 |
+
|
| 441 |
+
# Check that the target object is coverable
|
| 442 |
+
if object_states.Covered not in obj.states:
|
| 443 |
+
raise ActionPrimitiveError(
|
| 444 |
+
ActionPrimitiveError.Reason.PRE_CONDITION_ERROR,
|
| 445 |
+
"The target object is not coverable by any particles, so there is no need to wipe it.",
|
| 446 |
+
{"target object": obj.name},
|
| 447 |
+
)
|
| 448 |
+
|
| 449 |
+
# Check if the target object has any particles on it
|
| 450 |
+
covering_systems = {
|
| 451 |
+
ps for ps in obj.scene.system_registry.objects if obj.states[object_states.Covered].get_value(ps)
|
| 452 |
+
}
|
| 453 |
+
if not covering_systems:
|
| 454 |
+
raise ActionPrimitiveError(
|
| 455 |
+
ActionPrimitiveError.Reason.PRE_CONDITION_ERROR,
|
| 456 |
+
"The target object is not covered by any particles.",
|
| 457 |
+
{"target object": obj.name},
|
| 458 |
+
)
|
| 459 |
+
|
| 460 |
+
# Check that the current object can remove those particles
|
| 461 |
+
if object_states.ParticleRemover not in obj_in_hand.states:
|
| 462 |
+
raise ActionPrimitiveError(
|
| 463 |
+
ActionPrimitiveError.Reason.PRE_CONDITION_ERROR,
|
| 464 |
+
"The currently grasped object is not a particle remover.",
|
| 465 |
+
{"object in hand": obj_in_hand.name},
|
| 466 |
+
)
|
| 467 |
+
|
| 468 |
+
supported_systems = {
|
| 469 |
+
x for x in covering_systems if obj_in_hand.states[object_states.ParticleRemover].supports_system(x.name)
|
| 470 |
+
}
|
| 471 |
+
if not supported_systems:
|
| 472 |
+
raise ActionPrimitiveError(
|
| 473 |
+
ActionPrimitiveError.Reason.PRE_CONDITION_ERROR,
|
| 474 |
+
"The target object is covered only by particles that this cleaning tool cannot remove.",
|
| 475 |
+
{
|
| 476 |
+
"target object": obj.name,
|
| 477 |
+
"cleaning tool": obj_in_hand.name,
|
| 478 |
+
"particles the target object is covered by": sorted(x.name for x in covering_systems),
|
| 479 |
+
"particles the grasped object can remove": sorted(
|
| 480 |
+
[x for x in obj_in_hand.states[object_states.ParticleRemover].conditions.keys()]
|
| 481 |
+
),
|
| 482 |
+
},
|
| 483 |
+
)
|
| 484 |
+
|
| 485 |
+
currently_removable_systems = {
|
| 486 |
+
x
|
| 487 |
+
for x in supported_systems
|
| 488 |
+
if obj_in_hand.states[object_states.ParticleRemover].check_conditions_for_system(x.name)
|
| 489 |
+
}
|
| 490 |
+
if not currently_removable_systems:
|
| 491 |
+
# TODO: This needs to be far more descriptive.
|
| 492 |
+
raise ActionPrimitiveError(
|
| 493 |
+
ActionPrimitiveError.Reason.PRE_CONDITION_ERROR,
|
| 494 |
+
"The target object is covered by some particles that this cleaning tool can normally remove, but needs to be in a different state to do so (e.g. toggled on, soaked by another fluid first, etc.).",
|
| 495 |
+
{
|
| 496 |
+
"target object": obj.name,
|
| 497 |
+
"cleaning tool": obj_in_hand.name,
|
| 498 |
+
"particles the target object is covered by": sorted(x.name for x in covering_systems),
|
| 499 |
+
},
|
| 500 |
+
)
|
| 501 |
+
# If so, remove the particles on the target object
|
| 502 |
+
for system in currently_removable_systems:
|
| 503 |
+
obj.states[object_states.Covered].set_value(system, False)
|
| 504 |
+
|
| 505 |
+
# Yield some actions
|
| 506 |
+
yield from self._settle_robot()
|
| 507 |
+
|
| 508 |
+
def _cut(self, obj):
|
| 509 |
+
# Check that our current object is a slicer
|
| 510 |
+
obj_in_hand = self._get_obj_in_hand()
|
| 511 |
+
if obj_in_hand is None:
|
| 512 |
+
raise ActionPrimitiveError(
|
| 513 |
+
ActionPrimitiveError.Reason.PRE_CONDITION_ERROR,
|
| 514 |
+
"You need to be grasping a cutting tool first to slice an object.",
|
| 515 |
+
)
|
| 516 |
+
|
| 517 |
+
if "slicer" not in obj_in_hand._abilities:
|
| 518 |
+
raise ActionPrimitiveError(
|
| 519 |
+
ActionPrimitiveError.Reason.PRE_CONDITION_ERROR,
|
| 520 |
+
"The current object is not a cutting tool.",
|
| 521 |
+
{"object in hand": obj_in_hand.name},
|
| 522 |
+
)
|
| 523 |
+
|
| 524 |
+
# Check that the target object is sliceable
|
| 525 |
+
if "sliceable" not in obj._abilities and "diceable" not in obj._abilities:
|
| 526 |
+
raise ActionPrimitiveError(
|
| 527 |
+
ActionPrimitiveError.Reason.PRE_CONDITION_ERROR,
|
| 528 |
+
"The target object is not sliceable or diceable.",
|
| 529 |
+
{"target object": obj.name},
|
| 530 |
+
)
|
| 531 |
+
|
| 532 |
+
# Get close
|
| 533 |
+
# yield from self._navigate_if_needed(obj)
|
| 534 |
+
|
| 535 |
+
# TODO: Do some more validation
|
| 536 |
+
added_obj_attrs = []
|
| 537 |
+
removed_objs = []
|
| 538 |
+
(slicing_rule,) = [rule for rule in obj.scene.transition_rule_api.active_rules if isinstance(rule, SlicingRule)]
|
| 539 |
+
output = slicing_rule.transition({"sliceable": [obj]})
|
| 540 |
+
added_obj_attrs += output.add
|
| 541 |
+
removed_objs += output.remove
|
| 542 |
+
|
| 543 |
+
obj.scene.transition_rule_api.execute_transition(added_obj_attrs=added_obj_attrs, removed_objs=removed_objs)
|
| 544 |
+
yield from self._settle_robot()
|
| 545 |
+
|
| 546 |
+
def _place_near_heating_element(self, heat_source_obj):
|
| 547 |
+
obj_in_hand = self._get_obj_in_hand()
|
| 548 |
+
if obj_in_hand is None:
|
| 549 |
+
raise ActionPrimitiveError(
|
| 550 |
+
ActionPrimitiveError.Reason.PRE_CONDITION_ERROR,
|
| 551 |
+
"You need to be grasping an object first to place it somewhere.",
|
| 552 |
+
)
|
| 553 |
+
|
| 554 |
+
if object_states.HeatSourceOrSink not in heat_source_obj.states:
|
| 555 |
+
raise ActionPrimitiveError(
|
| 556 |
+
ActionPrimitiveError.Reason.PRE_CONDITION_ERROR,
|
| 557 |
+
"The target object is not a heat source or sink.",
|
| 558 |
+
{"target object": heat_source_obj.name},
|
| 559 |
+
)
|
| 560 |
+
|
| 561 |
+
if heat_source_obj.states[object_states.HeatSourceOrSink].requires_inside:
|
| 562 |
+
raise ActionPrimitiveError(
|
| 563 |
+
ActionPrimitiveError.Reason.PRE_CONDITION_ERROR,
|
| 564 |
+
"The heat source object has no explicit heating element, it just requires the cookable object to be placed inside it.",
|
| 565 |
+
{"target object": heat_source_obj.name},
|
| 566 |
+
)
|
| 567 |
+
|
| 568 |
+
# Get the position of the heat source on the thing we're placing near
|
| 569 |
+
heating_element_positions = th.tensor(
|
| 570 |
+
[
|
| 571 |
+
link.get_position_orientation()[0]
|
| 572 |
+
for link in heat_source_obj.states[object_states.HeatSourceOrSink].links.values()
|
| 573 |
+
]
|
| 574 |
+
)
|
| 575 |
+
heating_distance_threshold = heat_source_obj.states[object_states.HeatSourceOrSink].distance_threshold
|
| 576 |
+
|
| 577 |
+
# Call place-with-predicate
|
| 578 |
+
yield from self._place_with_predicate(
|
| 579 |
+
heat_source_obj,
|
| 580 |
+
object_states.OnTop,
|
| 581 |
+
near_poses=heating_element_positions,
|
| 582 |
+
near_poses_threshold=heating_distance_threshold,
|
| 583 |
+
)
|
| 584 |
+
|
| 585 |
+
def _wait_for_cooked(self, obj):
|
| 586 |
+
# Check that the current object is cookable
|
| 587 |
+
if object_states.Cooked not in obj.states:
|
| 588 |
+
raise ActionPrimitiveError(
|
| 589 |
+
ActionPrimitiveError.Reason.PRE_CONDITION_ERROR,
|
| 590 |
+
"Target object is not cookable.",
|
| 591 |
+
{"target object": obj.name},
|
| 592 |
+
)
|
| 593 |
+
|
| 594 |
+
# Keep waiting as long as the thing is warming up.
|
| 595 |
+
prev_temp = obj.states[object_states.Temperature].get_value()
|
| 596 |
+
while not obj.states[object_states.Cooked].get_value():
|
| 597 |
+
# Pass some time
|
| 598 |
+
for _ in range(10):
|
| 599 |
+
yield from self._empty_action()
|
| 600 |
+
|
| 601 |
+
# Check that we are still heating up
|
| 602 |
+
new_temp = obj.states[object_states.Temperature].get_value()
|
| 603 |
+
if new_temp - prev_temp < 1e-2:
|
| 604 |
+
raise ActionPrimitiveError(
|
| 605 |
+
ActionPrimitiveError.PRE_CONDITION_ERROR,
|
| 606 |
+
"Target object is not currently heating up.",
|
| 607 |
+
{"target object": obj.name},
|
| 608 |
+
)
|
| 609 |
+
|
| 610 |
+
def _navigate_to_pose(self, pose_2d):
|
| 611 |
+
"""
|
| 612 |
+
Yields the action to navigate robot to the specified 2d pose
|
| 613 |
+
|
| 614 |
+
Args:
|
| 615 |
+
pose_2d (Iterable): (x, y, yaw) 2d pose
|
| 616 |
+
|
| 617 |
+
Returns:
|
| 618 |
+
th.tensor or None: Action array for one step for the robot to navigate or None if it is done navigating
|
| 619 |
+
"""
|
| 620 |
+
robot_pose = self._get_robot_pose_from_2d_pose(pose_2d)
|
| 621 |
+
self.robot.set_position_orientation(*robot_pose)
|
| 622 |
+
yield from self._settle_robot()
|
source_data/pinned/behavior-1k-bddl/v3.9.3-post2/OmniGibson/omnigibson/configs/avg_category_specs.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
source_data/pinned/behavior-1k-bddl/v3.9.3-post2/OmniGibson/omnigibson/configs/controllers/dd.yaml
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Example Differential Drive control config (shown for base control)
|
| 2 |
+
# See omnigibson/controllers/dd_controller for docstring of arguments
|
| 3 |
+
# Arguments below are the arguments that should be specified by external user (other kwargs
|
| 4 |
+
# used in constructor are generated automatically at runtime)
|
| 5 |
+
robot:
|
| 6 |
+
controller_config:
|
| 7 |
+
base:
|
| 8 |
+
name: DifferentialDriveController
|
| 9 |
+
command_input_limits: default
|
| 10 |
+
command_output_limits: default
|
source_data/pinned/behavior-1k-bddl/v3.9.3-post2/OmniGibson/omnigibson/configs/controllers/ik.yaml
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Example IK config (shown for arm control)
|
| 2 |
+
# See omnigibson/controllers/ik_controller for docstring of arguments
|
| 3 |
+
# Arguments below are the arguments that should be specified by external user (other kwargs
|
| 4 |
+
# used in constructor are generated automatically at runtime)
|
| 5 |
+
robot:
|
| 6 |
+
controller_config:
|
| 7 |
+
arm:
|
| 8 |
+
name: InverseKinematicsController
|
| 9 |
+
command_input_limits: default
|
| 10 |
+
command_output_limits:
|
| 11 |
+
- [-0.2, -0.2, -0.2, -0.5, -0.5, -0.5]
|
| 12 |
+
- [0.2, 0.2, 0.2, 0.5, 0.5, 0.5]
|
| 13 |
+
kv: 2.0
|
| 14 |
+
mode: pose_delta_ori
|
| 15 |
+
smoothing_filter_size: 2
|
| 16 |
+
workspace_pose_limiter: null
|
| 17 |
+
joint_range_tolerance: 0.01
|
source_data/pinned/behavior-1k-bddl/v3.9.3-post2/OmniGibson/omnigibson/configs/controllers/joint.yaml
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Example Joint control config (shown for arm control)
|
| 2 |
+
# See omnigibson/controllers/joint_controller for docstring of arguments
|
| 3 |
+
# Arguments below are the arguments that should be specified by external user (other kwargs
|
| 4 |
+
# used in constructor are generated automatically at runtime)
|
| 5 |
+
robot:
|
| 6 |
+
controller_config:
|
| 7 |
+
arm:
|
| 8 |
+
name: JointController
|
| 9 |
+
motor_type: velocity
|
| 10 |
+
command_input_limits: default
|
| 11 |
+
command_output_limits: default
|
| 12 |
+
use_delta_commands: false
|
source_data/pinned/behavior-1k-bddl/v3.9.3-post2/OmniGibson/omnigibson/configs/controllers/multi_finger_gripper.yaml
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Example Multi Finger Gripper control config (shown for arm control)
|
| 2 |
+
# See omnigibson/controllers/parallel_jaw_gripper_controller for docstring of arguments
|
| 3 |
+
# Arguments below are the arguments that should be specified by external user (other kwargs
|
| 4 |
+
# used in constructor are generated automatically at runtime)
|
| 5 |
+
robot:
|
| 6 |
+
controller_config:
|
| 7 |
+
arm:
|
| 8 |
+
name: MultiFingerGripperController
|
| 9 |
+
motor_type: position
|
| 10 |
+
command_input_limits: default
|
| 11 |
+
command_output_limits: default
|
| 12 |
+
mode: binary
|
| 13 |
+
open_qpos: null
|
| 14 |
+
closed_qpos: null
|
| 15 |
+
limit_tolerance: 0.01
|
source_data/pinned/behavior-1k-bddl/v3.9.3-post2/OmniGibson/omnigibson/configs/controllers/null_gripper.yaml
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Example Null Gripper control config (shown for gripper control)
|
| 2 |
+
# See omnigibson/controllers/null_gripper_controller for docstring of arguments
|
| 3 |
+
# Arguments below are the arguments that should be specified by external user (other kwargs
|
| 4 |
+
# used in constructor are generated automatically at runtime)
|
| 5 |
+
robot:
|
| 6 |
+
controller_config:
|
| 7 |
+
gripper:
|
| 8 |
+
name: NullJointController
|
| 9 |
+
# no other args to specify (this is a dummy controller)
|
source_data/pinned/behavior-1k-bddl/v3.9.3-post2/OmniGibson/omnigibson/configs/default_cfg.yaml
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
env:
|
| 2 |
+
device: null # (None or str): specifies the device to be used if running on the gpu with torch backend
|
| 3 |
+
|
| 4 |
+
render:
|
| 5 |
+
viewer_width: 1280
|
| 6 |
+
viewer_height: 720
|
| 7 |
+
|
| 8 |
+
scene:
|
| 9 |
+
type: Scene
|
| 10 |
+
|
| 11 |
+
robots: []
|
| 12 |
+
|
| 13 |
+
objects: []
|
| 14 |
+
|
| 15 |
+
task:
|
| 16 |
+
type: DummyTask
|
source_data/pinned/behavior-1k-bddl/v3.9.3-post2/OmniGibson/omnigibson/configs/franka_vector_env.yaml
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
env:
|
| 2 |
+
action_frequency: 30 # (int): environment executes action at the action_frequency rate
|
| 3 |
+
physics_frequency: 120 # (int): physics frequency (1 / physics_timestep for physx)
|
| 4 |
+
device: null # (None or str): specifies the device to be used if running on the gpu with torch backend
|
| 5 |
+
automatic_reset: false # (bool): whether to automatic reset after an episode finishes
|
| 6 |
+
flatten_action_space: false # (bool): whether to flatten the action space as a sinle 1D-array
|
| 7 |
+
flatten_obs_space: false # (bool): whether the observation space should be flattened when generated
|
| 8 |
+
use_external_obs: false # (bool): Whether to use external observations or not
|
| 9 |
+
initial_pos_z_offset: 0.1
|
| 10 |
+
external_sensors: null # (None or list): If specified, list of sensor configurations for external sensors to add. Should specify sensor "type" and any additional kwargs to instantiate the sensor. Each entry should be the kwargs passed to @create_sensor, in addition to position, orientation
|
| 11 |
+
|
| 12 |
+
render:
|
| 13 |
+
viewer_width: 1280
|
| 14 |
+
viewer_height: 720
|
| 15 |
+
|
| 16 |
+
scene:
|
| 17 |
+
type: InteractiveTraversableScene
|
| 18 |
+
scene_model: Rs_int
|
| 19 |
+
trav_map_resolution: 0.1
|
| 20 |
+
default_erosion_radius: 0.0
|
| 21 |
+
trav_map_with_objects: true
|
| 22 |
+
num_waypoints: 1
|
| 23 |
+
waypoint_resolution: 0.2
|
| 24 |
+
load_object_categories: null
|
| 25 |
+
not_load_object_categories: null
|
| 26 |
+
load_room_types: null
|
| 27 |
+
load_room_instances: null
|
| 28 |
+
load_task_relevant_only: false
|
| 29 |
+
seg_map_resolution: 1.0
|
| 30 |
+
scene_source: OG
|
| 31 |
+
include_robots: false
|
| 32 |
+
|
| 33 |
+
robots:
|
| 34 |
+
- type: Franka
|
| 35 |
+
obs_modalities: [rgb]
|
| 36 |
+
include_sensor_names: null
|
| 37 |
+
exclude_sensor_names: null
|
| 38 |
+
scale: 1.0
|
| 39 |
+
self_collisions: true
|
| 40 |
+
action_normalize: false
|
| 41 |
+
action_type: continuous
|
| 42 |
+
grasping_mode: physical
|
| 43 |
+
sensor_config:
|
| 44 |
+
VisionSensor:
|
| 45 |
+
sensor_kwargs:
|
| 46 |
+
image_height: 128
|
| 47 |
+
image_width: 128
|
| 48 |
+
controller_config:
|
| 49 |
+
arm_0:
|
| 50 |
+
name: JointController
|
| 51 |
+
motor_type: position
|
| 52 |
+
command_input_limits: default
|
| 53 |
+
command_output_limits: default
|
| 54 |
+
use_delta_commands: false
|
| 55 |
+
use_impedances: False
|
| 56 |
+
gripper_0:
|
| 57 |
+
name: MultiFingerGripperController
|
| 58 |
+
mode: smooth
|
| 59 |
+
command_input_limits: default
|
| 60 |
+
command_output_limits: default
|
| 61 |
+
objects: []
|
| 62 |
+
|
| 63 |
+
task:
|
| 64 |
+
type: DummyTask
|
source_data/pinned/behavior-1k-bddl/v3.9.3-post2/OmniGibson/omnigibson/configs/r1_primitives.yaml
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
env:
|
| 2 |
+
action_frequency: 30 # (int): environment executes action at the action_frequency rate
|
| 3 |
+
physics_frequency: 120 # (int): physics frequency (1 / physics_timestep for physx)
|
| 4 |
+
device: null # (None or str): specifies the device to be used if running on the gpu with torch backend
|
| 5 |
+
automatic_reset: false # (bool): whether to automatic reset after an episode finishes
|
| 6 |
+
flatten_action_space: false # (bool): whether to flatten the action space as a sinle 1D-array
|
| 7 |
+
flatten_obs_space: false # (bool): whether the observation space should be flattened when generated
|
| 8 |
+
use_external_obs: false # (bool): Whether to use external observations or not
|
| 9 |
+
external_sensors: null # (None or list): If specified, list of sensor configurations for external sensors to add. Should specify sensor "type" and any additional kwargs to instantiate the sensor. Each entry should be the kwargs passed to @create_sensor, in addition to position, orientation
|
| 10 |
+
|
| 11 |
+
render:
|
| 12 |
+
viewer_width: 1280
|
| 13 |
+
viewer_height: 720
|
| 14 |
+
|
| 15 |
+
scene:
|
| 16 |
+
type: InteractiveTraversableScene
|
| 17 |
+
scene_model: Rs_int
|
| 18 |
+
trav_map_resolution: 0.1
|
| 19 |
+
default_erosion_radius: 0.0
|
| 20 |
+
trav_map_with_objects: true
|
| 21 |
+
num_waypoints: 1
|
| 22 |
+
waypoint_resolution: 0.2
|
| 23 |
+
load_object_categories: null
|
| 24 |
+
not_load_object_categories: null
|
| 25 |
+
load_room_types: null
|
| 26 |
+
load_room_instances: null
|
| 27 |
+
load_task_relevant_only: false
|
| 28 |
+
seg_map_resolution: 1.0
|
| 29 |
+
scene_source: OG
|
| 30 |
+
include_robots: false
|
| 31 |
+
|
| 32 |
+
robots:
|
| 33 |
+
- type: R1
|
| 34 |
+
obs_modalities: [rgb]
|
| 35 |
+
include_sensor_names: null
|
| 36 |
+
exclude_sensor_names: null
|
| 37 |
+
scale: 1.0
|
| 38 |
+
self_collisions: true
|
| 39 |
+
action_normalize: false
|
| 40 |
+
action_type: continuous
|
| 41 |
+
grasping_mode: sticky
|
| 42 |
+
reset_joint_pos: [
|
| 43 |
+
0.0000,
|
| 44 |
+
-0.0000,
|
| 45 |
+
0.0247,
|
| 46 |
+
0.0009,
|
| 47 |
+
0.0004,
|
| 48 |
+
-0.0000,
|
| 49 |
+
0.0000,
|
| 50 |
+
0.0000,
|
| 51 |
+
0.0000,
|
| 52 |
+
0.0000,
|
| 53 |
+
-0.0464,
|
| 54 |
+
0.0464,
|
| 55 |
+
2.6172,
|
| 56 |
+
2.6168,
|
| 57 |
+
-1.4584,
|
| 58 |
+
-1.4570,
|
| 59 |
+
-0.0433,
|
| 60 |
+
0.0418,
|
| 61 |
+
1.5899,
|
| 62 |
+
-1.5896,
|
| 63 |
+
-1.1587,
|
| 64 |
+
1.1593,
|
| 65 |
+
0.0300,
|
| 66 |
+
0.0300,
|
| 67 |
+
0.0300,
|
| 68 |
+
0.0300,
|
| 69 |
+
]
|
| 70 |
+
sensor_config:
|
| 71 |
+
VisionSensor:
|
| 72 |
+
sensor_kwargs:
|
| 73 |
+
image_height: 128
|
| 74 |
+
image_width: 128
|
| 75 |
+
controller_config:
|
| 76 |
+
base:
|
| 77 |
+
name: HolonomicBaseJointController
|
| 78 |
+
motor_type: position
|
| 79 |
+
command_input_limits: null
|
| 80 |
+
use_impedances: false
|
| 81 |
+
trunk:
|
| 82 |
+
name: JointController
|
| 83 |
+
motor_type: position
|
| 84 |
+
command_input_limits: null
|
| 85 |
+
use_delta_commands: false
|
| 86 |
+
use_impedances: false
|
| 87 |
+
arm_left:
|
| 88 |
+
name: JointController
|
| 89 |
+
motor_type: position
|
| 90 |
+
command_input_limits: null
|
| 91 |
+
use_delta_commands: false
|
| 92 |
+
use_impedances: false
|
| 93 |
+
arm_right:
|
| 94 |
+
name: JointController
|
| 95 |
+
motor_type: position
|
| 96 |
+
command_input_limits: null
|
| 97 |
+
use_delta_commands: false
|
| 98 |
+
use_impedances: false
|
| 99 |
+
gripper_left:
|
| 100 |
+
name: JointController
|
| 101 |
+
motor_type: position
|
| 102 |
+
command_input_limits: null
|
| 103 |
+
use_delta_commands: false
|
| 104 |
+
use_impedances: false
|
| 105 |
+
gripper_right:
|
| 106 |
+
name: JointController
|
| 107 |
+
motor_type: position
|
| 108 |
+
command_input_limits: null
|
| 109 |
+
use_delta_commands: false
|
| 110 |
+
use_impedances: false
|
| 111 |
+
|
| 112 |
+
objects: []
|
| 113 |
+
task:
|
| 114 |
+
type: DummyTask
|
source_data/pinned/behavior-1k-bddl/v3.9.3-post2/OmniGibson/omnigibson/configs/r1pro_behavior.yaml
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
env:
|
| 2 |
+
device: null # (None or str): specifies the device to be used if running on the gpu with torch backend
|
| 3 |
+
automatic_reset: false # (bool): whether to automatic reset after an episode finishes
|
| 4 |
+
flatten_action_space: false # (bool): whether to flatten the action space as a sinle 1D-array
|
| 5 |
+
flatten_obs_space: false # (bool): whether the observation space should be flattened when generated
|
| 6 |
+
use_external_obs: false # (bool): Whether to use external observations or not
|
| 7 |
+
initial_pos_z_offset: 0.1
|
| 8 |
+
external_sensors: # (None or list): If specified, list of sensor configurations for external sensors to add. Should specify sensor "type" and any additional kwargs to instantiate the sensor. Each entry should be the kwargs passed to @create_sensor, in addition to position, orientation
|
| 9 |
+
- sensor_type: VisionSensor
|
| 10 |
+
name: external_sensor0
|
| 11 |
+
relative_prim_path: /external_sensor0
|
| 12 |
+
modalities: [rgb, depth]
|
| 13 |
+
sensor_kwargs:
|
| 14 |
+
image_height: 128
|
| 15 |
+
image_width: 128
|
| 16 |
+
position: [0, 0, 1.0]
|
| 17 |
+
orientation: [0.707, 0.0, 0.0, 0.707]
|
| 18 |
+
pose_frame: parent
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
render:
|
| 22 |
+
viewer_width: 1280
|
| 23 |
+
viewer_height: 720
|
| 24 |
+
|
| 25 |
+
scene:
|
| 26 |
+
type: InteractiveTraversableScene
|
| 27 |
+
scene_model: house_double_floor_lower
|
| 28 |
+
trav_map_resolution: 0.1
|
| 29 |
+
default_erosion_radius: 0.0
|
| 30 |
+
trav_map_with_objects: true
|
| 31 |
+
num_waypoints: 1
|
| 32 |
+
waypoint_resolution: 0.2
|
| 33 |
+
not_load_object_categories: null
|
| 34 |
+
load_room_types: ["living_room", "kitchen"]
|
| 35 |
+
load_room_instances: null
|
| 36 |
+
seg_map_resolution: 1.0
|
| 37 |
+
scene_source: OG
|
| 38 |
+
include_robots: true
|
| 39 |
+
|
| 40 |
+
robots:
|
| 41 |
+
- type: R1Pro
|
| 42 |
+
obs_modalities: [rgb, depth]
|
| 43 |
+
include_sensor_names: null
|
| 44 |
+
exclude_sensor_names: null
|
| 45 |
+
scale: 1.0
|
| 46 |
+
self_collision: false
|
| 47 |
+
action_normalize: true
|
| 48 |
+
action_type: continuous
|
| 49 |
+
grasping_mode: physical
|
| 50 |
+
default_reset_mode: tuck
|
| 51 |
+
sensor_config:
|
| 52 |
+
VisionSensor:
|
| 53 |
+
sensor_kwargs:
|
| 54 |
+
image_height: 128
|
| 55 |
+
image_width: 128
|
| 56 |
+
controller_config:
|
| 57 |
+
base:
|
| 58 |
+
name: HolonomicBaseJointController
|
| 59 |
+
motor_type: velocity
|
| 60 |
+
vel_kp: 150
|
| 61 |
+
command_input_limits: default
|
| 62 |
+
command_output_limits: default
|
| 63 |
+
use_impedances: false
|
| 64 |
+
trunk:
|
| 65 |
+
name: JointController
|
| 66 |
+
motor_type: position
|
| 67 |
+
pos_kp: 150
|
| 68 |
+
command_input_limits: default
|
| 69 |
+
command_output_limits: default
|
| 70 |
+
use_impedances: false
|
| 71 |
+
use_delta_commands: false
|
| 72 |
+
arm_left:
|
| 73 |
+
name: JointController
|
| 74 |
+
motor_type: position
|
| 75 |
+
pos_kp: 150
|
| 76 |
+
command_input_limits: default
|
| 77 |
+
command_output_limits: default
|
| 78 |
+
use_impedances: false
|
| 79 |
+
use_delta_commands: false
|
| 80 |
+
arm_right:
|
| 81 |
+
name: JointController
|
| 82 |
+
motor_type: position
|
| 83 |
+
pos_kp: 150
|
| 84 |
+
command_input_limits: default
|
| 85 |
+
command_output_limits: default
|
| 86 |
+
use_impedances: false
|
| 87 |
+
use_delta_commands: false
|
| 88 |
+
gripper_left:
|
| 89 |
+
name: MultiFingerGripperController
|
| 90 |
+
mode: smooth
|
| 91 |
+
command_input_limits: default
|
| 92 |
+
command_output_limits: default
|
| 93 |
+
gripper_right:
|
| 94 |
+
name: MultiFingerGripperController
|
| 95 |
+
mode: smooth
|
| 96 |
+
command_input_limits: default
|
| 97 |
+
command_output_limits: default
|
| 98 |
+
|
| 99 |
+
objects: []
|
| 100 |
+
|
| 101 |
+
task:
|
| 102 |
+
type: BehaviorTask
|
| 103 |
+
activity_name: picking_up_trash
|
| 104 |
+
activity_definition_id: 0
|
| 105 |
+
activity_instance_id: 0
|
| 106 |
+
predefined_problem: null
|
| 107 |
+
online_object_sampling: false
|
| 108 |
+
debug_object_sampling: null
|
| 109 |
+
highlight_task_relevant_objects: false
|
| 110 |
+
use_presampled_robot_pose: true
|
| 111 |
+
termination_config:
|
| 112 |
+
max_steps: 500
|
| 113 |
+
reward_config:
|
| 114 |
+
r_potential: 1.0
|
source_data/pinned/behavior-1k-bddl/v3.9.3-post2/OmniGibson/omnigibson/configs/r1pro_primitives.yaml
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
env:
|
| 2 |
+
action_frequency: 30 # (int): environment executes action at the action_frequency rate
|
| 3 |
+
physics_frequency: 120 # (int): physics frequency (1 / physics_timestep for physx)
|
| 4 |
+
device: null # (None or str): specifies the device to be used if running on the gpu with torch backend
|
| 5 |
+
automatic_reset: false # (bool): whether to automatic reset after an episode finishes
|
| 6 |
+
flatten_action_space: false # (bool): whether to flatten the action space as a sinle 1D-array
|
| 7 |
+
flatten_obs_space: false # (bool): whether the observation space should be flattened when generated
|
| 8 |
+
use_external_obs: false # (bool): Whether to use external observations or not
|
| 9 |
+
external_sensors: null # (None or list): If specified, list of sensor configurations for external sensors to add. Should specify sensor "type" and any additional kwargs to instantiate the sensor. Each entry should be the kwargs passed to @create_sensor, in addition to position, orientation
|
| 10 |
+
|
| 11 |
+
render:
|
| 12 |
+
viewer_width: 1280
|
| 13 |
+
viewer_height: 720
|
| 14 |
+
|
| 15 |
+
scene:
|
| 16 |
+
type: InteractiveTraversableScene
|
| 17 |
+
scene_model: Rs_int
|
| 18 |
+
trav_map_resolution: 0.1
|
| 19 |
+
default_erosion_radius: 0.0
|
| 20 |
+
trav_map_with_objects: true
|
| 21 |
+
num_waypoints: 1
|
| 22 |
+
waypoint_resolution: 0.2
|
| 23 |
+
load_object_categories: null
|
| 24 |
+
not_load_object_categories: null
|
| 25 |
+
load_room_types: ["living_room"]
|
| 26 |
+
load_room_instances: null
|
| 27 |
+
load_task_relevant_only: false
|
| 28 |
+
seg_map_resolution: 1.0
|
| 29 |
+
scene_source: OG
|
| 30 |
+
include_robots: false
|
| 31 |
+
|
| 32 |
+
robots:
|
| 33 |
+
- type: R1Pro
|
| 34 |
+
obs_modalities: [rgb]
|
| 35 |
+
include_sensor_names: null
|
| 36 |
+
exclude_sensor_names: null
|
| 37 |
+
scale: 1.0
|
| 38 |
+
self_collisions: true
|
| 39 |
+
action_normalize: false
|
| 40 |
+
action_type: continuous
|
| 41 |
+
grasping_mode: sticky
|
| 42 |
+
reset_joint_pos: [
|
| 43 |
+
0.0000,
|
| 44 |
+
-0.0000,
|
| 45 |
+
0.0247,
|
| 46 |
+
0.0009,
|
| 47 |
+
0.0004,
|
| 48 |
+
-0.0000,
|
| 49 |
+
0.0000,
|
| 50 |
+
0.0000,
|
| 51 |
+
0.0000,
|
| 52 |
+
0.0000,
|
| 53 |
+
0.0,
|
| 54 |
+
0.0,
|
| 55 |
+
0.0,
|
| 56 |
+
0.0,
|
| 57 |
+
0.0,
|
| 58 |
+
0.0,
|
| 59 |
+
0.0,
|
| 60 |
+
0.0,
|
| 61 |
+
0.0,
|
| 62 |
+
0.0,
|
| 63 |
+
0.0,
|
| 64 |
+
0.0,
|
| 65 |
+
0.0,
|
| 66 |
+
0.0,
|
| 67 |
+
0.0300,
|
| 68 |
+
0.0300,
|
| 69 |
+
0.0300,
|
| 70 |
+
0.0300,
|
| 71 |
+
]
|
| 72 |
+
sensor_config:
|
| 73 |
+
VisionSensor:
|
| 74 |
+
sensor_kwargs:
|
| 75 |
+
image_height: 128
|
| 76 |
+
image_width: 128
|
| 77 |
+
controller_config:
|
| 78 |
+
base:
|
| 79 |
+
name: HolonomicBaseJointController
|
| 80 |
+
motor_type: position
|
| 81 |
+
command_input_limits: null
|
| 82 |
+
use_impedances: false
|
| 83 |
+
trunk:
|
| 84 |
+
name: JointController
|
| 85 |
+
motor_type: position
|
| 86 |
+
command_input_limits: null
|
| 87 |
+
use_delta_commands: false
|
| 88 |
+
use_impedances: false
|
| 89 |
+
arm_left:
|
| 90 |
+
name: JointController
|
| 91 |
+
motor_type: position
|
| 92 |
+
command_input_limits: null
|
| 93 |
+
use_delta_commands: false
|
| 94 |
+
use_impedances: false
|
| 95 |
+
arm_right:
|
| 96 |
+
name: JointController
|
| 97 |
+
motor_type: position
|
| 98 |
+
command_input_limits: null
|
| 99 |
+
use_delta_commands: false
|
| 100 |
+
use_impedances: false
|
| 101 |
+
gripper_left:
|
| 102 |
+
name: JointController
|
| 103 |
+
motor_type: position
|
| 104 |
+
command_input_limits: null
|
| 105 |
+
use_delta_commands: false
|
| 106 |
+
use_impedances: false
|
| 107 |
+
gripper_right:
|
| 108 |
+
name: JointController
|
| 109 |
+
motor_type: position
|
| 110 |
+
command_input_limits: null
|
| 111 |
+
use_delta_commands: false
|
| 112 |
+
use_impedances: false
|
| 113 |
+
|
| 114 |
+
objects: []
|
| 115 |
+
|
| 116 |
+
task:
|
| 117 |
+
type: DummyTask
|
source_data/pinned/behavior-1k-bddl/v3.9.3-post2/OmniGibson/omnigibson/configs/robots/fetch.yaml
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Example Fetch config
|
| 2 |
+
robot:
|
| 3 |
+
name: Fetch
|
| 4 |
+
action_type: continuous
|
| 5 |
+
action_normalize: true
|
| 6 |
+
proprio_obs:
|
| 7 |
+
- eef_0_pos
|
| 8 |
+
- eef_0_quat
|
| 9 |
+
- trunk_qpos
|
| 10 |
+
- arm_0_qpos_sin
|
| 11 |
+
- arm_0_qpos_cos
|
| 12 |
+
- gripper_0_qpos
|
| 13 |
+
- grasp_main
|
| 14 |
+
reset_joint_pos: null
|
| 15 |
+
base_name: null
|
| 16 |
+
scale: 1.0
|
| 17 |
+
self_collision: true
|
| 18 |
+
grasping_mode: physical
|
| 19 |
+
default_arm_pose: vertical
|
| 20 |
+
include_sensor_names: null
|
| 21 |
+
exclude_sensor_names: null
|
| 22 |
+
sensor_config:
|
| 23 |
+
VisionSensor:
|
| 24 |
+
sensor_kwargs:
|
| 25 |
+
image_height: 128
|
| 26 |
+
image_width: 128
|
| 27 |
+
ScanSensor:
|
| 28 |
+
sensor_kwargs:
|
| 29 |
+
min_range: 0.05
|
| 30 |
+
max_range: 10.0
|
| 31 |
+
controller_config:
|
| 32 |
+
base:
|
| 33 |
+
name: DifferentialDriveController
|
| 34 |
+
trunk:
|
| 35 |
+
name: JointController
|
| 36 |
+
arm_0:
|
| 37 |
+
name: InverseKinematicsController
|
| 38 |
+
subsume_controllers: [trunk]
|
| 39 |
+
gripper_0:
|
| 40 |
+
name: MultiFingerGripperController
|
| 41 |
+
camera:
|
| 42 |
+
name: JointController
|
source_data/pinned/behavior-1k-bddl/v3.9.3-post2/OmniGibson/omnigibson/configs/robots/freight.yaml
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Example Freight config
|
| 2 |
+
robot:
|
| 3 |
+
name: Freight
|
| 4 |
+
action_type: continuous
|
| 5 |
+
action_normalize: true
|
| 6 |
+
proprio_obs:
|
| 7 |
+
- dd_base_lin_vel
|
| 8 |
+
- dd_base_ang_vel
|
| 9 |
+
reset_joint_pos: null
|
| 10 |
+
base_name: null
|
| 11 |
+
scale: 1.0
|
| 12 |
+
self_collision: false
|
| 13 |
+
include_sensor_names: null
|
| 14 |
+
exclude_sensor_names: null
|
| 15 |
+
sensor_config:
|
| 16 |
+
VisionSensor:
|
| 17 |
+
sensor_kwargs:
|
| 18 |
+
image_height: 128
|
| 19 |
+
image_width: 128
|
| 20 |
+
ScanSensor:
|
| 21 |
+
sensor_kwargs:
|
| 22 |
+
min_range: 0.05
|
| 23 |
+
max_range: 10.0
|
| 24 |
+
controller_config:
|
| 25 |
+
base:
|
| 26 |
+
name: DifferentialDriveController
|
source_data/pinned/behavior-1k-bddl/v3.9.3-post2/OmniGibson/omnigibson/configs/robots/husky.yaml
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Example Husky config
|
| 2 |
+
robot:
|
| 3 |
+
name: Husky
|
| 4 |
+
action_type: continuous
|
| 5 |
+
action_normalize: true
|
| 6 |
+
proprio_obs:
|
| 7 |
+
- joint_qpos
|
| 8 |
+
- joint_qvel
|
| 9 |
+
reset_joint_pos: null
|
| 10 |
+
base_name: null
|
| 11 |
+
scale: 1.0
|
| 12 |
+
self_collision: false
|
| 13 |
+
include_sensor_names: null
|
| 14 |
+
exclude_sensor_names: null
|
| 15 |
+
sensor_config:
|
| 16 |
+
VisionSensor:
|
| 17 |
+
sensor_kwargs:
|
| 18 |
+
image_height: 128
|
| 19 |
+
image_width: 128
|
| 20 |
+
ScanSensor:
|
| 21 |
+
sensor_kwargs:
|
| 22 |
+
min_range: 0.05
|
| 23 |
+
max_range: 10.0
|
| 24 |
+
controller_config:
|
| 25 |
+
base:
|
| 26 |
+
name: JointController
|
source_data/pinned/behavior-1k-bddl/v3.9.3-post2/OmniGibson/omnigibson/configs/robots/locobot.yaml
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Example Locobot config
|
| 2 |
+
robot:
|
| 3 |
+
name: Locobot
|
| 4 |
+
action_type: continuous
|
| 5 |
+
action_normalize: true
|
| 6 |
+
proprio_obs:
|
| 7 |
+
- dd_base_lin_vel
|
| 8 |
+
- dd_base_ang_vel
|
| 9 |
+
reset_joint_pos: null
|
| 10 |
+
base_name: null
|
| 11 |
+
scale: 1.0
|
| 12 |
+
self_collision: false
|
| 13 |
+
include_sensor_names: null
|
| 14 |
+
exclude_sensor_names: null
|
| 15 |
+
sensor_config:
|
| 16 |
+
VisionSensor:
|
| 17 |
+
sensor_kwargs:
|
| 18 |
+
image_height: 128
|
| 19 |
+
image_width: 128
|
| 20 |
+
ScanSensor:
|
| 21 |
+
sensor_kwargs:
|
| 22 |
+
min_range: 0.05
|
| 23 |
+
max_range: 10.0
|
| 24 |
+
controller_config:
|
| 25 |
+
base:
|
| 26 |
+
name: DifferentialDriveController
|
source_data/pinned/behavior-1k-bddl/v3.9.3-post2/OmniGibson/omnigibson/configs/robots/turtlebot.yaml
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Example Turtlebot config
|
| 2 |
+
robot:
|
| 3 |
+
name: Turtlebot
|
| 4 |
+
action_type: continuous
|
| 5 |
+
action_normalize: true
|
| 6 |
+
proprio_obs:
|
| 7 |
+
- dd_base_lin_vel
|
| 8 |
+
- dd_base_ang_vel
|
| 9 |
+
reset_joint_pos: null
|
| 10 |
+
base_name: null
|
| 11 |
+
scale: 1.0
|
| 12 |
+
self_collision: false
|
| 13 |
+
include_sensor_names: null
|
| 14 |
+
exclude_sensor_names: null
|
| 15 |
+
sensor_config:
|
| 16 |
+
VisionSensor:
|
| 17 |
+
sensor_kwargs:
|
| 18 |
+
image_height: 128
|
| 19 |
+
image_width: 128
|
| 20 |
+
ScanSensor:
|
| 21 |
+
sensor_kwargs:
|
| 22 |
+
min_range: 0.05
|
| 23 |
+
max_range: 10.0
|
| 24 |
+
controller_config:
|
| 25 |
+
base:
|
| 26 |
+
name: DifferentialDriveController
|
source_data/pinned/behavior-1k-bddl/v3.9.3-post2/OmniGibson/omnigibson/configs/sensors/scan.yaml
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Example ScanSensor sensor config
|
| 2 |
+
# See omnigibson/sensors/__init__/create_sensor and omnigibson/sensors/scan_sensor for docstring of arguments
|
| 3 |
+
# Arguments below are the arguments that should be specified by external user (other kwargs
|
| 4 |
+
# used in constructor are generated automatically at runtime)
|
| 5 |
+
robot:
|
| 6 |
+
sensor_config:
|
| 7 |
+
ScanSensor:
|
| 8 |
+
modalities: [scan, occupancy_grid] # if specified, this will override the values in robots_config["obs_modalities"]
|
| 9 |
+
enabled: true
|
| 10 |
+
noise_type: null
|
| 11 |
+
noise_kwargs: null
|
| 12 |
+
sensor_kwargs:
|
| 13 |
+
|
| 14 |
+
# Basic LIDAR kwargs
|
| 15 |
+
min_range: 0.05
|
| 16 |
+
max_range: 10.0
|
| 17 |
+
horizontal_fov: 360.0
|
| 18 |
+
vertical_fov: 1.0
|
| 19 |
+
yaw_offset: 0.0
|
| 20 |
+
horizontal_resolution: 1.0
|
| 21 |
+
vertical_resolution: 1.0
|
| 22 |
+
rotation_rate: 0.0
|
| 23 |
+
draw_points: false
|
| 24 |
+
draw_lines: false
|
| 25 |
+
|
| 26 |
+
# Occupancy Grid kwargs
|
| 27 |
+
occupancy_grid_resolution: 128
|
| 28 |
+
occupancy_grid_range: 5.0
|
| 29 |
+
occupancy_grid_inner_radius: 0.5
|
| 30 |
+
occupancy_grid_local_link: null
|