liujinxin commited on
Commit ·
e458a7b
1
Parent(s): c6fc539
sync
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- .gitattributes +3 -6
- .gitignore +279 -21
- .gitmodules +2 -5
- .vscode/settings.json +5 -0
- README.md +3 -146
- __todo__/.gitattributes +6 -0
- __todo__/{.gitignore → __todo_assets__/.gitignore} +0 -0
- {__todo_assets__ → __todo__/__todo_assets__}/README.md +0 -0
- {__todo_assets__ → __todo__/__todo_assets__}/pyproject.toml +0 -0
- {__todo_assets__ → __todo__/__todo_assets_robots__}/.gitignore +0 -0
- __todo__/{README.md → __todo_assets_robots__/README.md} +0 -0
- {__todo_assets_robots__ → __todo__/__todo_assets_robots__}/pyproject.toml +0 -0
- __todo__/_nn_legacy/flex_attention.py +143 -0
- __todo__/_nn_legacy/paligemma_with_expert.py +428 -0
- __todo__/_nn_legacy/pi0_flow_matching.py +423 -0
- demo-maniskill-motionplanning.ipynb → __todo__/demo-maniskill-motionplanning.ipynb +0 -0
- __todo__/packages/robotodo.egg-info/PKG-INFO +0 -4
- __todo__/packages/robotodo.egg-info/SOURCES.txt +0 -14
- __todo__/packages/robotodo.egg-info/dependency_links.txt +0 -1
- __todo__/packages/robotodo.egg-info/requires.txt +0 -1
- __todo__/packages/robotodo.egg-info/top_level.txt +0 -2
- __todo__/packages/robotodo/__init__.py +0 -0
- __todo__/packages/robotodo/todos/_legacy.py +0 -352
- __todo__/packages/robotodo/todos/scene.py +0 -434
- __todo__/packages/robotodo/utils/asset.py +0 -88
- __todo__/packages/robotodo_assets/robotwin_objects/__init__.py +0 -76
- __todo__/packages/robotodo_assets/robotwin_objects/resources/assets/001_bottle-0/metadata.json +0 -1
- __todo__/packages/robotodo_assets/robotwin_objects/resources/assets/001_bottle-0/model.urdf +0 -2
- __todo__/packages/robotodo_assets/robotwin_objects/resources/assets/001_bottle-1/metadata.json +0 -1
- __todo__/packages/robotodo_assets/robotwin_objects/resources/assets/001_bottle-1/model.urdf +0 -2
- __todo__/packages/robotodo_assets/robotwin_objects/resources/assets/001_bottle-10/metadata.json +0 -1
- __todo__/packages/robotodo_assets/robotwin_objects/resources/assets/001_bottle-10/model.urdf +0 -2
- __todo__/packages/robotodo_assets/robotwin_objects/resources/assets/001_bottle-11/metadata.json +0 -1
- __todo__/packages/robotodo_assets/robotwin_objects/resources/assets/001_bottle-11/model.urdf +0 -2
- __todo__/packages/robotodo_assets/robotwin_objects/resources/assets/001_bottle-12/metadata.json +0 -1
- __todo__/packages/robotodo_assets/robotwin_objects/resources/assets/001_bottle-12/model.urdf +0 -2
- __todo__/packages/robotodo_assets/robotwin_objects/resources/assets/001_bottle-13/metadata.json +0 -1
- __todo__/packages/robotodo_assets/robotwin_objects/resources/assets/001_bottle-13/model.urdf +0 -2
- __todo__/packages/robotodo_assets/robotwin_objects/resources/assets/001_bottle-14/metadata.json +0 -1
- __todo__/packages/robotodo_assets/robotwin_objects/resources/assets/001_bottle-14/model.urdf +0 -2
- __todo__/packages/robotodo_assets/robotwin_objects/resources/assets/001_bottle-15/metadata.json +0 -1
- __todo__/packages/robotodo_assets/robotwin_objects/resources/assets/001_bottle-15/model.urdf +0 -2
- __todo__/packages/robotodo_assets/robotwin_objects/resources/assets/001_bottle-16/metadata.json +0 -1
- __todo__/packages/robotodo_assets/robotwin_objects/resources/assets/001_bottle-16/model.urdf +0 -2
- __todo__/packages/robotodo_assets/robotwin_objects/resources/assets/001_bottle-17/metadata.json +0 -1
- __todo__/packages/robotodo_assets/robotwin_objects/resources/assets/001_bottle-17/model.urdf +0 -2
- __todo__/packages/robotodo_assets/robotwin_objects/resources/assets/001_bottle-18/metadata.json +0 -1
- __todo__/packages/robotodo_assets/robotwin_objects/resources/assets/001_bottle-18/model.urdf +0 -2
- __todo__/packages/robotodo_assets/robotwin_objects/resources/assets/001_bottle-19/metadata.json +0 -1
- __todo__/packages/robotodo_assets/robotwin_objects/resources/assets/001_bottle-19/model.urdf +0 -2
.gitattributes
CHANGED
|
@@ -1,6 +1,3 @@
|
|
| 1 |
-
|
| 2 |
-
*
|
| 3 |
-
*
|
| 4 |
-
*.png filter=lfs diff=lfs merge=lfs -text
|
| 5 |
-
*.mtl filter=lfs diff=lfs merge=lfs -text
|
| 6 |
-
*.obj filter=lfs diff=lfs merge=lfs -text
|
|
|
|
| 1 |
+
# TODO mv to subpackages!!!!
|
| 2 |
+
packages/robotodo/actors/robotwin_materials/resources/** filter=lfs diff=lfs merge=lfs -text
|
| 3 |
+
packages/robotodo/actors/robotwin_objects/resources/** filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
.gitignore
CHANGED
|
@@ -1,28 +1,286 @@
|
|
| 1 |
-
|
| 2 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
__pycache__/
|
| 4 |
-
*
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
|
| 12 |
-
#
|
| 13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
|
| 15 |
-
#
|
| 16 |
-
|
| 17 |
-
!assets/_download.py
|
| 18 |
-
!assets/files
|
| 19 |
|
| 20 |
-
policy/weights/*
|
| 21 |
|
| 22 |
-
|
|
|
|
| 23 |
|
| 24 |
-
|
| 25 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
|
| 27 |
-
|
| 28 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Windows thumbnail cache files
|
| 2 |
+
Thumbs.db
|
| 3 |
+
Thumbs.db:encryptable
|
| 4 |
+
ehthumbs.db
|
| 5 |
+
ehthumbs_vista.db
|
| 6 |
+
|
| 7 |
+
# Dump file
|
| 8 |
+
*.stackdump
|
| 9 |
+
|
| 10 |
+
# Folder config file
|
| 11 |
+
[Dd]esktop.ini
|
| 12 |
+
|
| 13 |
+
# Recycle Bin used on file shares
|
| 14 |
+
$RECYCLE.BIN/
|
| 15 |
+
|
| 16 |
+
# Windows Installer files
|
| 17 |
+
*.cab
|
| 18 |
+
*.msi
|
| 19 |
+
*.msix
|
| 20 |
+
*.msm
|
| 21 |
+
*.msp
|
| 22 |
+
|
| 23 |
+
# Windows shortcuts
|
| 24 |
+
*.lnk
|
| 25 |
+
.vscode/*
|
| 26 |
+
!.vscode/settings.json
|
| 27 |
+
!.vscode/tasks.json
|
| 28 |
+
!.vscode/launch.json
|
| 29 |
+
!.vscode/extensions.json
|
| 30 |
+
!.vscode/*.code-snippets
|
| 31 |
+
|
| 32 |
+
# Local History for Visual Studio Code
|
| 33 |
+
.history/
|
| 34 |
+
|
| 35 |
+
# Built Visual Studio Code Extensions
|
| 36 |
+
*.vsix
|
| 37 |
+
# Byte-compiled / optimized / DLL files
|
| 38 |
__pycache__/
|
| 39 |
+
*.py[cod]
|
| 40 |
+
*$py.class
|
| 41 |
+
|
| 42 |
+
# C extensions
|
| 43 |
+
*.so
|
| 44 |
+
|
| 45 |
+
# Distribution / packaging
|
| 46 |
+
.Python
|
| 47 |
+
build/
|
| 48 |
+
develop-eggs/
|
| 49 |
+
dist/
|
| 50 |
+
downloads/
|
| 51 |
+
eggs/
|
| 52 |
+
.eggs/
|
| 53 |
+
lib/
|
| 54 |
+
lib64/
|
| 55 |
+
parts/
|
| 56 |
+
sdist/
|
| 57 |
+
var/
|
| 58 |
+
wheels/
|
| 59 |
+
share/python-wheels/
|
| 60 |
+
*.egg-info/
|
| 61 |
+
.installed.cfg
|
| 62 |
+
*.egg
|
| 63 |
+
MANIFEST
|
| 64 |
+
|
| 65 |
+
# PyInstaller
|
| 66 |
+
# Usually these files are written by a python script from a template
|
| 67 |
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
| 68 |
+
*.manifest
|
| 69 |
+
*.spec
|
| 70 |
+
|
| 71 |
+
# Installer logs
|
| 72 |
+
pip-log.txt
|
| 73 |
+
pip-delete-this-directory.txt
|
| 74 |
+
|
| 75 |
+
# Unit test / coverage reports
|
| 76 |
+
htmlcov/
|
| 77 |
+
.tox/
|
| 78 |
+
.nox/
|
| 79 |
+
.coverage
|
| 80 |
+
.coverage.*
|
| 81 |
+
.cache
|
| 82 |
+
nosetests.xml
|
| 83 |
+
coverage.xml
|
| 84 |
+
*.cover
|
| 85 |
+
*.py,cover
|
| 86 |
+
.hypothesis/
|
| 87 |
+
.pytest_cache/
|
| 88 |
+
cover/
|
| 89 |
+
|
| 90 |
+
# Translations
|
| 91 |
+
*.mo
|
| 92 |
+
*.pot
|
| 93 |
+
|
| 94 |
+
# Django stuff:
|
| 95 |
+
*.log
|
| 96 |
+
local_settings.py
|
| 97 |
+
db.sqlite3
|
| 98 |
+
db.sqlite3-journal
|
| 99 |
+
|
| 100 |
+
# Flask stuff:
|
| 101 |
+
instance/
|
| 102 |
+
.webassets-cache
|
| 103 |
+
|
| 104 |
+
# Scrapy stuff:
|
| 105 |
+
.scrapy
|
| 106 |
+
|
| 107 |
+
# Sphinx documentation
|
| 108 |
+
docs/_build/
|
| 109 |
+
|
| 110 |
+
# PyBuilder
|
| 111 |
+
.pybuilder/
|
| 112 |
+
target/
|
| 113 |
+
|
| 114 |
+
# Jupyter Notebook
|
| 115 |
+
.ipynb_checkpoints
|
| 116 |
+
|
| 117 |
+
# IPython
|
| 118 |
+
profile_default/
|
| 119 |
+
ipython_config.py
|
| 120 |
+
|
| 121 |
+
# pyenv
|
| 122 |
+
# For a library or package, you might want to ignore these files since the code is
|
| 123 |
+
# intended to run in multiple environments; otherwise, check them in:
|
| 124 |
+
# .python-version
|
| 125 |
+
|
| 126 |
+
# pipenv
|
| 127 |
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
| 128 |
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
| 129 |
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
| 130 |
+
# install all needed dependencies.
|
| 131 |
+
#Pipfile.lock
|
| 132 |
+
|
| 133 |
+
# poetry
|
| 134 |
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
| 135 |
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
| 136 |
+
# commonly ignored for libraries.
|
| 137 |
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
| 138 |
+
#poetry.lock
|
| 139 |
+
|
| 140 |
+
# pdm
|
| 141 |
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
| 142 |
+
#pdm.lock
|
| 143 |
+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
|
| 144 |
+
# in version control.
|
| 145 |
+
# https://pdm.fming.dev/#use-with-ide
|
| 146 |
+
.pdm.toml
|
| 147 |
+
|
| 148 |
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
| 149 |
+
__pypackages__/
|
| 150 |
+
|
| 151 |
+
# Celery stuff
|
| 152 |
+
celerybeat-schedule
|
| 153 |
+
celerybeat.pid
|
| 154 |
+
|
| 155 |
+
# SageMath parsed files
|
| 156 |
+
*.sage.py
|
| 157 |
+
|
| 158 |
+
# Environments
|
| 159 |
+
.env
|
| 160 |
+
.venv
|
| 161 |
+
env/
|
| 162 |
+
venv/
|
| 163 |
+
ENV/
|
| 164 |
+
env.bak/
|
| 165 |
+
venv.bak/
|
| 166 |
+
|
| 167 |
+
# Spyder project settings
|
| 168 |
+
.spyderproject
|
| 169 |
+
.spyproject
|
| 170 |
+
|
| 171 |
+
# Rope project settings
|
| 172 |
+
.ropeproject
|
| 173 |
+
|
| 174 |
+
# mkdocs documentation
|
| 175 |
+
/site
|
| 176 |
+
|
| 177 |
+
# mypy
|
| 178 |
+
.mypy_cache/
|
| 179 |
+
.dmypy.json
|
| 180 |
+
dmypy.json
|
| 181 |
+
|
| 182 |
+
# Pyre type checker
|
| 183 |
+
.pyre/
|
| 184 |
+
|
| 185 |
+
# pytype static type analyzer
|
| 186 |
+
.pytype/
|
| 187 |
+
|
| 188 |
+
# Cython debug symbols
|
| 189 |
+
cython_debug/
|
| 190 |
+
|
| 191 |
+
# PyCharm
|
| 192 |
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
| 193 |
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
| 194 |
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
| 195 |
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
| 196 |
+
#.idea/
|
| 197 |
+
# Swap
|
| 198 |
+
[._]*.s[a-v][a-z]
|
| 199 |
+
!*.svg # comment out if you don't need vector files
|
| 200 |
+
[._]*.sw[a-p]
|
| 201 |
+
[._]s[a-rt-v][a-z]
|
| 202 |
+
[._]ss[a-gi-z]
|
| 203 |
+
[._]sw[a-p]
|
| 204 |
+
|
| 205 |
+
# Session
|
| 206 |
+
Session.vim
|
| 207 |
+
Sessionx.vim
|
| 208 |
+
|
| 209 |
+
# Temporary
|
| 210 |
+
.netrwhist
|
| 211 |
+
*~
|
| 212 |
+
# Auto-generated tag files
|
| 213 |
+
tags
|
| 214 |
+
# Persistent undo
|
| 215 |
+
[._]*.un~
|
| 216 |
+
# Cache files for Sublime Text
|
| 217 |
+
*.tmlanguage.cache
|
| 218 |
+
*.tmPreferences.cache
|
| 219 |
+
*.stTheme.cache
|
| 220 |
+
|
| 221 |
+
# Workspace files are user-specific
|
| 222 |
+
*.sublime-workspace
|
| 223 |
+
|
| 224 |
+
# Project files should be checked into the repository, unless a significant
|
| 225 |
+
# proportion of contributors will probably not be using Sublime Text
|
| 226 |
+
# *.sublime-project
|
| 227 |
+
|
| 228 |
+
# SFTP configuration file
|
| 229 |
+
sftp-config.json
|
| 230 |
+
sftp-config-alt*.json
|
| 231 |
+
|
| 232 |
+
# Package control specific files
|
| 233 |
+
Package Control.last-run
|
| 234 |
+
Package Control.ca-list
|
| 235 |
+
Package Control.ca-bundle
|
| 236 |
+
Package Control.system-ca-bundle
|
| 237 |
+
Package Control.cache/
|
| 238 |
+
Package Control.ca-certs/
|
| 239 |
+
Package Control.merged-ca-bundle
|
| 240 |
+
Package Control.user-ca-bundle
|
| 241 |
+
oscrypto-ca-bundle.crt
|
| 242 |
+
bh_unicode_properties.cache
|
| 243 |
+
|
| 244 |
+
# Sublime-github package stores a github token in this file
|
| 245 |
+
# https://packagecontrol.io/packages/sublime-github
|
| 246 |
+
GitHub.sublime-settings
|
| 247 |
+
*~
|
| 248 |
+
|
| 249 |
+
# temporary files which can be created if a process still has a handle open of a deleted file
|
| 250 |
+
.fuse_hidden*
|
| 251 |
+
|
| 252 |
+
# KDE directory preferences
|
| 253 |
+
.directory
|
| 254 |
+
|
| 255 |
+
# Linux trash folder which might appear on any partition or disk
|
| 256 |
+
.Trash-*
|
| 257 |
|
| 258 |
+
# .nfs files are created when an open file is removed but is still being accessed
|
| 259 |
+
.nfs*
|
| 260 |
+
# General
|
| 261 |
+
.DS_Store
|
| 262 |
+
.AppleDouble
|
| 263 |
+
.LSOverride
|
| 264 |
|
| 265 |
+
# Icon must end with two \r
|
| 266 |
+
Icon
|
|
|
|
|
|
|
| 267 |
|
|
|
|
| 268 |
|
| 269 |
+
# Thumbnails
|
| 270 |
+
._*
|
| 271 |
|
| 272 |
+
# Files that might appear in the root of a volume
|
| 273 |
+
.DocumentRevisions-V100
|
| 274 |
+
.fseventsd
|
| 275 |
+
.Spotlight-V100
|
| 276 |
+
.TemporaryItems
|
| 277 |
+
.Trashes
|
| 278 |
+
.VolumeIcon.icns
|
| 279 |
+
.com.apple.timemachine.donotpresent
|
| 280 |
|
| 281 |
+
# Directories potentially created on remote AFP share
|
| 282 |
+
.AppleDB
|
| 283 |
+
.AppleDesktop
|
| 284 |
+
Network Trash Folder
|
| 285 |
+
Temporary Items
|
| 286 |
+
.apdisk
|
.gitmodules
CHANGED
|
@@ -1,6 +1,3 @@
|
|
| 1 |
-
[submodule "
|
| 2 |
-
path =
|
| 3 |
-
url = https://github.com/unitreerobotics/unitree_ros
|
| 4 |
-
[submodule "__todo__/packages/robotodo_assets/unitree_robots/resources/unitree_ros"]
|
| 5 |
-
path = __todo__/packages/robotodo_assets/unitree_robots/resources/unitree_ros
|
| 6 |
url = https://github.com/unitreerobotics/unitree_ros.git
|
|
|
|
| 1 |
+
[submodule "packages/robotodo/actors/unitree_robots/resources/unitree_ros"]
|
| 2 |
+
path = packages/robotodo/actors/unitree_robots/resources/unitree_ros
|
|
|
|
|
|
|
|
|
|
| 3 |
url = https://github.com/unitreerobotics/unitree_ros.git
|
.vscode/settings.json
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"python-envs.defaultEnvManager": "ms-python.python:conda",
|
| 3 |
+
"python-envs.defaultPackageManager": "ms-python.python:conda",
|
| 4 |
+
"python-envs.pythonProjects": []
|
| 5 |
+
}
|
README.md
CHANGED
|
@@ -1,148 +1,5 @@
|
|
| 1 |
-
|
| 2 |
-
<a href="https://robotwin-benchmark.github.io"><b>RoboTwin</b> Bimanual Robotic Manipulation Simulation Platform<br></a>
|
| 3 |
-
<small>Lastest Version: RoboTwin 2.0</small><br>
|
| 4 |
-
</h1>
|
| 5 |
|
| 6 |
-
|
| 7 |
-
|
| 8 |
|
| 9 |
-
https://private-user-images.githubusercontent.com/88101805/457745424-ce0aaab2-14cf-4902-acb6-13f8433e49a9.mp4
|
| 10 |
-
|
| 11 |
-
**[2.0 Version (lastest)]** RoboTwin 2.0: A Scalable Data Generator and Benchmark with Strong Domain Randomization for Robust Bimanual Robotic Manipulation<br>
|
| 12 |
-
<i>Under Review 2025</i>: [PDF](https://robotwin-platform.github.io/paper.pdf) | [arXiv (Coming Soon)]()<br>
|
| 13 |
-
> <a href="https://tianxingchen.github.io/">Tianxing Chen</a><sup>*</sup>, Zanxin Chen<sup>*</sup>, Baijun Chen<sup>*</sup>, Zijian Cai<sup>*</sup>, <a href="https://10-oasis-01.github.io">Yibin Liu</a><sup>*</sup>, <a href="https://kolakivy.github.io/">Qiwei Liang</a>, Zixuan Li, Xianliang Lin, <a href="https://geyiheng.github.io">Yiheng Ge</a>, Zhenyu Gu, Weiliang Deng, Yubin Guo, Tian Nian, Xuanbing Xie, <a href="https://www.linkedin.com/in/yusen-qin-5b23345b/">Qiangyu Chen</a>, Kailun Su, Tianling Xu, <a href="http://luoping.me/">Guodong Liu</a>, <a href="https://aaron617.github.io/">Mengkang Hu</a>, <a href="https://c7w.tech/about">Huan-ang Gao</a>, Kaixuan Wang, <a href="https://liang-zx.github.io/">Zhixuan Liang</a>, <a href="https://www.linkedin.com/in/yusen-qin-5b23345b/">Yusen Qin</a>, Xiaokang Yang, <a href="http://luoping.me/">Ping Luo</a><sup>†</sup>, <a href="https://yaomarkmu.github.io/">Yao Mu</a><sup>†</sup>
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
**[RoboTwin Dual-Arm Collaboration Challenge@CVPR'25 MEIS Workshop]** RoboTwin Dual-Arm Collaboration Challenge Technical Report at CVPR 2025 MEIS Workshop<br>
|
| 17 |
-
> Coming Soon.
|
| 18 |
-
|
| 19 |
-
**[1.0 Version]** RoboTwin: Dual-Arm Robot Benchmark with Generative Digital Twins<br>
|
| 20 |
-
Accepted to <i style="color: red; display: inline;"><b>CVPR 2025 (Highlight)</b></i>: [PDF](https://arxiv.org/pdf/2504.13059) | [arXiv](https://arxiv.org/abs/2504.13059)<br>
|
| 21 |
-
> <a href="https://yaomarkmu.github.io/">Yao Mu</a><sup>* †</sup>, <a href="https://tianxingchen.github.io">Tianxing Chen</a><sup>* </sup>, Zanxin Chen<sup>* </sup>, <a href="https://shijiapeng03.github.io">Shijia Peng</a><sup>* </sup>, Zhiqian Lan, Zeyu Gao, Zhixuan Liang, Qiaojun Yu, Yude Zou, Mingkun Xu, Lunkai Lin, Zhiqiang Xie, Mingyu Ding, <a href="http://luoping.me/">Ping Luo</a><sup>†</sup>.
|
| 22 |
-
|
| 23 |
-
**[Early Version]** RoboTwin: Dual-Arm Robot Benchmark with Generative Digital Twins (early version)<br>
|
| 24 |
-
Accepted to <i style="color: red; display: inline;"><b>ECCV Workshop 2024 (Best Paper Award)</b></i>: [PDF](https://arxiv.org/pdf/2409.02920) | [arXiv](https://arxiv.org/abs/2409.02920)<br>
|
| 25 |
-
> <a href="https://yaomarkmu.github.io/">Yao Mu</a><sup>* †</sup>, <a href="https://tianxingchen.github.io">Tianxing Chen</a><sup>* </sup>, Shijia Peng<sup>*</sup>, Zanxin Chen<sup>*</sup>, Zeyu Gao, Zhiqian Lan, Yude Zou, Lunkai Lin, Zhiqiang Xie, <a href="http://luoping.me/">Ping Luo</a><sup>†</sup>.
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
# 📚 Overview
|
| 30 |
-
|
| 31 |
-
| Branch Name | Link |
|
| 32 |
-
|-------------|------|
|
| 33 |
-
| 2.0 Version Branch | [main](https://github.com/RoboTwin-Platform/RoboTwin/tree/main) (latest) |
|
| 34 |
-
| 1.0 Version Branch | [1.0 Version](https://github.com/RoboTwin-Platform/RoboTwin/tree/main) |
|
| 35 |
-
| 1.0 Version Code Generation Branch | [1.0 Version GPT](https://github.com/RoboTwin-Platform/RoboTwin/tree/gpt) |
|
| 36 |
-
| Early Version Branch | [Early Version](https://github.com/RoboTwin-Platform/RoboTwin/tree/early_version) |
|
| 37 |
-
| 第十九届“挑战杯”人工智能专项赛分支 | Coming Soon... |
|
| 38 |
-
| CVPR 2025 Challenge Round 1 Branch | [CVPR-Challenge-2025-Round1](https://github.com/RoboTwin-Platform/RoboTwin/tree/CVPR-Challenge-2025-Round1) |
|
| 39 |
-
| CVPR 2025 Challenge Round 2 Branch | [CVPR-Challenge-2025-Round2](https://github.com/RoboTwin-Platform/RoboTwin/tree/CVPR-Challenge-2025-Round2) |
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
# 🐣 Update
|
| 44 |
-
* **2025/06/21**, We release RoboTwin 2.0 !
|
| 45 |
-
* **2025/04/11**, RoboTwin is seclected as <i>CVPR Highlight paper</i>!
|
| 46 |
-
* **2025/02/27**, RoboTwin is accepted to <i>CVPR 2025</i> !
|
| 47 |
-
* **2024/09/30**, RoboTwin (Early Version) received <i>the Best Paper Award at the ECCV Workshop</i>!
|
| 48 |
-
* **2024/09/20**, Officially released RoboTwin.
|
| 49 |
-
|
| 50 |
-
<!-- **Applications and extensions of RoboTwin from the community:**
|
| 51 |
-
|
| 52 |
-
[TODO]
|
| 53 |
-
|
| 54 |
-
[[arXiv 2411.18369](https://arxiv.org/abs/2411.18369)], <i>G3Flow: Generative 3D Semantic Flow for Pose-aware and Generalizable Object Manipulation</i>, where 5 RoboTwin tasks are selected for benchmarking. -->
|
| 55 |
-
|
| 56 |
-
# 🛠️ Installation
|
| 57 |
-
|
| 58 |
-
See [RoboTwin 2.0 Document (Usage - Install & Download)](https://robotwin-platform.github.io/doc/usage/robotwin-install.html) for installation instructions. It takes about 20 minutes for installation.
|
| 59 |
-
|
| 60 |
-
# 🤷♂️ Tasks Informations
|
| 61 |
-
See [RoboTwin 2.0 Tasks Doc](https://robotwin-platform.github.io/doc/tasks/index.html) for more details.
|
| 62 |
-
|
| 63 |
-
<p align="center">
|
| 64 |
-
<img src="./assets/files/50_tasks.gif" width="100%">
|
| 65 |
-
</p>
|
| 66 |
-
|
| 67 |
-
# 🧑🏻💻 Usage
|
| 68 |
-
|
| 69 |
-
> Please Refer to [RoboTwin 2.0 Document (Usage)](https://robotwin-platform.github.io/doc/usage/index.html) for more details.
|
| 70 |
-
|
| 71 |
-
## Data Collection
|
| 72 |
-
We provide over 100,000 pre-collected trajectories as part of the open-source release [RoboTwin Dataset](https://huggingface.co/datasets/TianxingChen/RoboTwin2.0/tree/main/dataset).
|
| 73 |
-
However, we strongly recommend users to perform data collection themselves due to the high configurability and diversity of task and embodiment setups.
|
| 74 |
-
|
| 75 |
-
<img src="./assets/files/domain_randomization.png" alt="description" style="display: block; margin: auto; width: 100%;">
|
| 76 |
-
|
| 77 |
-
## 1. Task Running and Data Collection
|
| 78 |
-
Running the following command will first search for a random seed for the target collection quantity, and then replay the seed to collect data.
|
| 79 |
-
|
| 80 |
-
```
|
| 81 |
-
bash collect_data.sh ${task_name} ${task_config} ${gpu_id}
|
| 82 |
-
# Example: bash collect_data.sh beat_block_hammer demo_randomized 0
|
| 83 |
-
```
|
| 84 |
-
|
| 85 |
-
## 2. Task Config
|
| 86 |
-
See [RoboTwin 2.0 Tasks Configurations Doc](https://robotwin-platform.github.io/doc/usage/configurations.html) for more details.
|
| 87 |
-
|
| 88 |
-
# 🚴♂️ Policy Baselines
|
| 89 |
-
## Policies Support
|
| 90 |
-
[DP](https://robotwin-platform.github.io/doc/usage/DP.html), [ACT](https://robotwin-platform.github.io/doc/usage/ACT.html), [DP3](https://robotwin-platform.github.io/doc/usage/DP3.html), [RDT](https://robotwin-platform.github.io/doc/usage/RDT.html), [PI0](https://robotwin-platform.github.io/doc/usage/Pi0.html)
|
| 91 |
-
|
| 92 |
-
[TinyVLA](https://robotwin-platform.github.io/doc/usage/TinyVLA.html), [DexVLA](https://robotwin-platform.github.io/doc/usage/DexVLA.html) (Contributed by Media Group)
|
| 93 |
-
|
| 94 |
-
Deploy Your Policy: [guide](https://robotwin-platform.github.io/doc/usage/deploy-your-policy.html)
|
| 95 |
-
|
| 96 |
-
⏰ TODO: G3Flow, HybridVLA, DexVLA, OpenVLA-OFT, SmolVLA, AVR, UniVLA
|
| 97 |
-
|
| 98 |
-
# 🏄♂️ Experiment & LeaderBoard
|
| 99 |
-
|
| 100 |
-
> We recommend that the RoboTwin Platform can be used to explore the following topics:
|
| 101 |
-
> 1. single - task fine - tuning capability
|
| 102 |
-
> 2. visual robustness
|
| 103 |
-
> 3. language diversity robustness (language condition)
|
| 104 |
-
> 4. multi-tasks capability
|
| 105 |
-
> 5. cross-embodiment performance
|
| 106 |
-
|
| 107 |
-
Coming Soon.
|
| 108 |
-
|
| 109 |
-
# 👍 Citations
|
| 110 |
-
If you find our work useful, please consider citing:
|
| 111 |
-
|
| 112 |
-
<b>RoboTwin 2.0</b>: A Scalable Data Generator and Benchmark with Strong Domain Randomization for Robust Bimanual Robotic Manipulation
|
| 113 |
-
```
|
| 114 |
-
Coming Soon.
|
| 115 |
-
```
|
| 116 |
-
|
| 117 |
-
<b>RoboTwin</b>: Dual-Arm Robot Benchmark with Generative Digital Twins, accepted to <i style="color: red; display: inline;"><b>CVPR 2025 (Highlight)</b></i>
|
| 118 |
-
```
|
| 119 |
-
@InProceedings{Mu_2025_CVPR,
|
| 120 |
-
author = {Mu, Yao and Chen, Tianxing and Chen, Zanxin and Peng, Shijia and Lan, Zhiqian and Gao, Zeyu and Liang, Zhixuan and Yu, Qiaojun and Zou, Yude and Xu, Mingkun and Lin, Lunkai and Xie, Zhiqiang and Ding, Mingyu and Luo, Ping},
|
| 121 |
-
title = {RoboTwin: Dual-Arm Robot Benchmark with Generative Digital Twins},
|
| 122 |
-
booktitle = {Proceedings of the Computer Vision and Pattern Recognition Conference (CVPR)},
|
| 123 |
-
month = {June},
|
| 124 |
-
year = {2025},
|
| 125 |
-
pages = {27649-27660}
|
| 126 |
-
}
|
| 127 |
-
```
|
| 128 |
-
|
| 129 |
-
<b>RoboTwin</b>: Dual-Arm Robot Benchmark with Generative Digital Twins (early version), accepted to <i style="color: red; display: inline;"><b>ECCV Workshop 2024 (Best Paper Award)</b></i>
|
| 130 |
-
```
|
| 131 |
-
@article{mu2024robotwin,
|
| 132 |
-
title={RoboTwin: Dual-Arm Robot Benchmark with Generative Digital Twins (early version)},
|
| 133 |
-
author={Mu, Yao and Chen, Tianxing and Peng, Shijia and Chen, Zanxin and Gao, Zeyu and Zou, Yude and Lin, Lunkai and Xie, Zhiqiang and Luo, Ping},
|
| 134 |
-
journal={arXiv preprint arXiv:2409.02920},
|
| 135 |
-
year={2024}
|
| 136 |
-
}
|
| 137 |
-
```
|
| 138 |
-
|
| 139 |
-
# 😺 Acknowledgement
|
| 140 |
-
|
| 141 |
-
**Software Support**: D-Robotics, **Hardware Support**: AgileX Robotics, **AIGC Support**: Deemos
|
| 142 |
-
|
| 143 |
-
Code Style: `find . -name "*.py" -exec sh -c 'echo "Processing: {}"; yapf -i --style='"'"'{based_on_style: pep8, column_limit: 120}'"'"' {}' \;`
|
| 144 |
-
|
| 145 |
-
Contact [Tianxing Chen](https://tianxingchen.github.io) if you have any questions or suggestions.
|
| 146 |
-
|
| 147 |
-
# 🏷️ License
|
| 148 |
-
This repository is released under the MIT license. See [LICENSE](./LICENSE) for additional details.
|
|
|
|
| 1 |
+
# robotodo
|
|
|
|
|
|
|
|
|
|
| 2 |
|
| 3 |
+
## TODO
|
| 4 |
+
- https://github.com/RoboTwin-Platform/RoboTwin
|
| 5 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
__todo__/.gitattributes
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
*.glb filter=lfs diff=lfs merge=lfs -text
|
| 2 |
+
*.jpg filter=lfs diff=lfs merge=lfs -text
|
| 3 |
+
*.gif filter=lfs diff=lfs merge=lfs -text
|
| 4 |
+
*.png filter=lfs diff=lfs merge=lfs -text
|
| 5 |
+
*.mtl filter=lfs diff=lfs merge=lfs -text
|
| 6 |
+
*.obj filter=lfs diff=lfs merge=lfs -text
|
__todo__/{.gitignore → __todo_assets__/.gitignore}
RENAMED
|
File without changes
|
{__todo_assets__ → __todo__/__todo_assets__}/README.md
RENAMED
|
File without changes
|
{__todo_assets__ → __todo__/__todo_assets__}/pyproject.toml
RENAMED
|
File without changes
|
{__todo_assets__ → __todo__/__todo_assets_robots__}/.gitignore
RENAMED
|
File without changes
|
__todo__/{README.md → __todo_assets_robots__/README.md}
RENAMED
|
File without changes
|
{__todo_assets_robots__ → __todo__/__todo_assets_robots__}/pyproject.toml
RENAMED
|
File without changes
|
__todo__/_nn_legacy/flex_attention.py
ADDED
|
@@ -0,0 +1,143 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2024 The HuggingFace Inc. team. All rights reserved.
|
| 2 |
+
#
|
| 3 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
# you may not use this file except in compliance with the License.
|
| 5 |
+
# You may obtain a copy of the License at
|
| 6 |
+
#
|
| 7 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
#
|
| 9 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
# See the License for the specific language governing permissions and
|
| 13 |
+
# limitations under the License.
|
| 14 |
+
|
| 15 |
+
import torch
|
| 16 |
+
import torch.nn.functional as F # noqa: N812
|
| 17 |
+
# from packaging.version import Version
|
| 18 |
+
|
| 19 |
+
# TODO mv to dependencies !!!!!!!!!
|
| 20 |
+
# if Version(torch.__version__) > Version("2.5.0"):
|
| 21 |
+
# Ffex attention is only available from torch 2.5 onwards
|
| 22 |
+
from torch.nn.attention.flex_attention import (
|
| 23 |
+
_mask_mod_signature,
|
| 24 |
+
_round_up_to_multiple,
|
| 25 |
+
create_block_mask,
|
| 26 |
+
create_mask,
|
| 27 |
+
flex_attention,
|
| 28 |
+
)
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
# TODO use torch.nn.Module !!!!!!!!!
|
| 32 |
+
# @torch.compile(dynamic=False)
|
| 33 |
+
def flex_attention_forward(
|
| 34 |
+
attention_mask: torch.Tensor,
|
| 35 |
+
batch_size: int,
|
| 36 |
+
head_dim: int,
|
| 37 |
+
query_states: torch.Tensor,
|
| 38 |
+
key_states: torch.Tensor,
|
| 39 |
+
value_states: torch.Tensor,
|
| 40 |
+
scaling=None,
|
| 41 |
+
):
|
| 42 |
+
"""
|
| 43 |
+
This is defined out of classes to make compile happy.
|
| 44 |
+
"""
|
| 45 |
+
|
| 46 |
+
original_dtype = query_states.dtype
|
| 47 |
+
num_att_heads = 8
|
| 48 |
+
num_key_value_heads = 1
|
| 49 |
+
num_key_value_groups = num_att_heads // num_key_value_heads
|
| 50 |
+
|
| 51 |
+
key_states = key_states[:, :, :, None, :]
|
| 52 |
+
key_states = key_states.expand(
|
| 53 |
+
batch_size, key_states.shape[1], num_key_value_heads, num_key_value_groups, head_dim
|
| 54 |
+
)
|
| 55 |
+
key_states = key_states.reshape(
|
| 56 |
+
batch_size, key_states.shape[1], num_key_value_heads * num_key_value_groups, head_dim
|
| 57 |
+
)
|
| 58 |
+
|
| 59 |
+
value_states = value_states[:, :, :, None, :]
|
| 60 |
+
value_states = value_states.expand(
|
| 61 |
+
batch_size, value_states.shape[1], num_key_value_heads, num_key_value_groups, head_dim
|
| 62 |
+
)
|
| 63 |
+
value_states = value_states.reshape(
|
| 64 |
+
batch_size, value_states.shape[1], num_key_value_heads * num_key_value_groups, head_dim
|
| 65 |
+
)
|
| 66 |
+
|
| 67 |
+
query_states = query_states.transpose(1, 2)
|
| 68 |
+
key_states = key_states.transpose(1, 2)
|
| 69 |
+
value_states = value_states.transpose(1, 2)
|
| 70 |
+
|
| 71 |
+
query_states = query_states.to(torch.float32)
|
| 72 |
+
key_states = key_states.to(torch.float32)
|
| 73 |
+
value_states = value_states.to(torch.float32)
|
| 74 |
+
|
| 75 |
+
causal_mask = attention_mask
|
| 76 |
+
if causal_mask is not None:
|
| 77 |
+
causal_mask = causal_mask[:, None, :, : key_states.shape[2]]
|
| 78 |
+
|
| 79 |
+
if causal_mask.shape[1] == 1 and query_states.shape[1] > 1:
|
| 80 |
+
causal_mask = causal_mask.expand(-1, query_states.shape[1], -1, -1)
|
| 81 |
+
|
| 82 |
+
def precomputed_mask_factory(precomputed_mask: torch.Tensor) -> _mask_mod_signature:
|
| 83 |
+
def mask_mod(b, h, q_idx, kv_idx):
|
| 84 |
+
# Danger zone: if b,h,q_idx,kv_idx exceed the shape, device-side assert occurs.
|
| 85 |
+
return precomputed_mask[b][h][q_idx][kv_idx]
|
| 86 |
+
|
| 87 |
+
return mask_mod
|
| 88 |
+
|
| 89 |
+
b_mask, h_mask, q_len, kv_len = causal_mask.shape # The shape of your mask
|
| 90 |
+
|
| 91 |
+
block_size = 128
|
| 92 |
+
q_len_rounded = _round_up_to_multiple(q_len, block_size)
|
| 93 |
+
kv_len_rounded = _round_up_to_multiple(kv_len, block_size)
|
| 94 |
+
|
| 95 |
+
# *CRITICAL* we do need to expand here, else we get a CUDA index error
|
| 96 |
+
|
| 97 |
+
pad_q = q_len_rounded - q_len
|
| 98 |
+
pad_k = kv_len_rounded - kv_len
|
| 99 |
+
|
| 100 |
+
padded_causal_mask = F.pad(causal_mask, (0, pad_k, 0, pad_q), value=0.0)
|
| 101 |
+
mask_mod_fn_orig = precomputed_mask_factory(padded_causal_mask)
|
| 102 |
+
|
| 103 |
+
mask_4d = create_mask(
|
| 104 |
+
mod_fn=mask_mod_fn_orig,
|
| 105 |
+
B=b_mask,
|
| 106 |
+
H=h_mask,
|
| 107 |
+
Q_LEN=q_len_rounded,
|
| 108 |
+
KV_LEN=kv_len_rounded,
|
| 109 |
+
device=causal_mask.device,
|
| 110 |
+
_compile=False,
|
| 111 |
+
)
|
| 112 |
+
|
| 113 |
+
mask_mod_fn_padded = precomputed_mask_factory(mask_4d)
|
| 114 |
+
block_mask = create_block_mask(
|
| 115 |
+
mask_mod=mask_mod_fn_padded,
|
| 116 |
+
B=b_mask,
|
| 117 |
+
H=h_mask,
|
| 118 |
+
Q_LEN=q_len_rounded,
|
| 119 |
+
KV_LEN=kv_len_rounded,
|
| 120 |
+
BLOCK_SIZE=block_size,
|
| 121 |
+
device=causal_mask.device,
|
| 122 |
+
_compile=False,
|
| 123 |
+
)
|
| 124 |
+
|
| 125 |
+
# mask is applied inside the kernel, ideally more efficiently than score_mod.
|
| 126 |
+
attn_output, attention_weights = flex_attention(
|
| 127 |
+
query_states,
|
| 128 |
+
key_states,
|
| 129 |
+
value_states,
|
| 130 |
+
block_mask=block_mask,
|
| 131 |
+
enable_gqa=True, # because we shaped query/key states for GQA
|
| 132 |
+
scale=head_dim**-0.5 if scaling is None else scaling,
|
| 133 |
+
return_lse=True,
|
| 134 |
+
)
|
| 135 |
+
|
| 136 |
+
attn_output = attn_output.to(dtype=original_dtype)
|
| 137 |
+
attn_output = attn_output.transpose(1, 2).contiguous() # [B, Q_LEN, H, head_dim]
|
| 138 |
+
attn_output = attn_output.reshape(
|
| 139 |
+
batch_size,
|
| 140 |
+
-1,
|
| 141 |
+
attn_output.shape[2] * attn_output.shape[3], # merges [H, head_dim]
|
| 142 |
+
)
|
| 143 |
+
return attn_output
|
__todo__/_nn_legacy/paligemma_with_expert.py
ADDED
|
@@ -0,0 +1,428 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2024 The HuggingFace Inc. team. All rights reserved.
|
| 2 |
+
#
|
| 3 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
# you may not use this file except in compliance with the License.
|
| 5 |
+
# You may obtain a copy of the License at
|
| 6 |
+
#
|
| 7 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
#
|
| 9 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
# See the License for the specific language governing permissions and
|
| 13 |
+
# limitations under the License.
|
| 14 |
+
|
| 15 |
+
from typing import List, Optional, Union
|
| 16 |
+
|
| 17 |
+
import torch
|
| 18 |
+
# import torch.version
|
| 19 |
+
# TODO !!!!!
|
| 20 |
+
# from pytest import Cache
|
| 21 |
+
# ####
|
| 22 |
+
from torch import nn
|
| 23 |
+
from transformers import (
|
| 24 |
+
AutoConfig,
|
| 25 |
+
GemmaForCausalLM,
|
| 26 |
+
PaliGemmaForConditionalGeneration,
|
| 27 |
+
PretrainedConfig,
|
| 28 |
+
PreTrainedModel,
|
| 29 |
+
)
|
| 30 |
+
from transformers.models.auto import CONFIG_MAPPING
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
def apply_rope(x, positions, max_wavelength=10_000):
|
| 35 |
+
"""
|
| 36 |
+
Applies RoPE positions [B, L] to x [B, L, H, D].
|
| 37 |
+
"""
|
| 38 |
+
d_half = x.shape[-1] // 2
|
| 39 |
+
device = x.device
|
| 40 |
+
dtype = x.dtype
|
| 41 |
+
x = x.to(torch.float32)
|
| 42 |
+
|
| 43 |
+
freq_exponents = (2.0 / x.shape[-1]) * torch.arange(d_half, dtype=torch.float32, device=device)
|
| 44 |
+
timescale = max_wavelength**freq_exponents
|
| 45 |
+
radians = positions[..., None].to(torch.float32) / timescale[None, None, :].to(torch.float32)
|
| 46 |
+
|
| 47 |
+
radians = radians[..., None, :]
|
| 48 |
+
|
| 49 |
+
sin = torch.sin(radians) # .to(dtype=dtype)
|
| 50 |
+
cos = torch.cos(radians) # .to(dtype=dtype)
|
| 51 |
+
|
| 52 |
+
x1, x2 = x.split(d_half, dim=-1)
|
| 53 |
+
res = torch.empty_like(x)
|
| 54 |
+
res[..., :d_half] = x1 * cos - x2 * sin
|
| 55 |
+
res[..., d_half:] = x2 * cos + x1 * sin
|
| 56 |
+
|
| 57 |
+
return res.to(dtype)
|
| 58 |
+
|
| 59 |
+
|
| 60 |
+
class PaliGemmaWithExpertConfig(PretrainedConfig):
|
| 61 |
+
model_type = "PaliGemmaWithExpertModel"
|
| 62 |
+
sub_configs = {"paligemma_config": AutoConfig, "gemma_expert_config": AutoConfig}
|
| 63 |
+
|
| 64 |
+
def __init__(
|
| 65 |
+
self,
|
| 66 |
+
paligemma_config: dict | None = None,
|
| 67 |
+
gemma_expert_config: dict | None = None,
|
| 68 |
+
freeze_vision_encoder: bool = True,
|
| 69 |
+
train_expert_only: bool = True,
|
| 70 |
+
attention_implementation: str = "eager",
|
| 71 |
+
**kwargs,
|
| 72 |
+
):
|
| 73 |
+
self.freeze_vision_encoder = freeze_vision_encoder
|
| 74 |
+
self.train_expert_only = train_expert_only
|
| 75 |
+
self.attention_implementation = attention_implementation
|
| 76 |
+
|
| 77 |
+
if paligemma_config is None:
|
| 78 |
+
# Default config from Pi0
|
| 79 |
+
self.paligemma_config = CONFIG_MAPPING["paligemma"](
|
| 80 |
+
transformers_version="4.48.1",
|
| 81 |
+
_vocab_size=257152,
|
| 82 |
+
bos_token_id=2,
|
| 83 |
+
eos_token_id=1,
|
| 84 |
+
hidden_size=2048,
|
| 85 |
+
image_token_index=257152,
|
| 86 |
+
model_type="paligemma",
|
| 87 |
+
pad_token_id=0,
|
| 88 |
+
projection_dim=2048,
|
| 89 |
+
text_config={
|
| 90 |
+
"hidden_activation": "gelu_pytorch_tanh",
|
| 91 |
+
"hidden_size": 2048,
|
| 92 |
+
"intermediate_size": 16384,
|
| 93 |
+
"model_type": "gemma",
|
| 94 |
+
"num_attention_heads": 8,
|
| 95 |
+
"num_hidden_layers": 18,
|
| 96 |
+
"num_image_tokens": 256,
|
| 97 |
+
"num_key_value_heads": 1,
|
| 98 |
+
"torch_dtype": "float32",
|
| 99 |
+
"vocab_size": 257152,
|
| 100 |
+
},
|
| 101 |
+
vision_config={
|
| 102 |
+
"hidden_size": 1152,
|
| 103 |
+
"intermediate_size": 4304,
|
| 104 |
+
"model_type": "siglip_vision_model",
|
| 105 |
+
"num_attention_heads": 16,
|
| 106 |
+
"num_hidden_layers": 27,
|
| 107 |
+
"num_image_tokens": 256,
|
| 108 |
+
"patch_size": 14,
|
| 109 |
+
"projection_dim": 2048,
|
| 110 |
+
"projector_hidden_act": "gelu_fast",
|
| 111 |
+
"torch_dtype": "float32",
|
| 112 |
+
"vision_use_head": False,
|
| 113 |
+
},
|
| 114 |
+
)
|
| 115 |
+
elif isinstance(self.paligemma_config, dict):
|
| 116 |
+
# Override Pi0 default config for PaliGemma
|
| 117 |
+
if "model_type" not in gemma_expert_config:
|
| 118 |
+
paligemma_config["model_type"] = "paligemma"
|
| 119 |
+
|
| 120 |
+
cfg_cls = CONFIG_MAPPING[paligemma_config["model_type"]]
|
| 121 |
+
self.paligemma_config = cfg_cls(**paligemma_config)
|
| 122 |
+
|
| 123 |
+
if gemma_expert_config is None:
|
| 124 |
+
# Default config from Pi0
|
| 125 |
+
self.gemma_expert_config = CONFIG_MAPPING["gemma"](
|
| 126 |
+
attention_bias=False,
|
| 127 |
+
attention_dropout=0.0,
|
| 128 |
+
bos_token_id=2,
|
| 129 |
+
eos_token_id=1,
|
| 130 |
+
head_dim=256,
|
| 131 |
+
hidden_act="gelu_pytorch_tanh",
|
| 132 |
+
hidden_activation="gelu_pytorch_tanh",
|
| 133 |
+
hidden_size=1024,
|
| 134 |
+
initializer_range=0.02,
|
| 135 |
+
intermediate_size=4096,
|
| 136 |
+
max_position_embeddings=8192,
|
| 137 |
+
model_type="gemma",
|
| 138 |
+
num_attention_heads=8,
|
| 139 |
+
num_hidden_layers=18,
|
| 140 |
+
num_key_value_heads=1,
|
| 141 |
+
pad_token_id=0,
|
| 142 |
+
rms_norm_eps=1e-06,
|
| 143 |
+
rope_theta=10000.0,
|
| 144 |
+
torch_dtype="float32",
|
| 145 |
+
transformers_version="4.48.1",
|
| 146 |
+
use_cache=True,
|
| 147 |
+
vocab_size=257152,
|
| 148 |
+
)
|
| 149 |
+
elif isinstance(self.gemma_expert_config, dict):
|
| 150 |
+
# Override Pi0 default config for Gemma Expert
|
| 151 |
+
if "model_type" not in gemma_expert_config:
|
| 152 |
+
gemma_expert_config["model_type"] = "gemma"
|
| 153 |
+
|
| 154 |
+
cfg_cls = CONFIG_MAPPING[paligemma_config["model_type"]]
|
| 155 |
+
self.gemma_expert_config = cfg_cls(**gemma_expert_config)
|
| 156 |
+
|
| 157 |
+
super().__init__(**kwargs)
|
| 158 |
+
|
| 159 |
+
def __post_init__(self):
|
| 160 |
+
super().__post_init__()
|
| 161 |
+
if self.train_expert_only and not self.freeze_vision_encoder:
|
| 162 |
+
raise ValueError(
|
| 163 |
+
"You set `freeze_vision_encoder=False` and `train_expert_only=True` which are not compatible."
|
| 164 |
+
)
|
| 165 |
+
|
| 166 |
+
if self.attention_implementation not in ["eager", "fa2", "flex"]:
|
| 167 |
+
raise ValueError(
|
| 168 |
+
f"Wrong value provided for `attention_implementation` ({self.attention_implementation}). Expected 'eager', 'fa2' or 'flex'."
|
| 169 |
+
)
|
| 170 |
+
|
| 171 |
+
|
| 172 |
+
class PaliGemmaWithExpertModel(PreTrainedModel):
|
| 173 |
+
config_class = PaliGemmaWithExpertConfig
|
| 174 |
+
|
| 175 |
+
def __init__(self, config: PaliGemmaWithExpertConfig):
|
| 176 |
+
super().__init__(config=config)
|
| 177 |
+
self.config = config
|
| 178 |
+
self.paligemma = PaliGemmaForConditionalGeneration(config=config.paligemma_config)
|
| 179 |
+
self.gemma_expert = GemmaForCausalLM(config=config.gemma_expert_config)
|
| 180 |
+
# Remove unused embed_tokens
|
| 181 |
+
self.gemma_expert.model.embed_tokens = None
|
| 182 |
+
|
| 183 |
+
self.to_bfloat16_like_physical_intelligence()
|
| 184 |
+
self.set_requires_grad()
|
| 185 |
+
|
| 186 |
+
def set_requires_grad(self):
|
| 187 |
+
if self.config.freeze_vision_encoder:
|
| 188 |
+
self.paligemma.vision_tower.eval()
|
| 189 |
+
for params in self.paligemma.vision_tower.parameters():
|
| 190 |
+
params.requires_grad = False
|
| 191 |
+
|
| 192 |
+
if self.config.train_expert_only:
|
| 193 |
+
self.paligemma.eval()
|
| 194 |
+
for params in self.paligemma.parameters():
|
| 195 |
+
params.requires_grad = False
|
| 196 |
+
|
| 197 |
+
def train(self, mode: bool = True):
|
| 198 |
+
super().train(mode)
|
| 199 |
+
|
| 200 |
+
if self.config.freeze_vision_encoder:
|
| 201 |
+
self.paligemma.vision_tower.eval()
|
| 202 |
+
|
| 203 |
+
if self.config.train_expert_only:
|
| 204 |
+
self.paligemma.eval()
|
| 205 |
+
|
| 206 |
+
def to_bfloat16_like_physical_intelligence(self):
|
| 207 |
+
self.paligemma = self.paligemma.to(dtype=torch.bfloat16)
|
| 208 |
+
|
| 209 |
+
params_to_change_dtype = [
|
| 210 |
+
"language_model.model.layers",
|
| 211 |
+
"gemma_expert.model.layers",
|
| 212 |
+
"vision_tower",
|
| 213 |
+
"multi_modal",
|
| 214 |
+
]
|
| 215 |
+
for name, param in self.named_parameters():
|
| 216 |
+
if any(selector in name for selector in params_to_change_dtype):
|
| 217 |
+
param.data = param.data.to(dtype=torch.bfloat16)
|
| 218 |
+
|
| 219 |
+
def embed_image(self, image: torch.Tensor):
|
| 220 |
+
# Handle different transformers versions
|
| 221 |
+
if hasattr(self.paligemma, "get_image_features"):
|
| 222 |
+
return self.paligemma.get_image_features(image)
|
| 223 |
+
else:
|
| 224 |
+
return self.paligemma.model.get_image_features(image)
|
| 225 |
+
|
| 226 |
+
def embed_language_tokens(self, tokens: torch.Tensor):
|
| 227 |
+
return self.paligemma.language_model.embed_tokens(tokens)
|
| 228 |
+
|
| 229 |
+
# TODO: break down this huge forward into modules or functions
|
| 230 |
+
def forward(
|
| 231 |
+
self,
|
| 232 |
+
attention_mask: Optional[torch.Tensor] = None,
|
| 233 |
+
position_ids: Optional[torch.LongTensor] = None,
|
| 234 |
+
# TODO typing !!!!!!
|
| 235 |
+
# past_key_values: Optional[Union[List[torch.FloatTensor], Cache]] = None,
|
| 236 |
+
past_key_values: Optional[List[torch.FloatTensor]] = None,
|
| 237 |
+
# TODO ACTUAL: past_key_values: {[layer_idx: int]: {"key_states": torch.Tensor, "value_states": torch.Tensor}} = None,
|
| 238 |
+
# #####
|
| 239 |
+
inputs_embeds: List[torch.FloatTensor] = None,
|
| 240 |
+
use_cache: Optional[bool] = None,
|
| 241 |
+
fill_kv_cache: Optional[bool] = None,
|
| 242 |
+
):
|
| 243 |
+
models = [self.paligemma.language_model, self.gemma_expert.model]
|
| 244 |
+
|
| 245 |
+
for hidden_states in inputs_embeds:
|
| 246 |
+
# TODO this is very inefficient
|
| 247 |
+
# dtype is always the same, batch size too (if > 1 len)
|
| 248 |
+
# device could be trickier in multi gpu edge cases but that's it
|
| 249 |
+
if hidden_states is None:
|
| 250 |
+
continue
|
| 251 |
+
batch_size = hidden_states.shape[0]
|
| 252 |
+
|
| 253 |
+
# RMSNorm
|
| 254 |
+
num_layers = self.paligemma.config.text_config.num_hidden_layers
|
| 255 |
+
head_dim = self.paligemma.config.text_config.head_dim
|
| 256 |
+
for layer_idx in range(num_layers):
|
| 257 |
+
query_states = []
|
| 258 |
+
key_states = []
|
| 259 |
+
value_states = []
|
| 260 |
+
for i, hidden_states in enumerate(inputs_embeds):
|
| 261 |
+
if hidden_states is None:
|
| 262 |
+
continue
|
| 263 |
+
layer = models[i].layers[layer_idx]
|
| 264 |
+
# normalizer = torch.tensor(models[i].config.hidden_size**0.5, dtype=hidden_states.dtype)
|
| 265 |
+
# hidden_states = hidden_states * normalizer
|
| 266 |
+
hidden_states = layer.input_layernorm(hidden_states)
|
| 267 |
+
|
| 268 |
+
input_shape = hidden_states.shape[:-1]
|
| 269 |
+
hidden_shape = (*input_shape, -1, layer.self_attn.head_dim)
|
| 270 |
+
|
| 271 |
+
hidden_states = hidden_states.to(dtype=torch.bfloat16)
|
| 272 |
+
query_state = layer.self_attn.q_proj(hidden_states).view(hidden_shape)
|
| 273 |
+
key_state = layer.self_attn.k_proj(hidden_states).view(hidden_shape)
|
| 274 |
+
value_state = layer.self_attn.v_proj(hidden_states).view(hidden_shape)
|
| 275 |
+
|
| 276 |
+
query_states.append(query_state)
|
| 277 |
+
key_states.append(key_state)
|
| 278 |
+
value_states.append(value_state)
|
| 279 |
+
|
| 280 |
+
# B,L,H,D with L sequence length, H number of heads, D head dim
|
| 281 |
+
# concatenate on the number of embeddings/tokens
|
| 282 |
+
query_states = torch.cat(query_states, dim=1)
|
| 283 |
+
key_states = torch.cat(key_states, dim=1)
|
| 284 |
+
value_states = torch.cat(value_states, dim=1)
|
| 285 |
+
|
| 286 |
+
query_states = apply_rope(query_states, position_ids)
|
| 287 |
+
key_states = apply_rope(key_states, position_ids)
|
| 288 |
+
|
| 289 |
+
if use_cache and past_key_values is None:
|
| 290 |
+
past_key_values = {}
|
| 291 |
+
|
| 292 |
+
if use_cache:
|
| 293 |
+
if fill_kv_cache:
|
| 294 |
+
past_key_values[layer_idx] = {
|
| 295 |
+
"key_states": key_states,
|
| 296 |
+
"value_states": value_states,
|
| 297 |
+
}
|
| 298 |
+
else:
|
| 299 |
+
# TODO here, some optimization can be done - similar to a `StaticCache` we can declare the `max_len` before.
|
| 300 |
+
# so we create an empty cache, with just one cuda malloc, and if (in autoregressive case) we reach
|
| 301 |
+
# the max len, then we (for instance) double the cache size. This implementation already exists
|
| 302 |
+
# in `transformers`. (molbap)
|
| 303 |
+
key_states = torch.cat([past_key_values[layer_idx]["key_states"], key_states], dim=1)
|
| 304 |
+
value_states = torch.cat(
|
| 305 |
+
[past_key_values[layer_idx]["value_states"], value_states], dim=1
|
| 306 |
+
)
|
| 307 |
+
|
| 308 |
+
attention_interface = self.get_attention_interface()
|
| 309 |
+
att_output = attention_interface(
|
| 310 |
+
attention_mask, batch_size, head_dim, query_states, key_states, value_states
|
| 311 |
+
)
|
| 312 |
+
att_output = att_output.to(dtype=torch.bfloat16)
|
| 313 |
+
|
| 314 |
+
# first part of att_output is prefix (up to sequence length, [:, 0:prefix_seq_len])
|
| 315 |
+
outputs_embeds = []
|
| 316 |
+
start = 0
|
| 317 |
+
for i, hidden_states in enumerate(inputs_embeds):
|
| 318 |
+
layer = models[i].layers[layer_idx]
|
| 319 |
+
|
| 320 |
+
if hidden_states is not None:
|
| 321 |
+
end = start + hidden_states.shape[1]
|
| 322 |
+
|
| 323 |
+
if att_output.dtype != layer.self_attn.o_proj.weight.dtype:
|
| 324 |
+
att_output = att_output.to(layer.self_attn.o_proj.weight.dtype)
|
| 325 |
+
out_emb = layer.self_attn.o_proj(att_output[:, start:end])
|
| 326 |
+
|
| 327 |
+
# TODO: first dropout (by default 0.0)
|
| 328 |
+
|
| 329 |
+
# first residual
|
| 330 |
+
out_emb += hidden_states
|
| 331 |
+
after_first_residual = out_emb.clone()
|
| 332 |
+
|
| 333 |
+
out_emb = layer.post_attention_layernorm(out_emb)
|
| 334 |
+
out_emb = layer.mlp(out_emb)
|
| 335 |
+
|
| 336 |
+
# TODO: second dropout (by default 0.0)
|
| 337 |
+
|
| 338 |
+
# second residual
|
| 339 |
+
out_emb += after_first_residual
|
| 340 |
+
|
| 341 |
+
outputs_embeds.append(out_emb)
|
| 342 |
+
|
| 343 |
+
start = end
|
| 344 |
+
else:
|
| 345 |
+
outputs_embeds.append(None)
|
| 346 |
+
|
| 347 |
+
inputs_embeds = outputs_embeds
|
| 348 |
+
|
| 349 |
+
# final norm
|
| 350 |
+
outputs_embeds = []
|
| 351 |
+
for i, hidden_states in enumerate(inputs_embeds):
|
| 352 |
+
if hidden_states is not None:
|
| 353 |
+
out_emb = models[i].norm(hidden_states)
|
| 354 |
+
outputs_embeds.append(out_emb)
|
| 355 |
+
else:
|
| 356 |
+
outputs_embeds.append(None)
|
| 357 |
+
|
| 358 |
+
return outputs_embeds, past_key_values
|
| 359 |
+
|
| 360 |
+
def get_attention_interface(self):
|
| 361 |
+
if self.config.attention_implementation == "fa2":
|
| 362 |
+
attention_interface = self.flash_attention_forward
|
| 363 |
+
elif self.config.attention_implementation == "flex":
|
| 364 |
+
# TODO
|
| 365 |
+
from .flex_attention import flex_attention_forward
|
| 366 |
+
attention_interface = flex_attention_forward
|
| 367 |
+
else:
|
| 368 |
+
attention_interface = self.eager_attention_forward
|
| 369 |
+
return attention_interface
|
| 370 |
+
|
| 371 |
+
def flash_attention_forward(
|
| 372 |
+
self, attention_mask, batch_size, head_dim, query_states, key_states, value_states
|
| 373 |
+
):
|
| 374 |
+
raise NotImplementedError("FA2 is not implemented (yet)")
|
| 375 |
+
|
| 376 |
+
def eager_attention_forward(
|
| 377 |
+
self, attention_mask, batch_size, head_dim, query_states, key_states, value_states
|
| 378 |
+
):
|
| 379 |
+
num_att_heads = self.config.paligemma_config.text_config.num_attention_heads
|
| 380 |
+
num_key_value_heads = self.config.paligemma_config.text_config.num_key_value_heads
|
| 381 |
+
num_key_value_groups = num_att_heads // num_key_value_heads
|
| 382 |
+
|
| 383 |
+
# query_states: batch_size, sequence_length, num_att_head, head_dim
|
| 384 |
+
# key_states: batch_size, sequence_length, num_key_value_head, head_dim
|
| 385 |
+
# value_states: batch_size, sequence_length, num_key_value_head, head_dim
|
| 386 |
+
sequence_length = key_states.shape[1]
|
| 387 |
+
|
| 388 |
+
key_states = key_states[:, :, :, None, :].expand(
|
| 389 |
+
batch_size, sequence_length, num_key_value_heads, num_key_value_groups, head_dim
|
| 390 |
+
)
|
| 391 |
+
key_states = key_states.reshape(
|
| 392 |
+
batch_size, sequence_length, num_key_value_heads * num_key_value_groups, head_dim
|
| 393 |
+
)
|
| 394 |
+
|
| 395 |
+
value_states = value_states[:, :, :, None, :].expand(
|
| 396 |
+
batch_size, sequence_length, num_key_value_heads, num_key_value_groups, head_dim
|
| 397 |
+
)
|
| 398 |
+
value_states = value_states.reshape(
|
| 399 |
+
batch_size, sequence_length, num_key_value_heads * num_key_value_groups, head_dim
|
| 400 |
+
)
|
| 401 |
+
|
| 402 |
+
# Attention here is upcasted to float32 to match the original eager implementation.
|
| 403 |
+
|
| 404 |
+
query_states = query_states.to(dtype=torch.float32)
|
| 405 |
+
key_states = key_states.to(dtype=torch.float32)
|
| 406 |
+
|
| 407 |
+
query_states = query_states.transpose(1, 2)
|
| 408 |
+
key_states = key_states.transpose(1, 2)
|
| 409 |
+
|
| 410 |
+
att_weights = torch.matmul(query_states, key_states.transpose(2, 3))
|
| 411 |
+
att_weights *= head_dim**-0.5
|
| 412 |
+
big_neg = -2.3819763e38 # See gemma/modules.py
|
| 413 |
+
|
| 414 |
+
masked_att_weights = torch.where(attention_mask[:, None, :, :], att_weights, big_neg)
|
| 415 |
+
|
| 416 |
+
probs = nn.functional.softmax(masked_att_weights, dim=-1)
|
| 417 |
+
probs = probs.to(dtype=value_states.dtype)
|
| 418 |
+
|
| 419 |
+
# probs: batch_size, num_key_value_head, num_att_head, sequence_length, sequence_length
|
| 420 |
+
# value_states: batch_size, sequence_length, num_att_heads, head_dim
|
| 421 |
+
|
| 422 |
+
att_output = torch.matmul(probs, value_states.permute(0, 2, 1, 3))
|
| 423 |
+
|
| 424 |
+
att_output = att_output.permute(0, 2, 1, 3)
|
| 425 |
+
# we use -1 because sequence length can change
|
| 426 |
+
att_output = att_output.reshape(batch_size, -1, num_key_value_heads * num_key_value_groups * head_dim)
|
| 427 |
+
|
| 428 |
+
return att_output
|
__todo__/_nn_legacy/pi0_flow_matching.py
ADDED
|
@@ -0,0 +1,423 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2025 Physical Intelligence and The HuggingFace Inc. team. All rights reserved.
|
| 2 |
+
#
|
| 3 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
# you may not use this file except in compliance with the License.
|
| 5 |
+
# You may obtain a copy of the License at
|
| 6 |
+
#
|
| 7 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
#
|
| 9 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
# See the License for the specific language governing permissions and
|
| 13 |
+
# limitations under the License.
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
import dataclasses
|
| 17 |
+
from typing import Literal
|
| 18 |
+
|
| 19 |
+
import torch
|
| 20 |
+
# TODO !!!!
|
| 21 |
+
from torch import Tensor, nn
|
| 22 |
+
import torch.nn.functional as F
|
| 23 |
+
|
| 24 |
+
from .paligemma_with_expert import PaliGemmaWithExpertModel, PaliGemmaWithExpertConfig
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
def get_safe_dtype(dtype: torch.dtype, device: torch.device | str):
|
| 28 |
+
"""
|
| 29 |
+
TODO
|
| 30 |
+
mps is currently not compatible with float64
|
| 31 |
+
"""
|
| 32 |
+
if isinstance(device, torch.device):
|
| 33 |
+
device = device.type
|
| 34 |
+
if device == "mps" and dtype == torch.float64:
|
| 35 |
+
return torch.float32
|
| 36 |
+
else:
|
| 37 |
+
return dtype
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
def create_sinusoidal_pos_embedding(
|
| 41 |
+
time: torch.Tensor, dimension: int, min_period: float, max_period: float, device: torch.device | str = "cpu"
|
| 42 |
+
) -> Tensor:
|
| 43 |
+
"""Computes sine-cosine positional embedding vectors for scalar positions."""
|
| 44 |
+
if dimension % 2 != 0:
|
| 45 |
+
raise ValueError(f"dimension ({dimension}) must be divisible by 2")
|
| 46 |
+
|
| 47 |
+
if time.ndim != 1:
|
| 48 |
+
raise ValueError("The time tensor is expected to be of shape `(batch_size, )`.")
|
| 49 |
+
|
| 50 |
+
device = torch.device(device)
|
| 51 |
+
dtype = get_safe_dtype(torch.float64, device.type)
|
| 52 |
+
fraction = torch.linspace(0.0, 1.0, dimension // 2, dtype=dtype, device=device)
|
| 53 |
+
period = min_period * (max_period / min_period) ** fraction
|
| 54 |
+
|
| 55 |
+
# Compute the outer product
|
| 56 |
+
scaling_factor = 1.0 / period * 2 * torch.pi
|
| 57 |
+
sin_input = scaling_factor[None, :] * time[:, None]
|
| 58 |
+
pos_emb = torch.cat([torch.sin(sin_input), torch.cos(sin_input)], dim=1)
|
| 59 |
+
return pos_emb
|
| 60 |
+
|
| 61 |
+
|
| 62 |
+
def sample_beta(alpha, beta, bsize, device):
|
| 63 |
+
gamma1 = torch.empty((bsize,), device=device).uniform_(0, 1).pow(1 / alpha)
|
| 64 |
+
gamma2 = torch.empty((bsize,), device=device).uniform_(0, 1).pow(1 / beta)
|
| 65 |
+
return gamma1 / (gamma1 + gamma2)
|
| 66 |
+
|
| 67 |
+
|
| 68 |
+
def make_att_2d_masks(pad_masks, att_masks):
|
| 69 |
+
"""Copied from big_vision.
|
| 70 |
+
|
| 71 |
+
Tokens can attend to valid inputs tokens which have a cumulative mask_ar
|
| 72 |
+
smaller or equal to theirs. This way `mask_ar` int[B, N] can be used to
|
| 73 |
+
setup several types of attention, for example:
|
| 74 |
+
|
| 75 |
+
[[1 1 1 1 1 1]]: pure causal attention.
|
| 76 |
+
|
| 77 |
+
[[0 0 0 1 1 1]]: prefix-lm attention. The first 3 tokens can attend between
|
| 78 |
+
themselves and the last 3 tokens have a causal attention. The first
|
| 79 |
+
entry could also be a 1 without changing behaviour.
|
| 80 |
+
|
| 81 |
+
[[1 0 1 0 1 0 0 1 0 0]]: causal attention between 4 blocks. Tokens of a
|
| 82 |
+
block can attend all previous blocks and all tokens on the same block.
|
| 83 |
+
|
| 84 |
+
Args:
|
| 85 |
+
input_mask: bool[B, N] true if its part of the input, false if padding.
|
| 86 |
+
mask_ar: int32[B, N] mask that's 1 where previous tokens cannot depend on
|
| 87 |
+
it and 0 where it shares the same attention mask as the previous token.
|
| 88 |
+
"""
|
| 89 |
+
if att_masks.ndim != 2:
|
| 90 |
+
raise ValueError(att_masks.ndim)
|
| 91 |
+
if pad_masks.ndim != 2:
|
| 92 |
+
raise ValueError(pad_masks.ndim)
|
| 93 |
+
|
| 94 |
+
cumsum = torch.cumsum(att_masks, dim=1)
|
| 95 |
+
att_2d_masks = cumsum[:, None, :] <= cumsum[:, :, None]
|
| 96 |
+
pad_2d_masks = pad_masks[:, None, :] * pad_masks[:, :, None]
|
| 97 |
+
att_2d_masks = att_2d_masks & pad_2d_masks
|
| 98 |
+
return att_2d_masks
|
| 99 |
+
|
| 100 |
+
|
| 101 |
+
|
| 102 |
+
class Pi0FlowMatching(nn.Module):
|
| 103 |
+
"""
|
| 104 |
+
π0: A Vision-Language-Action Flow Model for General Robot Control
|
| 105 |
+
|
| 106 |
+
[Paper](https://www.physicalintelligence.company/download/pi0.pdf)
|
| 107 |
+
[Jax code](https://github.com/Physical-Intelligence/openpi)
|
| 108 |
+
|
| 109 |
+
Designed by Physical Intelligence. Ported from Jax by Hugging Face.
|
| 110 |
+
┌──────────────────────────────┐
|
| 111 |
+
│ actions │
|
| 112 |
+
│ ▲ │
|
| 113 |
+
│ ┌┴─────┐ │
|
| 114 |
+
│ kv cache │Gemma │ │
|
| 115 |
+
│ ┌──────────►│Expert│ │
|
| 116 |
+
│ │ │ │ │
|
| 117 |
+
│ ┌┴────────┐ │x 10 │ │
|
| 118 |
+
│ │ │ └▲──▲──┘ │
|
| 119 |
+
│ │PaliGemma│ │ │ │
|
| 120 |
+
│ │ │ │ robot state │
|
| 121 |
+
│ │ │ noise │
|
| 122 |
+
│ └▲──▲─────┘ │
|
| 123 |
+
│ │ │ │
|
| 124 |
+
│ │ image(s) │
|
| 125 |
+
│ language tokens │
|
| 126 |
+
└──────────────────────���───────┘
|
| 127 |
+
"""
|
| 128 |
+
|
| 129 |
+
@dataclasses.dataclass
|
| 130 |
+
class Config:
|
| 131 |
+
# Finetuning settings
|
| 132 |
+
freeze_vision_encoder: bool = True
|
| 133 |
+
train_expert_only: bool = False
|
| 134 |
+
train_state_proj: bool = True
|
| 135 |
+
|
| 136 |
+
# TODO Shorter state and action vectors will be padded
|
| 137 |
+
max_state_dim: int = 32
|
| 138 |
+
max_action_dim: int = 32
|
| 139 |
+
# TODO
|
| 140 |
+
n_action_steps: int = 50
|
| 141 |
+
|
| 142 |
+
# TODO Projector
|
| 143 |
+
proj_width: int = 1024
|
| 144 |
+
|
| 145 |
+
# TODO
|
| 146 |
+
attention_implementation: Literal["eager", "fa2", "flex"] = "eager"
|
| 147 |
+
# TODO
|
| 148 |
+
use_cache: bool = True
|
| 149 |
+
|
| 150 |
+
# TODO Decoding
|
| 151 |
+
num_noising_steps: int = 10
|
| 152 |
+
|
| 153 |
+
def __init__(self, config: Config = Config()):
|
| 154 |
+
super().__init__()
|
| 155 |
+
self.config = config
|
| 156 |
+
|
| 157 |
+
paligemma_with_export_config = PaliGemmaWithExpertConfig(
|
| 158 |
+
freeze_vision_encoder=self.config.freeze_vision_encoder,
|
| 159 |
+
train_expert_only=self.config.train_expert_only,
|
| 160 |
+
attention_implementation=self.config.attention_implementation,
|
| 161 |
+
)
|
| 162 |
+
self.paligemma_with_expert = PaliGemmaWithExpertModel(paligemma_with_export_config)
|
| 163 |
+
|
| 164 |
+
# Projections are float32
|
| 165 |
+
self.state_proj = nn.Linear(self.config.max_state_dim, self.config.proj_width)
|
| 166 |
+
self.action_in_proj = nn.Linear(self.config.max_action_dim, self.config.proj_width)
|
| 167 |
+
self.action_out_proj = nn.Linear(self.config.proj_width, self.config.max_action_dim)
|
| 168 |
+
|
| 169 |
+
self.action_time_mlp_in = nn.Linear(self.config.proj_width * 2, self.config.proj_width)
|
| 170 |
+
self.action_time_mlp_out = nn.Linear(self.config.proj_width, self.config.proj_width)
|
| 171 |
+
|
| 172 |
+
self.set_requires_grad()
|
| 173 |
+
|
| 174 |
+
def set_requires_grad(self):
|
| 175 |
+
for params in self.state_proj.parameters():
|
| 176 |
+
params.requires_grad = self.config.train_state_proj
|
| 177 |
+
|
| 178 |
+
def sample_noise(self, shape, device):
|
| 179 |
+
noise = torch.normal(
|
| 180 |
+
mean=0.0,
|
| 181 |
+
std=1.0,
|
| 182 |
+
size=shape,
|
| 183 |
+
dtype=torch.float32,
|
| 184 |
+
device=device,
|
| 185 |
+
)
|
| 186 |
+
return noise
|
| 187 |
+
|
| 188 |
+
def sample_time(self, bsize, device):
|
| 189 |
+
time_beta = sample_beta(1.5, 1.0, bsize, device)
|
| 190 |
+
time = time_beta * 0.999 + 0.001
|
| 191 |
+
return time.to(dtype=torch.float32, device=device)
|
| 192 |
+
|
| 193 |
+
def embed_prefix(
|
| 194 |
+
self, images, img_masks, lang_tokens, lang_masks
|
| 195 |
+
) -> tuple[torch.Tensor, torch.Tensor, torch.Tensor]:
|
| 196 |
+
"""Embed images with SigLIP and language tokens with embedding layer to prepare
|
| 197 |
+
for PaliGemma transformer processing.
|
| 198 |
+
"""
|
| 199 |
+
# TODO: avoid list in python and torch.cat ; prefer pre-allocation with torch.empty
|
| 200 |
+
embs = []
|
| 201 |
+
pad_masks = []
|
| 202 |
+
att_masks = []
|
| 203 |
+
|
| 204 |
+
# TODO: remove for loop
|
| 205 |
+
for (
|
| 206 |
+
img,
|
| 207 |
+
img_mask,
|
| 208 |
+
) in zip(images, img_masks, strict=False):
|
| 209 |
+
img_emb = self.paligemma_with_expert.embed_image(img)
|
| 210 |
+
img_emb = img_emb.to(dtype=torch.bfloat16)
|
| 211 |
+
|
| 212 |
+
# Normalize image embeddings
|
| 213 |
+
img_emb_dim = img_emb.shape[-1]
|
| 214 |
+
img_emb = img_emb * torch.tensor(img_emb_dim**0.5, dtype=img_emb.dtype, device=img_emb.device)
|
| 215 |
+
|
| 216 |
+
bsize, num_img_embs = img_emb.shape[:2]
|
| 217 |
+
img_mask = img_mask[:, None].expand(bsize, num_img_embs)
|
| 218 |
+
|
| 219 |
+
embs.append(img_emb)
|
| 220 |
+
pad_masks.append(img_mask)
|
| 221 |
+
|
| 222 |
+
# Create attention masks so that image tokens attend to each other
|
| 223 |
+
att_masks += [0] * num_img_embs
|
| 224 |
+
|
| 225 |
+
lang_emb = self.paligemma_with_expert.embed_language_tokens(lang_tokens)
|
| 226 |
+
|
| 227 |
+
# Normalize language embeddings
|
| 228 |
+
lang_emb_dim = lang_emb.shape[-1]
|
| 229 |
+
lang_emb = lang_emb * torch.sqrt(lang_emb_dim)
|
| 230 |
+
|
| 231 |
+
embs.append(lang_emb)
|
| 232 |
+
pad_masks.append(lang_masks)
|
| 233 |
+
|
| 234 |
+
# full attention between image and language inputs
|
| 235 |
+
num_lang_embs = lang_emb.shape[1]
|
| 236 |
+
att_masks += [0] * num_lang_embs
|
| 237 |
+
|
| 238 |
+
embs = torch.cat(embs, dim=1)
|
| 239 |
+
pad_masks = torch.cat(pad_masks, dim=1)
|
| 240 |
+
att_masks = torch.tensor(att_masks, dtype=torch.bool, device=pad_masks.device)
|
| 241 |
+
att_masks = att_masks[None, :].expand(bsize, len(att_masks))
|
| 242 |
+
|
| 243 |
+
return embs, pad_masks, att_masks
|
| 244 |
+
|
| 245 |
+
def embed_suffix(self, state, noisy_actions, timestep):
|
| 246 |
+
"""Embed state, noisy_actions, timestep to prepare for Expert Gemma processing."""
|
| 247 |
+
embs = []
|
| 248 |
+
pad_masks = []
|
| 249 |
+
att_masks = []
|
| 250 |
+
|
| 251 |
+
# Embed state
|
| 252 |
+
state_emb = self.state_proj(state)
|
| 253 |
+
state_emb = state_emb.to(dtype=torch.bfloat16)
|
| 254 |
+
embs.append(state_emb[:, None, :])
|
| 255 |
+
bsize = state_emb.shape[0]
|
| 256 |
+
dtype = state_emb.dtype
|
| 257 |
+
device = state_emb.device
|
| 258 |
+
|
| 259 |
+
state_mask = torch.ones(bsize, 1, dtype=torch.bool, device=device)
|
| 260 |
+
pad_masks.append(state_mask)
|
| 261 |
+
|
| 262 |
+
# Set attention masks so that image and language inputs do not attend to state or actions
|
| 263 |
+
att_masks += [1]
|
| 264 |
+
|
| 265 |
+
# Embed timestep using sine-cosine positional encoding with sensitivity in the range [0, 1]
|
| 266 |
+
time_emb = create_sinusoidal_pos_embedding(
|
| 267 |
+
timestep, self.config.proj_width, min_period=4e-3, max_period=4.0, device=device
|
| 268 |
+
)
|
| 269 |
+
time_emb = time_emb.type(dtype=dtype)
|
| 270 |
+
|
| 271 |
+
# Fuse timestep + action information using an MLP
|
| 272 |
+
action_emb = self.action_in_proj(noisy_actions)
|
| 273 |
+
|
| 274 |
+
time_emb = time_emb[:, None, :].expand_as(action_emb)
|
| 275 |
+
action_time_emb = torch.cat([action_emb, time_emb], dim=2)
|
| 276 |
+
|
| 277 |
+
action_time_emb = self.action_time_mlp_in(action_time_emb)
|
| 278 |
+
action_time_emb = F.silu(action_time_emb) # swish == silu
|
| 279 |
+
action_time_emb = self.action_time_mlp_out(action_time_emb)
|
| 280 |
+
|
| 281 |
+
# Add to input tokens
|
| 282 |
+
embs.append(action_time_emb)
|
| 283 |
+
|
| 284 |
+
bsize, action_time_dim = action_time_emb.shape[:2]
|
| 285 |
+
action_time_mask = torch.ones(bsize, action_time_dim, dtype=torch.bool, device=device)
|
| 286 |
+
pad_masks.append(action_time_mask)
|
| 287 |
+
|
| 288 |
+
# Set attention masks so that image, language and state inputs do not attend to action tokens
|
| 289 |
+
att_masks += [1] + ([0] * (self.config.n_action_steps - 1))
|
| 290 |
+
|
| 291 |
+
embs = torch.cat(embs, dim=1)
|
| 292 |
+
pad_masks = torch.cat(pad_masks, dim=1)
|
| 293 |
+
att_masks = torch.tensor(att_masks, dtype=embs.dtype, device=embs.device)
|
| 294 |
+
att_masks = att_masks[None, :].expand(bsize, len(att_masks))
|
| 295 |
+
|
| 296 |
+
return embs, pad_masks, att_masks
|
| 297 |
+
|
| 298 |
+
# TODO req only images, texts, num_states
|
| 299 |
+
# TODO FIXME:standard ALSO forward SHOULD BE STRICTLY FOR INFERENCE!!!!! so no actions!!!! wtf!!!!
|
| 300 |
+
def forward(
|
| 301 |
+
self, images, img_masks, lang_tokens, lang_masks, state, actions, noise=None, time=None
|
| 302 |
+
) -> Tensor:
|
| 303 |
+
"""Do a full training forward pass and compute the loss (batch_size x num_steps x num_motors)"""
|
| 304 |
+
if noise is None:
|
| 305 |
+
noise = self.sample_noise(actions.shape, actions.device)
|
| 306 |
+
|
| 307 |
+
if time is None:
|
| 308 |
+
time = self.sample_time(actions.shape[0], actions.device)
|
| 309 |
+
|
| 310 |
+
time_expanded = time[:, None, None]
|
| 311 |
+
x_t = time_expanded * noise + (1 - time_expanded) * actions
|
| 312 |
+
u_t = noise - actions
|
| 313 |
+
|
| 314 |
+
prefix_embs, prefix_pad_masks, prefix_att_masks = self.embed_prefix(
|
| 315 |
+
images, img_masks, lang_tokens, lang_masks
|
| 316 |
+
)
|
| 317 |
+
suffix_embs, suffix_pad_masks, suffix_att_masks = self.embed_suffix(state, x_t, time)
|
| 318 |
+
|
| 319 |
+
pad_masks = torch.cat([prefix_pad_masks, suffix_pad_masks], dim=1)
|
| 320 |
+
att_masks = torch.cat([prefix_att_masks, suffix_att_masks], dim=1)
|
| 321 |
+
|
| 322 |
+
att_2d_masks = make_att_2d_masks(pad_masks, att_masks)
|
| 323 |
+
position_ids = torch.cumsum(pad_masks, dim=1) - 1
|
| 324 |
+
|
| 325 |
+
(_, suffix_out), _ = self.paligemma_with_expert.forward(
|
| 326 |
+
attention_mask=att_2d_masks,
|
| 327 |
+
position_ids=position_ids,
|
| 328 |
+
inputs_embeds=[prefix_embs, suffix_embs],
|
| 329 |
+
# TODO FIXME the current implementation sucks!!!!
|
| 330 |
+
past_key_values=None,
|
| 331 |
+
use_cache=False,
|
| 332 |
+
fill_kv_cache=False,
|
| 333 |
+
)
|
| 334 |
+
suffix_out = suffix_out[:, -self.config.n_action_steps :]
|
| 335 |
+
# Original openpi code, upcast attention output
|
| 336 |
+
suffix_out = suffix_out.to(dtype=torch.float32)
|
| 337 |
+
v_t = self.action_out_proj(suffix_out)
|
| 338 |
+
|
| 339 |
+
losses = F.mse_loss(u_t, v_t, reduction="none")
|
| 340 |
+
return losses
|
| 341 |
+
|
| 342 |
+
def sample_actions(self, images, img_masks, lang_tokens, lang_masks, state, noise=None) -> Tensor:
|
| 343 |
+
"""Do a full inference forward and compute the action (batch_size x num_steps x num_motors)"""
|
| 344 |
+
bsize = state.shape[0]
|
| 345 |
+
device = state.device
|
| 346 |
+
|
| 347 |
+
if noise is None:
|
| 348 |
+
actions_shape = (bsize, self.config.n_action_steps, self.config.max_action_dim)
|
| 349 |
+
noise = self.sample_noise(actions_shape, device)
|
| 350 |
+
|
| 351 |
+
prefix_embs, prefix_pad_masks, prefix_att_masks = self.embed_prefix(
|
| 352 |
+
images, img_masks, lang_tokens, lang_masks
|
| 353 |
+
)
|
| 354 |
+
prefix_att_2d_masks = make_att_2d_masks(prefix_pad_masks, prefix_att_masks)
|
| 355 |
+
prefix_position_ids = torch.cumsum(prefix_pad_masks, dim=1) - 1
|
| 356 |
+
|
| 357 |
+
# Compute image and language key value cache
|
| 358 |
+
_, past_key_values = self.paligemma_with_expert.forward(
|
| 359 |
+
attention_mask=prefix_att_2d_masks,
|
| 360 |
+
position_ids=prefix_position_ids,
|
| 361 |
+
inputs_embeds=[prefix_embs, None],
|
| 362 |
+
# TODO FIXME the current implementation sucks!!!!
|
| 363 |
+
past_key_values=None,
|
| 364 |
+
use_cache=self.config.use_cache,
|
| 365 |
+
fill_kv_cache=True,
|
| 366 |
+
)
|
| 367 |
+
|
| 368 |
+
dt = -1.0 / self.config.num_noising_steps
|
| 369 |
+
dt = torch.tensor(dt, dtype=torch.float32, device=device)
|
| 370 |
+
|
| 371 |
+
x_t = noise
|
| 372 |
+
time = torch.tensor(1.0, dtype=torch.float32, device=device)
|
| 373 |
+
while time >= -dt / 2:
|
| 374 |
+
expanded_time = time.expand(bsize)
|
| 375 |
+
v_t = self.denoise_step(
|
| 376 |
+
state,
|
| 377 |
+
prefix_pad_masks,
|
| 378 |
+
past_key_values,
|
| 379 |
+
x_t,
|
| 380 |
+
expanded_time,
|
| 381 |
+
)
|
| 382 |
+
|
| 383 |
+
# Euler step
|
| 384 |
+
x_t += dt * v_t
|
| 385 |
+
time += dt
|
| 386 |
+
return x_t
|
| 387 |
+
|
| 388 |
+
def denoise_step(
|
| 389 |
+
self,
|
| 390 |
+
state,
|
| 391 |
+
prefix_pad_masks,
|
| 392 |
+
past_key_values,
|
| 393 |
+
x_t,
|
| 394 |
+
timestep,
|
| 395 |
+
):
|
| 396 |
+
"""Apply one denoising step of the noise `x_t` at a given timestep."""
|
| 397 |
+
suffix_embs, suffix_pad_masks, suffix_att_masks = self.embed_suffix(state, x_t, timestep)
|
| 398 |
+
|
| 399 |
+
suffix_len = suffix_pad_masks.shape[1]
|
| 400 |
+
batch_size = prefix_pad_masks.shape[0]
|
| 401 |
+
prefix_len = prefix_pad_masks.shape[1]
|
| 402 |
+
prefix_pad_2d_masks = prefix_pad_masks[:, None, :].expand(batch_size, suffix_len, prefix_len)
|
| 403 |
+
|
| 404 |
+
suffix_att_2d_masks = make_att_2d_masks(suffix_pad_masks, suffix_att_masks)
|
| 405 |
+
|
| 406 |
+
full_att_2d_masks = torch.cat([prefix_pad_2d_masks, suffix_att_2d_masks], dim=2)
|
| 407 |
+
|
| 408 |
+
prefix_offsets = torch.sum(prefix_pad_masks, dim=-1)[:, None]
|
| 409 |
+
position_ids = prefix_offsets + torch.cumsum(suffix_pad_masks, dim=1) - 1
|
| 410 |
+
|
| 411 |
+
outputs_embeds, _ = self.paligemma_with_expert.forward(
|
| 412 |
+
attention_mask=full_att_2d_masks,
|
| 413 |
+
position_ids=position_ids,
|
| 414 |
+
past_key_values=past_key_values,
|
| 415 |
+
inputs_embeds=[None, suffix_embs],
|
| 416 |
+
use_cache=self.config.use_cache,
|
| 417 |
+
fill_kv_cache=False,
|
| 418 |
+
)
|
| 419 |
+
suffix_out = outputs_embeds[1]
|
| 420 |
+
suffix_out = suffix_out[:, -self.config.n_action_steps :]
|
| 421 |
+
suffix_out = suffix_out.to(dtype=torch.float32)
|
| 422 |
+
v_t = self.action_out_proj(suffix_out)
|
| 423 |
+
return v_t
|
demo-maniskill-motionplanning.ipynb → __todo__/demo-maniskill-motionplanning.ipynb
RENAMED
|
File without changes
|
__todo__/packages/robotodo.egg-info/PKG-INFO
DELETED
|
@@ -1,4 +0,0 @@
|
|
| 1 |
-
Metadata-Version: 2.4
|
| 2 |
-
Name: robotodo
|
| 3 |
-
Version: 0.0.0b0
|
| 4 |
-
Requires-Dist: sapien==3.0.0b1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
__todo__/packages/robotodo.egg-info/SOURCES.txt
DELETED
|
@@ -1,14 +0,0 @@
|
|
| 1 |
-
README.md
|
| 2 |
-
pyproject.toml
|
| 3 |
-
packages/robotodo/__init__.py
|
| 4 |
-
packages/robotodo.egg-info/PKG-INFO
|
| 5 |
-
packages/robotodo.egg-info/SOURCES.txt
|
| 6 |
-
packages/robotodo.egg-info/dependency_links.txt
|
| 7 |
-
packages/robotodo.egg-info/requires.txt
|
| 8 |
-
packages/robotodo.egg-info/top_level.txt
|
| 9 |
-
packages/robotodo/todos/_legacy.py
|
| 10 |
-
packages/robotodo/todos/placement_planners.py
|
| 11 |
-
packages/robotodo/todos/scene.py
|
| 12 |
-
packages/robotodo/utils/asset.py
|
| 13 |
-
packages/robotodo_assets/robotwin_objects/__init__.py
|
| 14 |
-
packages/robotodo_assets/unitree_robots/__init__.py
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
__todo__/packages/robotodo.egg-info/dependency_links.txt
DELETED
|
@@ -1 +0,0 @@
|
|
| 1 |
-
|
|
|
|
|
|
__todo__/packages/robotodo.egg-info/requires.txt
DELETED
|
@@ -1 +0,0 @@
|
|
| 1 |
-
sapien==3.0.0b1
|
|
|
|
|
|
__todo__/packages/robotodo.egg-info/top_level.txt
DELETED
|
@@ -1,2 +0,0 @@
|
|
| 1 |
-
robotodo
|
| 2 |
-
robotodo_assets
|
|
|
|
|
|
|
|
|
__todo__/packages/robotodo/__init__.py
DELETED
|
File without changes
|
__todo__/packages/robotodo/todos/_legacy.py
DELETED
|
@@ -1,352 +0,0 @@
|
|
| 1 |
-
import sapien
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
# TODO rm
|
| 6 |
-
def _todo_get_actor_dataset_entry(
|
| 7 |
-
# scene: sapien.Scene,
|
| 8 |
-
# pose: sapien.Pose,
|
| 9 |
-
modelname: str = "001_bottle",
|
| 10 |
-
# scale=(1, 1, 1),
|
| 11 |
-
# convex=False,
|
| 12 |
-
# is_static=False,
|
| 13 |
-
model_id=0,
|
| 14 |
-
):
|
| 15 |
-
from pathlib import Path
|
| 16 |
-
import json
|
| 17 |
-
|
| 18 |
-
def get_glb_or_obj_file(modeldir, model_id):
|
| 19 |
-
modeldir = Path(modeldir)
|
| 20 |
-
if model_id is None:
|
| 21 |
-
file = modeldir / "base.glb"
|
| 22 |
-
else:
|
| 23 |
-
file = modeldir / f"base{model_id}.glb"
|
| 24 |
-
if not file.exists():
|
| 25 |
-
if model_id is None:
|
| 26 |
-
file = modeldir / "textured.obj"
|
| 27 |
-
else:
|
| 28 |
-
file = modeldir / f"textured{model_id}.obj"
|
| 29 |
-
return file
|
| 30 |
-
|
| 31 |
-
modeldir = Path("assets/objects") / modelname
|
| 32 |
-
|
| 33 |
-
if model_id is None:
|
| 34 |
-
json_file_path = modeldir / "model_data.json"
|
| 35 |
-
else:
|
| 36 |
-
json_file_path = modeldir / f"model_data{model_id}.json"
|
| 37 |
-
|
| 38 |
-
# TODO !!!!!
|
| 39 |
-
collision_file = ""
|
| 40 |
-
visual_file = ""
|
| 41 |
-
if (modeldir / "collision").exists():
|
| 42 |
-
collision_file = get_glb_or_obj_file(modeldir / "collision", model_id)
|
| 43 |
-
if collision_file == "" or not collision_file.exists():
|
| 44 |
-
collision_file = get_glb_or_obj_file(modeldir, model_id)
|
| 45 |
-
|
| 46 |
-
if (modeldir / "visual").exists():
|
| 47 |
-
visual_file = get_glb_or_obj_file(modeldir / "visual", model_id)
|
| 48 |
-
if visual_file == "" or not visual_file.exists():
|
| 49 |
-
visual_file = get_glb_or_obj_file(modeldir, model_id)
|
| 50 |
-
|
| 51 |
-
if not collision_file.exists() or not visual_file.exists():
|
| 52 |
-
raise FileNotFoundError(f"Cannot find model files for {modelname} id={model_id}")
|
| 53 |
-
|
| 54 |
-
with open(json_file_path, "r") as file:
|
| 55 |
-
model_data = json.load(file)
|
| 56 |
-
|
| 57 |
-
return {
|
| 58 |
-
"metadata": model_data,
|
| 59 |
-
"collision_file": collision_file,
|
| 60 |
-
"visual_file": visual_file,
|
| 61 |
-
}
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
# # TODO
|
| 65 |
-
# _todo_get_actor_dataset_entry_entity(
|
| 66 |
-
# scene,
|
| 67 |
-
# model_name="001_bottle",
|
| 68 |
-
# model_id=16,
|
| 69 |
-
# # model_name="023_tissue-box",
|
| 70 |
-
# # model_id=0,
|
| 71 |
-
# convex=True,
|
| 72 |
-
# physical_material=physical_material,
|
| 73 |
-
# )
|
| 74 |
-
# _todo_robotwin_objects_create_entity(
|
| 75 |
-
# scene,
|
| 76 |
-
# id="001_bottle-16",
|
| 77 |
-
# )
|
| 78 |
-
|
| 79 |
-
# TODO rm
|
| 80 |
-
def _todo_get_actor_dataset_entry_entity(
|
| 81 |
-
scene: sapien.Scene,
|
| 82 |
-
model_name: str = "001_bottle",
|
| 83 |
-
model_id=0,
|
| 84 |
-
convex=False,
|
| 85 |
-
# TODO
|
| 86 |
-
# physical_type: str = "dynamic",
|
| 87 |
-
physical_material: sapien.physx.PhysxMaterial | None = None,
|
| 88 |
-
):
|
| 89 |
-
todo = _todo_get_actor_dataset_entry(modelname=model_name, model_id=model_id)
|
| 90 |
-
|
| 91 |
-
scale = todo["metadata"]["scale"]
|
| 92 |
-
collision_file = (todo["collision_file"])
|
| 93 |
-
visual_file = (todo["visual_file"])
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
builder = scene.create_actor_builder()
|
| 97 |
-
# TODO
|
| 98 |
-
builder.set_physx_body_type("dynamic")
|
| 99 |
-
|
| 100 |
-
if convex == True:
|
| 101 |
-
builder.add_multiple_convex_collisions_from_file(
|
| 102 |
-
filename=str(collision_file),
|
| 103 |
-
scale=scale,
|
| 104 |
-
material=physical_material,
|
| 105 |
-
)
|
| 106 |
-
else:
|
| 107 |
-
builder.add_nonconvex_collision_from_file(
|
| 108 |
-
filename=str(collision_file),
|
| 109 |
-
scale=scale,
|
| 110 |
-
material=physical_material,
|
| 111 |
-
)
|
| 112 |
-
|
| 113 |
-
builder.add_visual_from_file(filename=str(visual_file), scale=scale)
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
entity = builder.build(name=model_name)
|
| 117 |
-
# mesh.set_name(modelname)
|
| 118 |
-
# mesh.set_pose(pose)
|
| 119 |
-
# return Actor(mesh, model_data)
|
| 120 |
-
|
| 121 |
-
# TODO HACK!!!! set mass!!!!!
|
| 122 |
-
for component in entity.get_components():
|
| 123 |
-
if isinstance(component, sapien.physx.PhysxRigidDynamicComponent):
|
| 124 |
-
component.mass = 1.
|
| 125 |
-
# TODO !!!!
|
| 126 |
-
# component.inertia = [0., 0., 0.]
|
| 127 |
-
# component.put_to_sleep()
|
| 128 |
-
|
| 129 |
-
return entity
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
# # TODO rm
|
| 134 |
-
# def _todo_robotwin_objects_create_entity(scene: sapien.Scene, id: str = "001_bottle-2"):
|
| 135 |
-
# loader = scene.create_urdf_loader()
|
| 136 |
-
# loader.load_multiple_collisions_from_file = True
|
| 137 |
-
# _, [entity] = loader.load_multiple(f"__todo_assets__/assets/{id}/model.urdf")
|
| 138 |
-
# return entity
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
import types
|
| 144 |
-
from typing import TypedDict
|
| 145 |
-
|
| 146 |
-
import numpy
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
class ARX5Robot:
|
| 150 |
-
def __init__(self, scene: sapien.Scene):
|
| 151 |
-
self._scene = scene
|
| 152 |
-
|
| 153 |
-
# whole robot
|
| 154 |
-
loader = scene.create_urdf_loader()
|
| 155 |
-
loader.fix_root_link = True
|
| 156 |
-
# TODO args["left_embodiment_config"]["urdf_path"]
|
| 157 |
-
# TODO !!!!!!!! incl asset in package
|
| 158 |
-
self._entity = loader.load("./assets/embodiments/aloha-agilex/urdf/arx5_description_isaac.urdf")
|
| 159 |
-
# TODO args["left_embodiment_config"]["robot_pose"]
|
| 160 |
-
# TODO !!!!!
|
| 161 |
-
# self._entity.set_root_pose(
|
| 162 |
-
# sapien.Pose(p=[0, -0.65, 0.0], q=[0.707, 0, 0, 0.707])
|
| 163 |
-
# )
|
| 164 |
-
|
| 165 |
-
def _find_joint_by_name(articulation: sapien.physx.PhysxArticulation, joint_name: str):
|
| 166 |
-
joint = articulation.find_joint_by_name(joint_name)
|
| 167 |
-
if joint is None:
|
| 168 |
-
raise ValueError(f"Joint {joint_name} not found in the robot model.")
|
| 169 |
-
return joint
|
| 170 |
-
|
| 171 |
-
# joints (grouped by function)
|
| 172 |
-
self._joints = {
|
| 173 |
-
"left_arm": tuple(
|
| 174 |
-
_find_joint_by_name(self._entity, joint_name)
|
| 175 |
-
for joint_name in (
|
| 176 |
-
"fl_joint1",
|
| 177 |
-
"fl_joint2",
|
| 178 |
-
"fl_joint3",
|
| 179 |
-
"fl_joint4",
|
| 180 |
-
"fl_joint5",
|
| 181 |
-
"fl_joint6",
|
| 182 |
-
)
|
| 183 |
-
),
|
| 184 |
-
"right_arm": tuple(
|
| 185 |
-
_find_joint_by_name(self._entity, joint_name)
|
| 186 |
-
for joint_name in (
|
| 187 |
-
"fr_joint1",
|
| 188 |
-
"fr_joint2",
|
| 189 |
-
"fr_joint3",
|
| 190 |
-
"fr_joint4",
|
| 191 |
-
"fr_joint5",
|
| 192 |
-
"fr_joint6",
|
| 193 |
-
)
|
| 194 |
-
),
|
| 195 |
-
"left_gripper": tuple(
|
| 196 |
-
_find_joint_by_name(self._entity, joint_name)
|
| 197 |
-
for joint_name in (
|
| 198 |
-
"fl_joint7",
|
| 199 |
-
"fl_joint8",
|
| 200 |
-
)
|
| 201 |
-
),
|
| 202 |
-
"right_gripper": tuple(
|
| 203 |
-
_find_joint_by_name(self._entity, joint_name)
|
| 204 |
-
for joint_name in (
|
| 205 |
-
"fr_joint7",
|
| 206 |
-
"fr_joint8",
|
| 207 |
-
)
|
| 208 |
-
),
|
| 209 |
-
}
|
| 210 |
-
|
| 211 |
-
# TODO args["left_embodiment_config"]["arm_joints_name"]
|
| 212 |
-
# TODO args["left_embodiment_config"]["joint_stiffness"]
|
| 213 |
-
# TODO args["left_embodiment_config"]["joint_damping"]
|
| 214 |
-
for joint in (*self._joints["left_arm"], *self._joints["right_arm"]):
|
| 215 |
-
joint.set_drive_property(
|
| 216 |
-
stiffness=1_000,
|
| 217 |
-
damping=200,
|
| 218 |
-
)
|
| 219 |
-
|
| 220 |
-
# TODO args["left_embodiment_config"]["gripper_name"]
|
| 221 |
-
# TODO args["left_embodiment_config"]["gripper_stiffness"]
|
| 222 |
-
# TODO args["left_embodiment_config"]["gripper_damping"]
|
| 223 |
-
for joint in (*self._joints["left_gripper"], *self._joints["right_gripper"]):
|
| 224 |
-
joint.set_drive_property(
|
| 225 |
-
stiffness=1_000,
|
| 226 |
-
damping=200,
|
| 227 |
-
)
|
| 228 |
-
|
| 229 |
-
for link in self._entity.links:
|
| 230 |
-
link.set_mass(1)
|
| 231 |
-
|
| 232 |
-
# cameras
|
| 233 |
-
# TODO lifecycle mgmt: destroy when robot destroyed? upstream controllables
|
| 234 |
-
self._cameras = {
|
| 235 |
-
camera_link_name: self._scene.add_mounted_camera(
|
| 236 |
-
# TODO uuid bc the name cannot be used as an identifier!!!!!!???
|
| 237 |
-
name=f"{camera_link_name}",
|
| 238 |
-
mount=self._entity.find_link_by_name(camera_link_name).entity,
|
| 239 |
-
pose=sapien.Pose(),
|
| 240 |
-
width=640,
|
| 241 |
-
height=480,
|
| 242 |
-
fovy=numpy.deg2rad(93),
|
| 243 |
-
near=.1,
|
| 244 |
-
far=100.,
|
| 245 |
-
)
|
| 246 |
-
for camera_link_name in (
|
| 247 |
-
"left_camera",
|
| 248 |
-
"right_camera",
|
| 249 |
-
"camera_link1",
|
| 250 |
-
"camera_link2",
|
| 251 |
-
)
|
| 252 |
-
}
|
| 253 |
-
# TODO args['left_embodiment_config']['static_camera_list'] NOPE!!!
|
| 254 |
-
# replaces: key: "front_camera" => "waist_camera"; "head_camera"
|
| 255 |
-
# NOTE aliases
|
| 256 |
-
self._cameras["left_wrist_camera"] = self._cameras["left_camera"]
|
| 257 |
-
self._cameras["right_wrist_camera"] = self._cameras["right_camera"]
|
| 258 |
-
self._cameras["waist_camera"] = self._cameras["camera_link1"]
|
| 259 |
-
self._cameras["head_camera"] = self._cameras["camera_link2"]
|
| 260 |
-
|
| 261 |
-
class CameraDict(TypedDict):
|
| 262 |
-
left_wrist_camera: sapien.render.RenderCameraComponent
|
| 263 |
-
right_wrist_camera: sapien.render.RenderCameraComponent
|
| 264 |
-
waist_camera: sapien.render.RenderCameraComponent
|
| 265 |
-
head_camera: sapien.render.RenderCameraComponent
|
| 266 |
-
|
| 267 |
-
@property
|
| 268 |
-
def cameras(self) -> CameraDict:
|
| 269 |
-
return types.MappingProxyType(self._cameras)
|
| 270 |
-
|
| 271 |
-
class JointsDict(TypedDict):
|
| 272 |
-
left_arm: tuple[sapien.physx.PhysxArticulationJoint, ...]
|
| 273 |
-
right_arm: tuple[sapien.physx.PhysxArticulationJoint, ...]
|
| 274 |
-
left_gripper: tuple[sapien.physx.PhysxArticulationJoint, ...]
|
| 275 |
-
right_gripper: tuple[sapien.physx.PhysxArticulationJoint, ...]
|
| 276 |
-
|
| 277 |
-
@property
|
| 278 |
-
def joints(self) -> JointsDict:
|
| 279 |
-
return types.MappingProxyType(self._joints)
|
| 280 |
-
|
| 281 |
-
|
| 282 |
-
|
| 283 |
-
class UnitreeG1DFQRobot:
|
| 284 |
-
def __init__(self, scene: sapien.Scene):
|
| 285 |
-
self._scene = scene
|
| 286 |
-
|
| 287 |
-
loader = scene.create_urdf_loader()
|
| 288 |
-
loader.fix_root_link = True
|
| 289 |
-
# TODO args["left_embodiment_config"]["urdf_path"]
|
| 290 |
-
# TODO !!!!!!!! incl asset in package
|
| 291 |
-
self._entity = loader.load("__thirdparty__/unitree_ros/robots/g1_description/g1_29dof_rev_1_0_with_inspire_hand_DFQ.urdf")
|
| 292 |
-
# self._entity = loader.load("__thirdparty__/unitree_ros/robots/g1_description/g1_29dof_rev_1_0.urdf")
|
| 293 |
-
# TODO args["left_embodiment_config"]["robot_pose"]
|
| 294 |
-
self._entity.root_pose = (
|
| 295 |
-
# TODO
|
| 296 |
-
# sapien.Pose(p=[0., -0.65, 1.], q=[0.707, 0, 0, 0.707])
|
| 297 |
-
sapien.Pose(p=[0., 0., 1.])
|
| 298 |
-
)
|
| 299 |
-
|
| 300 |
-
self._joints = {
|
| 301 |
-
joint.name: joint
|
| 302 |
-
for joint in self._entity.joints
|
| 303 |
-
}
|
| 304 |
-
|
| 305 |
-
# TODO
|
| 306 |
-
self._cameras = {
|
| 307 |
-
camera_link_name: self._scene.add_mounted_camera(
|
| 308 |
-
# TODO uuid bc the name cannot be used as an identifier!!!!!!???
|
| 309 |
-
name=f"{camera_link_name}",
|
| 310 |
-
mount=self._entity.find_link_by_name(camera_link_name).entity,
|
| 311 |
-
pose=sapien.Pose(),
|
| 312 |
-
width=1280,
|
| 313 |
-
height=720,
|
| 314 |
-
# TODO
|
| 315 |
-
fovy=numpy.deg2rad(0),
|
| 316 |
-
near=.1,
|
| 317 |
-
far=100.,
|
| 318 |
-
)
|
| 319 |
-
for camera_link_name in (
|
| 320 |
-
"d435_link",
|
| 321 |
-
)
|
| 322 |
-
}
|
| 323 |
-
|
| 324 |
-
# TODO ref https://www.intel.com/content/www/us/en/support/articles/000030385/emerging-technologies/intel-realsense-technology.html
|
| 325 |
-
self._cameras["d435_link"].set_fovx(numpy.deg2rad(86), compute_y=False)
|
| 326 |
-
self._cameras["d435_link"].set_fovy(numpy.deg2rad(57), compute_x=False)
|
| 327 |
-
|
| 328 |
-
self._cameras["head_camera"] = self._cameras["d435_link"]
|
| 329 |
-
|
| 330 |
-
# # TODO !!!!!!!!
|
| 331 |
-
for link in self._entity.links:
|
| 332 |
-
link.set_mass(1)
|
| 333 |
-
|
| 334 |
-
@property
|
| 335 |
-
def root_pose(self):
|
| 336 |
-
return self._entity.root_pose
|
| 337 |
-
|
| 338 |
-
@root_pose.setter
|
| 339 |
-
def root_pose(self, value: sapien.Pose):
|
| 340 |
-
self._entity.root_pose = value
|
| 341 |
-
|
| 342 |
-
# TODO !!!!
|
| 343 |
-
@property
|
| 344 |
-
def joints(self): # TODO !!!!!!
|
| 345 |
-
return types.MappingProxyType(self._joints)
|
| 346 |
-
|
| 347 |
-
class CameraDict(TypedDict):
|
| 348 |
-
head_camera: sapien.render.RenderCameraComponent
|
| 349 |
-
|
| 350 |
-
@property
|
| 351 |
-
def cameras(self) -> CameraDict:
|
| 352 |
-
return types.MappingProxyType(self._cameras)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
__todo__/packages/robotodo/todos/scene.py
DELETED
|
@@ -1,434 +0,0 @@
|
|
| 1 |
-
# TODO rm
|
| 2 |
-
from ._legacy import _todo_get_actor_dataset_entry, _todo_get_actor_dataset_entry_entity, ARX5Robot, UnitreeG1DFQRobot
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
import sapien
|
| 7 |
-
|
| 8 |
-
def make_scene(options: dict = dict()):
|
| 9 |
-
engine = sapien.Engine()
|
| 10 |
-
# declare sapien renderer
|
| 11 |
-
# from sapien.render import set_global_config
|
| 12 |
-
# set_global_config(max_num_materials=50000, max_num_textures=50000)
|
| 13 |
-
|
| 14 |
-
# TODO
|
| 15 |
-
renderer = sapien.SapienRenderer()
|
| 16 |
-
engine.set_renderer(renderer)
|
| 17 |
-
|
| 18 |
-
# sapien.render.set_camera_shader_dir("rt")
|
| 19 |
-
# sapien.render.set_ray_tracing_samples_per_pixel(32)
|
| 20 |
-
# sapien.render.set_ray_tracing_path_depth(8)
|
| 21 |
-
# sapien.render.set_ray_tracing_denoiser("oidn")
|
| 22 |
-
|
| 23 |
-
scene_config = sapien.SceneConfig()
|
| 24 |
-
# TODO
|
| 25 |
-
# scene_config.gravity = options.get("gravity", [0, 0, -9.81])
|
| 26 |
-
|
| 27 |
-
scene = engine.create_scene(scene_config)
|
| 28 |
-
# TODO
|
| 29 |
-
# scene.set_timestep(options.get("timestep", 1 / 250))
|
| 30 |
-
scene.add_ground(options.get("ground_height", 0))
|
| 31 |
-
# TODO used by `create_box`!!!!!
|
| 32 |
-
# scene.default_physical_material = scene.create_physical_material(
|
| 33 |
-
# options.get("static_friction", 0.5),
|
| 34 |
-
# options.get("dynamic_friction", 0.5),
|
| 35 |
-
# options.get("restitution", 0),
|
| 36 |
-
# )
|
| 37 |
-
|
| 38 |
-
scene.set_ambient_light(
|
| 39 |
-
options.get("ambient_light", [0.5, 0.5, 0.5])
|
| 40 |
-
)
|
| 41 |
-
|
| 42 |
-
return scene
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
class LightingController:
|
| 47 |
-
def __init__(self, scene: sapien.Scene):
|
| 48 |
-
self.scene = scene
|
| 49 |
-
|
| 50 |
-
# TODO
|
| 51 |
-
options = dict()
|
| 52 |
-
|
| 53 |
-
# TODO
|
| 54 |
-
self.scene.set_ambient_light(
|
| 55 |
-
options.get("ambient_light", [0.5, 0.5, 0.5])
|
| 56 |
-
)
|
| 57 |
-
|
| 58 |
-
# TODO #########################
|
| 59 |
-
random_light = True
|
| 60 |
-
# default enable shadow unless specified otherwise
|
| 61 |
-
enable_shadow = options.get("enable_shadow", True)
|
| 62 |
-
# default spotlight angle and intensity
|
| 63 |
-
direction_lights = options.get("direction_lights", [[[0, 0.5, -1], [0.5, 0.5, 0.5]]])
|
| 64 |
-
self.direction_light_lst = []
|
| 65 |
-
|
| 66 |
-
# TODO
|
| 67 |
-
import numpy as np
|
| 68 |
-
|
| 69 |
-
for direction_light in direction_lights:
|
| 70 |
-
if random_light:
|
| 71 |
-
direction_light[1] = [
|
| 72 |
-
np.random.rand(),
|
| 73 |
-
np.random.rand(),
|
| 74 |
-
np.random.rand(),
|
| 75 |
-
]
|
| 76 |
-
self.direction_light_lst.append(
|
| 77 |
-
self.scene.add_directional_light(direction_light[0], direction_light[1], shadow=enable_shadow))
|
| 78 |
-
# default point lights position and intensity
|
| 79 |
-
point_lights = options.get("point_lights", [[[1, 0, 1.8], [1, 1, 1]], [[-1, 0, 1.8], [1, 1, 1]]])
|
| 80 |
-
self.point_light_lst = []
|
| 81 |
-
for point_light in point_lights:
|
| 82 |
-
if random_light:
|
| 83 |
-
point_light[1] = [np.random.rand(), np.random.rand(), np.random.rand()]
|
| 84 |
-
self.point_light_lst.append(self.scene.add_point_light(point_light[0], point_light[1], shadow=enable_shadow))
|
| 85 |
-
# #########################
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
# TODO !!!!!
|
| 90 |
-
def _todo_get_textured_render_material() -> sapien.render.RenderMaterial:
|
| 91 |
-
texture2d = sapien.render.RenderTexture2D(
|
| 92 |
-
f"./assets/background_texture/seen/0.png"
|
| 93 |
-
)
|
| 94 |
-
material = sapien.render.RenderMaterial()
|
| 95 |
-
material.set_base_color_texture(texture2d)
|
| 96 |
-
material.base_color = [1, 1, 1, 1]
|
| 97 |
-
material.metallic = 0.1
|
| 98 |
-
material.roughness = 0.3
|
| 99 |
-
return material
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
# TODO tabletop color=(1, 1, 1); wall color=(1, 0.9, 0.9)
|
| 103 |
-
def _todo_get_plain_render_material(color=(1, 1, 1)) -> sapien.render.RenderMaterial:
|
| 104 |
-
return sapien.render.RenderMaterial(base_color=[*color[:3], 1])
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
def _todo_create_observer_camera(scene: sapien.Scene):
|
| 111 |
-
import numpy
|
| 112 |
-
|
| 113 |
-
# near, far = 0.1, 100
|
| 114 |
-
# width, height = 640, 480
|
| 115 |
-
# camera = self.scene.add_camera(
|
| 116 |
-
# # TODO
|
| 117 |
-
# name="camera",
|
| 118 |
-
# width=width,
|
| 119 |
-
# height=height,
|
| 120 |
-
# fovy=numpy.deg2rad(90),
|
| 121 |
-
# near=near,
|
| 122 |
-
# far=far,
|
| 123 |
-
# )
|
| 124 |
-
# camera.set_pose(sapien.Pose(p=[1, 0, 0]))
|
| 125 |
-
|
| 126 |
-
# observer camera
|
| 127 |
-
import numpy as np
|
| 128 |
-
|
| 129 |
-
observer_camera = scene.add_camera(
|
| 130 |
-
name="observer_camera",
|
| 131 |
-
width=640,
|
| 132 |
-
height=480,
|
| 133 |
-
fovy=np.deg2rad(93),
|
| 134 |
-
near=.1,
|
| 135 |
-
far=100,
|
| 136 |
-
)
|
| 137 |
-
# TODO
|
| 138 |
-
# observer_cam_pos = np.array([0.0, -0.23, 1.33])
|
| 139 |
-
observer_cam_pos = np.array([0.0, 0.5, 1.5])
|
| 140 |
-
# observer_cam_forward = np.array([0, -1, -1.02])
|
| 141 |
-
observer_cam_forward = np.array([0, -2, -1.02])
|
| 142 |
-
# observer_cam_left = np.array([1,-1, 0])
|
| 143 |
-
observer_cam_left = np.array([1, 0, 0])
|
| 144 |
-
observer_up = np.cross(observer_cam_forward, observer_cam_left)
|
| 145 |
-
observer_mat44 = np.eye(4)
|
| 146 |
-
observer_mat44[:3, :3] = np.stack([observer_cam_forward, observer_cam_left, observer_up], axis=1)
|
| 147 |
-
observer_mat44[:3, 3] = observer_cam_pos
|
| 148 |
-
observer_camera.entity.set_pose(sapien.Pose(observer_mat44))
|
| 149 |
-
|
| 150 |
-
return observer_camera
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
import numpy
|
| 159 |
-
|
| 160 |
-
class Wall:
|
| 161 |
-
def __init__(
|
| 162 |
-
self,
|
| 163 |
-
scene: sapien.Scene,
|
| 164 |
-
|
| 165 |
-
pose: sapien.Pose = sapien.Pose(p=[0, 1, 1.5]),
|
| 166 |
-
|
| 167 |
-
width: float = 6,
|
| 168 |
-
height: float = 3,
|
| 169 |
-
thickness: float = 1.2,
|
| 170 |
-
|
| 171 |
-
# TODO scene.default_physical_material
|
| 172 |
-
physical_material: sapien.physx.PhysxMaterial | None = None,
|
| 173 |
-
# TODO material gallery/dataset??? call _todo_get_*_render_material color=(1, 0.9, 0.9),
|
| 174 |
-
render_material: sapien.render.RenderMaterial | None = None,
|
| 175 |
-
# TODO ##################################
|
| 176 |
-
name: str | None = "wall", # TODO
|
| 177 |
-
# ##################################
|
| 178 |
-
|
| 179 |
-
):
|
| 180 |
-
# TODO
|
| 181 |
-
half_size = numpy.array([width, thickness, height]) / 2
|
| 182 |
-
|
| 183 |
-
builder: sapien.ActorBuilder = scene.create_actor_builder()
|
| 184 |
-
builder.physx_body_type = "static"
|
| 185 |
-
builder.add_box_collision(half_size=half_size, material=physical_material)
|
| 186 |
-
builder.add_box_visual(half_size=half_size, material=render_material)
|
| 187 |
-
builder.initial_pose = pose
|
| 188 |
-
|
| 189 |
-
self._entity = builder.build(name=name)
|
| 190 |
-
|
| 191 |
-
# TODO scene.add_entity????
|
| 192 |
-
# scene.add_entity(self._entity)
|
| 193 |
-
|
| 194 |
-
|
| 195 |
-
|
| 196 |
-
import types
|
| 197 |
-
from typing import Literal, TypedDict, Iterable
|
| 198 |
-
|
| 199 |
-
import numpy
|
| 200 |
-
import gymnasium.spaces
|
| 201 |
-
|
| 202 |
-
# TODO
|
| 203 |
-
class Table:
|
| 204 |
-
def __init__(
|
| 205 |
-
self,
|
| 206 |
-
scene: sapien.Scene,
|
| 207 |
-
|
| 208 |
-
# pose: sapien.Pose = sapien.Pose(p=[0, 0, .74]),
|
| 209 |
-
# TODO NOTE pose relative to bottom
|
| 210 |
-
pose: sapien.Pose = sapien.Pose(p=[0, 0, 0]),
|
| 211 |
-
|
| 212 |
-
# TODO expose self.*
|
| 213 |
-
# TODO robotwin defaults below
|
| 214 |
-
# length: float = 1.2,
|
| 215 |
-
# width: float = .7,
|
| 216 |
-
# height: float = .74,
|
| 217 |
-
# thickness: float = .05,
|
| 218 |
-
|
| 219 |
-
length: float = 1.,
|
| 220 |
-
width: float = 1.,
|
| 221 |
-
height: float = 1.,
|
| 222 |
-
thickness: float = .05,
|
| 223 |
-
|
| 224 |
-
physical_type: Literal["static", "dynamic"] = "static",
|
| 225 |
-
# TODO scene.default_physical_material
|
| 226 |
-
physical_material: sapien.physx.PhysxMaterial | None = None,
|
| 227 |
-
# TODO material gallery/dataset??? call _todo_get_*_render_material
|
| 228 |
-
render_material: sapien.render.RenderMaterial | None = None,
|
| 229 |
-
# TODO ##################################
|
| 230 |
-
name: str | None = "table", # TODO
|
| 231 |
-
# ##################################
|
| 232 |
-
|
| 233 |
-
) -> sapien.Entity:
|
| 234 |
-
|
| 235 |
-
builder = scene.create_actor_builder()
|
| 236 |
-
builder.physx_body_type = physical_type # TODO "dynamic"? is_static?
|
| 237 |
-
|
| 238 |
-
# Table legs (x4)
|
| 239 |
-
for i in [-1, 1]:
|
| 240 |
-
for j in [-1, 1]:
|
| 241 |
-
x = i * (length - thickness) / 2
|
| 242 |
-
y = j * (width - thickness) / 2
|
| 243 |
-
table_leg_pose = sapien.Pose([x, y, height / 2])
|
| 244 |
-
table_leg_half_size = [thickness / 2, thickness / 2, height / 2]
|
| 245 |
-
# TODO upstream: obtain ref to the collision/viz shape!!!!!!!
|
| 246 |
-
builder.add_box_collision(
|
| 247 |
-
pose=table_leg_pose,
|
| 248 |
-
half_size=table_leg_half_size,
|
| 249 |
-
)
|
| 250 |
-
builder.add_box_visual(
|
| 251 |
-
pose=table_leg_pose,
|
| 252 |
-
half_size=table_leg_half_size,
|
| 253 |
-
material=render_material,
|
| 254 |
-
)
|
| 255 |
-
|
| 256 |
-
# Tabletop
|
| 257 |
-
tabletop_pose = sapien.Pose([0.0, 0.0, height + thickness / 2]) # Center the tabletop at z=0
|
| 258 |
-
tabletop_half_size = [length / 2, width / 2, thickness / 2]
|
| 259 |
-
builder.add_box_collision(
|
| 260 |
-
pose=tabletop_pose,
|
| 261 |
-
half_size=tabletop_half_size,
|
| 262 |
-
material=physical_material,
|
| 263 |
-
)
|
| 264 |
-
builder.add_box_visual(
|
| 265 |
-
pose=tabletop_pose,
|
| 266 |
-
half_size=tabletop_half_size,
|
| 267 |
-
material=render_material,
|
| 268 |
-
)
|
| 269 |
-
|
| 270 |
-
# TODO
|
| 271 |
-
# leg_spacing = 0.1
|
| 272 |
-
# for i in [-1, 1]:
|
| 273 |
-
# for j in [-1, 1]:
|
| 274 |
-
# x = i * (length / 2 - leg_spacing / 2)
|
| 275 |
-
# y = j * (width / 2 - leg_spacing / 2)
|
| 276 |
-
# table_leg_pose = sapien.Pose([x, y, -height / 2 - 0.002])
|
| 277 |
-
# table_leg_half_size = [thickness / 2, thickness / 2, height / 2 - 0.002]
|
| 278 |
-
# builder.add_box_collision(pose=table_leg_pose, half_size=table_leg_half_size)
|
| 279 |
-
# builder.add_box_visual(
|
| 280 |
-
# pose=table_leg_pose,
|
| 281 |
-
# half_size=table_leg_half_size,
|
| 282 |
-
# material=render_material,
|
| 283 |
-
# )
|
| 284 |
-
|
| 285 |
-
builder.set_initial_pose(pose)
|
| 286 |
-
|
| 287 |
-
# builder.set_mass_and_inertia(
|
| 288 |
-
# mass=10,
|
| 289 |
-
# cmass_local_pose=sapien.Pose([0, 0, 0]),
|
| 290 |
-
# inertia=[0, 0, 0],
|
| 291 |
-
# )
|
| 292 |
-
|
| 293 |
-
self._scene = scene
|
| 294 |
-
self._entity = builder.build(name=name)
|
| 295 |
-
# TODO !!!!!
|
| 296 |
-
# scene.add_entity(self._entity)
|
| 297 |
-
|
| 298 |
-
self._key_poses_local = {
|
| 299 |
-
"tablefront": sapien.Pose(
|
| 300 |
-
p=[0, -width / 2, 0],
|
| 301 |
-
q=[-1, 0, 0, -1],
|
| 302 |
-
),
|
| 303 |
-
}
|
| 304 |
-
|
| 305 |
-
class KeyPosesDict(TypedDict):
|
| 306 |
-
tablefront: sapien.Pose
|
| 307 |
-
|
| 308 |
-
@property
|
| 309 |
-
def pose(self):
|
| 310 |
-
return self._entity.pose
|
| 311 |
-
|
| 312 |
-
@pose.setter
|
| 313 |
-
def pose(self, value: sapien.Pose):
|
| 314 |
-
self._entity.pose = value
|
| 315 |
-
|
| 316 |
-
# TODO
|
| 317 |
-
@property
|
| 318 |
-
def key_poses_local(self) -> KeyPosesDict:
|
| 319 |
-
return types.MappingProxyType(self._key_poses_local)
|
| 320 |
-
|
| 321 |
-
@property
|
| 322 |
-
def _bbox_global(self):
|
| 323 |
-
for component in self._entity.components:
|
| 324 |
-
if isinstance(component, sapien.physx.PhysxRigidBaseComponent):
|
| 325 |
-
# TODO use component.collision_shapes !!!!
|
| 326 |
-
return component.compute_global_aabb_tight()
|
| 327 |
-
raise ValueError("No PhysxRigidBaseComponent found in entity.")
|
| 328 |
-
|
| 329 |
-
# TODO doesnt work if table is rotated!!!!!!!
|
| 330 |
-
# TODO x y z
|
| 331 |
-
@property
|
| 332 |
-
def tabletop_pos_space(self):
|
| 333 |
-
# TODO NOTE ...
|
| 334 |
-
|
| 335 |
-
table_pos_low, table_pos_high = self._bbox_global
|
| 336 |
-
return gymnasium.spaces.Box(
|
| 337 |
-
low=numpy.array([table_pos_low[0], table_pos_low[1], table_pos_high[2]]),
|
| 338 |
-
high=numpy.array([table_pos_high[0], table_pos_high[1], table_pos_high[2]]),
|
| 339 |
-
)
|
| 340 |
-
|
| 341 |
-
@property
|
| 342 |
-
def tabletop_entities(self):
|
| 343 |
-
# TODO !!!!!!
|
| 344 |
-
|
| 345 |
-
entities: set[sapien.Entity] = set()
|
| 346 |
-
|
| 347 |
-
# TODO upstream typing
|
| 348 |
-
contacts: list[sapien.physx.PhysxContact] = self._scene.get_contacts()
|
| 349 |
-
for contact in contacts:
|
| 350 |
-
table_contact_components: set[sapien.Component] = set(contact.bodies) - set(self._entity.components)
|
| 351 |
-
if len(table_contact_components) == 0:
|
| 352 |
-
continue
|
| 353 |
-
|
| 354 |
-
for point in contact.points:
|
| 355 |
-
if (point.position - point.separation) in self.tabletop_pos_space:
|
| 356 |
-
entities.update(component.entity for component in table_contact_components)
|
| 357 |
-
break
|
| 358 |
-
|
| 359 |
-
return entities
|
| 360 |
-
|
| 361 |
-
# TODO rm
|
| 362 |
-
# return [
|
| 363 |
-
# entity
|
| 364 |
-
# for entity in self._entity.scene.entities
|
| 365 |
-
# if entity != self._entity and entity.pose.p in self.tabletop_pos_space
|
| 366 |
-
# ]
|
| 367 |
-
|
| 368 |
-
# TODO !!!!!!
|
| 369 |
-
def scatter_entities_on_tabletop(
|
| 370 |
-
self,
|
| 371 |
-
entities: Iterable[sapien.Entity],
|
| 372 |
-
out_of_space_behavior: Literal["abort", "ignore", "raise"] = "ignore",
|
| 373 |
-
) -> list[sapien.Entity]:
|
| 374 |
-
"""
|
| 375 |
-
TODO doc: return placed entities ONLY
|
| 376 |
-
|
| 377 |
-
"""
|
| 378 |
-
|
| 379 |
-
# TODO
|
| 380 |
-
import shapely
|
| 381 |
-
from .placement_planners import _todo_place_polygon_randomly
|
| 382 |
-
|
| 383 |
-
def _todo_aabb_from_sapien_entity(entity: sapien.Entity):
|
| 384 |
-
# TODO simplify; handle multiple components!!!!!
|
| 385 |
-
for component in entity.components:
|
| 386 |
-
if isinstance(component, sapien.physx.PhysxRigidBaseComponent):
|
| 387 |
-
return component.compute_global_aabb_tight()
|
| 388 |
-
|
| 389 |
-
def _todo_polygon_from_sapien_entity(entity: sapien.Entity):
|
| 390 |
-
# TODO simplify !!!!!!
|
| 391 |
-
(x_min, y_min, z_min), (x_max, y_max, z_max) = _todo_aabb_from_sapien_entity(entity)
|
| 392 |
-
return shapely.geometry.box(x_min, y_min, x_max, y_max)
|
| 393 |
-
|
| 394 |
-
placed_entities = []
|
| 395 |
-
collisions = [
|
| 396 |
-
_todo_polygon_from_sapien_entity(entity)
|
| 397 |
-
for entity in self.tabletop_entities
|
| 398 |
-
]
|
| 399 |
-
|
| 400 |
-
for entity in entities:
|
| 401 |
-
res = _todo_place_polygon_randomly(
|
| 402 |
-
_todo_polygon_from_sapien_entity(entity),
|
| 403 |
-
surface=shapely.box(
|
| 404 |
-
# TODO simplify; readablility: .low[["x", "y"]]
|
| 405 |
-
*self.tabletop_pos_space.low[[0, 1]],
|
| 406 |
-
*self.tabletop_pos_space.high[[0, 1]],
|
| 407 |
-
),
|
| 408 |
-
# TODO
|
| 409 |
-
collisions=collisions,
|
| 410 |
-
)
|
| 411 |
-
# NOTE TODO out of space; try another
|
| 412 |
-
if res is None:
|
| 413 |
-
match out_of_space_behavior:
|
| 414 |
-
case "abort":
|
| 415 |
-
break
|
| 416 |
-
case "raise":
|
| 417 |
-
raise RuntimeError(f"Out of space. Failed to place entity {entity} on table.")
|
| 418 |
-
case "ignore":
|
| 419 |
-
continue
|
| 420 |
-
raise ValueError(f"Unknown out of space behavior: {out_of_space_behavior}")
|
| 421 |
-
# TODO NOTE alt: derive collision from scene - maybe unreliable
|
| 422 |
-
collisions += [res.placed_polygon]
|
| 423 |
-
|
| 424 |
-
# TODO simplify!!!!!!
|
| 425 |
-
xyzmin, xyzmax = _todo_aabb_from_sapien_entity(entity)
|
| 426 |
-
_, _, z_half = (xyzmax - xyzmin) / 2
|
| 427 |
-
|
| 428 |
-
# TODO simplify; no offset!!!
|
| 429 |
-
pose = sapien.Pose([res.transform.x, res.transform.y, self.tabletop_pos_space.low[2] + z_half])
|
| 430 |
-
pose.set_rpy([0, 0, res.transform.angle_rad])
|
| 431 |
-
entity.set_pose(pose)
|
| 432 |
-
placed_entities += [entity]
|
| 433 |
-
|
| 434 |
-
return placed_entities
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
__todo__/packages/robotodo/utils/asset.py
DELETED
|
@@ -1,88 +0,0 @@
|
|
| 1 |
-
"""
|
| 2 |
-
TODO asset loading specification? standardization for robotodo_assets?
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
"""
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
import os
|
| 9 |
-
import pathlib
|
| 10 |
-
from typing import Any, Literal, Optional, TypedDict, Iterable, TypeAlias
|
| 11 |
-
|
| 12 |
-
# TODO
|
| 13 |
-
import json
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
MetadataObjectOrPath: TypeAlias = """
|
| 18 |
-
os.PathLike
|
| 19 |
-
| MetadataCatalog
|
| 20 |
-
| MetadataResource
|
| 21 |
-
"""
|
| 22 |
-
|
| 23 |
-
class MetadataResource(TypedDict):
|
| 24 |
-
type: Optional[Literal["resource"]]
|
| 25 |
-
base_path: Optional[os.PathLike] # TODO or url!!!!!
|
| 26 |
-
content: Optional[Any]
|
| 27 |
-
# TODO unused for now !!!!!!!
|
| 28 |
-
id: Optional[str]
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
class MetadataCatalog(TypedDict):
|
| 32 |
-
type: Literal["catalog"]
|
| 33 |
-
base_path: Optional[os.PathLike] # TODO or url!!!!!
|
| 34 |
-
includes: Optional[list[MetadataObjectOrPath]] # TODO url!!!!!
|
| 35 |
-
|
| 36 |
-
class MetadataResourceLoader:
|
| 37 |
-
"""
|
| 38 |
-
TODO doc metadata data structures!!!!
|
| 39 |
-
|
| 40 |
-
"""
|
| 41 |
-
|
| 42 |
-
# TODO find resource by id????
|
| 43 |
-
|
| 44 |
-
# TODO
|
| 45 |
-
def __call__(
|
| 46 |
-
self,
|
| 47 |
-
metadata_or_path: MetadataObjectOrPath,
|
| 48 |
-
base_path: os.PathLike | None = None,
|
| 49 |
-
) -> Iterable[MetadataResource]:
|
| 50 |
-
"""
|
| 51 |
-
TODO
|
| 52 |
-
"""
|
| 53 |
-
|
| 54 |
-
if isinstance(metadata_or_path, dict):
|
| 55 |
-
metadata = dict(metadata_or_path)
|
| 56 |
-
match metadata.get("type", "resource"):
|
| 57 |
-
case "resource":
|
| 58 |
-
metadata: MetadataResource
|
| 59 |
-
yield {
|
| 60 |
-
**metadata,
|
| 61 |
-
"base_path": os.fspath(
|
| 62 |
-
pathlib.Path(base_path or "")
|
| 63 |
-
/ (metadata.get("base_path") or "")
|
| 64 |
-
),
|
| 65 |
-
}
|
| 66 |
-
return
|
| 67 |
-
case "catalog":
|
| 68 |
-
metadata: MetadataCatalog
|
| 69 |
-
# TODO
|
| 70 |
-
for include in metadata.get("includes") or []:
|
| 71 |
-
# TODO
|
| 72 |
-
yield from self.__call__(
|
| 73 |
-
include,
|
| 74 |
-
base_path=base_path,
|
| 75 |
-
)
|
| 76 |
-
return
|
| 77 |
-
|
| 78 |
-
if isinstance(metadata_or_path, (str, bytes, os.PathLike)):
|
| 79 |
-
metadata_path = pathlib.Path(base_path or "") / os.fspath(metadata_or_path)
|
| 80 |
-
with open(os.fspath(metadata_path), "r") as f:
|
| 81 |
-
yield from self.__call__(
|
| 82 |
-
json.load(f),
|
| 83 |
-
base_path=metadata_path.parent,
|
| 84 |
-
)
|
| 85 |
-
return
|
| 86 |
-
|
| 87 |
-
raise ValueError(f"Invalid metadata (or path) of type {type(metadata_or_path)}: {metadata_or_path}")
|
| 88 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
__todo__/packages/robotodo_assets/robotwin_objects/__init__.py
DELETED
|
@@ -1,76 +0,0 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
import os
|
| 7 |
-
import pathlib
|
| 8 |
-
import types
|
| 9 |
-
from typing import TypedDict
|
| 10 |
-
import importlib.resources
|
| 11 |
-
|
| 12 |
-
import numpy
|
| 13 |
-
import sapien
|
| 14 |
-
|
| 15 |
-
from robotodo.utils.asset import MetadataResourceLoader
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
# TODO
|
| 19 |
-
class RobotwinObjectInfo(TypedDict):
|
| 20 |
-
id: str
|
| 21 |
-
category: str
|
| 22 |
-
model_path: pathlib.Path
|
| 23 |
-
contact_transforms: list[numpy.ndarray]
|
| 24 |
-
target_transforms: list[numpy.ndarray]
|
| 25 |
-
functional_transforms: list[numpy.ndarray]
|
| 26 |
-
orientation_transforms: list[numpy.ndarray]
|
| 27 |
-
|
| 28 |
-
# TODO
|
| 29 |
-
class RobotwinEntityFactory:
|
| 30 |
-
def __init__(self):
|
| 31 |
-
# TODO metadata_or_path
|
| 32 |
-
|
| 33 |
-
self._infos_by_id: dict[str, RobotwinObjectInfo] = {}
|
| 34 |
-
|
| 35 |
-
res_loader = MetadataResourceLoader()
|
| 36 |
-
# TODO load the dataset from somewhere else?
|
| 37 |
-
for resource in res_loader(
|
| 38 |
-
importlib.resources.files(__package__) / "resources" / "metadata.json"
|
| 39 |
-
):
|
| 40 |
-
base_path = resource.get("base_path") or ""
|
| 41 |
-
content = resource["content"]
|
| 42 |
-
assert isinstance(content, dict)
|
| 43 |
-
self._infos_by_id[content["id"]] = RobotwinObjectInfo(
|
| 44 |
-
id=content["id"],
|
| 45 |
-
category=content["category"],
|
| 46 |
-
model_path=(pathlib.Path(base_path) / content["model_path"]).resolve(),
|
| 47 |
-
contact_transforms=content.get("contact_transforms", []),
|
| 48 |
-
target_transforms=content.get("target_transforms", []),
|
| 49 |
-
functional_transforms=content.get("functional_transforms", []),
|
| 50 |
-
orientation_transforms=content.get("orientation_transforms", []),
|
| 51 |
-
)
|
| 52 |
-
|
| 53 |
-
@property
|
| 54 |
-
def infos_by_id(self) -> dict[str, RobotwinObjectInfo]:
|
| 55 |
-
return types.MappingProxyType(self._infos_by_id)
|
| 56 |
-
|
| 57 |
-
def query(self, entity_or_id: sapien.Entity | str) -> RobotwinObjectInfo | None:
|
| 58 |
-
if isinstance(entity_or_id, str):
|
| 59 |
-
return self._infos_by_id.get(entity_or_id)
|
| 60 |
-
|
| 61 |
-
if isinstance(entity_or_id, sapien.Entity):
|
| 62 |
-
return self._infos_by_id.get(entity_or_id.name)
|
| 63 |
-
|
| 64 |
-
raise TypeError(f"Unsupported entity (or id): {entity_or_id}")
|
| 65 |
-
|
| 66 |
-
def create(self, scene: sapien.Scene, id: str) -> list[sapien.Entity]:
|
| 67 |
-
loader = scene.create_urdf_loader()
|
| 68 |
-
loader.load_multiple_collisions_from_file = True
|
| 69 |
-
_, entities = loader.load_multiple(
|
| 70 |
-
os.fspath(self._infos_by_id[id]["model_path"])
|
| 71 |
-
)
|
| 72 |
-
# TODO !!!!!
|
| 73 |
-
for entity in entities:
|
| 74 |
-
entity: sapien.Entity
|
| 75 |
-
entity.name = id
|
| 76 |
-
return entities
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
__todo__/packages/robotodo_assets/robotwin_objects/resources/assets/001_bottle-0/metadata.json
DELETED
|
@@ -1 +0,0 @@
|
|
| 1 |
-
{"type": "resource", "content": {"id": "001_bottle-0", "category": "bottle", "model_path": "model.urdf", "contact_transforms": [[[6.123233995736766e-17, -1.0, 0.0, 0.0], [1.0, 6.123233995736766e-17, 0.0, 0.9487648192335866], [0.0, 0.0, 1.0, 0.0], [0.0, 0.0, 0.0, 1.0]], [[6.123233995736766e-17, -6.123233995736766e-17, 1.0, 0.0], [1.0, 3.749399456654644e-33, -6.123233995736766e-17, 0.9487648192335866], [0.0, 1.0, 6.123233995736766e-17, 0.0], [0.0, 0.0, 0.0, 1.0]], [[6.123233995736766e-17, 1.0, 1.2246467991473532e-16, 0.0], [1.0, -6.123233995736766e-17, -7.498798913309288e-33, 0.9487648192335866], [0.0, 1.2246467991473532e-16, -1.0, 0.0], [0.0, 0.0, 0.0, 1.0]], [[6.123233995736766e-17, -6.123233995736766e-17, -1.0, 0.0], [1.0, 3.749399456654644e-33, 6.123233995736766e-17, 0.9487648192335866], [0.0, -1.0, 6.123233995736766e-17, 0.0], [0.0, 0.0, 0.0, 1.0]], [[6.123233995736766e-17, -0.7071067811865476, 0.7071067811865475, 0.0], [1.0, 4.329780281177467e-17, -4.329780281177466e-17, 0.9487648192335866], [0.0, 0.7071067811865475, 0.7071067811865476, 0.0], [0.0, 0.0, 0.0, 1.0]], [[6.123233995736766e-17, 0.7071067811865475, 0.7071067811865476, 0.0], [1.0, -4.329780281177466e-17, -4.329780281177467e-17, 0.9487648192335866], [0.0, 0.7071067811865476, -0.7071067811865475, 0.0], [0.0, 0.0, 0.0, 1.0]], [[6.123233995736766e-17, 0.7071067811865475, -0.7071067811865476, 0.0], [1.0, -4.329780281177466e-17, 4.329780281177467e-17, 0.9487648192335866], [0.0, -0.7071067811865476, -0.7071067811865475, 0.0], [0.0, 0.0, 0.0, 1.0]], [[6.123233995736766e-17, -0.7071067811865476, -0.7071067811865475, 0.0], [1.0, 4.329780281177467e-17, 4.329780281177466e-17, 0.9487648192335866], [0.0, -0.7071067811865475, 0.7071067811865476, 0.0], [0.0, 0.0, 0.0, 1.0]]], "target_transforms": [[[1.0, 0.0, 0.0, 0.0], [0.0, 1.0, 0.0, 0.9487648192335866], [0.0, 0.0, 1.0, 0.0], [0.0, 0.0, 0.0, 1.0]]], "functional_transforms": [[[1.0, 0.0, 0.0, 0.0], [0.0, 6.123233995736766e-17, -1.0, 0.9487648192335866], [0.0, 1.0, 6.123233995736766e-17, 0.0], [0.0, 0.0, 0.0, 1.0]]], "orientation_transforms": [[1.0, 0.0, 0.0, 0.0], [0.0, 1.0, 0.0, 1.8975296384671732], [0.0, 0.0, 1.0, 0.0], [0.0, 0.0, 0.0, 1.0]]}}
|
|
|
|
|
|
__todo__/packages/robotodo_assets/robotwin_objects/resources/assets/001_bottle-0/model.urdf
DELETED
|
@@ -1,2 +0,0 @@
|
|
| 1 |
-
<?xml version='1.0' encoding='utf-8'?>
|
| 2 |
-
<robot name="001_bottle-0"><link name="base_link"><visual><geometry><mesh filename="mesh/visual.glb" scale="0.132 0.132 0.132" /></geometry></visual><collision><geometry><mesh filename="mesh/collision.glb" scale="0.132 0.132 0.132" /></geometry></collision></link></robot>
|
|
|
|
|
|
|
|
|
__todo__/packages/robotodo_assets/robotwin_objects/resources/assets/001_bottle-1/metadata.json
DELETED
|
@@ -1 +0,0 @@
|
|
| 1 |
-
{"type": "resource", "content": {"id": "001_bottle-1", "category": "bottle", "model_path": "model.urdf", "contact_transforms": [[[6.123233995736766e-17, -1.0, 0.0, 0.0], [1.0, 6.123233995736766e-17, 0.0, 0.950504765229936], [0.0, 0.0, 1.0, 0.0], [0.0, 0.0, 0.0, 1.0]], [[6.123233995736766e-17, -6.123233995736766e-17, 1.0, 0.0], [1.0, 3.749399456654644e-33, -6.123233995736766e-17, 0.950504765229936], [0.0, 1.0, 6.123233995736766e-17, 0.0], [0.0, 0.0, 0.0, 1.0]], [[6.123233995736766e-17, 1.0, 1.2246467991473532e-16, 0.0], [1.0, -6.123233995736766e-17, -7.498798913309288e-33, 0.950504765229936], [0.0, 1.2246467991473532e-16, -1.0, 0.0], [0.0, 0.0, 0.0, 1.0]], [[6.123233995736766e-17, -6.123233995736766e-17, -1.0, 0.0], [1.0, 3.749399456654644e-33, 6.123233995736766e-17, 0.950504765229936], [0.0, -1.0, 6.123233995736766e-17, 0.0], [0.0, 0.0, 0.0, 1.0]], [[6.123233995736766e-17, -0.7071067811865476, 0.7071067811865475, 0.0], [1.0, 4.329780281177467e-17, -4.329780281177466e-17, 0.950504765229936], [0.0, 0.7071067811865475, 0.7071067811865476, 0.0], [0.0, 0.0, 0.0, 1.0]], [[6.123233995736766e-17, 0.7071067811865475, 0.7071067811865476, 0.0], [1.0, -4.329780281177466e-17, -4.329780281177467e-17, 0.950504765229936], [0.0, 0.7071067811865476, -0.7071067811865475, 0.0], [0.0, 0.0, 0.0, 1.0]], [[6.123233995736766e-17, 0.7071067811865475, -0.7071067811865476, 0.0], [1.0, -4.329780281177466e-17, 4.329780281177467e-17, 0.950504765229936], [0.0, -0.7071067811865476, -0.7071067811865475, 0.0], [0.0, 0.0, 0.0, 1.0]], [[6.123233995736766e-17, -0.7071067811865476, -0.7071067811865475, 0.0], [1.0, 4.329780281177467e-17, 4.329780281177466e-17, 0.950504765229936], [0.0, -0.7071067811865475, 0.7071067811865476, 0.0], [0.0, 0.0, 0.0, 1.0]]], "target_transforms": [[[1.0, 0.0, 0.0, 0.0], [0.0, 1.0, 0.0, 0.950504765229936], [0.0, 0.0, 1.0, 0.0], [0.0, 0.0, 0.0, 1.0]]], "functional_transforms": [[[1.0, 0.0, 0.0, 0.0], [0.0, 6.123233995736766e-17, -1.0, 0.950504765229936], [0.0, 1.0, 6.123233995736766e-17, 0.0], [0.0, 0.0, 0.0, 1.0]]], "orientation_transforms": [[1.0, 0.0, 0.0, 0.0], [0.0, 1.0, 0.0, 1.901009530459872], [0.0, 0.0, 1.0, 0.0], [0.0, 0.0, 0.0, 1.0]]}}
|
|
|
|
|
|
__todo__/packages/robotodo_assets/robotwin_objects/resources/assets/001_bottle-1/model.urdf
DELETED
|
@@ -1,2 +0,0 @@
|
|
| 1 |
-
<?xml version='1.0' encoding='utf-8'?>
|
| 2 |
-
<robot name="001_bottle-1"><link name="base_link"><visual><geometry><mesh filename="mesh/visual.glb" scale="0.132 0.132 0.132" /></geometry></visual><collision><geometry><mesh filename="mesh/collision.glb" scale="0.132 0.132 0.132" /></geometry></collision></link></robot>
|
|
|
|
|
|
|
|
|
__todo__/packages/robotodo_assets/robotwin_objects/resources/assets/001_bottle-10/metadata.json
DELETED
|
@@ -1 +0,0 @@
|
|
| 1 |
-
{"type": "resource", "content": {"id": "001_bottle-10", "category": "bottle", "model_path": "model.urdf", "contact_transforms": [[[6.123233995736766e-17, -1.0, 0.0, 0.0], [1.0, 6.123233995736766e-17, 0.0, 0.948301549251603], [0.0, 0.0, 1.0, 0.0], [0.0, 0.0, 0.0, 1.0]], [[6.123233995736766e-17, -6.123233995736766e-17, 1.0, 0.0], [1.0, 3.749399456654644e-33, -6.123233995736766e-17, 0.948301549251603], [0.0, 1.0, 6.123233995736766e-17, 0.0], [0.0, 0.0, 0.0, 1.0]], [[6.123233995736766e-17, 1.0, 1.2246467991473532e-16, 0.0], [1.0, -6.123233995736766e-17, -7.498798913309288e-33, 0.948301549251603], [0.0, 1.2246467991473532e-16, -1.0, 0.0], [0.0, 0.0, 0.0, 1.0]], [[6.123233995736766e-17, -6.123233995736766e-17, -1.0, 0.0], [1.0, 3.749399456654644e-33, 6.123233995736766e-17, 0.948301549251603], [0.0, -1.0, 6.123233995736766e-17, 0.0], [0.0, 0.0, 0.0, 1.0]]], "target_transforms": [[[1.0, 0.0, 0.0, 0.0], [0.0, 1.0, 0.0, 0.948301549251603], [0.0, 0.0, 1.0, 0.0], [0.0, 0.0, 0.0, 1.0]]], "functional_transforms": [[[1.0, 0.0, 0.0, 0.0], [0.0, 6.123233995736766e-17, -1.0, 0.948301549251603], [0.0, 1.0, 6.123233995736766e-17, 0.0], [0.0, 0.0, 0.0, 1.0]]], "orientation_transforms": [[1.0, 0.0, 0.0, 0.0], [0.0, 1.0, 0.0, 1.896603098503206], [0.0, 0.0, 1.0, 0.0], [0.0, 0.0, 0.0, 1.0]]}}
|
|
|
|
|
|
__todo__/packages/robotodo_assets/robotwin_objects/resources/assets/001_bottle-10/model.urdf
DELETED
|
@@ -1,2 +0,0 @@
|
|
| 1 |
-
<?xml version='1.0' encoding='utf-8'?>
|
| 2 |
-
<robot name="001_bottle-10"><link name="base_link"><visual><geometry><mesh filename="mesh/visual.glb" scale="0.132 0.132 0.132" /></geometry></visual><collision><geometry><mesh filename="mesh/collision.glb" scale="0.132 0.132 0.132" /></geometry></collision></link></robot>
|
|
|
|
|
|
|
|
|
__todo__/packages/robotodo_assets/robotwin_objects/resources/assets/001_bottle-11/metadata.json
DELETED
|
@@ -1 +0,0 @@
|
|
| 1 |
-
{"type": "resource", "content": {"id": "001_bottle-11", "category": "bottle", "model_path": "model.urdf", "contact_transforms": [[[6.123233995736766e-17, -1.0, 0.0, 0.0], [1.0, 6.123233995736766e-17, 0.0, 0.8241185306297152], [0.0, 0.0, 1.0, 0.0], [0.0, 0.0, 0.0, 1.0]], [[6.123233995736766e-17, -6.123233995736766e-17, 1.0, 0.0], [1.0, 3.749399456654644e-33, -6.123233995736766e-17, 0.8241185306297152], [0.0, 1.0, 6.123233995736766e-17, 0.0], [0.0, 0.0, 0.0, 1.0]], [[6.123233995736766e-17, 1.0, 1.2246467991473532e-16, 0.0], [1.0, -6.123233995736766e-17, -7.498798913309288e-33, 0.8241185306297152], [0.0, 1.2246467991473532e-16, -1.0, 0.0], [0.0, 0.0, 0.0, 1.0]], [[6.123233995736766e-17, -6.123233995736766e-17, -1.0, 0.0], [1.0, 3.749399456654644e-33, 6.123233995736766e-17, 0.8241185306297152], [0.0, -1.0, 6.123233995736766e-17, 0.0], [0.0, 0.0, 0.0, 1.0]]], "target_transforms": [[[1.0, 0.0, 0.0, 0.0], [0.0, 1.0, 0.0, 0.8241185306297152], [0.0, 0.0, 1.0, 0.0], [0.0, 0.0, 0.0, 1.0]]], "functional_transforms": [[[1.0, 0.0, 0.0, 0.0], [0.0, 6.123233995736766e-17, -1.0, 0.8241185306297152], [0.0, 1.0, 6.123233995736766e-17, 0.0], [0.0, 0.0, 0.0, 1.0]]], "orientation_transforms": [[1.0, 0.0, 0.0, 0.0], [0.0, 1.0, 0.0, 1.6482370612594304], [0.0, 0.0, 1.0, 0.0], [0.0, 0.0, 0.0, 1.0]]}}
|
|
|
|
|
|
__todo__/packages/robotodo_assets/robotwin_objects/resources/assets/001_bottle-11/model.urdf
DELETED
|
@@ -1,2 +0,0 @@
|
|
| 1 |
-
<?xml version='1.0' encoding='utf-8'?>
|
| 2 |
-
<robot name="001_bottle-11"><link name="base_link"><visual><geometry><mesh filename="mesh/visual.glb" scale="0.155 0.155 0.155" /></geometry></visual><collision><geometry><mesh filename="mesh/collision.glb" scale="0.155 0.155 0.155" /></geometry></collision></link></robot>
|
|
|
|
|
|
|
|
|
__todo__/packages/robotodo_assets/robotwin_objects/resources/assets/001_bottle-12/metadata.json
DELETED
|
@@ -1 +0,0 @@
|
|
| 1 |
-
{"type": "resource", "content": {"id": "001_bottle-12", "category": "bottle", "model_path": "model.urdf", "contact_transforms": [[[6.123233995736766e-17, -1.0, 0.0, 0.0], [1.0, 6.123233995736766e-17, 0.0, 0.9484654406094759], [0.0, 0.0, 1.0, 0.0], [0.0, 0.0, 0.0, 1.0]], [[6.123233995736766e-17, -6.123233995736766e-17, 1.0, 0.0], [1.0, 3.749399456654644e-33, -6.123233995736766e-17, 0.9484654406094759], [0.0, 1.0, 6.123233995736766e-17, 0.0], [0.0, 0.0, 0.0, 1.0]], [[6.123233995736766e-17, 1.0, 1.2246467991473532e-16, 0.0], [1.0, -6.123233995736766e-17, -7.498798913309288e-33, 0.9484654406094759], [0.0, 1.2246467991473532e-16, -1.0, 0.0], [0.0, 0.0, 0.0, 1.0]], [[6.123233995736766e-17, -6.123233995736766e-17, -1.0, 0.0], [1.0, 3.749399456654644e-33, 6.123233995736766e-17, 0.9484654406094759], [0.0, -1.0, 6.123233995736766e-17, 0.0], [0.0, 0.0, 0.0, 1.0]], [[6.123233995736766e-17, -0.7071067811865476, 0.7071067811865475, 0.0], [1.0, 4.329780281177467e-17, -4.329780281177466e-17, 0.9484654406094759], [0.0, 0.7071067811865475, 0.7071067811865476, 0.0], [0.0, 0.0, 0.0, 1.0]], [[6.123233995736766e-17, 0.7071067811865475, 0.7071067811865476, 0.0], [1.0, -4.329780281177466e-17, -4.329780281177467e-17, 0.9484654406094759], [0.0, 0.7071067811865476, -0.7071067811865475, 0.0], [0.0, 0.0, 0.0, 1.0]], [[6.123233995736766e-17, 0.7071067811865475, -0.7071067811865476, 0.0], [1.0, -4.329780281177466e-17, 4.329780281177467e-17, 0.9484654406094759], [0.0, -0.7071067811865476, -0.7071067811865475, 0.0], [0.0, 0.0, 0.0, 1.0]], [[6.123233995736766e-17, -0.7071067811865476, -0.7071067811865475, 0.0], [1.0, 4.329780281177467e-17, 4.329780281177466e-17, 0.9484654406094759], [0.0, -0.7071067811865475, 0.7071067811865476, 0.0], [0.0, 0.0, 0.0, 1.0]]], "target_transforms": [[[1.0, 0.0, 0.0, 0.0], [0.0, 1.0, 0.0, 0.9484654406094759], [0.0, 0.0, 1.0, 0.0], [0.0, 0.0, 0.0, 1.0]]], "functional_transforms": [[[1.0, 0.0, 0.0, 0.0], [0.0, 6.123233995736766e-17, -1.0, 0.9484654406094759], [0.0, 1.0, 6.123233995736766e-17, 0.0], [0.0, 0.0, 0.0, 1.0]]], "orientation_transforms": [[1.0, 0.0, 0.0, 0.0], [0.0, 1.0, 0.0, 1.8969308812189518], [0.0, 0.0, 1.0, 0.0], [0.0, 0.0, 0.0, 1.0]]}}
|
|
|
|
|
|
__todo__/packages/robotodo_assets/robotwin_objects/resources/assets/001_bottle-12/model.urdf
DELETED
|
@@ -1,2 +0,0 @@
|
|
| 1 |
-
<?xml version='1.0' encoding='utf-8'?>
|
| 2 |
-
<robot name="001_bottle-12"><link name="base_link"><visual><geometry><mesh filename="mesh/visual.glb" scale="0.132 0.132 0.132" /></geometry></visual><collision><geometry><mesh filename="mesh/collision.glb" scale="0.132 0.132 0.132" /></geometry></collision></link></robot>
|
|
|
|
|
|
|
|
|
__todo__/packages/robotodo_assets/robotwin_objects/resources/assets/001_bottle-13/metadata.json
DELETED
|
@@ -1 +0,0 @@
|
|
| 1 |
-
{"type": "resource", "content": {"id": "001_bottle-13", "category": "bottle", "model_path": "model.urdf", "contact_transforms": [[[6.123233995736766e-17, -1.0, 0.0, 0.0], [1.0, 6.123233995736766e-17, 0.0, 0.9238575889494822], [0.0, 0.0, 1.0, 0.0], [0.0, 0.0, 0.0, 1.0]], [[6.123233995736766e-17, -6.123233995736766e-17, 1.0, 0.0], [1.0, 3.749399456654644e-33, -6.123233995736766e-17, 0.9238575889494822], [0.0, 1.0, 6.123233995736766e-17, 0.0], [0.0, 0.0, 0.0, 1.0]], [[6.123233995736766e-17, 1.0, 1.2246467991473532e-16, 0.0], [1.0, -6.123233995736766e-17, -7.498798913309288e-33, 0.9238575889494822], [0.0, 1.2246467991473532e-16, -1.0, 0.0], [0.0, 0.0, 0.0, 1.0]], [[6.123233995736766e-17, -6.123233995736766e-17, -1.0, 0.0], [1.0, 3.749399456654644e-33, 6.123233995736766e-17, 0.9238575889494822], [0.0, -1.0, 6.123233995736766e-17, 0.0], [0.0, 0.0, 0.0, 1.0]], [[6.123233995736766e-17, -0.7071067811865476, 0.7071067811865475, 0.0], [1.0, 4.329780281177467e-17, -4.329780281177466e-17, 0.9238575889494822], [0.0, 0.7071067811865475, 0.7071067811865476, 0.0], [0.0, 0.0, 0.0, 1.0]], [[6.123233995736766e-17, 0.7071067811865475, 0.7071067811865476, 0.0], [1.0, -4.329780281177466e-17, -4.329780281177467e-17, 0.9238575889494822], [0.0, 0.7071067811865476, -0.7071067811865475, 0.0], [0.0, 0.0, 0.0, 1.0]], [[6.123233995736766e-17, 0.7071067811865475, -0.7071067811865476, 0.0], [1.0, -4.329780281177466e-17, 4.329780281177467e-17, 0.9238575889494822], [0.0, -0.7071067811865476, -0.7071067811865475, 0.0], [0.0, 0.0, 0.0, 1.0]], [[6.123233995736766e-17, -0.7071067811865476, -0.7071067811865475, 0.0], [1.0, 4.329780281177467e-17, 4.329780281177466e-17, 0.9238575889494822], [0.0, -0.7071067811865475, 0.7071067811865476, 0.0], [0.0, 0.0, 0.0, 1.0]]], "target_transforms": [[[1.0, 0.0, 0.0, 0.0], [0.0, 1.0, 0.0, 0.9238575889494822], [0.0, 0.0, 1.0, 0.0], [0.0, 0.0, 0.0, 1.0]]], "functional_transforms": [[[1.0, 0.0, 0.0, 0.0], [0.0, 6.123233995736766e-17, -1.0, 0.9238575889494822], [0.0, 1.0, 6.123233995736766e-17, 0.0], [0.0, 0.0, 0.0, 1.0]]], "orientation_transforms": [[1.0, 0.0, 0.0, 0.0], [0.0, 1.0, 0.0, 1.8477151778989644], [0.0, 0.0, 1.0, 0.0], [0.0, 0.0, 0.0, 1.0]]}}
|
|
|
|
|
|
__todo__/packages/robotodo_assets/robotwin_objects/resources/assets/001_bottle-13/model.urdf
DELETED
|
@@ -1,2 +0,0 @@
|
|
| 1 |
-
<?xml version='1.0' encoding='utf-8'?>
|
| 2 |
-
<robot name="001_bottle-13"><link name="base_link"><visual><geometry><mesh filename="mesh/visual.glb" scale="0.132 0.132 0.132" /></geometry></visual><collision><geometry><mesh filename="mesh/collision.glb" scale="0.132 0.132 0.132" /></geometry></collision></link></robot>
|
|
|
|
|
|
|
|
|
__todo__/packages/robotodo_assets/robotwin_objects/resources/assets/001_bottle-14/metadata.json
DELETED
|
@@ -1 +0,0 @@
|
|
| 1 |
-
{"type": "resource", "content": {"id": "001_bottle-14", "category": "bottle", "model_path": "model.urdf", "contact_transforms": [[[6.123233995736766e-17, -1.0, 0.0, 0.0], [1.0, 6.123233995736766e-17, 0.0, 0.9509331448649547], [0.0, 0.0, 1.0, 0.0], [0.0, 0.0, 0.0, 1.0]], [[6.123233995736766e-17, -6.123233995736766e-17, 1.0, 0.0], [1.0, 3.749399456654644e-33, -6.123233995736766e-17, 0.9509331448649547], [0.0, 1.0, 6.123233995736766e-17, 0.0], [0.0, 0.0, 0.0, 1.0]], [[6.123233995736766e-17, 1.0, 1.2246467991473532e-16, 0.0], [1.0, -6.123233995736766e-17, -7.498798913309288e-33, 0.9509331448649547], [0.0, 1.2246467991473532e-16, -1.0, 0.0], [0.0, 0.0, 0.0, 1.0]], [[6.123233995736766e-17, -6.123233995736766e-17, -1.0, 0.0], [1.0, 3.749399456654644e-33, 6.123233995736766e-17, 0.9509331448649547], [0.0, -1.0, 6.123233995736766e-17, 0.0], [0.0, 0.0, 0.0, 1.0]], [[6.123233995736766e-17, -0.7071067811865476, 0.7071067811865475, 0.0], [1.0, 4.329780281177467e-17, -4.329780281177466e-17, 0.9509331448649547], [0.0, 0.7071067811865475, 0.7071067811865476, 0.0], [0.0, 0.0, 0.0, 1.0]], [[6.123233995736766e-17, 0.7071067811865475, 0.7071067811865476, 0.0], [1.0, -4.329780281177466e-17, -4.329780281177467e-17, 0.9509331448649547], [0.0, 0.7071067811865476, -0.7071067811865475, 0.0], [0.0, 0.0, 0.0, 1.0]], [[6.123233995736766e-17, 0.7071067811865475, -0.7071067811865476, 0.0], [1.0, -4.329780281177466e-17, 4.329780281177467e-17, 0.9509331448649547], [0.0, -0.7071067811865476, -0.7071067811865475, 0.0], [0.0, 0.0, 0.0, 1.0]], [[6.123233995736766e-17, -0.7071067811865476, -0.7071067811865475, 0.0], [1.0, 4.329780281177467e-17, 4.329780281177466e-17, 0.9509331448649547], [0.0, -0.7071067811865475, 0.7071067811865476, 0.0], [0.0, 0.0, 0.0, 1.0]]], "target_transforms": [[[1.0, 0.0, 0.0, 0.0], [0.0, 1.0, 0.0, 0.9509331448649547], [0.0, 0.0, 1.0, 0.0], [0.0, 0.0, 0.0, 1.0]]], "functional_transforms": [[[1.0, 0.0, 0.0, 0.0], [0.0, 6.123233995736766e-17, -1.0, 0.9509331448649547], [0.0, 1.0, 6.123233995736766e-17, 0.0], [0.0, 0.0, 0.0, 1.0]]], "orientation_transforms": [[1.0, 0.0, 0.0, 0.0], [0.0, 1.0, 0.0, 1.9018662897299095], [0.0, 0.0, 1.0, 0.0], [0.0, 0.0, 0.0, 1.0]]}}
|
|
|
|
|
|
__todo__/packages/robotodo_assets/robotwin_objects/resources/assets/001_bottle-14/model.urdf
DELETED
|
@@ -1,2 +0,0 @@
|
|
| 1 |
-
<?xml version='1.0' encoding='utf-8'?>
|
| 2 |
-
<robot name="001_bottle-14"><link name="base_link"><visual><geometry><mesh filename="mesh/visual.glb" scale="0.12 0.12 0.12" /></geometry></visual><collision><geometry><mesh filename="mesh/collision.glb" scale="0.12 0.12 0.12" /></geometry></collision></link></robot>
|
|
|
|
|
|
|
|
|
__todo__/packages/robotodo_assets/robotwin_objects/resources/assets/001_bottle-15/metadata.json
DELETED
|
@@ -1 +0,0 @@
|
|
| 1 |
-
{"type": "resource", "content": {"id": "001_bottle-15", "category": "bottle", "model_path": "model.urdf", "contact_transforms": [[[6.123233995736766e-17, -1.0, 0.0, 0.0], [1.0, 6.123233995736766e-17, 0.0, 1.1505662867821471], [0.0, 0.0, 1.0, 0.0], [0.0, 0.0, 0.0, 1.0]], [[6.123233995736766e-17, -6.123233995736766e-17, 1.0, 0.0], [1.0, 3.749399456654644e-33, -6.123233995736766e-17, 1.1505662867821471], [0.0, 1.0, 6.123233995736766e-17, 0.0], [0.0, 0.0, 0.0, 1.0]], [[6.123233995736766e-17, 1.0, 1.2246467991473532e-16, 0.0], [1.0, -6.123233995736766e-17, -7.498798913309288e-33, 1.1505662867821471], [0.0, 1.2246467991473532e-16, -1.0, 0.0], [0.0, 0.0, 0.0, 1.0]], [[6.123233995736766e-17, -6.123233995736766e-17, -1.0, 0.0], [1.0, 3.749399456654644e-33, 6.123233995736766e-17, 1.1505662867821471], [0.0, -1.0, 6.123233995736766e-17, 0.0], [0.0, 0.0, 0.0, 1.0]], [[6.123233995736766e-17, -0.7071067811865476, 0.7071067811865475, 0.0], [1.0, 4.329780281177467e-17, -4.329780281177466e-17, 1.1505662867821471], [0.0, 0.7071067811865475, 0.7071067811865476, 0.0], [0.0, 0.0, 0.0, 1.0]], [[6.123233995736766e-17, 0.7071067811865475, 0.7071067811865476, 0.0], [1.0, -4.329780281177466e-17, -4.329780281177467e-17, 1.1505662867821471], [0.0, 0.7071067811865476, -0.7071067811865475, 0.0], [0.0, 0.0, 0.0, 1.0]], [[6.123233995736766e-17, 0.7071067811865475, -0.7071067811865476, 0.0], [1.0, -4.329780281177466e-17, 4.329780281177467e-17, 1.1505662867821471], [0.0, -0.7071067811865476, -0.7071067811865475, 0.0], [0.0, 0.0, 0.0, 1.0]], [[6.123233995736766e-17, -0.7071067811865476, -0.7071067811865475, 0.0], [1.0, 4.329780281177467e-17, 4.329780281177466e-17, 1.1505662867821471], [0.0, -0.7071067811865475, 0.7071067811865476, 0.0], [0.0, 0.0, 0.0, 1.0]]], "target_transforms": [[[1.0, 0.0, 0.0, 0.0], [0.0, 1.0, 0.0, 0.950566286782147], [0.0, 0.0, 1.0, 0.0], [0.0, 0.0, 0.0, 1.0]]], "functional_transforms": [[[1.0, 0.0, 0.0, 0.0], [0.0, 6.123233995736766e-17, -1.0, 0.950566286782147], [0.0, 1.0, 6.123233995736766e-17, 0.0], [0.0, 0.0, 0.0, 1.0]]], "orientation_transforms": [[1.0, 0.0, 0.0, 0.0], [0.0, 1.0, 0.0, 1.901132573564294], [0.0, 0.0, 1.0, 0.0], [0.0, 0.0, 0.0, 1.0]]}}
|
|
|
|
|
|
__todo__/packages/robotodo_assets/robotwin_objects/resources/assets/001_bottle-15/model.urdf
DELETED
|
@@ -1,2 +0,0 @@
|
|
| 1 |
-
<?xml version='1.0' encoding='utf-8'?>
|
| 2 |
-
<robot name="001_bottle-15"><link name="base_link"><visual><geometry><mesh filename="mesh/visual.glb" scale="0.132 0.132 0.132" /></geometry></visual><collision><geometry><mesh filename="mesh/collision.glb" scale="0.132 0.132 0.132" /></geometry></collision></link></robot>
|
|
|
|
|
|
|
|
|
__todo__/packages/robotodo_assets/robotwin_objects/resources/assets/001_bottle-16/metadata.json
DELETED
|
@@ -1 +0,0 @@
|
|
| 1 |
-
{"type": "resource", "content": {"id": "001_bottle-16", "category": "bottle", "model_path": "model.urdf", "contact_transforms": [[[6.123233995736766e-17, -1.0, 0.0, 0.0], [1.0, 6.123233995736766e-17, 0.0, 0.9536239987553657], [0.0, 0.0, 1.0, 0.0], [0.0, 0.0, 0.0, 1.0]], [[6.123233995736766e-17, -6.123233995736766e-17, 1.0, 0.0], [1.0, 3.749399456654644e-33, -6.123233995736766e-17, 0.9536239987553657], [0.0, 1.0, 6.123233995736766e-17, 0.0], [0.0, 0.0, 0.0, 1.0]], [[6.123233995736766e-17, 1.0, 1.2246467991473532e-16, 0.0], [1.0, -6.123233995736766e-17, -7.498798913309288e-33, 0.9536239987553657], [0.0, 1.2246467991473532e-16, -1.0, 0.0], [0.0, 0.0, 0.0, 1.0]], [[6.123233995736766e-17, -6.123233995736766e-17, -1.0, 0.0], [1.0, 3.749399456654644e-33, 6.123233995736766e-17, 0.9536239987553657], [0.0, -1.0, 6.123233995736766e-17, 0.0], [0.0, 0.0, 0.0, 1.0]], [[6.123233995736766e-17, -0.7071067811865476, 0.7071067811865475, 0.0], [1.0, 4.329780281177467e-17, -4.329780281177466e-17, 0.9536239987553657], [0.0, 0.7071067811865475, 0.7071067811865476, 0.0], [0.0, 0.0, 0.0, 1.0]], [[6.123233995736766e-17, 0.7071067811865475, 0.7071067811865476, 0.0], [1.0, -4.329780281177466e-17, -4.329780281177467e-17, 0.9536239987553657], [0.0, 0.7071067811865476, -0.7071067811865475, 0.0], [0.0, 0.0, 0.0, 1.0]], [[6.123233995736766e-17, 0.7071067811865475, -0.7071067811865476, 0.0], [1.0, -4.329780281177466e-17, 4.329780281177467e-17, 0.9536239987553657], [0.0, -0.7071067811865476, -0.7071067811865475, 0.0], [0.0, 0.0, 0.0, 1.0]], [[6.123233995736766e-17, -0.7071067811865476, -0.7071067811865475, 0.0], [1.0, 4.329780281177467e-17, 4.329780281177466e-17, 0.9536239987553657], [0.0, -0.7071067811865475, 0.7071067811865476, 0.0], [0.0, 0.0, 0.0, 1.0]]], "target_transforms": [[[1.0, 0.0, 0.0, 0.0], [0.0, 1.0, 0.0, 0.9536239987553657], [0.0, 0.0, 1.0, 0.0], [0.0, 0.0, 0.0, 1.0]]], "functional_transforms": [[[1.0, 0.0, 0.0, 0.0], [0.0, 6.123233995736766e-17, -1.0, 0.9536239987553657], [0.0, 1.0, 6.123233995736766e-17, 0.0], [0.0, 0.0, 0.0, 1.0]]], "orientation_transforms": [[1.0, 0.0, 0.0, 0.0], [0.0, 1.0, 0.0, 1.9072479975107315], [0.0, 0.0, 1.0, 0.0], [0.0, 0.0, 0.0, 1.0]]}}
|
|
|
|
|
|
__todo__/packages/robotodo_assets/robotwin_objects/resources/assets/001_bottle-16/model.urdf
DELETED
|
@@ -1,2 +0,0 @@
|
|
| 1 |
-
<?xml version='1.0' encoding='utf-8'?>
|
| 2 |
-
<robot name="001_bottle-16"><link name="base_link"><visual><geometry><mesh filename="mesh/visual.glb" scale="0.132 0.132 0.132" /></geometry></visual><collision><geometry><mesh filename="mesh/collision.glb" scale="0.132 0.132 0.132" /></geometry></collision></link></robot>
|
|
|
|
|
|
|
|
|
__todo__/packages/robotodo_assets/robotwin_objects/resources/assets/001_bottle-17/metadata.json
DELETED
|
@@ -1 +0,0 @@
|
|
| 1 |
-
{"type": "resource", "content": {"id": "001_bottle-17", "category": "bottle", "model_path": "model.urdf", "contact_transforms": [[[6.123233995736766e-17, -1.0, 0.0, 0.0], [1.0, 6.123233995736766e-17, 0.0, 0.9461165877571774], [0.0, 0.0, 1.0, 0.0], [0.0, 0.0, 0.0, 1.0]], [[6.123233995736766e-17, -6.123233995736766e-17, 1.0, 0.0], [1.0, 3.749399456654644e-33, -6.123233995736766e-17, 0.9461165877571774], [0.0, 1.0, 6.123233995736766e-17, 0.0], [0.0, 0.0, 0.0, 1.0]], [[6.123233995736766e-17, 1.0, 1.2246467991473532e-16, 0.0], [1.0, -6.123233995736766e-17, -7.498798913309288e-33, 0.9461165877571774], [0.0, 1.2246467991473532e-16, -1.0, 0.0], [0.0, 0.0, 0.0, 1.0]], [[6.123233995736766e-17, -6.123233995736766e-17, -1.0, 0.0], [1.0, 3.749399456654644e-33, 6.123233995736766e-17, 0.9461165877571774], [0.0, -1.0, 6.123233995736766e-17, 0.0], [0.0, 0.0, 0.0, 1.0]], [[6.123233995736766e-17, -0.7071067811865476, 0.7071067811865475, 0.0], [1.0, 4.329780281177467e-17, -4.329780281177466e-17, 0.9461165877571774], [0.0, 0.7071067811865475, 0.7071067811865476, 0.0], [0.0, 0.0, 0.0, 1.0]], [[6.123233995736766e-17, 0.7071067811865475, 0.7071067811865476, 0.0], [1.0, -4.329780281177466e-17, -4.329780281177467e-17, 0.9461165877571774], [0.0, 0.7071067811865476, -0.7071067811865475, 0.0], [0.0, 0.0, 0.0, 1.0]], [[6.123233995736766e-17, 0.7071067811865475, -0.7071067811865476, 0.0], [1.0, -4.329780281177466e-17, 4.329780281177467e-17, 0.9461165877571774], [0.0, -0.7071067811865476, -0.7071067811865475, 0.0], [0.0, 0.0, 0.0, 1.0]], [[6.123233995736766e-17, -0.7071067811865476, -0.7071067811865475, 0.0], [1.0, 4.329780281177467e-17, 4.329780281177466e-17, 0.9461165877571774], [0.0, -0.7071067811865475, 0.7071067811865476, 0.0], [0.0, 0.0, 0.0, 1.0]]], "target_transforms": [[[1.0, 0.0, 0.0, 0.0], [0.0, 1.0, 0.0, 0.9461165877571774], [0.0, 0.0, 1.0, 0.0], [0.0, 0.0, 0.0, 1.0]]], "functional_transforms": [[[1.0, 0.0, 0.0, 0.0], [0.0, 6.123233995736766e-17, -1.0, 0.9461165877571774], [0.0, 1.0, 6.123233995736766e-17, 0.0], [0.0, 0.0, 0.0, 1.0]]], "orientation_transforms": [[1.0, 0.0, 0.0, 0.0], [0.0, 1.0, 0.0, 1.8922331755143549], [0.0, 0.0, 1.0, 0.0], [0.0, 0.0, 0.0, 1.0]]}}
|
|
|
|
|
|
__todo__/packages/robotodo_assets/robotwin_objects/resources/assets/001_bottle-17/model.urdf
DELETED
|
@@ -1,2 +0,0 @@
|
|
| 1 |
-
<?xml version='1.0' encoding='utf-8'?>
|
| 2 |
-
<robot name="001_bottle-17"><link name="base_link"><visual><geometry><mesh filename="mesh/visual.glb" scale="0.13 0.13 0.13" /></geometry></visual><collision><geometry><mesh filename="mesh/collision.glb" scale="0.13 0.13 0.13" /></geometry></collision></link></robot>
|
|
|
|
|
|
|
|
|
__todo__/packages/robotodo_assets/robotwin_objects/resources/assets/001_bottle-18/metadata.json
DELETED
|
@@ -1 +0,0 @@
|
|
| 1 |
-
{"type": "resource", "content": {"id": "001_bottle-18", "category": "bottle", "model_path": "model.urdf", "contact_transforms": [[[6.123233995736766e-17, -1.0, 0.0, 0.0], [1.0, 6.123233995736766e-17, 0.0, 1.0493247123315754], [0.0, 0.0, 1.0, 0.0], [0.0, 0.0, 0.0, 1.0]], [[6.123233995736766e-17, -6.123233995736766e-17, 1.0, 0.0], [1.0, 3.749399456654644e-33, -6.123233995736766e-17, 1.0493247123315754], [0.0, 1.0, 6.123233995736766e-17, 0.0], [0.0, 0.0, 0.0, 1.0]], [[6.123233995736766e-17, 1.0, 1.2246467991473532e-16, 0.0], [1.0, -6.123233995736766e-17, -7.498798913309288e-33, 1.0493247123315754], [0.0, 1.2246467991473532e-16, -1.0, 0.0], [0.0, 0.0, 0.0, 1.0]], [[6.123233995736766e-17, -6.123233995736766e-17, -1.0, 0.0], [1.0, 3.749399456654644e-33, 6.123233995736766e-17, 1.0493247123315754], [0.0, -1.0, 6.123233995736766e-17, 0.0], [0.0, 0.0, 0.0, 1.0]], [[6.123233995736766e-17, -0.7071067811865476, 0.7071067811865475, 0.0], [1.0, 4.329780281177467e-17, -4.329780281177466e-17, 1.0493247123315754], [0.0, 0.7071067811865475, 0.7071067811865476, 0.0], [0.0, 0.0, 0.0, 1.0]], [[6.123233995736766e-17, 0.7071067811865475, 0.7071067811865476, 0.0], [1.0, -4.329780281177466e-17, -4.329780281177467e-17, 1.0493247123315754], [0.0, 0.7071067811865476, -0.7071067811865475, 0.0], [0.0, 0.0, 0.0, 1.0]], [[6.123233995736766e-17, 0.7071067811865475, -0.7071067811865476, 0.0], [1.0, -4.329780281177466e-17, 4.329780281177467e-17, 1.0493247123315754], [0.0, -0.7071067811865476, -0.7071067811865475, 0.0], [0.0, 0.0, 0.0, 1.0]], [[6.123233995736766e-17, -0.7071067811865476, -0.7071067811865475, 0.0], [1.0, 4.329780281177467e-17, 4.329780281177466e-17, 1.0493247123315754], [0.0, -0.7071067811865475, 0.7071067811865476, 0.0], [0.0, 0.0, 0.0, 1.0]]], "target_transforms": [[[1.0, 0.0, 0.0, 0.0], [0.0, 1.0, 0.0, 0.9493247123315753], [0.0, 0.0, 1.0, 0.0], [0.0, 0.0, 0.0, 1.0]]], "functional_transforms": [[[1.0, 0.0, 0.0, 0.0], [0.0, 6.123233995736766e-17, -1.0, 0.9493247123315753], [0.0, 1.0, 6.123233995736766e-17, 0.0], [0.0, 0.0, 0.0, 1.0]]], "orientation_transforms": [[1.0, 0.0, 0.0, 0.0], [0.0, 1.0, 0.0, 1.8986494246631507], [0.0, 0.0, 1.0, 0.0], [0.0, 0.0, 0.0, 1.0]]}}
|
|
|
|
|
|
__todo__/packages/robotodo_assets/robotwin_objects/resources/assets/001_bottle-18/model.urdf
DELETED
|
@@ -1,2 +0,0 @@
|
|
| 1 |
-
<?xml version='1.0' encoding='utf-8'?>
|
| 2 |
-
<robot name="001_bottle-18"><link name="base_link"><visual><geometry><mesh filename="mesh/visual.glb" scale="0.1 0.1 0.1" /></geometry></visual><collision><geometry><mesh filename="mesh/collision.glb" scale="0.1 0.1 0.1" /></geometry></collision></link></robot>
|
|
|
|
|
|
|
|
|
__todo__/packages/robotodo_assets/robotwin_objects/resources/assets/001_bottle-19/metadata.json
DELETED
|
@@ -1 +0,0 @@
|
|
| 1 |
-
{"type": "resource", "content": {"id": "001_bottle-19", "category": "bottle", "model_path": "model.urdf", "contact_transforms": [[[6.123233995736766e-17, -1.0, 0.0, 0.0], [1.0, 6.123233995736766e-17, 0.0, 0.8149122034543642], [0.0, 0.0, 1.0, 0.0], [0.0, 0.0, 0.0, 1.0]], [[6.123233995736766e-17, -6.123233995736766e-17, 1.0, 0.0], [1.0, 3.749399456654644e-33, -6.123233995736766e-17, 0.8149122034543642], [0.0, 1.0, 6.123233995736766e-17, 0.0], [0.0, 0.0, 0.0, 1.0]], [[6.123233995736766e-17, 1.0, 1.2246467991473532e-16, 0.0], [1.0, -6.123233995736766e-17, -7.498798913309288e-33, 0.8149122034543642], [0.0, 1.2246467991473532e-16, -1.0, 0.0], [0.0, 0.0, 0.0, 1.0]], [[6.123233995736766e-17, -6.123233995736766e-17, -1.0, 0.0], [1.0, 3.749399456654644e-33, 6.123233995736766e-17, 0.8149122034543642], [0.0, -1.0, 6.123233995736766e-17, 0.0], [0.0, 0.0, 0.0, 1.0]], [[6.123233995736766e-17, -0.7071067811865476, 0.7071067811865475, 0.0], [1.0, 4.329780281177467e-17, -4.329780281177466e-17, 0.8149122034543642], [0.0, 0.7071067811865475, 0.7071067811865476, 0.0], [0.0, 0.0, 0.0, 1.0]], [[6.123233995736766e-17, 0.7071067811865475, 0.7071067811865476, 0.0], [1.0, -4.329780281177466e-17, -4.329780281177467e-17, 0.8149122034543642], [0.0, 0.7071067811865476, -0.7071067811865475, 0.0], [0.0, 0.0, 0.0, 1.0]], [[6.123233995736766e-17, 0.7071067811865475, -0.7071067811865476, 0.0], [1.0, -4.329780281177466e-17, 4.329780281177467e-17, 0.8149122034543642], [0.0, -0.7071067811865476, -0.7071067811865475, 0.0], [0.0, 0.0, 0.0, 1.0]], [[6.123233995736766e-17, -0.7071067811865476, -0.7071067811865475, 0.0], [1.0, 4.329780281177467e-17, 4.329780281177466e-17, 0.8149122034543642], [0.0, -0.7071067811865475, 0.7071067811865476, 0.0], [0.0, 0.0, 0.0, 1.0]]], "target_transforms": [[[1.0, 0.0, 0.0, 0.0], [0.0, 1.0, 0.0, 0.8149122034543642], [0.0, 0.0, 1.0, 0.0], [0.0, 0.0, 0.0, 1.0]]], "functional_transforms": [[[1.0, 0.0, 0.0, 0.0], [0.0, 6.123233995736766e-17, -1.0, 0.8149122034543642], [0.0, 1.0, 6.123233995736766e-17, 0.0], [0.0, 0.0, 0.0, 1.0]]], "orientation_transforms": [[1.0, 0.0, 0.0, 0.0], [0.0, 1.0, 0.0, 1.6298244069087284], [0.0, 0.0, 1.0, 0.0], [0.0, 0.0, 0.0, 1.0]]}}
|
|
|
|
|
|
__todo__/packages/robotodo_assets/robotwin_objects/resources/assets/001_bottle-19/model.urdf
DELETED
|
@@ -1,2 +0,0 @@
|
|
| 1 |
-
<?xml version='1.0' encoding='utf-8'?>
|
| 2 |
-
<robot name="001_bottle-19"><link name="base_link"><visual><geometry><mesh filename="mesh/visual.glb" scale="0.132 0.132 0.132" /></geometry></visual><collision><geometry><mesh filename="mesh/collision.glb" scale="0.132 0.132 0.132" /></geometry></collision></link></robot>
|
|
|
|
|
|
|
|
|