Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- .TimeRecord +1 -0
- LICENSE +8 -0
- atec_robot_model/.gitattributes +6 -0
- atec_robot_model/README.md +27 -0
- atec_robot_model/robot/piper/configuration/piper_physics.usd +0 -0
- atec_robot_model/robot/piper/configuration/piper_sensor.usd +0 -0
- atec_robot_model/robot/tron1/configuration/WF_TRON1A_physics.usd +0 -0
- atec_robot_model/robot/tron1/configuration/WF_TRON1A_sensor.usd +0 -0
- atec_robot_model/robot/tron2/SFYG_TRON2A/configuration/robot_physics.usd +0 -0
- atec_robot_model/robot/tron2/SFYG_TRON2A/configuration/robot_robot.usd +0 -0
- atec_robot_model/robot/tron2/SFYG_TRON2A/configuration/robot_sensor.usd +0 -0
- atec_robot_model/robot/tron2/SFYG_TRON2A/robot.usd +0 -0
- atec_robot_model/robot/tron2/WFYG_TRON2A/configuration/robot_physics.usd +0 -0
- atec_robot_model/robot/tron2/WFYG_TRON2A/configuration/robot_robot.usd +0 -0
- atec_robot_model/robot/tron2/WFYG_TRON2A/configuration/robot_sensor.usd +0 -0
- atec_robot_model/robot/tron2/WFYG_TRON2A/robot.usd +0 -0
- atec_robot_model/scene/plane/default_environment.usd +0 -0
- demo/Dockerfile +70 -0
- demo/__init__.py +0 -0
- demo/requirements.txt +4 -0
- demo/run.sh +6 -0
- demo/server.py +166 -0
- demo/solution.py +17 -0
- demo/solution_act.py +292 -0
- demo/solution_dual_act.py +66 -0
- demo/solution_hybrid_obj1_pca.py +68 -0
- demo/solution_pca.py +1243 -0
- demo/solution_pi05.py +169 -0
- demo/solution_pi05_native8.py +181 -0
- demo/solution_rl.py +210 -0
- demo/solution_zero.py +12 -0
- docs/ATEC2026_TaskE_规则物理配置与提交说明_20260604.md +273 -0
- example.md +95 -0
- readme.md +238 -0
- scripts/list_envs.py +112 -0
- scripts/play_atec_task.py +168 -0
- scripts/rl_utils.py +46 -0
- scripts/view_robots.py +109 -0
- scripts/view_task_a.py +57 -0
- scripts/view_task_b.py +58 -0
- scripts/view_task_d.py +58 -0
- scripts/view_task_e.py +57 -0
- source/__init__.py +0 -0
- source/atec_rl_lab/__init__.py +0 -0
- source/atec_rl_lab/atec_rl_lab.egg-info/PKG-INFO +15 -0
- source/atec_rl_lab/atec_rl_lab.egg-info/SOURCES.txt +9 -0
- source/atec_rl_lab/atec_rl_lab.egg-info/dependency_links.txt +1 -0
- source/atec_rl_lab/atec_rl_lab.egg-info/not-zip-safe +1 -0
- source/atec_rl_lab/atec_rl_lab.egg-info/requires.txt +1 -0
- source/atec_rl_lab/atec_rl_lab.egg-info/top_level.txt +1 -0
.TimeRecord
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
u Mr4Z4yC 36QwinZcFfRldpR ==
|
LICENSE
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Copyright 2026 ATEC (Advanced Technology Exploration Community)
|
| 2 |
+
|
| 3 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
| 4 |
+
|
| 5 |
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
| 6 |
+
|
| 7 |
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
| 8 |
+
|
atec_robot_model/.gitattributes
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
*.png filter=lfs diff=lfs merge=lfs -text
|
| 2 |
+
*.usd filter=lfs diff=lfs merge=lfs -text
|
| 3 |
+
*.usda filter=lfs diff=lfs merge=lfs -text
|
| 4 |
+
*.yaml filter=lfs diff=lfs merge=lfs -text
|
| 5 |
+
*.hdr filter=lfs diff=lfs merge=lfs -text
|
| 6 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
atec_robot_model/README.md
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# atec_robot_model
|
| 2 |
+
|
| 3 |
+
This repository provides robot and object 3D models for simulation and different environments.
|
| 4 |
+
|
| 5 |
+
## Repository Overview
|
| 6 |
+
|
| 7 |
+
- `robot/`: robot model assets (USD/USDA and configuration)
|
| 8 |
+
- `objects/`: task-related object assets
|
| 9 |
+
- `scene/`: task-related scene assets
|
| 10 |
+
- `baseline/`: baseline policy weight
|
| 11 |
+
|
| 12 |
+
## Git Clone (with Git LFS)
|
| 13 |
+
|
| 14 |
+
This repository stores model files with **Git LFS**
|
| 15 |
+
|
| 16 |
+
Clone repository
|
| 17 |
+
|
| 18 |
+
```bash
|
| 19 |
+
git clone https://github.com/skywoodsz/atec_robot_model.git
|
| 20 |
+
cd atec_robot_model
|
| 21 |
+
```
|
| 22 |
+
|
| 23 |
+
Pull LFS files
|
| 24 |
+
|
| 25 |
+
```bash
|
| 26 |
+
git lfs pull
|
| 27 |
+
```
|
atec_robot_model/robot/piper/configuration/piper_physics.usd
ADDED
|
Binary file (5.55 kB). View file
|
|
|
atec_robot_model/robot/piper/configuration/piper_sensor.usd
ADDED
|
Binary file (645 Bytes). View file
|
|
|
atec_robot_model/robot/tron1/configuration/WF_TRON1A_physics.usd
ADDED
|
Binary file (13.1 kB). View file
|
|
|
atec_robot_model/robot/tron1/configuration/WF_TRON1A_sensor.usd
ADDED
|
Binary file (651 Bytes). View file
|
|
|
atec_robot_model/robot/tron2/SFYG_TRON2A/configuration/robot_physics.usd
ADDED
|
Binary file (11.3 kB). View file
|
|
|
atec_robot_model/robot/tron2/SFYG_TRON2A/configuration/robot_robot.usd
ADDED
|
Binary file (2.5 kB). View file
|
|
|
atec_robot_model/robot/tron2/SFYG_TRON2A/configuration/robot_sensor.usd
ADDED
|
Binary file (653 Bytes). View file
|
|
|
atec_robot_model/robot/tron2/SFYG_TRON2A/robot.usd
ADDED
|
Binary file (1.46 kB). View file
|
|
|
atec_robot_model/robot/tron2/WFYG_TRON2A/configuration/robot_physics.usd
ADDED
|
Binary file (11.2 kB). View file
|
|
|
atec_robot_model/robot/tron2/WFYG_TRON2A/configuration/robot_robot.usd
ADDED
|
Binary file (2.5 kB). View file
|
|
|
atec_robot_model/robot/tron2/WFYG_TRON2A/configuration/robot_sensor.usd
ADDED
|
Binary file (653 Bytes). View file
|
|
|
atec_robot_model/robot/tron2/WFYG_TRON2A/robot.usd
ADDED
|
Binary file (1.46 kB). View file
|
|
|
atec_robot_model/scene/plane/default_environment.usd
ADDED
|
Binary file (13.6 kB). View file
|
|
|
demo/Dockerfile
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# 基础镜像(选手可自由选择)
|
| 2 |
+
FROM ac2-registry.cn-hangzhou.cr.aliyuncs.com/ac2/pytorch:2.7.1.8-cuda12.8.1-py312-alinux3.2104
|
| 3 |
+
|
| 4 |
+
# 设置时区(不要改)
|
| 5 |
+
ENV TZ=Asia/Shanghai
|
| 6 |
+
|
| 7 |
+
# 基础设置(不要改)
|
| 8 |
+
RUN set -x && \
|
| 9 |
+
groupadd -g 1000 admin && \
|
| 10 |
+
useradd -u 1000 -g admin -m admin && \
|
| 11 |
+
mkdir -p /home/admin/appspace/atec2026/robot/solution/ && \
|
| 12 |
+
chown -R admin:admin /home/admin/appspace
|
| 13 |
+
|
| 14 |
+
# 将镜像自带的 python ac2 虚拟环境所有者改为 admin 用户(选手根据实际情况调整)
|
| 15 |
+
RUN chown -R admin:admin /opt/ac2
|
| 16 |
+
|
| 17 |
+
# 设置 pip 源(选手根据实际情况调整)
|
| 18 |
+
ENV PIP_INDEX_URL=https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple
|
| 19 |
+
ENV PIP_TRUSTED_HOST=mirrors.tuna.tsinghua.edu.cn
|
| 20 |
+
|
| 21 |
+
# 使用 admin 用户运行(不要改)
|
| 22 |
+
USER admin
|
| 23 |
+
|
| 24 |
+
# 工作目录(不要改)
|
| 25 |
+
WORKDIR /home/admin/appspace/atec2026/robot
|
| 26 |
+
|
| 27 |
+
# 选手的文件都要放到 solution 目录下(不要改)
|
| 28 |
+
|
| 29 |
+
# 通用文件:run.sh,requirements.txt,server.py
|
| 30 |
+
COPY --chown=admin:admin run.sh ./solution/
|
| 31 |
+
COPY --chown=admin:admin requirements.txt ./solution/
|
| 32 |
+
COPY --chown=admin:admin server.py ./solution/
|
| 33 |
+
|
| 34 |
+
# Task E ACT/XSA submission
|
| 35 |
+
COPY --chown=admin:admin solution_act.py ./solution/solution.py
|
| 36 |
+
COPY --chown=admin:admin act ./solution/act
|
| 37 |
+
COPY --chown=admin:admin policy_act.pt ./solution/policy_act.pt
|
| 38 |
+
|
| 39 |
+
# demo2: RL demo
|
| 40 |
+
# COPY --chown=admin:admin solution_rl.py ./solution/solution.py
|
| 41 |
+
# COPY --chown=admin:admin policy.pt ./solution/
|
| 42 |
+
|
| 43 |
+
# demo3: ACT demo
|
| 44 |
+
# COPY --chown=admin:admin solution_act.py ./solution/solution.py
|
| 45 |
+
# COPY --chown=admin:admin act ./solution/act
|
| 46 |
+
# COPY --chown=admin:admin policy_act.pt ./solution/policy_act.pt
|
| 47 |
+
|
| 48 |
+
|
| 49 |
+
# 赋予 run.sh 可执行权限(不要改)
|
| 50 |
+
RUN set -x && \
|
| 51 |
+
chmod +x ./solution/run.sh
|
| 52 |
+
|
| 53 |
+
# 在工作目录下创建虚拟环境软链接,复用镜像自带的 python ac2 虚拟环境(选手根据实际情况调整)
|
| 54 |
+
RUN set -x && \
|
| 55 |
+
ln -s /opt/ac2 venv
|
| 56 |
+
|
| 57 |
+
# python 虚拟环境设置,并安装HTTP服务所需依赖(不要改)
|
| 58 |
+
RUN set -x && \
|
| 59 |
+
source ./venv/bin/activate && \
|
| 60 |
+
pip install --no-cache-dir fastapi==0.136.0 uvicorn==0.45.0 python-multipart==0.0.26
|
| 61 |
+
|
| 62 |
+
# 依赖安装(选手根据实际情况调整)
|
| 63 |
+
RUN set -x && \
|
| 64 |
+
source ./venv/bin/activate && \
|
| 65 |
+
if [ -s "solution/requirements.txt" ]; then \
|
| 66 |
+
pip install --no-cache-dir -r solution/requirements.txt; \
|
| 67 |
+
fi
|
| 68 |
+
|
| 69 |
+
# 选手镜像启动命令(不要改)
|
| 70 |
+
CMD ["./solution/run.sh"]
|
demo/__init__.py
ADDED
|
File without changes
|
demo/requirements.txt
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
h5py
|
| 2 |
+
fastapi
|
| 3 |
+
uvicorn
|
| 4 |
+
python-multipart
|
demo/run.sh
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
set -e
|
| 3 |
+
mkdir -p /home/admin/logs/atec2026/robot/solution
|
| 4 |
+
cd /home/admin/appspace/atec2026/robot
|
| 5 |
+
source ./venv/bin/activate
|
| 6 |
+
python solution/server.py 2>&1 | tee /home/admin/logs/atec2026/robot/solution/server.stdout
|
demo/server.py
ADDED
|
@@ -0,0 +1,166 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from fastapi import FastAPI, Request, Form, File, UploadFile
|
| 2 |
+
from fastapi.responses import JSONResponse
|
| 3 |
+
import logging
|
| 4 |
+
import os
|
| 5 |
+
import sys
|
| 6 |
+
import signal
|
| 7 |
+
import threading
|
| 8 |
+
import base64
|
| 9 |
+
import torch
|
| 10 |
+
import pickle
|
| 11 |
+
import json
|
| 12 |
+
from io import BytesIO
|
| 13 |
+
import numpy as np
|
| 14 |
+
from typing import Optional
|
| 15 |
+
|
| 16 |
+
def setup_logging():
|
| 17 |
+
"""Setup logging configuration with LOG_DIR environment variable support"""
|
| 18 |
+
# default log directory: atec/logs/
|
| 19 |
+
project_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
| 20 |
+
log_dir = os.environ.get('LOG_DIR', os.path.join(project_dir, 'logs'))
|
| 21 |
+
|
| 22 |
+
# Create log directory if it doesn't exist
|
| 23 |
+
if not os.path.exists(log_dir):
|
| 24 |
+
os.makedirs(log_dir)
|
| 25 |
+
|
| 26 |
+
log_file = os.path.join(log_dir, 'user.log')
|
| 27 |
+
|
| 28 |
+
# Create module-specific logger
|
| 29 |
+
logger = logging.getLogger(__name__)
|
| 30 |
+
logger.setLevel(logging.INFO)
|
| 31 |
+
|
| 32 |
+
# Create formatter
|
| 33 |
+
formatter = logging.Formatter('%(asctime)s - %(levelname)s - %(message)s')
|
| 34 |
+
|
| 35 |
+
# Create file handler
|
| 36 |
+
file_handler = logging.FileHandler(log_file)
|
| 37 |
+
file_handler.setFormatter(formatter)
|
| 38 |
+
|
| 39 |
+
# Create console handler
|
| 40 |
+
console_handler = logging.StreamHandler(sys.stdout)
|
| 41 |
+
console_handler.setFormatter(formatter)
|
| 42 |
+
|
| 43 |
+
# Add handlers to logger
|
| 44 |
+
logger.addHandler(file_handler)
|
| 45 |
+
if os.environ.get('LOG_TO_CONSOLE'):
|
| 46 |
+
logger.addHandler(console_handler)
|
| 47 |
+
|
| 48 |
+
return logger
|
| 49 |
+
|
| 50 |
+
# Setup logging
|
| 51 |
+
logger = setup_logging()
|
| 52 |
+
|
| 53 |
+
|
| 54 |
+
try:
|
| 55 |
+
from solution import AlgSolution
|
| 56 |
+
agent = AlgSolution()
|
| 57 |
+
except Exception as e:
|
| 58 |
+
import traceback
|
| 59 |
+
logger.error("Failed to initialize AlgSolution: %s", traceback.format_exc())
|
| 60 |
+
exit(-1)
|
| 61 |
+
|
| 62 |
+
app = FastAPI()
|
| 63 |
+
|
| 64 |
+
logger.info("Server started")
|
| 65 |
+
|
| 66 |
+
@app.post('/step')
|
| 67 |
+
async def step(
|
| 68 |
+
proprio: UploadFile = File(),
|
| 69 |
+
extero: Optional[UploadFile] = File(None),
|
| 70 |
+
head_rgb: Optional[UploadFile] = File(None),
|
| 71 |
+
head_depth: Optional[UploadFile] = File(None),
|
| 72 |
+
ee_rgb: UploadFile = File(),
|
| 73 |
+
ee_depth: UploadFile = File(),
|
| 74 |
+
video_rgb: Optional[UploadFile] = File(None),
|
| 75 |
+
video_depth: Optional[UploadFile] = File(None),
|
| 76 |
+
current_score: float= Form(),
|
| 77 |
+
):
|
| 78 |
+
|
| 79 |
+
proprio = torch.tensor(np.frombuffer(await proprio.read(), dtype=np.float32).reshape(1, -1)).cuda()
|
| 80 |
+
extero = torch.tensor(np.frombuffer(await extero.read(), dtype=np.float32).reshape(1, -1)).cuda() if extero is not None else None
|
| 81 |
+
head_rgb = torch.tensor(np.frombuffer(await head_rgb.read(), dtype=np.uint8).reshape(1, 480, 640, 3)).cuda() if head_rgb is not None else None
|
| 82 |
+
head_depth = torch.tensor(np.frombuffer(await head_depth.read(), dtype=np.float32).reshape(1, 480, 640, 1)).cuda() if head_depth is not None else None
|
| 83 |
+
video_rgb = torch.tensor(np.frombuffer(await video_rgb.read(), dtype=np.uint8).reshape(1, 480, 640, 3)).cuda() if video_rgb is not None else None
|
| 84 |
+
video_depth = torch.tensor(np.frombuffer(await video_depth.read(), dtype=np.float32).reshape(1, 480, 640, 1)).cuda() if video_depth is not None else None
|
| 85 |
+
|
| 86 |
+
ee_rgb = torch.tensor(np.frombuffer(await ee_rgb.read(), dtype=np.uint8).reshape(1, 480, 640, 3)).cuda()
|
| 87 |
+
ee_depth = torch.tensor(np.frombuffer(await ee_depth.read(), dtype=np.float32).reshape(1, 480, 640, 1)).cuda()
|
| 88 |
+
|
| 89 |
+
if head_rgb is not None:
|
| 90 |
+
obs = {
|
| 91 |
+
'proprio': proprio,
|
| 92 |
+
'extero': extero,
|
| 93 |
+
'image': {
|
| 94 |
+
'head_rgb': head_rgb,
|
| 95 |
+
'head_depth': head_depth,
|
| 96 |
+
'ee_rgb': ee_rgb,
|
| 97 |
+
'ee_depth': ee_depth,
|
| 98 |
+
}
|
| 99 |
+
}
|
| 100 |
+
else:
|
| 101 |
+
obs = {
|
| 102 |
+
'proprio': proprio,
|
| 103 |
+
'extero': extero,
|
| 104 |
+
'image': {
|
| 105 |
+
'video_rgb': video_rgb,
|
| 106 |
+
'video_depth': video_depth,
|
| 107 |
+
'ee_rgb': ee_rgb,
|
| 108 |
+
'ee_depth': ee_depth,
|
| 109 |
+
}
|
| 110 |
+
}
|
| 111 |
+
action = agent.predicts(obs=obs, current_score=current_score)
|
| 112 |
+
return action
|
| 113 |
+
|
| 114 |
+
@app.post('/reset')
|
| 115 |
+
async def reset(request: Request):
|
| 116 |
+
form_data = await request.json()
|
| 117 |
+
agent.reset(**form_data)
|
| 118 |
+
return {"message": "success"}
|
| 119 |
+
|
| 120 |
+
@app.get('/synchronize')
|
| 121 |
+
async def synchronize():
|
| 122 |
+
return {"message": "success"}
|
| 123 |
+
|
| 124 |
+
@app.get('/health')
|
| 125 |
+
async def health():
|
| 126 |
+
return {"message": "success"}
|
| 127 |
+
|
| 128 |
+
|
| 129 |
+
@app.get('/get_action_spec')
|
| 130 |
+
async def get_action_spec():
|
| 131 |
+
if hasattr(agent, 'get_action_spec'):
|
| 132 |
+
return agent.get_action_spec()
|
| 133 |
+
logger.warning("'get_action_spec' not found in solution")
|
| 134 |
+
return {}
|
| 135 |
+
|
| 136 |
+
|
| 137 |
+
@app.post('/stop')
|
| 138 |
+
async def stop(request: Request):
|
| 139 |
+
body = await request.json()
|
| 140 |
+
msg = body.get('msg')
|
| 141 |
+
logger.info("Stop message received: %s", msg)
|
| 142 |
+
return {"message": "success"}
|
| 143 |
+
|
| 144 |
+
@app.post('/quit')
|
| 145 |
+
async def quit(request: Request):
|
| 146 |
+
"""Gracefully shutdown the FastAPI application"""
|
| 147 |
+
body = await request.json()
|
| 148 |
+
msg = body.get('msg', 'quit')
|
| 149 |
+
logger.info("Quit message received: %s", msg)
|
| 150 |
+
|
| 151 |
+
# Use a timer to shutdown the server after sending response
|
| 152 |
+
def shutdown_server():
|
| 153 |
+
import uvicorn
|
| 154 |
+
logger.info("Shutting down the server...")
|
| 155 |
+
# This will send SIGTERM to the process
|
| 156 |
+
os.kill(os.getpid(), signal.SIGTERM)
|
| 157 |
+
|
| 158 |
+
# Start shutdown in a separate thread with a small delay to ensure response is sent
|
| 159 |
+
shutdown_timer = threading.Timer(1.0, shutdown_server)
|
| 160 |
+
shutdown_timer.start()
|
| 161 |
+
|
| 162 |
+
return {"message": "Server is shutting down gracefully"}
|
| 163 |
+
|
| 164 |
+
if __name__ == '__main__':
|
| 165 |
+
import uvicorn
|
| 166 |
+
uvicorn.run(app, host='0.0.0.0', port=5000)
|
demo/solution.py
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Submission entry point for ATEC Task E.
|
| 2 |
+
|
| 3 |
+
The judging server imports `solution.AlgSolution`, so keep this tiny wrapper in
|
| 4 |
+
place and put the actual ACT/XSA implementation in `solution_act.py`.
|
| 5 |
+
"""
|
| 6 |
+
|
| 7 |
+
import os
|
| 8 |
+
import sys
|
| 9 |
+
|
| 10 |
+
_DEMO_DIR = os.path.dirname(os.path.abspath(__file__))
|
| 11 |
+
if _DEMO_DIR not in sys.path:
|
| 12 |
+
sys.path.insert(0, _DEMO_DIR)
|
| 13 |
+
|
| 14 |
+
try:
|
| 15 |
+
from .solution_act import AlgSolution
|
| 16 |
+
except ImportError:
|
| 17 |
+
from solution_act import AlgSolution
|
demo/solution_act.py
ADDED
|
@@ -0,0 +1,292 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch
|
| 2 |
+
import torch.nn as nn
|
| 3 |
+
from collections import deque
|
| 4 |
+
import torchvision.transforms.functional as TF
|
| 5 |
+
import torchvision.transforms as T
|
| 6 |
+
from dataclasses import dataclass
|
| 7 |
+
import sys
|
| 8 |
+
import os
|
| 9 |
+
|
| 10 |
+
current_path = os.path.dirname(os.path.abspath(__file__))
|
| 11 |
+
#sys.path.insert(0, current_path)
|
| 12 |
+
|
| 13 |
+
from act.detr.backbone import build_backbone
|
| 14 |
+
from act.detr.transformer import build_transformer
|
| 15 |
+
from act.detr.detr_vae import build_encoder, DETRVAE
|
| 16 |
+
|
| 17 |
+
@dataclass
|
| 18 |
+
class Args:
|
| 19 |
+
torch_deterministic: bool = True
|
| 20 |
+
"""if toggled, `torch.backends.cudnn.deterministic=False`"""
|
| 21 |
+
cuda: bool = True
|
| 22 |
+
"""if toggled, cuda will be enabled by default"""
|
| 23 |
+
temporal_agg: bool = True
|
| 24 |
+
"""if toggled, temporal ensembling will be performed at inference"""
|
| 25 |
+
|
| 26 |
+
# Backbone
|
| 27 |
+
position_embedding: str = 'sine'
|
| 28 |
+
backbone: str = 'resnet18'
|
| 29 |
+
lr_backbone: float = 1e-5
|
| 30 |
+
masks: bool = False
|
| 31 |
+
dilation: bool = False
|
| 32 |
+
include_depth: bool = False
|
| 33 |
+
"""always False — depth not collected; kept for backbone API compatibility"""
|
| 34 |
+
include_rgb: bool = True
|
| 35 |
+
"""use RGB images as input (requires --save_images during collection)"""
|
| 36 |
+
|
| 37 |
+
# Transformer
|
| 38 |
+
enc_layers: int = 2
|
| 39 |
+
dec_layers: int = 4
|
| 40 |
+
dim_feedforward: int = 512
|
| 41 |
+
hidden_dim: int = 256
|
| 42 |
+
dropout: float = 0.1
|
| 43 |
+
nheads: int = 8
|
| 44 |
+
num_queries: int = 30
|
| 45 |
+
pre_norm: bool = False
|
| 46 |
+
use_xsa: bool = False
|
| 47 |
+
|
| 48 |
+
|
| 49 |
+
class Agent(nn.Module):
|
| 50 |
+
def __init__(self, state_dim: int, act_dim: int, args: Args):
|
| 51 |
+
super().__init__()
|
| 52 |
+
self.device = 'cuda'
|
| 53 |
+
self.state_dim = state_dim
|
| 54 |
+
self.act_dim = act_dim
|
| 55 |
+
self.normalize = T.Normalize(mean=[0.485, 0.456, 0.406],
|
| 56 |
+
std=[0.229, 0.224, 0.225])
|
| 57 |
+
self.include_rgb = args.include_rgb
|
| 58 |
+
|
| 59 |
+
# CNN backbone — None for state-only mode (DETRVAE handles both paths)
|
| 60 |
+
backbones = [build_backbone(args)] if args.include_rgb else None
|
| 61 |
+
|
| 62 |
+
# CVAE decoder
|
| 63 |
+
transformer = build_transformer(args)
|
| 64 |
+
|
| 65 |
+
# CVAE encoder
|
| 66 |
+
encoder = build_encoder(args)
|
| 67 |
+
|
| 68 |
+
# ACT ( CVAE encoder + (CNN backbones + CVAE decoder) )
|
| 69 |
+
self.model = DETRVAE(
|
| 70 |
+
backbones,
|
| 71 |
+
transformer,
|
| 72 |
+
encoder,
|
| 73 |
+
state_dim=state_dim,
|
| 74 |
+
action_dim=act_dim,
|
| 75 |
+
num_queries=args.num_queries,
|
| 76 |
+
)
|
| 77 |
+
|
| 78 |
+
|
| 79 |
+
|
| 80 |
+
def _preprocess_rgb(self, obs: dict) -> None:
|
| 81 |
+
if self.include_rgb and 'rgb' in obs:
|
| 82 |
+
obs['rgb'] = obs['rgb'].float() / 255.0
|
| 83 |
+
# obs['rgb']: (B, num_cams, 3, 224, 224)
|
| 84 |
+
B, N, C, H, W = obs['rgb'].shape
|
| 85 |
+
obs['rgb'] = self.normalize(obs['rgb'].view(B * N, C, H, W)).view(B, N, C, H, W)
|
| 86 |
+
|
| 87 |
+
def _model_input(self, obs: dict):
|
| 88 |
+
# DETRVAE state-only path expects the state tensor directly, not a dict
|
| 89 |
+
return obs if self.include_rgb else obs['state']
|
| 90 |
+
|
| 91 |
+
def get_action(self, obs: dict) -> torch.Tensor:
|
| 92 |
+
self._preprocess_rgb(obs)
|
| 93 |
+
a_hat, _ = self.model(self._model_input(obs))
|
| 94 |
+
return a_hat
|
| 95 |
+
|
| 96 |
+
|
| 97 |
+
|
| 98 |
+
class AlgSolution:
|
| 99 |
+
|
| 100 |
+
# Slice into proprio for joint positions (relative to default).
|
| 101 |
+
_QPOS_SLICE = slice(0, 8)
|
| 102 |
+
_QVEL_SLICE = slice(8, 16)
|
| 103 |
+
_RGB_CHANNELS = 3
|
| 104 |
+
_CONCAT_IMAGE_CHANNELS = 8
|
| 105 |
+
|
| 106 |
+
def __init__(self):
|
| 107 |
+
self.device = 'cuda'
|
| 108 |
+
# Default to the submission-layout policy file, but allow local eval to
|
| 109 |
+
# point at a checkpoint without copying 100MB+ files around.
|
| 110 |
+
policy_path = os.environ.get("ATEC_ACT_POLICY_PATH", current_path + '/policy_act.pt')
|
| 111 |
+
ckpt = torch.load(policy_path, map_location=self.device)
|
| 112 |
+
norm_stats = ckpt["norm_stats"]
|
| 113 |
+
state_dim = norm_stats["state_mean"].shape[-1]
|
| 114 |
+
act_dim = norm_stats["action_mean"].shape[-1]
|
| 115 |
+
weight_key = "ema_agent"# if use_ema and "ema_agent" in ckpt else "agent"
|
| 116 |
+
|
| 117 |
+
train_args = Args()
|
| 118 |
+
model_args = ckpt.get("model_args", {})
|
| 119 |
+
for key in (
|
| 120 |
+
"enc_layers",
|
| 121 |
+
"dec_layers",
|
| 122 |
+
"dim_feedforward",
|
| 123 |
+
"hidden_dim",
|
| 124 |
+
"dropout",
|
| 125 |
+
"nheads",
|
| 126 |
+
"num_queries",
|
| 127 |
+
"pre_norm",
|
| 128 |
+
"use_xsa",
|
| 129 |
+
):
|
| 130 |
+
if key in model_args:
|
| 131 |
+
setattr(train_args, key, model_args[key])
|
| 132 |
+
train_args.include_rgb = model_args.get(
|
| 133 |
+
"include_rgb",
|
| 134 |
+
any("backbone" in k for k in ckpt[weight_key].keys()),
|
| 135 |
+
)
|
| 136 |
+
|
| 137 |
+
self.agent = Agent(state_dim, act_dim, train_args).to(self.device)
|
| 138 |
+
self.agent.load_state_dict(ckpt[weight_key])
|
| 139 |
+
self.agent.eval()
|
| 140 |
+
|
| 141 |
+
self.num_queries = train_args.num_queries
|
| 142 |
+
self.temporal_agg = os.environ.get("ATEC_ACT_TEMPORAL_AGG", "1").lower() not in ("0", "false", "no")
|
| 143 |
+
self._k = float(os.environ.get("ATEC_ACT_TEMPORAL_K", "0.01"))
|
| 144 |
+
self._prefer_new_actions = os.environ.get("ATEC_ACT_PREFER_NEW", "0").lower() in ("1", "true", "yes")
|
| 145 |
+
|
| 146 |
+
self.state_mean = norm_stats["state_mean"].to(self.device) # (1, state_dim)
|
| 147 |
+
self.state_std = norm_stats["state_std"].to(self.device) # (1, state_dim)
|
| 148 |
+
self.act_mean = norm_stats["action_mean"].to(self.device) # (1, act_dim)
|
| 149 |
+
self.act_std = norm_stats["action_std"].to(self.device) # (1, act_dim)
|
| 150 |
+
|
| 151 |
+
self.default_joint_pos = torch.tensor(
|
| 152 |
+
[[0.0, 1.2, -1.5, 0.0, 1.2, 0.0, 0.035, -0.035]],
|
| 153 |
+
dtype=torch.float32,
|
| 154 |
+
device=self.device,
|
| 155 |
+
)
|
| 156 |
+
# Per-episode state
|
| 157 |
+
self._ts: int = 0
|
| 158 |
+
self._action_history: deque = deque(maxlen=self.num_queries)
|
| 159 |
+
self._last_action_seq: torch.Tensor | None = None
|
| 160 |
+
|
| 161 |
+
|
| 162 |
+
startup_zero_steps = 25
|
| 163 |
+
home_qpos_tolerance = 0.10
|
| 164 |
+
home_hold_steps = 5
|
| 165 |
+
|
| 166 |
+
self.teleop_home_joint_pos = torch.tensor(
|
| 167 |
+
[[-0.000033, 0.924525, -1.514983, 0.000011, 1.219900, -0.000033, 0.035000, -0.035000]],
|
| 168 |
+
dtype=torch.float32,
|
| 169 |
+
device=self.device,
|
| 170 |
+
)
|
| 171 |
+
|
| 172 |
+
self._startup_zero_steps = max(0, int(startup_zero_steps))
|
| 173 |
+
self._home_qpos_tolerance = float(home_qpos_tolerance)
|
| 174 |
+
self._home_hold_steps = max(0, int(home_hold_steps))
|
| 175 |
+
self._home_action = torch.clamp(
|
| 176 |
+
(self.teleop_home_joint_pos - self.default_joint_pos) / 0.5,
|
| 177 |
+
-1.0,
|
| 178 |
+
1.0,
|
| 179 |
+
)
|
| 180 |
+
|
| 181 |
+
self._startup_step = 0
|
| 182 |
+
self._home_stable_steps = 0
|
| 183 |
+
self._home_done = False
|
| 184 |
+
|
| 185 |
+
def reset_episode(self):
|
| 186 |
+
self._ts = 0
|
| 187 |
+
self._action_history.clear()
|
| 188 |
+
self._last_action_seq = None
|
| 189 |
+
self._startup_step = 0
|
| 190 |
+
self._home_stable_steps = 0
|
| 191 |
+
self._home_done = False
|
| 192 |
+
|
| 193 |
+
def get_action_spec(self):
|
| 194 |
+
# Use the official default Task-E Piper action configuration.
|
| 195 |
+
return None
|
| 196 |
+
|
| 197 |
+
|
| 198 |
+
def _compute_home_action(self, proprio):
|
| 199 |
+
joint_pos_rel = proprio[:, self._QPOS_SLICE]
|
| 200 |
+
qpos = joint_pos_rel + self.default_joint_pos
|
| 201 |
+
qerr = self.teleop_home_joint_pos - qpos
|
| 202 |
+
|
| 203 |
+
within_tolerance = torch.all(torch.abs(qerr) <= self._home_qpos_tolerance, dim=1)
|
| 204 |
+
self._home_stable_steps = self._home_stable_steps + 1 if bool(torch.all(within_tolerance)) else 0
|
| 205 |
+
|
| 206 |
+
# Env action is a relative joint-position target, not velocity/torque.
|
| 207 |
+
# Keep commanding the absolute teleop-home target until the ACT rollout starts.
|
| 208 |
+
action = self._home_action.repeat(proprio.shape[0], 1)
|
| 209 |
+
home_reached = self._home_stable_steps >= self._home_hold_steps
|
| 210 |
+
return action, home_reached
|
| 211 |
+
|
| 212 |
+
|
| 213 |
+
def predicts(self, obs, current_score):
|
| 214 |
+
if not isinstance(obs, dict) or "proprio" not in obs:
|
| 215 |
+
raise ValueError("Expected obs dict with 'proprio' key.")
|
| 216 |
+
|
| 217 |
+
proprio = obs["proprio"].to(self.device) # (num_envs, 24)
|
| 218 |
+
|
| 219 |
+
# Stage 1: output zero actions for the first few steps.
|
| 220 |
+
if self._startup_step < self._startup_zero_steps:
|
| 221 |
+
self._startup_step += 1
|
| 222 |
+
return {'action': torch.zeros((proprio.shape[0], self.agent.act_dim)).numpy().tolist(), 'giveup': False}
|
| 223 |
+
|
| 224 |
+
# Stage 2: move to teleop_home using only observations.
|
| 225 |
+
if not self._home_done:
|
| 226 |
+
home_action, home_reached = self._compute_home_action(proprio)
|
| 227 |
+
if home_reached:
|
| 228 |
+
self._home_done = True
|
| 229 |
+
self._ts = 0
|
| 230 |
+
self._action_history.clear()
|
| 231 |
+
self._last_action_seq = None
|
| 232 |
+
return {'action': home_action.cpu().numpy().tolist(), 'giveup': False}
|
| 233 |
+
|
| 234 |
+
# Recover absolute joint positions from relative obs.
|
| 235 |
+
joint_pos_rel = proprio[:, self._QPOS_SLICE] # (num_envs, 8)
|
| 236 |
+
qpos = joint_pos_rel + self.default_joint_pos # (num_envs, 8)
|
| 237 |
+
state = (qpos - self.state_mean) / self.state_std # (num_envs, 8)
|
| 238 |
+
model_obs = {"state": state}
|
| 239 |
+
|
| 240 |
+
if self.agent.include_rgb:
|
| 241 |
+
rgb = obs["image"]["video_rgb"].to(self.device)
|
| 242 |
+
if rgb.shape[1] == 4:
|
| 243 |
+
rgb = rgb[:, :3] # drop alpha if RGBA/NCHW
|
| 244 |
+
if rgb.ndim == 4 and rgb.shape[-1] == 4:
|
| 245 |
+
rgb = rgb[..., :3] # drop alpha if RGBA/NHWC
|
| 246 |
+
if rgb.dtype != torch.uint8:
|
| 247 |
+
rgb = (rgb.float() * 255.0).clamp(0, 255).to(torch.uint8)
|
| 248 |
+
if rgb.ndim == 4 and rgb.shape[1] in (3, 4):
|
| 249 |
+
pass
|
| 250 |
+
else:
|
| 251 |
+
rgb = rgb.permute(0, 3, 1, 2)
|
| 252 |
+
if rgb.shape[-2:] != (224, 224):
|
| 253 |
+
rgb = TF.resize(rgb, [224, 224],
|
| 254 |
+
interpolation=TF.InterpolationMode.BILINEAR,
|
| 255 |
+
antialias=True)
|
| 256 |
+
model_obs["rgb"] = rgb.unsqueeze(1) # (num_envs, 1, 3, 224, 224) uint8
|
| 257 |
+
|
| 258 |
+
ts = self._ts
|
| 259 |
+
query_frequency = 1 if self.temporal_agg else self.num_queries
|
| 260 |
+
|
| 261 |
+
if ts % query_frequency == 0:
|
| 262 |
+
with torch.no_grad():
|
| 263 |
+
action_seq = self.agent.get_action(model_obs) # (num_envs, num_queries, act_dim)
|
| 264 |
+
if self.temporal_agg:
|
| 265 |
+
self._action_history.append(action_seq)
|
| 266 |
+
else:
|
| 267 |
+
self._last_action_seq = action_seq
|
| 268 |
+
|
| 269 |
+
if self.temporal_agg:
|
| 270 |
+
n = len(self._action_history)
|
| 271 |
+
# deque[i=0] = oldest (added n-1 steps ago); for current step its offset = n-1-i
|
| 272 |
+
actions_for_curr = torch.stack(
|
| 273 |
+
[seq[:, n - 1 - i, :] for i, seq in enumerate(self._action_history)],
|
| 274 |
+
dim=1,
|
| 275 |
+
) # (num_envs, n, act_dim)
|
| 276 |
+
|
| 277 |
+
# Default preserves the original convention. ATECs long-horizon
|
| 278 |
+
# rollout can also be evaluated with newer predictions weighted
|
| 279 |
+
# higher via ATEC_ACT_PREFER_NEW=1.
|
| 280 |
+
order = torch.arange(n, device=self.device)
|
| 281 |
+
if self._prefer_new_actions:
|
| 282 |
+
order = torch.flip(order, dims=[0])
|
| 283 |
+
exp_weights = torch.exp(-self._k * order)
|
| 284 |
+
exp_weights = (exp_weights / exp_weights.sum()).unsqueeze(0).unsqueeze(-1)
|
| 285 |
+
raw_action = (actions_for_curr * exp_weights).sum(dim=1) # (num_envs, act_dim)
|
| 286 |
+
else:
|
| 287 |
+
raw_action = self._last_action_seq[:, ts % query_frequency] # (num_envs, act_dim)
|
| 288 |
+
|
| 289 |
+
# Denormalise → env action format
|
| 290 |
+
action = raw_action * self.act_std + self.act_mean
|
| 291 |
+
self._ts += 1
|
| 292 |
+
return {'action': action.tolist(), 'giveup': False}
|
demo/solution_dual_act.py
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Two-ACT relay experiment for ATEC Task E.
|
| 2 |
+
|
| 3 |
+
Both policies are stepped on every observation so their temporal histories stay
|
| 4 |
+
aligned with the actual rollout. The primary policy controls the reliable
|
| 5 |
+
early phase; after the score reaches the configured band, the secondary policy
|
| 6 |
+
may take over the late object_1 phase.
|
| 7 |
+
"""
|
| 8 |
+
|
| 9 |
+
from __future__ import annotations
|
| 10 |
+
|
| 11 |
+
import os
|
| 12 |
+
|
| 13 |
+
from solution_act import AlgSolution as _ActSolution
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
class AlgSolution:
|
| 17 |
+
def __init__(self):
|
| 18 |
+
self._primary_path = os.environ.get("ATEC_DUAL_PRIMARY_POLICY", os.environ.get("ATEC_ACT_POLICY_PATH", ""))
|
| 19 |
+
self._secondary_path = os.environ.get("ATEC_DUAL_SECONDARY_POLICY", "")
|
| 20 |
+
if not self._secondary_path:
|
| 21 |
+
raise RuntimeError("ATEC_DUAL_SECONDARY_POLICY is required for solution_dual_act")
|
| 22 |
+
|
| 23 |
+
old_policy_path = os.environ.get("ATEC_ACT_POLICY_PATH")
|
| 24 |
+
try:
|
| 25 |
+
if self._primary_path:
|
| 26 |
+
os.environ["ATEC_ACT_POLICY_PATH"] = self._primary_path
|
| 27 |
+
self.primary = _ActSolution()
|
| 28 |
+
os.environ["ATEC_ACT_POLICY_PATH"] = self._secondary_path
|
| 29 |
+
self.secondary = _ActSolution()
|
| 30 |
+
finally:
|
| 31 |
+
if old_policy_path is None:
|
| 32 |
+
os.environ.pop("ATEC_ACT_POLICY_PATH", None)
|
| 33 |
+
else:
|
| 34 |
+
os.environ["ATEC_ACT_POLICY_PATH"] = old_policy_path
|
| 35 |
+
|
| 36 |
+
self._switch_score = float(os.environ.get("ATEC_DUAL_SWITCH_SCORE", "12.0"))
|
| 37 |
+
self._switch_act_steps = int(os.environ.get("ATEC_DUAL_SWITCH_ACT_STEPS", "900"))
|
| 38 |
+
self._mode = "primary"
|
| 39 |
+
self._step = 0
|
| 40 |
+
|
| 41 |
+
def reset_episode(self):
|
| 42 |
+
self.primary.reset_episode()
|
| 43 |
+
self.secondary.reset_episode()
|
| 44 |
+
self._mode = "primary"
|
| 45 |
+
self._step = 0
|
| 46 |
+
|
| 47 |
+
def get_action_spec(self):
|
| 48 |
+
return None
|
| 49 |
+
|
| 50 |
+
def predicts(self, obs, current_score):
|
| 51 |
+
self._step += 1
|
| 52 |
+
primary_resp = self.primary.predicts(obs, current_score)
|
| 53 |
+
secondary_resp = self.secondary.predicts(obs, current_score)
|
| 54 |
+
primary_steps = int(getattr(self.primary, "_ts", 0))
|
| 55 |
+
if (
|
| 56 |
+
self._mode == "primary"
|
| 57 |
+
and float(current_score) >= self._switch_score
|
| 58 |
+
and primary_steps >= self._switch_act_steps
|
| 59 |
+
):
|
| 60 |
+
self._mode = "secondary"
|
| 61 |
+
print(
|
| 62 |
+
f"[DUAL_ACT] switching to secondary score={float(current_score):.2f} "
|
| 63 |
+
f"primary_steps={primary_steps}",
|
| 64 |
+
flush=True,
|
| 65 |
+
)
|
| 66 |
+
return secondary_resp if self._mode == "secondary" else primary_resp
|
demo/solution_hybrid_obj1_pca.py
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""ACT plus object_1-only PCA rescue for Task E experiments.
|
| 2 |
+
|
| 3 |
+
This is intentionally conservative: keep the ACT policy in control until the
|
| 4 |
+
episode has already reached the 15-point band, then spend remaining time trying
|
| 5 |
+
to move object_1 into the basket. It is not the protected submission baseline.
|
| 6 |
+
"""
|
| 7 |
+
|
| 8 |
+
from __future__ import annotations
|
| 9 |
+
|
| 10 |
+
import os
|
| 11 |
+
|
| 12 |
+
os.environ.setdefault("ATEC_PCA_OBJECTS", "1")
|
| 13 |
+
|
| 14 |
+
from solution_act import AlgSolution as _ActSolution
|
| 15 |
+
from solution_pca import AlgSolution as _PcaSolution
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
class AlgSolution:
|
| 19 |
+
def __init__(self):
|
| 20 |
+
self.act = _ActSolution()
|
| 21 |
+
self.pca = _PcaSolution()
|
| 22 |
+
self._mode = "act"
|
| 23 |
+
self._pca_started = False
|
| 24 |
+
self._switch_score = float(os.environ.get("ATEC_HYBRID_SWITCH_SCORE", "15.0"))
|
| 25 |
+
self._min_act_policy_steps = int(os.environ.get("ATEC_HYBRID_MIN_ACT_POLICY_STEPS", "900"))
|
| 26 |
+
self._force_act_policy_steps = int(os.environ.get("ATEC_HYBRID_FORCE_ACT_POLICY_STEPS", "999999"))
|
| 27 |
+
self._force_env_steps = int(os.environ.get("ATEC_HYBRID_FORCE_ENV_STEPS", "999999"))
|
| 28 |
+
self._env_steps = 0
|
| 29 |
+
|
| 30 |
+
def reset_episode(self):
|
| 31 |
+
self.act.reset_episode()
|
| 32 |
+
self.pca.reset_episode()
|
| 33 |
+
self._mode = "act"
|
| 34 |
+
self._pca_started = False
|
| 35 |
+
self._env_steps = 0
|
| 36 |
+
|
| 37 |
+
def get_action_spec(self):
|
| 38 |
+
return None
|
| 39 |
+
|
| 40 |
+
def _start_pca(self, reason=""):
|
| 41 |
+
self.pca.reset_episode()
|
| 42 |
+
# ACT has already moved the arm into the workspace. Skip PCA startup
|
| 43 |
+
# and home, otherwise the late rescue often times out.
|
| 44 |
+
self.pca.t = 25
|
| 45 |
+
self.pca.home_count = 80
|
| 46 |
+
self._mode = "pca"
|
| 47 |
+
self._pca_started = True
|
| 48 |
+
print(f"[HYBRID] switching to object_1 PCA rescue {reason}".rstrip(), flush=True)
|
| 49 |
+
|
| 50 |
+
def predicts(self, obs, current_score):
|
| 51 |
+
if self._mode == "act":
|
| 52 |
+
self._env_steps += 1
|
| 53 |
+
act_steps = int(getattr(self.act, "_ts", 0))
|
| 54 |
+
score_gate = (
|
| 55 |
+
float(current_score) >= self._switch_score
|
| 56 |
+
and act_steps >= self._min_act_policy_steps
|
| 57 |
+
)
|
| 58 |
+
act_gate = act_steps >= self._force_act_policy_steps
|
| 59 |
+
env_gate = self._env_steps >= self._force_env_steps
|
| 60 |
+
if score_gate or act_gate or env_gate:
|
| 61 |
+
self._start_pca(
|
| 62 |
+
f"score={float(current_score):.2f} act_steps={act_steps} "
|
| 63 |
+
f"env_steps={self._env_steps} gate="
|
| 64 |
+
f"{'score' if score_gate else ('act' if act_gate else 'env')}"
|
| 65 |
+
)
|
| 66 |
+
else:
|
| 67 |
+
return self.act.predicts(obs, current_score)
|
| 68 |
+
return self.pca.predicts(obs, current_score)
|
demo/solution_pca.py
ADDED
|
@@ -0,0 +1,1243 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Observation-only GraspGen-style PCA/AABB controller for ATEC Task E.
|
| 2 |
+
|
| 3 |
+
This is an experimental submit-style policy: it uses only proprioception plus
|
| 4 |
+
the fixed external RGB-D camera observation to estimate object centres, then
|
| 5 |
+
drives a calibrated Piper pick/place primitive with local kinematics.
|
| 6 |
+
"""
|
| 7 |
+
|
| 8 |
+
from __future__ import annotations
|
| 9 |
+
|
| 10 |
+
import os
|
| 11 |
+
from dataclasses import dataclass
|
| 12 |
+
|
| 13 |
+
import numpy as np
|
| 14 |
+
import torch
|
| 15 |
+
|
| 16 |
+
try:
|
| 17 |
+
import pinocchio as pin
|
| 18 |
+
except Exception: # pragma: no cover - handled at runtime by the judge/server
|
| 19 |
+
pin = None
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
TABLE_CENTER_X = 1.00
|
| 23 |
+
TABLE_CENTER_Y = 0.00
|
| 24 |
+
TABLE_DIMS_AT_0P008 = (0.6468062441005529, 0.9084968693231588, 0.6613141183247961)
|
| 25 |
+
TABLE_SCALE = 0.01
|
| 26 |
+
TABLE_DIMS = tuple(dim * (TABLE_SCALE / 0.008) for dim in TABLE_DIMS_AT_0P008)
|
| 27 |
+
TABLE_HALF_X = TABLE_DIMS[0] * 0.5
|
| 28 |
+
TABLE_TOP_Z = TABLE_DIMS[2]
|
| 29 |
+
BASKET_CENTER_X = TABLE_CENTER_X + 0.08
|
| 30 |
+
BASKET_CENTER_Y = TABLE_CENTER_Y - 0.30
|
| 31 |
+
|
| 32 |
+
DEFAULT_Q = np.array([0.0, 1.2, -1.5, 0.0, 1.2, 0.0, 0.035, -0.035], dtype=np.float64)
|
| 33 |
+
HOME_Q = np.array([-0.000033, 0.924525, -1.514983, 0.000011, 1.219900, -0.000033, 0.035, -0.035], dtype=np.float64)
|
| 34 |
+
ACTION_SCALE = 0.5
|
| 35 |
+
GRIP_OPEN = np.array([0.035, -0.035], dtype=np.float64)
|
| 36 |
+
GRIP_HALF = np.array([0.018, -0.018], dtype=np.float64)
|
| 37 |
+
GRIP_CLOSE = np.array([0.0, 0.0], dtype=np.float64)
|
| 38 |
+
OBJ1_HOLD_GAP = 0.0415
|
| 39 |
+
OBJ3_HOLD_GAP = float(os.environ.get("ATEC_PCA_OBJ3_HOLD_GAP", "0.0675"))
|
| 40 |
+
OBJ3_CLOSE_MIN_STEPS = int(os.environ.get("ATEC_PCA_OBJ3_CLOSE_MIN_STEPS", "160"))
|
| 41 |
+
OBJ3_LOW_HOLD_STEPS = int(os.environ.get("ATEC_PCA_OBJ3_LOW_HOLD_STEPS", "0"))
|
| 42 |
+
OBJ3_LIFT_CLEARANCE = float(os.environ.get("ATEC_PCA_OBJ3_LIFT_CLEARANCE", "0.12"))
|
| 43 |
+
OBJ3_CARRY_CLEARANCE = float(os.environ.get("ATEC_PCA_OBJ3_CARRY_CLEARANCE", "0.145"))
|
| 44 |
+
OBJ3_OBJECT_SERVO_GAIN = float(os.environ.get("ATEC_PCA_OBJ3_OBJECT_SERVO_GAIN", "1.0"))
|
| 45 |
+
OBJ3_OBJECT_SERVO_MAX_XY = float(os.environ.get("ATEC_PCA_OBJ3_OBJECT_SERVO_MAX_XY", "0.300"))
|
| 46 |
+
OBJ3_FINGER_SERVO_MAX_XY = float(os.environ.get("ATEC_PCA_OBJ3_FINGER_SERVO_MAX_XY", "0.240"))
|
| 47 |
+
OBJ3_APPROACH_FINGER_Z = float(os.environ.get("ATEC_PCA_OBJ3_APPROACH_FINGER_Z", str(TABLE_TOP_Z + 0.090)))
|
| 48 |
+
OBJ3_CLOSE_FINGER_Z = float(os.environ.get("ATEC_PCA_OBJ3_CLOSE_FINGER_Z", str(TABLE_TOP_Z + 0.000)))
|
| 49 |
+
OBJ3_LIFT_FINGER_Z = float(os.environ.get("ATEC_PCA_OBJ3_LIFT_FINGER_Z", str(TABLE_TOP_Z + 0.045)))
|
| 50 |
+
OBJ3_ENABLE_INSERT = os.environ.get("ATEC_PCA_OBJ3_ENABLE_INSERT", "0") != "0"
|
| 51 |
+
OBJ3_PREGRASP_OFFSET = np.array(
|
| 52 |
+
[
|
| 53 |
+
float(os.environ.get("ATEC_PCA_OBJ3_PREGRASP_X_OFFSET", "0.000")),
|
| 54 |
+
float(os.environ.get("ATEC_PCA_OBJ3_PREGRASP_Y_OFFSET", "0.080")),
|
| 55 |
+
],
|
| 56 |
+
dtype=np.float64,
|
| 57 |
+
)
|
| 58 |
+
OBJ3_SIDE_APPROACH_STEPS = int(os.environ.get("ATEC_PCA_OBJ3_SIDE_APPROACH_STEPS", "160"))
|
| 59 |
+
OBJ3_SIDE_LOW_STEPS = int(os.environ.get("ATEC_PCA_OBJ3_SIDE_LOW_STEPS", "140"))
|
| 60 |
+
OBJ3_INSERT_STEPS = int(os.environ.get("ATEC_PCA_OBJ3_INSERT_STEPS", "220"))
|
| 61 |
+
OBJ3_PREGRASP_LOW_FINGER_Z = float(os.environ.get("ATEC_PCA_OBJ3_PREGRASP_LOW_FINGER_Z", str(TABLE_TOP_Z + 0.024)))
|
| 62 |
+
OBJ3_FALLBACK_DRAG_Z = float(os.environ.get("ATEC_PCA_OBJ3_FALLBACK_DRAG_Z", str(TABLE_TOP_Z + 0.035)))
|
| 63 |
+
OBJ3_FALLBACK_START_STEPS = int(os.environ.get("ATEC_PCA_OBJ3_FALLBACK_START_STEPS", "60"))
|
| 64 |
+
OBJ3_FALLBACK_MID_STEPS = int(os.environ.get("ATEC_PCA_OBJ3_FALLBACK_MID_STEPS", "260"))
|
| 65 |
+
OBJ3_FALLBACK_END_STEPS = int(os.environ.get("ATEC_PCA_OBJ3_FALLBACK_END_STEPS", "260"))
|
| 66 |
+
OBJ3_FALLBACK_OPEN_STEPS = int(os.environ.get("ATEC_PCA_OBJ3_FALLBACK_OPEN_STEPS", "100"))
|
| 67 |
+
OBJ3_DRAG_START_STEPS = int(os.environ.get("ATEC_PCA_OBJ3_DRAG_START_STEPS", "80"))
|
| 68 |
+
OBJ3_DRAG_MID_STEPS = int(os.environ.get("ATEC_PCA_OBJ3_DRAG_MID_STEPS", "360"))
|
| 69 |
+
OBJ3_DRAG_END_STEPS = int(os.environ.get("ATEC_PCA_OBJ3_DRAG_END_STEPS", "360"))
|
| 70 |
+
OBJ3_DRAG_SETTLE_STEPS = int(os.environ.get("ATEC_PCA_OBJ3_DRAG_SETTLE_STEPS", "120"))
|
| 71 |
+
PCA_DLS_MAX_DELTA = float(os.environ.get("ATEC_PCA_DLS_MAX_DELTA", "0.18"))
|
| 72 |
+
PCA_FINGER_IK_MAX_DELTA = float(os.environ.get("ATEC_PCA_FINGER_IK_MAX_DELTA", "0.18"))
|
| 73 |
+
OBJ3_GRIPPER_MAX_DELTA = float(os.environ.get("ATEC_PCA_OBJ3_GRIPPER_MAX_DELTA", "0.003"))
|
| 74 |
+
OBJ3_HOLD_GRIP_DEFAULT = np.array(
|
| 75 |
+
[
|
| 76 |
+
float(os.environ.get("ATEC_PCA_OBJ3_HOLD_Q_POS", "0.0000")),
|
| 77 |
+
float(os.environ.get("ATEC_PCA_OBJ3_HOLD_Q_NEG", "0.0000")),
|
| 78 |
+
],
|
| 79 |
+
dtype=np.float64,
|
| 80 |
+
)
|
| 81 |
+
|
| 82 |
+
BASE_POS_W = np.array([TABLE_CENTER_X + TABLE_HALF_X, TABLE_CENTER_Y, TABLE_TOP_Z], dtype=np.float64)
|
| 83 |
+
R_W_B = np.diag([-1.0, -1.0, 1.0])
|
| 84 |
+
K_VIDEO = np.array([[732.99927, 0.0, 320.0], [0.0, 732.99927, 240.0], [0.0, 0.0, 1.0]], dtype=np.float64)
|
| 85 |
+
CAM_POS_W = np.array([-0.2, 0.0, 1.6266427], dtype=np.float64)
|
| 86 |
+
CAM_QUAT_WXYZ = np.array([-0.33350849, 0.62351596, -0.62351584, 0.33350849], dtype=np.float64)
|
| 87 |
+
|
| 88 |
+
OBJ_Y_BANDS = {
|
| 89 |
+
1: (TABLE_CENTER_Y + 0.25, TABLE_CENTER_Y + 0.29),
|
| 90 |
+
2: (TABLE_CENTER_Y + 0.14, TABLE_CENTER_Y + 0.20),
|
| 91 |
+
3: (TABLE_CENTER_Y + 0.03, TABLE_CENTER_Y + 0.09),
|
| 92 |
+
}
|
| 93 |
+
OBJ_Z_LIMITS = {
|
| 94 |
+
1: (TABLE_TOP_Z + 0.035, TABLE_TOP_Z + 0.130),
|
| 95 |
+
2: (TABLE_TOP_Z + 0.020, TABLE_TOP_Z + 0.190),
|
| 96 |
+
3: (TABLE_TOP_Z + 0.012, TABLE_TOP_Z + 0.095),
|
| 97 |
+
}
|
| 98 |
+
OBJ_GRASP_CENTER_OFFSETS = {
|
| 99 |
+
1: np.array([0.0, 0.0], dtype=np.float64),
|
| 100 |
+
2: np.array([0.060, 0.0], dtype=np.float64),
|
| 101 |
+
3: np.array([float(os.environ.get("ATEC_PCA_OBJ3_X_OFFSET", "0.0")), 0.0], dtype=np.float64),
|
| 102 |
+
}
|
| 103 |
+
OBJ_CENTER_COMPLETION_OFFSETS = {
|
| 104 |
+
# The fixed camera sees object_1 from the lower-y side when it is near the
|
| 105 |
+
# top band edge; RGB-D AABB/median centres land on the visible side instead
|
| 106 |
+
# of the root/contact centre. This completes the centre before applying
|
| 107 |
+
# the Piper finger offset below.
|
| 108 |
+
1: np.array([0.020, 0.0], dtype=np.float64),
|
| 109 |
+
2: np.array([0.0, 0.0], dtype=np.float64),
|
| 110 |
+
3: np.array(
|
| 111 |
+
[
|
| 112 |
+
0.0,
|
| 113 |
+
float(os.environ.get("ATEC_PCA_OBJ3_CENTER_Y_OFFSET", "0.000")),
|
| 114 |
+
],
|
| 115 |
+
dtype=np.float64,
|
| 116 |
+
),
|
| 117 |
+
}
|
| 118 |
+
OBJ_TCP_Z = {1: 0.140, 2: 0.040, 3: 0.090}
|
| 119 |
+
OBJ_CLOSE_Z_OFFSETS = {1: 0.020, 2: 0.020, 3: float(os.environ.get("ATEC_PCA_OBJ3_CLOSE_Z_OFFSET", "-0.005"))}
|
| 120 |
+
OBJ_CLOSE_Z = {
|
| 121 |
+
1: TABLE_TOP_Z + 0.030, # low close plane; compensate submit IK's high-contact bias
|
| 122 |
+
2: TABLE_TOP_Z + 0.030,
|
| 123 |
+
3: TABLE_TOP_Z + 0.030,
|
| 124 |
+
}
|
| 125 |
+
OBJ_ROOT_Z_EST = {
|
| 126 |
+
1: TABLE_TOP_Z + 0.045,
|
| 127 |
+
2: TABLE_TOP_Z + 0.055,
|
| 128 |
+
3: TABLE_TOP_Z + 0.035,
|
| 129 |
+
}
|
| 130 |
+
OBJ_PRECLOSE_INSERT_OFFSETS = {
|
| 131 |
+
1: np.array([0.0, 0.0], dtype=np.float64),
|
| 132 |
+
}
|
| 133 |
+
OBJ_FINGER_XY_OFFSETS = {
|
| 134 |
+
# Calibrated from successful 2026-05-20 scripted traces. Banana succeeds
|
| 135 |
+
# when the actual link7/link8 centre is slightly on the -X side of the
|
| 136 |
+
# object root, cradling the curve instead of pushing from the +X side.
|
| 137 |
+
3: np.array(
|
| 138 |
+
[
|
| 139 |
+
float(os.environ.get("ATEC_PCA_OBJ3_FINGER_X_OFFSET", "-0.010")),
|
| 140 |
+
float(os.environ.get("ATEC_PCA_OBJ3_FINGER_Y_OFFSET", "0.000")),
|
| 141 |
+
],
|
| 142 |
+
dtype=np.float64,
|
| 143 |
+
),
|
| 144 |
+
}
|
| 145 |
+
OBJ_FINGER_TARGET_REL_Z = {
|
| 146 |
+
1: -0.025,
|
| 147 |
+
3: float(os.environ.get("ATEC_PCA_OBJ3_FINGER_REL_Z", "0.027")),
|
| 148 |
+
}
|
| 149 |
+
OBJ_FINGER_SERVO_MAX_Z = {1: 0.050, 3: 0.040}
|
| 150 |
+
OBJ_REACH_STEPS = {1: 200, 2: 200, 3: 200}
|
| 151 |
+
OBJ_CLOSE_STEPS = {1: 220, 2: 180, 3: int(os.environ.get("ATEC_PCA_OBJ3_CLOSE_STEPS", "90"))}
|
| 152 |
+
OBJ_LIFT_STEPS = {1: 300, 2: 200, 3: int(os.environ.get("ATEC_PCA_OBJ3_LIFT_STEPS", "35"))}
|
| 153 |
+
OBJ_TRANSPORT_STEPS = {1: 1400, 2: 1400, 3: int(os.environ.get("ATEC_PCA_OBJ3_TRANSPORT_STEPS", "440"))}
|
| 154 |
+
OBJ_PLACE_STEPS = {1: 260, 2: 260, 3: 220}
|
| 155 |
+
OBJ_OPEN_STEPS = {1: 260, 2: 260, 3: 220}
|
| 156 |
+
OBJ_PLACE_XY_OFFSETS = {
|
| 157 |
+
1: np.array([0.0, 0.0], dtype=np.float64),
|
| 158 |
+
3: np.array(
|
| 159 |
+
[
|
| 160 |
+
float(os.environ.get("ATEC_PCA_OBJ3_PLACE_X_OFFSET", "0.0")),
|
| 161 |
+
float(os.environ.get("ATEC_PCA_OBJ3_PLACE_Y_OFFSET", "0.0")),
|
| 162 |
+
],
|
| 163 |
+
dtype=np.float64,
|
| 164 |
+
),
|
| 165 |
+
}
|
| 166 |
+
|
| 167 |
+
|
| 168 |
+
def _quat_wxyz_to_rot(q: np.ndarray) -> np.ndarray:
|
| 169 |
+
q = np.asarray(q, dtype=np.float64)
|
| 170 |
+
q = q / max(np.linalg.norm(q), 1e-12)
|
| 171 |
+
w, x, y, z = q
|
| 172 |
+
return np.array(
|
| 173 |
+
[
|
| 174 |
+
[1 - 2 * (y * y + z * z), 2 * (x * y - z * w), 2 * (x * z + y * w)],
|
| 175 |
+
[2 * (x * y + z * w), 1 - 2 * (x * x + z * z), 2 * (y * z - x * w)],
|
| 176 |
+
[2 * (x * z - y * w), 2 * (y * z + x * w), 1 - 2 * (x * x + y * y)],
|
| 177 |
+
],
|
| 178 |
+
dtype=np.float64,
|
| 179 |
+
)
|
| 180 |
+
|
| 181 |
+
|
| 182 |
+
def _rot_error(current: np.ndarray, target: np.ndarray) -> np.ndarray:
|
| 183 |
+
err = target @ current.T
|
| 184 |
+
return 0.5 * np.array(
|
| 185 |
+
[err[2, 1] - err[1, 2], err[0, 2] - err[2, 0], err[1, 0] - err[0, 1]],
|
| 186 |
+
dtype=np.float64,
|
| 187 |
+
)
|
| 188 |
+
|
| 189 |
+
|
| 190 |
+
def _world_to_base_pos(pos_w: np.ndarray) -> np.ndarray:
|
| 191 |
+
return R_W_B.T @ (np.asarray(pos_w, dtype=np.float64) - BASE_POS_W)
|
| 192 |
+
|
| 193 |
+
|
| 194 |
+
def _world_to_base_rot(rot_w: np.ndarray) -> np.ndarray:
|
| 195 |
+
return R_W_B.T @ rot_w
|
| 196 |
+
|
| 197 |
+
|
| 198 |
+
@dataclass
|
| 199 |
+
class PoseTarget:
|
| 200 |
+
pos_w: np.ndarray
|
| 201 |
+
rot_w: np.ndarray
|
| 202 |
+
grip: np.ndarray
|
| 203 |
+
steps: int
|
| 204 |
+
finger_xy: np.ndarray | None = None
|
| 205 |
+
finger_z: float | None = None
|
| 206 |
+
servo_obj_z: float | None = None
|
| 207 |
+
servo_target_rel_z: float | None = None
|
| 208 |
+
freeze_arm: bool = False
|
| 209 |
+
label: str = ""
|
| 210 |
+
|
| 211 |
+
|
| 212 |
+
class _PiperIK:
|
| 213 |
+
def __init__(self):
|
| 214 |
+
if pin is None:
|
| 215 |
+
raise RuntimeError("pinocchio is required for solution_pca.py")
|
| 216 |
+
root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
| 217 |
+
urdf = os.path.join(root, "third_party", "Agilex-College", "piper", "handpose_det", "models", "modified_piper_without_camera.urdf")
|
| 218 |
+
if not os.path.exists(urdf):
|
| 219 |
+
urdf = os.environ.get("ATEC_PIPER_URDF", urdf)
|
| 220 |
+
self.model = pin.buildModelFromUrdf(urdf)
|
| 221 |
+
self.data = self.model.createData()
|
| 222 |
+
self.frame_id = self.model.getFrameId("gripper_base")
|
| 223 |
+
self.link7_id = self.model.getFrameId("link7")
|
| 224 |
+
self.link8_id = self.model.getFrameId("link8")
|
| 225 |
+
self._last_q = HOME_Q[:6].copy()
|
| 226 |
+
|
| 227 |
+
def fk_base(self, q6: np.ndarray):
|
| 228 |
+
q = np.concatenate([np.asarray(q6, dtype=np.float64), GRIP_OPEN])
|
| 229 |
+
pin.forwardKinematics(self.model, self.data, q)
|
| 230 |
+
pin.updateFramePlacements(self.model, self.data)
|
| 231 |
+
M = self.data.oMf[self.frame_id]
|
| 232 |
+
return M.translation.copy(), M.rotation.copy()
|
| 233 |
+
|
| 234 |
+
def solve(self, q_current8: np.ndarray, pos_w: np.ndarray, rot_w: np.ndarray) -> np.ndarray:
|
| 235 |
+
target_pos_b = _world_to_base_pos(pos_w)
|
| 236 |
+
target_rot_b = _world_to_base_rot(rot_w)
|
| 237 |
+
q6 = np.asarray(q_current8[:6], dtype=np.float64).copy()
|
| 238 |
+
if not np.all(np.isfinite(q6)):
|
| 239 |
+
q6 = self._last_q.copy()
|
| 240 |
+
for _ in range(35):
|
| 241 |
+
pos_b, rot_b = self.fk_base(q6)
|
| 242 |
+
err = np.concatenate([target_pos_b - pos_b, _rot_error(rot_b, target_rot_b)])
|
| 243 |
+
if np.linalg.norm(err[:3]) < 0.003 and np.linalg.norm(err[3:]) < 0.03:
|
| 244 |
+
break
|
| 245 |
+
J = pin.computeFrameJacobian(
|
| 246 |
+
self.model,
|
| 247 |
+
self.data,
|
| 248 |
+
np.concatenate([q6, GRIP_OPEN]),
|
| 249 |
+
self.frame_id,
|
| 250 |
+
pin.ReferenceFrame.LOCAL_WORLD_ALIGNED,
|
| 251 |
+
)[:, :6]
|
| 252 |
+
damping = 0.020
|
| 253 |
+
dq = J.T @ np.linalg.solve(J @ J.T + damping * damping * np.eye(6), err)
|
| 254 |
+
dq = np.clip(dq, -0.20, 0.20)
|
| 255 |
+
q6 = np.clip(q6 + dq, [-2.618, 0.0, -2.967, -1.745, -1.22, -2.0944], [2.618, 3.14, 0.0, 1.745, 1.22, 2.0944])
|
| 256 |
+
# Near contact, being centimetres high is worse than a small wrist
|
| 257 |
+
# orientation error. The successful simulator runner effectively
|
| 258 |
+
# servos the link7/link8 centre every step; this position-only cleanup
|
| 259 |
+
# gives the submit-style IK the same priority.
|
| 260 |
+
for _ in range(20):
|
| 261 |
+
pos_b, _ = self.fk_base(q6)
|
| 262 |
+
pos_err = target_pos_b - pos_b
|
| 263 |
+
if np.linalg.norm(pos_err) < 0.002:
|
| 264 |
+
break
|
| 265 |
+
J = pin.computeFrameJacobian(
|
| 266 |
+
self.model,
|
| 267 |
+
self.data,
|
| 268 |
+
np.concatenate([q6, GRIP_OPEN]),
|
| 269 |
+
self.frame_id,
|
| 270 |
+
pin.ReferenceFrame.LOCAL_WORLD_ALIGNED,
|
| 271 |
+
)[:3, :6]
|
| 272 |
+
damping = 0.012
|
| 273 |
+
dq = J.T @ np.linalg.solve(J @ J.T + damping * damping * np.eye(3), pos_err)
|
| 274 |
+
dq = np.clip(dq, -0.18, 0.18)
|
| 275 |
+
q6 = np.clip(q6 + dq, [-2.618, 0.0, -2.967, -1.745, -1.22, -2.0944], [2.618, 3.14, 0.0, 1.745, 1.22, 2.0944])
|
| 276 |
+
self._last_q = q6.copy()
|
| 277 |
+
return q6
|
| 278 |
+
|
| 279 |
+
def step_dls(
|
| 280 |
+
self,
|
| 281 |
+
q_current8: np.ndarray,
|
| 282 |
+
pos_w: np.ndarray,
|
| 283 |
+
rot_w: np.ndarray,
|
| 284 |
+
*,
|
| 285 |
+
lambda_val: float = 0.05,
|
| 286 |
+
max_joint_delta: float = PCA_DLS_MAX_DELTA,
|
| 287 |
+
position_only: bool = False,
|
| 288 |
+
) -> np.ndarray:
|
| 289 |
+
"""One DifferentialIK-style DLS update from the current joint state.
|
| 290 |
+
|
| 291 |
+
The successful simulator runner uses IsaacLab's CartesianController,
|
| 292 |
+
which computes a small damped least-squares update from the current
|
| 293 |
+
PhysX state on every frame. This mirrors that behavior more closely
|
| 294 |
+
than solving a full IK target and then clipping the final joint target.
|
| 295 |
+
"""
|
| 296 |
+
target_pos_b = _world_to_base_pos(pos_w)
|
| 297 |
+
target_rot_b = _world_to_base_rot(rot_w)
|
| 298 |
+
q6 = np.asarray(q_current8[:6], dtype=np.float64).copy()
|
| 299 |
+
if not np.all(np.isfinite(q6)):
|
| 300 |
+
q6 = self._last_q.copy()
|
| 301 |
+
q8 = np.concatenate([q6, GRIP_OPEN])
|
| 302 |
+
pos_b, rot_b = self.fk_base(q6)
|
| 303 |
+
J_full = pin.computeFrameJacobian(
|
| 304 |
+
self.model,
|
| 305 |
+
self.data,
|
| 306 |
+
q8,
|
| 307 |
+
self.frame_id,
|
| 308 |
+
pin.ReferenceFrame.LOCAL_WORLD_ALIGNED,
|
| 309 |
+
)[:, :6]
|
| 310 |
+
if position_only:
|
| 311 |
+
err = target_pos_b - pos_b
|
| 312 |
+
J = J_full[:3, :]
|
| 313 |
+
else:
|
| 314 |
+
err = np.concatenate([target_pos_b - pos_b, _rot_error(rot_b, target_rot_b)])
|
| 315 |
+
J = J_full
|
| 316 |
+
damping = float(lambda_val)
|
| 317 |
+
dq = J.T @ np.linalg.solve(J @ J.T + damping * damping * np.eye(J.shape[0]), err)
|
| 318 |
+
dq = np.clip(dq, -max_joint_delta, max_joint_delta)
|
| 319 |
+
q6 = np.clip(
|
| 320 |
+
q6 + dq,
|
| 321 |
+
[-2.618, 0.0, -2.967, -1.745, -1.22, -2.0944],
|
| 322 |
+
[2.618, 3.14, 0.0, 1.745, 1.22, 2.0944],
|
| 323 |
+
)
|
| 324 |
+
self._last_q = q6.copy()
|
| 325 |
+
return q6
|
| 326 |
+
|
| 327 |
+
def finger_center_world(self, q_current8: np.ndarray) -> np.ndarray:
|
| 328 |
+
q = np.asarray(q_current8, dtype=np.float64).copy()
|
| 329 |
+
pin.forwardKinematics(self.model, self.data, q)
|
| 330 |
+
pin.updateFramePlacements(self.model, self.data)
|
| 331 |
+
p7 = self.data.oMf[self.link7_id].translation
|
| 332 |
+
p8 = self.data.oMf[self.link8_id].translation
|
| 333 |
+
center_b = 0.5 * (p7 + p8)
|
| 334 |
+
return BASE_POS_W + R_W_B @ center_b
|
| 335 |
+
|
| 336 |
+
def finger_gap(self, q_current8: np.ndarray) -> float:
|
| 337 |
+
q = np.asarray(q_current8, dtype=np.float64).copy()
|
| 338 |
+
pin.forwardKinematics(self.model, self.data, q)
|
| 339 |
+
pin.updateFramePlacements(self.model, self.data)
|
| 340 |
+
p7 = self.data.oMf[self.link7_id].translation
|
| 341 |
+
p8 = self.data.oMf[self.link8_id].translation
|
| 342 |
+
return float(np.linalg.norm(p7 - p8))
|
| 343 |
+
|
| 344 |
+
def solve_finger(self, q_current8: np.ndarray, finger_w: np.ndarray, rot_w: np.ndarray) -> np.ndarray:
|
| 345 |
+
"""IK on the actual link7/link8 centre, not the gripper_base proxy."""
|
| 346 |
+
target_pos_b = _world_to_base_pos(finger_w)
|
| 347 |
+
target_rot_b = _world_to_base_rot(rot_w)
|
| 348 |
+
q_current8 = np.asarray(q_current8, dtype=np.float64).copy()
|
| 349 |
+
q6 = q_current8[:6].copy()
|
| 350 |
+
grip = q_current8[6:8].copy()
|
| 351 |
+
if not np.all(np.isfinite(q6)):
|
| 352 |
+
q6 = self._last_q.copy()
|
| 353 |
+
for _ in range(40):
|
| 354 |
+
q8 = np.concatenate([q6, grip])
|
| 355 |
+
pin.forwardKinematics(self.model, self.data, q8)
|
| 356 |
+
pin.updateFramePlacements(self.model, self.data)
|
| 357 |
+
p7 = self.data.oMf[self.link7_id].translation
|
| 358 |
+
p8 = self.data.oMf[self.link8_id].translation
|
| 359 |
+
center_b = 0.5 * (p7 + p8)
|
| 360 |
+
gb_rot = self.data.oMf[self.frame_id].rotation
|
| 361 |
+
pos_err = target_pos_b - center_b
|
| 362 |
+
rot_err = _rot_error(gb_rot, target_rot_b)
|
| 363 |
+
if np.linalg.norm(pos_err) < 0.002 and np.linalg.norm(rot_err) < 0.05:
|
| 364 |
+
break
|
| 365 |
+
J7 = pin.computeFrameJacobian(self.model, self.data, q8, self.link7_id, pin.ReferenceFrame.LOCAL_WORLD_ALIGNED)[:3, :6]
|
| 366 |
+
J8 = pin.computeFrameJacobian(self.model, self.data, q8, self.link8_id, pin.ReferenceFrame.LOCAL_WORLD_ALIGNED)[:3, :6]
|
| 367 |
+
Jpos = 0.5 * (J7 + J8)
|
| 368 |
+
Jrot = pin.computeFrameJacobian(self.model, self.data, q8, self.frame_id, pin.ReferenceFrame.LOCAL_WORLD_ALIGNED)[3:, :6]
|
| 369 |
+
rot_wt = 0.05
|
| 370 |
+
J = np.vstack([Jpos, rot_wt * Jrot])
|
| 371 |
+
err = np.concatenate([pos_err, rot_wt * rot_err])
|
| 372 |
+
damping = 0.018
|
| 373 |
+
dq = J.T @ np.linalg.solve(J @ J.T + damping * damping * np.eye(6), err)
|
| 374 |
+
dq = np.clip(dq, -PCA_FINGER_IK_MAX_DELTA, PCA_FINGER_IK_MAX_DELTA)
|
| 375 |
+
q6 = np.clip(q6 + dq, [-2.618, 0.0, -2.967, -1.745, -1.22, -2.0944], [2.618, 3.14, 0.0, 1.745, 1.22, 2.0944])
|
| 376 |
+
self._last_q = q6.copy()
|
| 377 |
+
return q6
|
| 378 |
+
|
| 379 |
+
|
| 380 |
+
class AlgSolution:
|
| 381 |
+
def __init__(self):
|
| 382 |
+
self.device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 383 |
+
self.ik = _PiperIK()
|
| 384 |
+
self.reset()
|
| 385 |
+
|
| 386 |
+
def reset(self, **_kwargs):
|
| 387 |
+
self.t = 0
|
| 388 |
+
self.home_count = 0
|
| 389 |
+
self.plan: list[PoseTarget] = []
|
| 390 |
+
self.plan_idx = 0
|
| 391 |
+
self.step_in_target = 0
|
| 392 |
+
self.detected = False
|
| 393 |
+
self.fallback_done = False
|
| 394 |
+
self.objects: tuple[int, ...] = ()
|
| 395 |
+
self._last_action = np.zeros(8, dtype=np.float64)
|
| 396 |
+
self._obj1_hold_grip: np.ndarray | None = None
|
| 397 |
+
self._obj3_hold_grip: np.ndarray | None = None
|
| 398 |
+
self._obj3_carry_offset_xy: np.ndarray | None = None
|
| 399 |
+
self._detected_centers: dict[int, np.ndarray] = {}
|
| 400 |
+
|
| 401 |
+
def reset_episode(self):
|
| 402 |
+
self.reset()
|
| 403 |
+
|
| 404 |
+
def _obs_qpos(self, obs: dict) -> np.ndarray:
|
| 405 |
+
proprio = obs["proprio"]
|
| 406 |
+
if isinstance(proprio, torch.Tensor):
|
| 407 |
+
p = proprio.detach().cpu().numpy()[0]
|
| 408 |
+
else:
|
| 409 |
+
p = np.asarray(proprio)[0]
|
| 410 |
+
return p[:8].astype(np.float64) + DEFAULT_Q
|
| 411 |
+
|
| 412 |
+
def _video_rgb_depth(self, obs: dict) -> tuple[np.ndarray, np.ndarray]:
|
| 413 |
+
rgb = obs["image"]["video_rgb"]
|
| 414 |
+
if isinstance(rgb, torch.Tensor):
|
| 415 |
+
rgb_arr = rgb.detach().cpu().numpy()[0]
|
| 416 |
+
else:
|
| 417 |
+
rgb_arr = np.asarray(rgb)[0]
|
| 418 |
+
if rgb_arr.ndim == 3 and rgb_arr.shape[0] in (3, 4):
|
| 419 |
+
rgb_arr = np.transpose(rgb_arr[:3], (1, 2, 0))
|
| 420 |
+
if rgb_arr.shape[-1] == 4:
|
| 421 |
+
rgb_arr = rgb_arr[..., :3]
|
| 422 |
+
if np.issubdtype(rgb_arr.dtype, np.floating):
|
| 423 |
+
rgb_arr = (rgb_arr * 255.0).clip(0, 255).astype(np.uint8)
|
| 424 |
+
|
| 425 |
+
depth = obs["image"]["video_depth"]
|
| 426 |
+
if isinstance(depth, torch.Tensor):
|
| 427 |
+
arr = depth.detach().cpu().numpy()[0]
|
| 428 |
+
else:
|
| 429 |
+
arr = np.asarray(depth)[0]
|
| 430 |
+
if arr.ndim == 3:
|
| 431 |
+
arr = arr[..., 0]
|
| 432 |
+
return rgb_arr.astype(np.uint8, copy=False), arr.astype(np.float64)
|
| 433 |
+
|
| 434 |
+
def _points_for_object(
|
| 435 |
+
self,
|
| 436 |
+
rgb: np.ndarray,
|
| 437 |
+
depth: np.ndarray,
|
| 438 |
+
obj_idx: int,
|
| 439 |
+
*,
|
| 440 |
+
wide: bool = False,
|
| 441 |
+
fill_holes: bool = True,
|
| 442 |
+
) -> np.ndarray:
|
| 443 |
+
h, w = depth.shape
|
| 444 |
+
ys, xs = np.where(np.isfinite(depth) & (depth > 0.0) & (depth < 6.0))
|
| 445 |
+
if len(xs) == 0:
|
| 446 |
+
return np.zeros((0, 3), dtype=np.float64)
|
| 447 |
+
z = depth[ys, xs]
|
| 448 |
+
x = (xs.astype(np.float64) - K_VIDEO[0, 2]) / K_VIDEO[0, 0] * z
|
| 449 |
+
y = (ys.astype(np.float64) - K_VIDEO[1, 2]) / K_VIDEO[1, 1] * z
|
| 450 |
+
pts_cam = np.stack([x, y, z], axis=1)
|
| 451 |
+
rot_w_cam = _quat_wxyz_to_rot(CAM_QUAT_WXYZ)
|
| 452 |
+
pts = (rot_w_cam @ pts_cam.T).T + CAM_POS_W
|
| 453 |
+
y0, y1 = OBJ_Y_BANDS[obj_idx]
|
| 454 |
+
if wide:
|
| 455 |
+
y0 = BASKET_CENTER_Y - 0.10
|
| 456 |
+
y1 = OBJ_Y_BANDS[obj_idx][1] + (0.045 if obj_idx == 3 else 0.10)
|
| 457 |
+
z0, z1 = OBJ_Z_LIMITS[obj_idx]
|
| 458 |
+
if wide:
|
| 459 |
+
z0 = TABLE_TOP_Z + 0.005
|
| 460 |
+
if obj_idx == 3:
|
| 461 |
+
z1 = TABLE_TOP_Z + 0.220
|
| 462 |
+
rgb_pts = rgb[ys, xs].astype(np.float32)
|
| 463 |
+
maxc = rgb_pts.max(axis=1)
|
| 464 |
+
minc = rgb_pts.min(axis=1)
|
| 465 |
+
non_gray = ((maxc - minc) > 18.0) | (maxc > 170.0)
|
| 466 |
+
if obj_idx == 3:
|
| 467 |
+
# Use the banana's yellow appearance for dynamic tracking. The broad
|
| 468 |
+
# world band can include the pink basket, white gripper, and mustard;
|
| 469 |
+
# a simple color gate is more reliable than generic non-gray there.
|
| 470 |
+
r, g, b = rgb_pts[:, 0], rgb_pts[:, 1], rgb_pts[:, 2]
|
| 471 |
+
non_gray = (r > 105.0) & (g > 75.0) & (b < 130.0) & ((r - b) > 35.0)
|
| 472 |
+
keep = (
|
| 473 |
+
(pts[:, 0] >= TABLE_CENTER_X - 0.18)
|
| 474 |
+
& (pts[:, 0] <= TABLE_CENTER_X + 0.18)
|
| 475 |
+
& (pts[:, 1] >= y0 - 0.035)
|
| 476 |
+
& (pts[:, 1] <= y1 + 0.035)
|
| 477 |
+
& (pts[:, 2] >= z0)
|
| 478 |
+
& (pts[:, 2] <= z1)
|
| 479 |
+
& non_gray
|
| 480 |
+
)
|
| 481 |
+
if np.count_nonzero(keep) == 0:
|
| 482 |
+
return pts[keep]
|
| 483 |
+
if not fill_holes:
|
| 484 |
+
return pts[keep]
|
| 485 |
+
# Mirror rgbd_band_object_mask(): fill shallow holes inside the detected
|
| 486 |
+
# component ROI, still constrained by the legal world band and z gate.
|
| 487 |
+
yy = ys[keep]
|
| 488 |
+
xx = xs[keep]
|
| 489 |
+
x1, x2 = int(xx.min()), int(xx.max())
|
| 490 |
+
y1p, y2p = int(yy.min()), int(yy.max())
|
| 491 |
+
in_roi = (xs >= x1) & (xs <= x2) & (ys >= y1p) & (ys <= y2p)
|
| 492 |
+
fill_keep = (
|
| 493 |
+
in_roi
|
| 494 |
+
& (pts[:, 0] >= TABLE_CENTER_X - 0.18)
|
| 495 |
+
& (pts[:, 0] <= TABLE_CENTER_X + 0.18)
|
| 496 |
+
& (pts[:, 1] >= y0 - 0.035)
|
| 497 |
+
& (pts[:, 1] <= y1 + 0.035)
|
| 498 |
+
& (pts[:, 2] >= z0)
|
| 499 |
+
& (pts[:, 2] <= z1)
|
| 500 |
+
)
|
| 501 |
+
return pts[fill_keep]
|
| 502 |
+
|
| 503 |
+
def _estimate_grasp(self, rgb: np.ndarray, depth: np.ndarray, obj_idx: int, *, wide: bool = False) -> tuple[np.ndarray, np.ndarray]:
|
| 504 |
+
pts = self._points_for_object(rgb, depth, obj_idx, wide=wide, fill_holes=(obj_idx != 1))
|
| 505 |
+
if len(pts) < 64:
|
| 506 |
+
# Spawn-band fallback keeps the controller alive if one frame is bad.
|
| 507 |
+
y0, y1 = OBJ_Y_BANDS[obj_idx]
|
| 508 |
+
center = np.array([TABLE_CENTER_X, 0.5 * (y0 + y1), TABLE_TOP_Z + 0.06], dtype=np.float64)
|
| 509 |
+
return center, _quat_wxyz_to_rot(np.array([0.0, 1.0, 0.0, 0.0], dtype=np.float64))
|
| 510 |
+
center = pts.mean(axis=0)
|
| 511 |
+
world_aabb_center = 0.5 * (pts.min(axis=0) + pts.max(axis=0))
|
| 512 |
+
cov = (pts - center).T @ (pts - center) / max(len(pts) - 1, 1)
|
| 513 |
+
vals, vecs = np.linalg.eigh(cov)
|
| 514 |
+
order = np.argsort(vals)[::-1]
|
| 515 |
+
axes = vecs[:, order]
|
| 516 |
+
if np.linalg.det(axes) < 0:
|
| 517 |
+
axes[:, 2] *= -1
|
| 518 |
+
local = (axes.T @ (pts - center).T).T
|
| 519 |
+
mn, mx = local.min(axis=0), local.max(axis=0)
|
| 520 |
+
aabb_center = axes @ ((mn + mx) * 0.5) + center
|
| 521 |
+
extents = mx - mn
|
| 522 |
+
if obj_idx == 3:
|
| 523 |
+
exec_center = aabb_center.copy()
|
| 524 |
+
# The banana is curved; when the visible PCA/AABB centre drifts
|
| 525 |
+
# toward the far end of the crescent, the calibrated -X finger
|
| 526 |
+
# offset is cancelled and the gripper closes on the outside. In
|
| 527 |
+
# that case the RGB-D point mean is a better proxy for the contact
|
| 528 |
+
# root used by the successful runner traces.
|
| 529 |
+
if abs(float(aabb_center[0] - center[0])) > float(os.environ.get("ATEC_PCA_OBJ3_AABB_MEAN_X_SWITCH", "0.025")):
|
| 530 |
+
exec_center[0] = center[0] + float(os.environ.get("ATEC_PCA_OBJ3_MEAN_X_BIAS", "0.005"))
|
| 531 |
+
else:
|
| 532 |
+
upper = pts[pts[:, 2] >= np.percentile(pts[:, 2], 70)]
|
| 533 |
+
# Object 1/2 visible-surface medians can be biased toward the
|
| 534 |
+
# camera-facing side by 2+ cm. Use the world AABB centre for XY
|
| 535 |
+
# completion, while keeping a high visible-surface z for approach.
|
| 536 |
+
exec_center = world_aabb_center.copy()
|
| 537 |
+
z_src = upper if len(upper) else pts
|
| 538 |
+
exec_center[2] = float(np.percentile(z_src[:, 2], 85))
|
| 539 |
+
if os.environ.get("ATEC_PCA_DEBUG_TARGET"):
|
| 540 |
+
upper = pts[pts[:, 2] >= np.percentile(pts[:, 2], 70)]
|
| 541 |
+
upper_med = np.median(upper if len(upper) else pts, axis=0)
|
| 542 |
+
print(
|
| 543 |
+
f"[PCA_EST] obj={obj_idx} n={len(pts)} "
|
| 544 |
+
f"mean=({center[0]:.3f},{center[1]:.3f},{center[2]:.3f}) "
|
| 545 |
+
f"world_aabb=({world_aabb_center[0]:.3f},{world_aabb_center[1]:.3f},{world_aabb_center[2]:.3f}) "
|
| 546 |
+
f"upper_med=({upper_med[0]:.3f},{upper_med[1]:.3f},{upper_med[2]:.3f}) "
|
| 547 |
+
f"exec=({exec_center[0]:.3f},{exec_center[1]:.3f},{exec_center[2]:.3f})",
|
| 548 |
+
flush=True,
|
| 549 |
+
)
|
| 550 |
+
|
| 551 |
+
grasp_axis = int(np.argmin(extents))
|
| 552 |
+
if grasp_axis == 0:
|
| 553 |
+
jaw_hint_w = axes[:, 1]
|
| 554 |
+
else:
|
| 555 |
+
jaw_hint_w = axes[:, 0]
|
| 556 |
+
jaw_xy = np.array([jaw_hint_w[0], jaw_hint_w[1], 0.0], dtype=np.float64)
|
| 557 |
+
if np.linalg.norm(jaw_xy) < 1e-6:
|
| 558 |
+
jaw_xy = np.array([0.0, 1.0, 0.0], dtype=np.float64)
|
| 559 |
+
jaw_xy /= np.linalg.norm(jaw_xy)
|
| 560 |
+
grip_z = np.array([0.0, 0.0, -1.0], dtype=np.float64)
|
| 561 |
+
align_x = np.cross(jaw_xy, grip_z)
|
| 562 |
+
align_x /= max(np.linalg.norm(align_x), 1e-6)
|
| 563 |
+
jaw_y = np.cross(grip_z, align_x)
|
| 564 |
+
jaw_y /= max(np.linalg.norm(jaw_y), 1e-6)
|
| 565 |
+
rot_w_tool = np.stack([align_x, jaw_y, grip_z], axis=1)
|
| 566 |
+
return exec_center.astype(np.float64), rot_w_tool.astype(np.float64)
|
| 567 |
+
|
| 568 |
+
def _estimate_object3_current_center(self, obs: dict) -> np.ndarray | None:
|
| 569 |
+
rgb, depth = self._video_rgb_depth(obs)
|
| 570 |
+
pts = self._points_for_object(rgb, depth, 3, wide=True, fill_holes=True)
|
| 571 |
+
if len(pts) < 64:
|
| 572 |
+
return None
|
| 573 |
+
center = 0.5 * (pts.min(axis=0) + pts.max(axis=0))
|
| 574 |
+
# Track the table-near/lifted banana body, not high gripper occluders.
|
| 575 |
+
center[2] = float(np.percentile(pts[:, 2], 65))
|
| 576 |
+
center[:2] += OBJ_CENTER_COMPLETION_OFFSETS[3]
|
| 577 |
+
if not np.all(np.isfinite(center)):
|
| 578 |
+
return None
|
| 579 |
+
if not (TABLE_CENTER_X - 0.22 <= center[0] <= TABLE_CENTER_X + 0.22):
|
| 580 |
+
return None
|
| 581 |
+
if not (BASKET_CENTER_Y - 0.14 <= center[1] <= OBJ_Y_BANDS[3][1] + 0.10):
|
| 582 |
+
return None
|
| 583 |
+
return center.astype(np.float64)
|
| 584 |
+
|
| 585 |
+
def _build_object3_drag_fallback(self, obs: dict) -> bool:
|
| 586 |
+
topdown = _quat_wxyz_to_rot(np.array([0.0, 1.0, 0.0, 0.0], dtype=np.float64))
|
| 587 |
+
# Re-localize the banana at fallback time. Use the same narrow
|
| 588 |
+
# closed-drag recovery that succeeded in run_graspnet_pick.py: keep the
|
| 589 |
+
# gripper closed and drag from the current object centre to the basket
|
| 590 |
+
# centre in two smooth segments.
|
| 591 |
+
drag_z = OBJ3_FALLBACK_DRAG_Z
|
| 592 |
+
c_live = self._estimate_object3_current_center(obs)
|
| 593 |
+
c0 = c_live if c_live is not None else self._detected_centers.get(
|
| 594 |
+
3, np.array([TABLE_CENTER_X, OBJ_Y_BANDS[3][0], TABLE_TOP_Z], dtype=np.float64)
|
| 595 |
+
)
|
| 596 |
+
start = np.array([c0[0], c0[1], drag_z], dtype=np.float64)
|
| 597 |
+
mid = np.array([BASKET_CENTER_X, 0.5 * (c0[1] + BASKET_CENTER_Y), drag_z], dtype=np.float64)
|
| 598 |
+
end = np.array([BASKET_CENTER_X, BASKET_CENTER_Y, drag_z], dtype=np.float64)
|
| 599 |
+
print(
|
| 600 |
+
f"[PCA_FALLBACK] object_3 closed_drag cur=({c0[0]:.3f},{c0[1]:.3f},{c0[2]:.3f}) "
|
| 601 |
+
f"mid=({mid[0]:.3f},{mid[1]:.3f},{mid[2]:.3f}) "
|
| 602 |
+
f"end=({end[0]:.3f},{end[1]:.3f},{end[2]:.3f})",
|
| 603 |
+
flush=True,
|
| 604 |
+
)
|
| 605 |
+
self.plan = []
|
| 606 |
+
self.plan_idx = 0
|
| 607 |
+
self.step_in_target = 0
|
| 608 |
+
hold_grip = self._obj3_hold_grip.copy() if self._obj3_hold_grip is not None else OBJ3_HOLD_GRIP_DEFAULT.copy()
|
| 609 |
+
finger_offset = OBJ_FINGER_XY_OFFSETS[3]
|
| 610 |
+
start_finger = start[:2] + finger_offset
|
| 611 |
+
mid_finger = mid[:2] + finger_offset
|
| 612 |
+
end_finger = end[:2] + finger_offset
|
| 613 |
+
self._add_pose([start_finger[0], start_finger[1], drag_z], topdown, hold_grip, OBJ3_FALLBACK_START_STEPS, finger_xy=start_finger, finger_z=drag_z, label="fallback_closed_drag_start")
|
| 614 |
+
self._add_pose([mid_finger[0], mid_finger[1], drag_z], topdown, hold_grip, OBJ3_FALLBACK_MID_STEPS, finger_xy=mid_finger, finger_z=drag_z, label="fallback_closed_drag_mid")
|
| 615 |
+
self._add_pose([end_finger[0], end_finger[1], drag_z], topdown, hold_grip, OBJ3_FALLBACK_END_STEPS, finger_xy=end_finger, finger_z=drag_z, label="fallback_closed_drag_end")
|
| 616 |
+
self._add_pose([end_finger[0], end_finger[1], drag_z], topdown, GRIP_OPEN, OBJ3_FALLBACK_OPEN_STEPS, finger_xy=end_finger, finger_z=drag_z, label="fallback_closed_drag_open")
|
| 617 |
+
self._add_pose([BASKET_CENTER_X, BASKET_CENTER_Y, TABLE_TOP_Z + 0.18], topdown, GRIP_OPEN, 120, label="fallback_retract")
|
| 618 |
+
return True
|
| 619 |
+
|
| 620 |
+
def _build_object1_drag_rescue(self, obs: dict) -> bool:
|
| 621 |
+
rgb, depth = self._video_rgb_depth(obs)
|
| 622 |
+
pts = self._points_for_object(rgb, depth, 1, wide=True, fill_holes=False)
|
| 623 |
+
if len(pts) < 64:
|
| 624 |
+
print(f"[PCA_RESCUE] skip object_1 drag: only {len(pts)} points", flush=True)
|
| 625 |
+
return False
|
| 626 |
+
# After transport failures object_1 is usually back on the table. The
|
| 627 |
+
# high visible points can be the gripper/finger occluder or a lifted
|
| 628 |
+
# face, so estimate the rescue push centre from table-near points only.
|
| 629 |
+
low = pts[(pts[:, 2] >= TABLE_TOP_Z + 0.030) & (pts[:, 2] <= TABLE_TOP_Z + 0.110)]
|
| 630 |
+
if len(low) >= 32:
|
| 631 |
+
c = 0.5 * (low.min(axis=0) + low.max(axis=0))
|
| 632 |
+
c[2] = float(np.median(low[:, 2]))
|
| 633 |
+
else:
|
| 634 |
+
c, _ = self._estimate_grasp(rgb, depth, 1, wide=True)
|
| 635 |
+
if not np.all(np.isfinite(c)):
|
| 636 |
+
return False
|
| 637 |
+
topdown = _quat_wxyz_to_rot(np.array([0.0, 1.0, 0.0, 0.0], dtype=np.float64))
|
| 638 |
+
drag_z = TABLE_TOP_Z + 0.055
|
| 639 |
+
# Push from the object's positive-y side toward the basket. A fixed
|
| 640 |
+
# start_y misses the cube after ACT/hybrid rollouts because object_1
|
| 641 |
+
# often remains around y=0.26..0.34.
|
| 642 |
+
lanes_x = [
|
| 643 |
+
float(np.clip(c[0] - 0.045, TABLE_CENTER_X - 0.16, TABLE_CENTER_X + 0.22)),
|
| 644 |
+
float(np.clip(c[0], TABLE_CENTER_X - 0.16, TABLE_CENTER_X + 0.22)),
|
| 645 |
+
float(np.clip(c[0] + 0.045, TABLE_CENTER_X - 0.16, TABLE_CENTER_X + 0.22)),
|
| 646 |
+
]
|
| 647 |
+
start_y = float(np.clip(c[1] + 0.085, TABLE_CENTER_Y + 0.085, TABLE_CENTER_Y + 0.46))
|
| 648 |
+
end_y = BASKET_CENTER_Y
|
| 649 |
+
print(
|
| 650 |
+
f"[PCA_RESCUE] object_1 drag c=({c[0]:.3f},{c[1]:.3f},{c[2]:.3f}) "
|
| 651 |
+
f"low_n={len(low)} "
|
| 652 |
+
f"lanes={','.join(f'{x:.2f}' for x in lanes_x)} y=({start_y:.3f}->{end_y:.3f})",
|
| 653 |
+
flush=True,
|
| 654 |
+
)
|
| 655 |
+
self.objects = (1,)
|
| 656 |
+
self.plan = []
|
| 657 |
+
self.plan_idx = 0
|
| 658 |
+
self.step_in_target = 0
|
| 659 |
+
for i, lane_x in enumerate(lanes_x):
|
| 660 |
+
start = np.array([lane_x, start_y, drag_z], dtype=np.float64)
|
| 661 |
+
end = np.array([lane_x, end_y, drag_z], dtype=np.float64)
|
| 662 |
+
self._add_pose([lane_x, start_y, TABLE_TOP_Z + 0.20], topdown, GRIP_OPEN, 70, label=f"obj1_rescue_lane{i}_pre")
|
| 663 |
+
self._add_pose(start, topdown, GRIP_OPEN, 100, finger_xy=start[:2], finger_z=drag_z, label=f"obj1_rescue_lane{i}_start")
|
| 664 |
+
self._add_pose(end, topdown, GRIP_OPEN, 520, finger_xy=end[:2], finger_z=drag_z, label=f"obj1_rescue_lane{i}_mid")
|
| 665 |
+
self._add_pose([BASKET_CENTER_X, BASKET_CENTER_Y, TABLE_TOP_Z + 0.15], topdown, GRIP_OPEN, 160, label="obj1_rescue_open")
|
| 666 |
+
self._add_pose([RETRACT_X, RETRACT_Y, TABLE_TOP_Z + 0.40], topdown, GRIP_OPEN, 80, label="obj1_rescue_retract")
|
| 667 |
+
return True
|
| 668 |
+
|
| 669 |
+
def _build_plan(self, obs: dict):
|
| 670 |
+
rgb, depth = self._video_rgb_depth(obs)
|
| 671 |
+
topdown = _quat_wxyz_to_rot(np.array([0.0, 1.0, 0.0, 0.0], dtype=np.float64))
|
| 672 |
+
self.plan = []
|
| 673 |
+
objects = tuple(int(x) for x in os.environ.get("ATEC_PCA_OBJECTS", "3,2,1").replace(" ", ",").split(",") if x)
|
| 674 |
+
self.objects = objects
|
| 675 |
+
for obj_idx in objects:
|
| 676 |
+
c, grasp_rot = self._estimate_grasp(rgb, depth, obj_idx)
|
| 677 |
+
if obj_idx == 1:
|
| 678 |
+
grasp_rot = _quat_wxyz_to_rot(np.array([0.0, 0.709, 0.705, 0.0], dtype=np.float64))
|
| 679 |
+
# The submit-style RGB-D PCA estimate is biased toward the visible
|
| 680 |
+
# left crescent of the banana. Keep GraspGen/PCA for its centre,
|
| 681 |
+
# but use the task-calibrated top-down wrist pose that the runner
|
| 682 |
+
# already validated for object_3.
|
| 683 |
+
if obj_idx == 3 and os.environ.get("ATEC_PCA_OBJ3_USE_PCA_ROT") != "1":
|
| 684 |
+
grasp_rot = _quat_wxyz_to_rot(np.array([0.0, 1.0, 0.004, 0.0], dtype=np.float64))
|
| 685 |
+
c[:2] += OBJ_CENTER_COMPLETION_OFFSETS[obj_idx]
|
| 686 |
+
self._detected_centers[obj_idx] = c.copy()
|
| 687 |
+
pick_xy = c[:2] + OBJ_GRASP_CENTER_OFFSETS[obj_idx]
|
| 688 |
+
yaw = float(np.arctan2(grasp_rot[1, 1], grasp_rot[0, 1]))
|
| 689 |
+
print(
|
| 690 |
+
f"[PCA_PLAN] obj={obj_idx} center=({c[0]:.3f},{c[1]:.3f},{c[2]:.3f}) "
|
| 691 |
+
f"pick=({pick_xy[0]:.3f},{pick_xy[1]:.3f}) jaw_yaw={yaw:+.2f}",
|
| 692 |
+
flush=True,
|
| 693 |
+
)
|
| 694 |
+
reach_z = max(float(c[2] + OBJ_TCP_Z[obj_idx]), TABLE_TOP_Z + 0.055)
|
| 695 |
+
# The PCA point cloud z is a visible-surface estimate, not the USD
|
| 696 |
+
# object root z used by the validated runner. Closing from
|
| 697 |
+
# c[2]+offset is too high for object_1 and makes the gripper miss
|
| 698 |
+
# the cube. Use the calibrated task close plane instead.
|
| 699 |
+
root_z_est = OBJ_ROOT_Z_EST.get(obj_idx, TABLE_TOP_Z + 0.045)
|
| 700 |
+
close_z = max(root_z_est + OBJ_CLOSE_Z_OFFSETS.get(obj_idx, 0.020), TABLE_TOP_Z + 0.030)
|
| 701 |
+
lift_z = TABLE_TOP_Z + (OBJ3_LIFT_CLEARANCE if obj_idx == 3 else 0.30)
|
| 702 |
+
release_z = TABLE_TOP_Z + (OBJ3_CARRY_CLEARANCE if obj_idx == 3 else (0.32 if obj_idx == 1 else 0.24))
|
| 703 |
+
open_z = TABLE_TOP_Z + (OBJ3_CARRY_CLEARANCE if obj_idx == 3 else (0.24 if obj_idx == 1 else 0.15))
|
| 704 |
+
place_xy = np.array([BASKET_CENTER_X, BASKET_CENTER_Y]) + OBJ_PLACE_XY_OFFSETS.get(
|
| 705 |
+
obj_idx, np.zeros(2, dtype=np.float64)
|
| 706 |
+
)
|
| 707 |
+
# Keep the calibrated top-down task quaternion for all objects. The
|
| 708 |
+
# PCA/AABB centre supplies translation; Task-E contact tuning supplies
|
| 709 |
+
# the wrist orientation and release heights.
|
| 710 |
+
finger_xy = pick_xy.copy() + OBJ_FINGER_XY_OFFSETS.get(obj_idx, np.zeros(2, dtype=np.float64)) if obj_idx in (1, 2, 3) else None
|
| 711 |
+
close_finger_xy = (
|
| 712 |
+
pick_xy
|
| 713 |
+
+ OBJ_PRECLOSE_INSERT_OFFSETS.get(obj_idx, np.zeros(2, dtype=np.float64))
|
| 714 |
+
+ OBJ_FINGER_XY_OFFSETS.get(obj_idx, np.zeros(2, dtype=np.float64))
|
| 715 |
+
)
|
| 716 |
+
closed_grip = OBJ3_HOLD_GRIP_DEFAULT.copy() if obj_idx == 3 else GRIP_CLOSE
|
| 717 |
+
finger_z = reach_z if obj_idx in (1, 2) else None
|
| 718 |
+
place_rot = grasp_rot if obj_idx in (1, 2) else topdown
|
| 719 |
+
self._add_pose([pick_xy[0], pick_xy[1], TABLE_TOP_Z + 0.30], grasp_rot, GRIP_OPEN, 90, label=f"obj{obj_idx}_pre")
|
| 720 |
+
servo_rel_z = OBJ_FINGER_TARGET_REL_Z.get(obj_idx)
|
| 721 |
+
if obj_idx == 3 and OBJ3_ENABLE_INSERT:
|
| 722 |
+
# Diagnostic-only guarded side approach. Local tests showed
|
| 723 |
+
# low open-finger insertion can shove the banana laterally, so
|
| 724 |
+
# the default path below matches the successful GraspNet runner:
|
| 725 |
+
# reach the calibrated contact point first, then close there.
|
| 726 |
+
side_finger_xy = close_finger_xy + OBJ3_PREGRASP_OFFSET
|
| 727 |
+
self._add_pose(
|
| 728 |
+
[side_finger_xy[0], side_finger_xy[1], reach_z],
|
| 729 |
+
grasp_rot,
|
| 730 |
+
GRIP_OPEN,
|
| 731 |
+
OBJ3_SIDE_APPROACH_STEPS,
|
| 732 |
+
finger_xy=side_finger_xy,
|
| 733 |
+
finger_z=OBJ3_APPROACH_FINGER_Z,
|
| 734 |
+
servo_obj_z=root_z_est,
|
| 735 |
+
servo_target_rel_z=None,
|
| 736 |
+
label=f"obj{obj_idx}_side_pre",
|
| 737 |
+
)
|
| 738 |
+
self._add_pose(
|
| 739 |
+
[side_finger_xy[0], side_finger_xy[1], close_z],
|
| 740 |
+
grasp_rot,
|
| 741 |
+
GRIP_OPEN,
|
| 742 |
+
OBJ3_SIDE_LOW_STEPS,
|
| 743 |
+
finger_xy=side_finger_xy,
|
| 744 |
+
finger_z=OBJ3_PREGRASP_LOW_FINGER_Z,
|
| 745 |
+
servo_obj_z=root_z_est,
|
| 746 |
+
servo_target_rel_z=None,
|
| 747 |
+
label=f"obj{obj_idx}_side_low",
|
| 748 |
+
)
|
| 749 |
+
self._add_pose(
|
| 750 |
+
[close_finger_xy[0], close_finger_xy[1], close_z],
|
| 751 |
+
grasp_rot,
|
| 752 |
+
GRIP_OPEN,
|
| 753 |
+
OBJ3_INSERT_STEPS,
|
| 754 |
+
finger_xy=close_finger_xy,
|
| 755 |
+
finger_z=OBJ3_PREGRASP_LOW_FINGER_Z,
|
| 756 |
+
servo_obj_z=root_z_est,
|
| 757 |
+
servo_target_rel_z=None,
|
| 758 |
+
label=f"obj{obj_idx}_insert",
|
| 759 |
+
)
|
| 760 |
+
else:
|
| 761 |
+
self._add_pose(
|
| 762 |
+
[pick_xy[0], pick_xy[1], reach_z],
|
| 763 |
+
grasp_rot,
|
| 764 |
+
GRIP_OPEN,
|
| 765 |
+
OBJ_REACH_STEPS[obj_idx],
|
| 766 |
+
finger_xy=finger_xy,
|
| 767 |
+
finger_z=None,
|
| 768 |
+
servo_obj_z=root_z_est,
|
| 769 |
+
servo_target_rel_z=None,
|
| 770 |
+
label=f"obj{obj_idx}_reach",
|
| 771 |
+
)
|
| 772 |
+
if obj_idx != 3 and np.linalg.norm(OBJ_PRECLOSE_INSERT_OFFSETS.get(obj_idx, np.zeros(2, dtype=np.float64))) > 1e-6:
|
| 773 |
+
self._add_pose(
|
| 774 |
+
[close_finger_xy[0], close_finger_xy[1], close_z],
|
| 775 |
+
grasp_rot,
|
| 776 |
+
GRIP_OPEN,
|
| 777 |
+
180,
|
| 778 |
+
finger_xy=close_finger_xy,
|
| 779 |
+
finger_z=None,
|
| 780 |
+
servo_obj_z=root_z_est,
|
| 781 |
+
servo_target_rel_z=servo_rel_z,
|
| 782 |
+
label=f"obj{obj_idx}_insert",
|
| 783 |
+
)
|
| 784 |
+
obj3_finger_z = OBJ3_CLOSE_FINGER_Z if obj_idx == 3 else None
|
| 785 |
+
self._add_pose(
|
| 786 |
+
[close_finger_xy[0], close_finger_xy[1], close_z],
|
| 787 |
+
grasp_rot,
|
| 788 |
+
closed_grip,
|
| 789 |
+
OBJ_CLOSE_STEPS[obj_idx],
|
| 790 |
+
finger_xy=close_finger_xy,
|
| 791 |
+
finger_z=obj3_finger_z,
|
| 792 |
+
servo_obj_z=root_z_est,
|
| 793 |
+
servo_target_rel_z=None if obj_idx == 3 else servo_rel_z,
|
| 794 |
+
label=f"obj{obj_idx}_close",
|
| 795 |
+
)
|
| 796 |
+
if obj_idx == 3:
|
| 797 |
+
self._add_pose(
|
| 798 |
+
[close_finger_xy[0], close_finger_xy[1], close_z],
|
| 799 |
+
grasp_rot,
|
| 800 |
+
closed_grip,
|
| 801 |
+
OBJ3_LOW_HOLD_STEPS,
|
| 802 |
+
finger_xy=close_finger_xy,
|
| 803 |
+
finger_z=OBJ3_CLOSE_FINGER_Z,
|
| 804 |
+
servo_obj_z=root_z_est,
|
| 805 |
+
servo_target_rel_z=None,
|
| 806 |
+
label=f"obj{obj_idx}_low_hold",
|
| 807 |
+
)
|
| 808 |
+
if obj_idx == 1:
|
| 809 |
+
self._add_pose(
|
| 810 |
+
[close_finger_xy[0], close_finger_xy[1], close_z],
|
| 811 |
+
grasp_rot,
|
| 812 |
+
GRIP_CLOSE,
|
| 813 |
+
160,
|
| 814 |
+
finger_xy=None,
|
| 815 |
+
finger_z=None,
|
| 816 |
+
freeze_arm=True,
|
| 817 |
+
label=f"obj{obj_idx}_squeeze",
|
| 818 |
+
)
|
| 819 |
+
self._add_pose(
|
| 820 |
+
[close_finger_xy[0], close_finger_xy[1], lift_z],
|
| 821 |
+
grasp_rot,
|
| 822 |
+
closed_grip,
|
| 823 |
+
OBJ_LIFT_STEPS[obj_idx],
|
| 824 |
+
finger_xy=close_finger_xy,
|
| 825 |
+
finger_z=OBJ3_LIFT_FINGER_Z if obj_idx == 3 else None,
|
| 826 |
+
servo_obj_z=None if obj_idx == 3 else root_z_est,
|
| 827 |
+
servo_target_rel_z=None if obj_idx == 3 else servo_rel_z,
|
| 828 |
+
label=f"obj{obj_idx}_lift",
|
| 829 |
+
)
|
| 830 |
+
if obj_idx == 3:
|
| 831 |
+
# After a short lift confirms contact, do not keep a high-air
|
| 832 |
+
# friction grasp. Banana is contact-sensitive in official
|
| 833 |
+
# physics; a low closed-drag/cradle path preserves contact and
|
| 834 |
+
# avoids the DLS high-transport singularity seen in videos.
|
| 835 |
+
drag_z = OBJ3_FALLBACK_DRAG_Z
|
| 836 |
+
drag_start_finger = close_finger_xy.copy()
|
| 837 |
+
drag_mid_obj = np.array([BASKET_CENTER_X, 0.5 * (pick_xy[1] + BASKET_CENTER_Y)], dtype=np.float64)
|
| 838 |
+
drag_end_obj = np.array([BASKET_CENTER_X, BASKET_CENTER_Y], dtype=np.float64)
|
| 839 |
+
drag_mid_finger = drag_mid_obj + OBJ_FINGER_XY_OFFSETS[3]
|
| 840 |
+
drag_end_finger = drag_end_obj + OBJ_FINGER_XY_OFFSETS[3]
|
| 841 |
+
self._add_pose(
|
| 842 |
+
[drag_start_finger[0], drag_start_finger[1], drag_z],
|
| 843 |
+
topdown,
|
| 844 |
+
closed_grip,
|
| 845 |
+
OBJ3_DRAG_START_STEPS,
|
| 846 |
+
finger_xy=drag_start_finger,
|
| 847 |
+
finger_z=drag_z,
|
| 848 |
+
label=f"obj{obj_idx}_drag_start",
|
| 849 |
+
)
|
| 850 |
+
self._add_pose(
|
| 851 |
+
[drag_mid_finger[0], drag_mid_finger[1], drag_z],
|
| 852 |
+
topdown,
|
| 853 |
+
closed_grip,
|
| 854 |
+
OBJ3_DRAG_MID_STEPS,
|
| 855 |
+
finger_xy=drag_mid_finger,
|
| 856 |
+
finger_z=drag_z,
|
| 857 |
+
label=f"obj{obj_idx}_drag_mid",
|
| 858 |
+
)
|
| 859 |
+
self._add_pose(
|
| 860 |
+
[drag_end_finger[0], drag_end_finger[1], drag_z],
|
| 861 |
+
topdown,
|
| 862 |
+
closed_grip,
|
| 863 |
+
OBJ3_DRAG_END_STEPS,
|
| 864 |
+
finger_xy=drag_end_finger,
|
| 865 |
+
finger_z=drag_z,
|
| 866 |
+
label=f"obj{obj_idx}_drag_end",
|
| 867 |
+
)
|
| 868 |
+
self._add_pose(
|
| 869 |
+
[drag_end_finger[0], drag_end_finger[1], drag_z],
|
| 870 |
+
topdown,
|
| 871 |
+
closed_grip,
|
| 872 |
+
OBJ3_DRAG_SETTLE_STEPS,
|
| 873 |
+
finger_xy=drag_end_finger,
|
| 874 |
+
finger_z=drag_z,
|
| 875 |
+
label=f"obj{obj_idx}_drag_settle",
|
| 876 |
+
)
|
| 877 |
+
self._add_pose(
|
| 878 |
+
[drag_end_finger[0], drag_end_finger[1], drag_z],
|
| 879 |
+
topdown,
|
| 880 |
+
GRIP_OPEN,
|
| 881 |
+
OBJ_OPEN_STEPS[obj_idx],
|
| 882 |
+
finger_xy=drag_end_finger,
|
| 883 |
+
finger_z=drag_z,
|
| 884 |
+
label=f"obj{obj_idx}_drag_open",
|
| 885 |
+
)
|
| 886 |
+
self._add_pose([RETRACT_X, RETRACT_Y, TABLE_TOP_Z + 0.40], topdown, GRIP_OPEN, 80, label=f"obj{obj_idx}_retract")
|
| 887 |
+
continue
|
| 888 |
+
mid = np.array([(close_finger_xy[0] + place_xy[0]) * 0.5, (close_finger_xy[1] + place_xy[1]) * 0.5, release_z])
|
| 889 |
+
if obj_idx == 3:
|
| 890 |
+
carry_mid_finger = mid[:2] + OBJ_FINGER_XY_OFFSETS[3]
|
| 891 |
+
release_finger = place_xy + OBJ_FINGER_XY_OFFSETS[3]
|
| 892 |
+
else:
|
| 893 |
+
carry_mid_finger = mid[:2] if obj_idx in (1, 2) else None
|
| 894 |
+
release_finger = place_xy if obj_idx in (1, 2) else None
|
| 895 |
+
carry_finger_z = OBJ3_LIFT_FINGER_Z if obj_idx == 3 else None
|
| 896 |
+
self._add_pose(
|
| 897 |
+
mid,
|
| 898 |
+
place_rot,
|
| 899 |
+
closed_grip,
|
| 900 |
+
max(OBJ_TRANSPORT_STEPS[obj_idx] // 2, 1),
|
| 901 |
+
finger_xy=carry_mid_finger,
|
| 902 |
+
finger_z=carry_finger_z,
|
| 903 |
+
label=f"obj{obj_idx}_mid",
|
| 904 |
+
)
|
| 905 |
+
if obj_idx == 1:
|
| 906 |
+
self._add_pose(
|
| 907 |
+
mid,
|
| 908 |
+
place_rot,
|
| 909 |
+
GRIP_CLOSE,
|
| 910 |
+
140,
|
| 911 |
+
freeze_arm=True,
|
| 912 |
+
label=f"obj{obj_idx}_mid_squeeze",
|
| 913 |
+
)
|
| 914 |
+
self._add_pose(
|
| 915 |
+
[place_xy[0], place_xy[1], release_z],
|
| 916 |
+
place_rot,
|
| 917 |
+
closed_grip,
|
| 918 |
+
max(OBJ_TRANSPORT_STEPS[obj_idx] - OBJ_TRANSPORT_STEPS[obj_idx] // 2, 1),
|
| 919 |
+
finger_xy=release_finger,
|
| 920 |
+
finger_z=carry_finger_z,
|
| 921 |
+
label=f"obj{obj_idx}_release",
|
| 922 |
+
)
|
| 923 |
+
if obj_idx == 3:
|
| 924 |
+
# Match the runner's basket-hold phase: keep the gripper closed
|
| 925 |
+
# above the release pose while the object centre is servoed into
|
| 926 |
+
# the real basket centre before opening.
|
| 927 |
+
self._add_pose(
|
| 928 |
+
[place_xy[0], place_xy[1], release_z],
|
| 929 |
+
place_rot,
|
| 930 |
+
closed_grip,
|
| 931 |
+
420,
|
| 932 |
+
finger_xy=release_finger,
|
| 933 |
+
finger_z=carry_finger_z,
|
| 934 |
+
label=f"obj{obj_idx}_basket_hold",
|
| 935 |
+
)
|
| 936 |
+
if obj_idx == 1 and os.environ.get("ATEC_PCA_ENABLE_OBJ1_RESCUE") == "1":
|
| 937 |
+
self._add_pose([place_xy[0], place_xy[1], release_z], place_rot, GRIP_CLOSE, 1, label="obj1_relocalize_drag")
|
| 938 |
+
settle_xy = np.array([BASKET_CENTER_X, BASKET_CENTER_Y], dtype=np.float64) if obj_idx == 1 else place_xy
|
| 939 |
+
settle_finger = release_finger if obj_idx == 3 else (settle_xy if obj_idx in (1, 2) else None)
|
| 940 |
+
self._add_pose([settle_xy[0], settle_xy[1], open_z], place_rot, closed_grip, 80 if obj_idx != 3 else 120, finger_xy=settle_finger, label=f"obj{obj_idx}_settle")
|
| 941 |
+
self._add_pose([settle_xy[0], settle_xy[1], open_z], place_rot, GRIP_OPEN, OBJ_OPEN_STEPS[obj_idx], label=f"obj{obj_idx}_open")
|
| 942 |
+
self._add_pose([RETRACT_X, RETRACT_Y, TABLE_TOP_Z + 0.40], topdown, GRIP_OPEN, 80, label=f"obj{obj_idx}_retract")
|
| 943 |
+
self.detected = True
|
| 944 |
+
|
| 945 |
+
def _add_pose(
|
| 946 |
+
self,
|
| 947 |
+
pos,
|
| 948 |
+
rot,
|
| 949 |
+
grip,
|
| 950 |
+
steps,
|
| 951 |
+
finger_xy=None,
|
| 952 |
+
finger_z=None,
|
| 953 |
+
servo_obj_z=None,
|
| 954 |
+
servo_target_rel_z=None,
|
| 955 |
+
freeze_arm=False,
|
| 956 |
+
label="",
|
| 957 |
+
):
|
| 958 |
+
if int(steps) <= 0:
|
| 959 |
+
return
|
| 960 |
+
self.plan.append(
|
| 961 |
+
PoseTarget(
|
| 962 |
+
np.asarray(pos, dtype=np.float64),
|
| 963 |
+
np.asarray(rot, dtype=np.float64),
|
| 964 |
+
np.asarray(grip, dtype=np.float64),
|
| 965 |
+
int(steps),
|
| 966 |
+
None if finger_xy is None else np.asarray(finger_xy, dtype=np.float64),
|
| 967 |
+
None if finger_z is None else float(finger_z),
|
| 968 |
+
None if servo_obj_z is None else float(servo_obj_z),
|
| 969 |
+
None if servo_target_rel_z is None else float(servo_target_rel_z),
|
| 970 |
+
bool(freeze_arm),
|
| 971 |
+
str(label),
|
| 972 |
+
)
|
| 973 |
+
)
|
| 974 |
+
|
| 975 |
+
def predicts(self, obs, current_score):
|
| 976 |
+
qpos = self._obs_qpos(obs)
|
| 977 |
+
if self.t < 25:
|
| 978 |
+
self.t += 1
|
| 979 |
+
return {"action": np.zeros((1, 8), dtype=np.float32).tolist(), "giveup": False}
|
| 980 |
+
if self.home_count < 80:
|
| 981 |
+
self.home_count += 1
|
| 982 |
+
action = np.clip((HOME_Q - DEFAULT_Q) / ACTION_SCALE, -3.0, 3.0)
|
| 983 |
+
return {"action": action.reshape(1, -1).astype(np.float32).tolist(), "giveup": False}
|
| 984 |
+
if not self.detected:
|
| 985 |
+
if (
|
| 986 |
+
os.environ.get("ATEC_PCA_OBJ1_DIRECT_RESCUE") == "1"
|
| 987 |
+
and tuple(int(x) for x in os.environ.get("ATEC_PCA_OBJECTS", "3,2,1").replace(" ", ",").split(",") if x) == (1,)
|
| 988 |
+
and self._build_object1_drag_rescue(obs)
|
| 989 |
+
):
|
| 990 |
+
self.detected = True
|
| 991 |
+
else:
|
| 992 |
+
self._build_plan(obs)
|
| 993 |
+
if self.plan_idx >= len(self.plan):
|
| 994 |
+
if (
|
| 995 |
+
not self.fallback_done
|
| 996 |
+
and 3 in self.objects
|
| 997 |
+
and os.environ.get("ATEC_PCA_ENABLE_FALLBACK") == "1"
|
| 998 |
+
):
|
| 999 |
+
self.fallback_done = True
|
| 1000 |
+
if self._build_object3_drag_fallback(obs):
|
| 1001 |
+
target = self.plan[self.plan_idx]
|
| 1002 |
+
pos_w = target.pos_w.copy()
|
| 1003 |
+
else:
|
| 1004 |
+
action = np.clip((HOME_Q - DEFAULT_Q) / ACTION_SCALE, -3.0, 3.0)
|
| 1005 |
+
return {"action": action.reshape(1, -1).astype(np.float32).tolist(), "giveup": False}
|
| 1006 |
+
else:
|
| 1007 |
+
action = np.clip((HOME_Q - DEFAULT_Q) / ACTION_SCALE, -3.0, 3.0)
|
| 1008 |
+
return {"action": action.reshape(1, -1).astype(np.float32).tolist(), "giveup": False}
|
| 1009 |
+
else:
|
| 1010 |
+
target = self.plan[self.plan_idx]
|
| 1011 |
+
pos_w = target.pos_w.copy()
|
| 1012 |
+
if target.label == "obj1_relocalize_drag":
|
| 1013 |
+
if self._build_object1_drag_rescue(obs):
|
| 1014 |
+
target = self.plan[self.plan_idx]
|
| 1015 |
+
pos_w = target.pos_w.copy()
|
| 1016 |
+
else:
|
| 1017 |
+
self.plan_idx += 1
|
| 1018 |
+
return {"action": np.zeros((1, 8), dtype=np.float32).tolist(), "giveup": False}
|
| 1019 |
+
raw_pos_w = pos_w.copy()
|
| 1020 |
+
dynamic_finger_xy = None
|
| 1021 |
+
finger_target_w = None
|
| 1022 |
+
if target.label in ("obj3_basket_hold", "obj3_settle") and os.environ.get(
|
| 1023 |
+
"ATEC_PCA_OBJ3_OBJECT_SERVO", "1"
|
| 1024 |
+
) != "0":
|
| 1025 |
+
c_now = self._estimate_object3_current_center(obs)
|
| 1026 |
+
if c_now is not None:
|
| 1027 |
+
if self._obj3_carry_offset_xy is None:
|
| 1028 |
+
finger_now = self.ik.finger_center_world(qpos)
|
| 1029 |
+
observed_offset = finger_now[:2] - c_now[:2]
|
| 1030 |
+
# Preserve the actual contact relation reached at lift,
|
| 1031 |
+
# but bound it so a bad visual frame cannot launch the arm.
|
| 1032 |
+
observed_offset = np.clip(observed_offset, [-0.055, -0.055], [0.055, 0.055])
|
| 1033 |
+
if np.all(np.isfinite(observed_offset)):
|
| 1034 |
+
self._obj3_carry_offset_xy = observed_offset.astype(np.float64)
|
| 1035 |
+
carry_offset = (
|
| 1036 |
+
self._obj3_carry_offset_xy
|
| 1037 |
+
if self._obj3_carry_offset_xy is not None
|
| 1038 |
+
else OBJ_FINGER_XY_OFFSETS[3]
|
| 1039 |
+
)
|
| 1040 |
+
object_target_xy = np.array([BASKET_CENTER_X, BASKET_CENTER_Y], dtype=np.float64)
|
| 1041 |
+
correction = np.zeros(2, dtype=np.float64)
|
| 1042 |
+
correction = (object_target_xy - c_now[:2]) * OBJ3_OBJECT_SERVO_GAIN
|
| 1043 |
+
corr_norm = float(np.linalg.norm(correction))
|
| 1044 |
+
max_corr = OBJ3_OBJECT_SERVO_MAX_XY
|
| 1045 |
+
if corr_norm > max_corr:
|
| 1046 |
+
correction = correction / max(corr_norm, 1e-6) * max_corr
|
| 1047 |
+
pos_w[:2] = raw_pos_w[:2] + correction
|
| 1048 |
+
raw_pos_w = pos_w.copy()
|
| 1049 |
+
# Keep the same finger-to-object contact relation while
|
| 1050 |
+
# servoing the object centre into the basket. Pointing the
|
| 1051 |
+
# finger target at c_now pins the hand near the old table pose
|
| 1052 |
+
# and fights the basket correction.
|
| 1053 |
+
dynamic_finger_xy = object_target_xy + carry_offset
|
| 1054 |
+
if (
|
| 1055 |
+
os.environ.get("ATEC_PCA_ENABLE_FALLBACK") == "1"
|
| 1056 |
+
and
|
| 1057 |
+
os.environ.get("ATEC_PCA_OBJ3_DYNAMIC_FALLBACK", "1") != "0"
|
| 1058 |
+
and not self.fallback_done
|
| 1059 |
+
and target.label in ("obj3_mid", "obj3_release", "obj3_basket_hold")
|
| 1060 |
+
and c_now[1] > BASKET_CENTER_Y + 0.16
|
| 1061 |
+
and c_now[2] < TABLE_TOP_Z + 0.045
|
| 1062 |
+
and self.step_in_target > 80
|
| 1063 |
+
):
|
| 1064 |
+
self.fallback_done = True
|
| 1065 |
+
print(
|
| 1066 |
+
f"[PCA_FALLBACK_TRIGGER] object_3 stalled c=({c_now[0]:.3f},{c_now[1]:.3f},{c_now[2]:.3f}) "
|
| 1067 |
+
f"target={target.label} step={self.step_in_target}",
|
| 1068 |
+
flush=True,
|
| 1069 |
+
)
|
| 1070 |
+
if self._build_object3_drag_fallback(obs):
|
| 1071 |
+
target = self.plan[self.plan_idx]
|
| 1072 |
+
pos_w = target.pos_w.copy()
|
| 1073 |
+
raw_pos_w = pos_w.copy()
|
| 1074 |
+
dynamic_finger_xy = None
|
| 1075 |
+
if os.environ.get("ATEC_PCA_DEBUG_TARGET") and self.step_in_target % 25 == 0:
|
| 1076 |
+
print(
|
| 1077 |
+
f"[PCA_OBJ_SERVO] {target.label} c=({c_now[0]:.3f},{c_now[1]:.3f}) "
|
| 1078 |
+
f"target=({object_target_xy[0]:.3f},{object_target_xy[1]:.3f}) "
|
| 1079 |
+
f"corr=({correction[0]:+.3f},{correction[1]:+.3f})",
|
| 1080 |
+
flush=True,
|
| 1081 |
+
)
|
| 1082 |
+
if target.finger_xy is not None:
|
| 1083 |
+
finger = self.ik.finger_center_world(qpos)
|
| 1084 |
+
gb_b, _ = self.ik.fk_base(qpos[:6])
|
| 1085 |
+
gb_w = BASE_POS_W + R_W_B @ gb_b
|
| 1086 |
+
finger_from_gb = finger - gb_w
|
| 1087 |
+
desired_finger_xy = target.finger_xy if dynamic_finger_xy is None else dynamic_finger_xy
|
| 1088 |
+
finger_target_z = target.finger_z if target.finger_z is not None else finger[2]
|
| 1089 |
+
finger_target_w = np.array([desired_finger_xy[0], desired_finger_xy[1], finger_target_z], dtype=np.float64)
|
| 1090 |
+
xy_error = finger[:2] - desired_finger_xy
|
| 1091 |
+
correction = -xy_error
|
| 1092 |
+
corr_norm = float(np.linalg.norm(correction))
|
| 1093 |
+
max_xy = 0.12
|
| 1094 |
+
if target.label.startswith("obj3_") and (
|
| 1095 |
+
("_mid" in target.label)
|
| 1096 |
+
or ("_release" in target.label)
|
| 1097 |
+
or ("_basket_hold" in target.label)
|
| 1098 |
+
or ("_settle" in target.label)
|
| 1099 |
+
or ("_drag" in target.label)
|
| 1100 |
+
):
|
| 1101 |
+
max_xy = OBJ3_FINGER_SERVO_MAX_XY
|
| 1102 |
+
elif ("_mid" in target.label) or ("_release" in target.label) or ("_settle" in target.label):
|
| 1103 |
+
max_xy = 0.32
|
| 1104 |
+
if corr_norm > max_xy:
|
| 1105 |
+
correction = correction / max(corr_norm, 1e-6) * max_xy
|
| 1106 |
+
pos_w[:2] = raw_pos_w[:2] + correction
|
| 1107 |
+
if target.finger_z is not None:
|
| 1108 |
+
pos_w[2] = float(target.finger_z - finger_from_gb[2])
|
| 1109 |
+
elif target.servo_obj_z is not None and target.servo_target_rel_z is not None:
|
| 1110 |
+
rel_z = float(finger[2] - target.servo_obj_z)
|
| 1111 |
+
z_error = float(target.servo_target_rel_z - rel_z)
|
| 1112 |
+
obj_for_label = 3 if target.label.startswith("obj3_") else 1
|
| 1113 |
+
max_z = OBJ_FINGER_SERVO_MAX_Z.get(obj_for_label, 0.050)
|
| 1114 |
+
if obj_for_label == 3:
|
| 1115 |
+
z_correction = float(np.clip(z_error, -max_z, max_z))
|
| 1116 |
+
else:
|
| 1117 |
+
z_correction = min(0.0, max(-max_z, z_error))
|
| 1118 |
+
pos_w[2] = float(raw_pos_w[2] + z_correction)
|
| 1119 |
+
if os.environ.get("ATEC_PCA_DEBUG_TARGET") and self.step_in_target % 25 == 0:
|
| 1120 |
+
print(
|
| 1121 |
+
f"[PCA_TARGET] plan={self.plan_idx} step={self.step_in_target} "
|
| 1122 |
+
f"raw=({raw_pos_w[0]:.3f},{raw_pos_w[1]:.3f},{raw_pos_w[2]:.3f}) "
|
| 1123 |
+
f"gb=({gb_w[0]:.3f},{gb_w[1]:.3f},{gb_w[2]:.3f}) "
|
| 1124 |
+
f"finger=({finger[0]:.3f},{finger[1]:.3f},{finger[2]:.3f}) "
|
| 1125 |
+
f"desired=({desired_finger_xy[0]:.3f},{desired_finger_xy[1]:.3f}) "
|
| 1126 |
+
f"pos=({pos_w[0]:.3f},{pos_w[1]:.3f},{pos_w[2]:.3f})",
|
| 1127 |
+
flush=True,
|
| 1128 |
+
)
|
| 1129 |
+
# Use a submit-side equivalent of the runner's CartesianController:
|
| 1130 |
+
# one DLS update from the current qpos per simulator step. Close/reach
|
| 1131 |
+
# phases prioritize position because centimetres of z error are enough
|
| 1132 |
+
# to miss the object, while a small wrist error is tolerable.
|
| 1133 |
+
position_only = (
|
| 1134 |
+
("_reach" in target.label)
|
| 1135 |
+
or ("_side_pre" in target.label)
|
| 1136 |
+
or ("_side_low" in target.label)
|
| 1137 |
+
or ("_insert" in target.label)
|
| 1138 |
+
or ("_close" in target.label)
|
| 1139 |
+
or ("_low_hold" in target.label)
|
| 1140 |
+
or (target.label.startswith("obj3_") and any(key in target.label for key in ("drag", "mid", "release", "basket_hold", "settle")))
|
| 1141 |
+
)
|
| 1142 |
+
if target.freeze_arm:
|
| 1143 |
+
q6 = qpos[:6].copy()
|
| 1144 |
+
elif (
|
| 1145 |
+
finger_target_w is not None
|
| 1146 |
+
and (
|
| 1147 |
+
(
|
| 1148 |
+
target.label.startswith("fallback_")
|
| 1149 |
+
and os.environ.get("ATEC_PCA_FALLBACK_FINGER_IK", "0") != "0"
|
| 1150 |
+
)
|
| 1151 |
+
or (
|
| 1152 |
+
target.label.startswith("obj3_")
|
| 1153 |
+
and os.environ.get("ATEC_PCA_OBJ3_USE_FINGER_IK", "0") == "1"
|
| 1154 |
+
and any(key in target.label for key in ("mid", "release", "basket_hold", "settle"))
|
| 1155 |
+
)
|
| 1156 |
+
)
|
| 1157 |
+
):
|
| 1158 |
+
q6 = self.ik.solve_finger(qpos, finger_target_w, target.rot_w)
|
| 1159 |
+
elif os.environ.get("ATEC_PCA_USE_FULL_IK") == "1":
|
| 1160 |
+
q6 = self.ik.solve(qpos, pos_w, target.rot_w)
|
| 1161 |
+
else:
|
| 1162 |
+
q6 = self.ik.step_dls(qpos, pos_w, target.rot_w, position_only=position_only)
|
| 1163 |
+
q_target = np.concatenate([q6, target.grip])
|
| 1164 |
+
if target.label.startswith("obj1_"):
|
| 1165 |
+
gap = self.ik.finger_gap(qpos)
|
| 1166 |
+
if (
|
| 1167 |
+
self._obj1_hold_grip is None
|
| 1168 |
+
and
|
| 1169 |
+
target.label in ("obj1_close", "obj1_lift", "obj1_mid")
|
| 1170 |
+
and gap <= OBJ1_HOLD_GAP
|
| 1171 |
+
and self.step_in_target > 10
|
| 1172 |
+
):
|
| 1173 |
+
self._obj1_hold_grip = qpos[6:8].copy()
|
| 1174 |
+
if self._obj1_hold_grip is not None and any(
|
| 1175 |
+
key in target.label for key in ("close", "squeeze", "lift", "mid", "release", "settle")
|
| 1176 |
+
):
|
| 1177 |
+
q_target[6:8] = self._obj1_hold_grip
|
| 1178 |
+
if target.label.startswith("obj3_"):
|
| 1179 |
+
gap = self.ik.finger_gap(qpos)
|
| 1180 |
+
if (
|
| 1181 |
+
self._obj3_hold_grip is None
|
| 1182 |
+
and target.label == "obj3_lift"
|
| 1183 |
+
and gap <= OBJ3_HOLD_GAP
|
| 1184 |
+
and self.step_in_target >= int(os.environ.get("ATEC_PCA_OBJ3_LIFT_LATCH_STEP", "20"))
|
| 1185 |
+
):
|
| 1186 |
+
self._obj3_hold_grip = qpos[6:8].copy()
|
| 1187 |
+
if self._obj3_hold_grip is not None and any(
|
| 1188 |
+
key in target.label for key in ("close", "low_hold", "lift", "mid", "release", "basket_hold", "settle", "drag")
|
| 1189 |
+
):
|
| 1190 |
+
q_target[6:8] = self._obj3_hold_grip
|
| 1191 |
+
# Match IsaacLab CartesianController's per-step clamp; gripper fingers
|
| 1192 |
+
# still close gradually so they do not shove the object sideways.
|
| 1193 |
+
gripper_max_delta = 0.010
|
| 1194 |
+
if target.label.startswith("obj3_") and self._obj3_hold_grip is None and any(
|
| 1195 |
+
key in target.label for key in ("close", "low_hold")
|
| 1196 |
+
):
|
| 1197 |
+
gripper_max_delta = OBJ3_GRIPPER_MAX_DELTA
|
| 1198 |
+
max_delta = np.array(
|
| 1199 |
+
[0.18, 0.18, 0.18, 0.18, 0.18, 0.18, gripper_max_delta, gripper_max_delta],
|
| 1200 |
+
dtype=np.float64,
|
| 1201 |
+
)
|
| 1202 |
+
q_target = qpos + np.clip(q_target - qpos, -max_delta, max_delta)
|
| 1203 |
+
action = np.clip((q_target - DEFAULT_Q) / ACTION_SCALE, -5.0, 5.0)
|
| 1204 |
+
self.step_in_target += 1
|
| 1205 |
+
advance = self.step_in_target >= target.steps
|
| 1206 |
+
if target.label == "obj1_close" and self._obj1_hold_grip is not None:
|
| 1207 |
+
advance = True
|
| 1208 |
+
if (
|
| 1209 |
+
target.label == "obj3_close"
|
| 1210 |
+
and self._obj3_hold_grip is not None
|
| 1211 |
+
and self.step_in_target >= OBJ3_CLOSE_MIN_STEPS
|
| 1212 |
+
):
|
| 1213 |
+
advance = True
|
| 1214 |
+
if "_squeeze" in target.label:
|
| 1215 |
+
gap = self.ik.finger_gap(qpos)
|
| 1216 |
+
if self._obj1_hold_grip is not None and target.label.startswith("obj1_"):
|
| 1217 |
+
advance = self.step_in_target >= 20
|
| 1218 |
+
elif gap > OBJ1_HOLD_GAP and self.step_in_target < 420:
|
| 1219 |
+
advance = False
|
| 1220 |
+
if os.environ.get("ATEC_PCA_DEBUG_TARGET") and self.step_in_target % 25 == 0:
|
| 1221 |
+
print(f"[PCA_SQUEEZE] step={self.step_in_target} gap={gap:.4f} advance={advance}", flush=True)
|
| 1222 |
+
if advance:
|
| 1223 |
+
if os.environ.get("ATEC_PCA_DEBUG_TARGET") and target.label.startswith("obj3_"):
|
| 1224 |
+
c_dbg = self._estimate_object3_current_center(obs)
|
| 1225 |
+
f_dbg = self.ik.finger_center_world(qpos)
|
| 1226 |
+
gap_dbg = self.ik.finger_gap(qpos)
|
| 1227 |
+
c_msg = "none"
|
| 1228 |
+
if c_dbg is not None:
|
| 1229 |
+
c_msg = f"({c_dbg[0]:.3f},{c_dbg[1]:.3f},{c_dbg[2]:.3f})"
|
| 1230 |
+
print(
|
| 1231 |
+
f"[PCA_STAGE_END] {target.label} c={c_msg} "
|
| 1232 |
+
f"finger=({f_dbg[0]:.3f},{f_dbg[1]:.3f},{f_dbg[2]:.3f}) "
|
| 1233 |
+
f"gap={gap_dbg:.4f} hold="
|
| 1234 |
+
f"{None if self._obj3_hold_grip is None else [float(v) for v in self._obj3_hold_grip]}",
|
| 1235 |
+
flush=True,
|
| 1236 |
+
)
|
| 1237 |
+
self.step_in_target = 0
|
| 1238 |
+
self.plan_idx += 1
|
| 1239 |
+
return {"action": action.reshape(1, -1).astype(np.float32).tolist(), "giveup": False}
|
| 1240 |
+
|
| 1241 |
+
|
| 1242 |
+
RETRACT_X = TABLE_CENTER_X + TABLE_HALF_X - 0.05
|
| 1243 |
+
RETRACT_Y = TABLE_CENTER_Y
|
demo/solution_pi05.py
ADDED
|
@@ -0,0 +1,169 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""ATEC Task E adapter for an OpenPI/pi0.5 websocket policy server.
|
| 2 |
+
|
| 3 |
+
This is a local evaluation bridge, not the current submission default. Start
|
| 4 |
+
the OpenPI server first, then evaluate this solution against the Isaac task.
|
| 5 |
+
"""
|
| 6 |
+
|
| 7 |
+
from __future__ import annotations
|
| 8 |
+
|
| 9 |
+
from collections import deque
|
| 10 |
+
import os
|
| 11 |
+
import sys
|
| 12 |
+
from pathlib import Path
|
| 13 |
+
|
| 14 |
+
import numpy as np
|
| 15 |
+
import torch
|
| 16 |
+
import torchvision.transforms.functional as TF
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
_OPENPI_REPO = Path(os.environ.get("OPENPI_REPO", "/home/ubuntu/src/openpi-ebench-clean"))
|
| 20 |
+
_OPENPI_CLIENT = _OPENPI_REPO / "packages" / "openpi-client" / "src"
|
| 21 |
+
if str(_OPENPI_CLIENT) not in sys.path:
|
| 22 |
+
sys.path.insert(0, str(_OPENPI_CLIENT))
|
| 23 |
+
|
| 24 |
+
from openpi_client import websocket_client_policy # noqa: E402
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
class AlgSolution:
|
| 28 |
+
"""Competition-style solution wrapper backed by a pi0.5 action chunk server."""
|
| 29 |
+
|
| 30 |
+
_QPOS_SLICE = slice(0, 8)
|
| 31 |
+
_DEFAULT_PROMPT = "identify all objects, pick them up, and place them into the target basket"
|
| 32 |
+
|
| 33 |
+
def __init__(self):
|
| 34 |
+
self.device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 35 |
+
host = os.environ.get("ATEC_PI05_HOST", "127.0.0.1")
|
| 36 |
+
port = int(os.environ.get("ATEC_PI05_PORT", "8000"))
|
| 37 |
+
self.policy = websocket_client_policy.WebsocketClientPolicy(host=host, port=port)
|
| 38 |
+
self.prompt = os.environ.get("ATEC_PI05_PROMPT", self._DEFAULT_PROMPT)
|
| 39 |
+
|
| 40 |
+
self.default_joint_pos = torch.tensor(
|
| 41 |
+
[[0.0, 1.2, -1.5, 0.0, 1.2, 0.0, 0.035, -0.035]],
|
| 42 |
+
dtype=torch.float32,
|
| 43 |
+
device=self.device,
|
| 44 |
+
)
|
| 45 |
+
self.teleop_home_joint_pos = torch.tensor(
|
| 46 |
+
[[-0.000033, 0.924525, -1.514983, 0.000011, 1.219900, -0.000033, 0.035000, -0.035000]],
|
| 47 |
+
dtype=torch.float32,
|
| 48 |
+
device=self.device,
|
| 49 |
+
)
|
| 50 |
+
self._home_action = torch.clamp(
|
| 51 |
+
(self.teleop_home_joint_pos - self.default_joint_pos) / 0.5,
|
| 52 |
+
-1.0,
|
| 53 |
+
1.0,
|
| 54 |
+
)
|
| 55 |
+
self._startup_zero_steps = int(os.environ.get("ATEC_PI05_STARTUP_ZERO_STEPS", "25"))
|
| 56 |
+
self._home_qpos_tolerance = float(os.environ.get("ATEC_PI05_HOME_QPOS_TOLERANCE", "0.10"))
|
| 57 |
+
self._home_hold_steps = int(os.environ.get("ATEC_PI05_HOME_HOLD_STEPS", "5"))
|
| 58 |
+
self._action_repeat = max(1, int(os.environ.get("ATEC_PI05_ACTION_REPEAT", "5")))
|
| 59 |
+
self._resize_size = (224, 224)
|
| 60 |
+
self.reset_episode()
|
| 61 |
+
|
| 62 |
+
def reset_episode(self):
|
| 63 |
+
self._startup_step = 0
|
| 64 |
+
self._home_stable_steps = 0
|
| 65 |
+
self._home_done = False
|
| 66 |
+
self._action_queue: deque[np.ndarray] = deque()
|
| 67 |
+
self._held_action: np.ndarray | None = None
|
| 68 |
+
self._held_remaining = 0
|
| 69 |
+
|
| 70 |
+
def _compute_home_action(self, proprio: torch.Tensor) -> tuple[torch.Tensor, bool]:
|
| 71 |
+
joint_pos_rel = proprio[:, self._QPOS_SLICE]
|
| 72 |
+
qpos = joint_pos_rel + self.default_joint_pos
|
| 73 |
+
qerr = self.teleop_home_joint_pos - qpos
|
| 74 |
+
within_tolerance = torch.all(torch.abs(qerr) <= self._home_qpos_tolerance, dim=1)
|
| 75 |
+
self._home_stable_steps = self._home_stable_steps + 1 if bool(torch.all(within_tolerance)) else 0
|
| 76 |
+
home_reached = self._home_stable_steps >= self._home_hold_steps
|
| 77 |
+
return self._home_action.repeat(proprio.shape[0], 1), home_reached
|
| 78 |
+
|
| 79 |
+
def _rgb_from_obs(self, obs: dict) -> np.ndarray:
|
| 80 |
+
rgb = obs["image"]["video_rgb"]
|
| 81 |
+
if isinstance(rgb, torch.Tensor):
|
| 82 |
+
rgb = rgb[0].detach().cpu()
|
| 83 |
+
if rgb.ndim == 3 and rgb.shape[0] in (3, 4):
|
| 84 |
+
rgb = rgb[:3].permute(1, 2, 0)
|
| 85 |
+
if rgb.ndim == 3 and rgb.shape[-1] == 4:
|
| 86 |
+
rgb = rgb[..., :3]
|
| 87 |
+
if rgb.dtype != torch.uint8:
|
| 88 |
+
rgb = (rgb.float() * 255.0).clamp(0, 255).to(torch.uint8)
|
| 89 |
+
if tuple(rgb.shape[:2]) != self._resize_size:
|
| 90 |
+
rgb = TF.resize(
|
| 91 |
+
rgb.permute(2, 0, 1),
|
| 92 |
+
list(self._resize_size),
|
| 93 |
+
interpolation=TF.InterpolationMode.BILINEAR,
|
| 94 |
+
antialias=True,
|
| 95 |
+
).permute(1, 2, 0)
|
| 96 |
+
return rgb.numpy()
|
| 97 |
+
|
| 98 |
+
rgb = np.asarray(rgb[0])
|
| 99 |
+
if rgb.shape[-1] == 4:
|
| 100 |
+
rgb = rgb[..., :3]
|
| 101 |
+
if np.issubdtype(rgb.dtype, np.floating):
|
| 102 |
+
rgb = (rgb * 255.0).clip(0, 255).astype(np.uint8)
|
| 103 |
+
return rgb.astype(np.uint8, copy=False)
|
| 104 |
+
|
| 105 |
+
def _openpi_obs(self, obs: dict, proprio: torch.Tensor) -> dict:
|
| 106 |
+
qpos = (proprio[:, self._QPOS_SLICE] + self.default_joint_pos).detach().cpu().numpy()[0]
|
| 107 |
+
joints = np.zeros(12, dtype=np.float32)
|
| 108 |
+
gripper = np.zeros(4, dtype=np.float32)
|
| 109 |
+
joints[:6] = qpos[:6]
|
| 110 |
+
gripper[:2] = qpos[6:8]
|
| 111 |
+
rgb = self._rgb_from_obs(obs)
|
| 112 |
+
return {
|
| 113 |
+
"states/joint": joints,
|
| 114 |
+
"states/gripper": gripper,
|
| 115 |
+
"images/head": rgb,
|
| 116 |
+
"images/hand_left": rgb,
|
| 117 |
+
"images/hand_right": rgb,
|
| 118 |
+
"prompt": self.prompt,
|
| 119 |
+
}
|
| 120 |
+
|
| 121 |
+
@staticmethod
|
| 122 |
+
def _to_env_action(action16: np.ndarray) -> np.ndarray:
|
| 123 |
+
action16 = np.asarray(action16, dtype=np.float32)
|
| 124 |
+
env_action = np.zeros(8, dtype=np.float32)
|
| 125 |
+
env_action[:6] = action16[:6]
|
| 126 |
+
env_action[6:8] = action16[12:14]
|
| 127 |
+
return env_action
|
| 128 |
+
|
| 129 |
+
def _next_pi05_action(self, obs: dict, proprio: torch.Tensor) -> np.ndarray:
|
| 130 |
+
if self._held_action is not None and self._held_remaining > 0:
|
| 131 |
+
self._held_remaining -= 1
|
| 132 |
+
return self._held_action
|
| 133 |
+
|
| 134 |
+
if not self._action_queue:
|
| 135 |
+
response = self.policy.infer(self._openpi_obs(obs, proprio))
|
| 136 |
+
actions = np.asarray(response["actions"], dtype=np.float32)
|
| 137 |
+
if actions.ndim != 2 or actions.shape[-1] < 16:
|
| 138 |
+
raise ValueError(f"Expected OpenPI actions with shape (T, >=16), got {actions.shape}")
|
| 139 |
+
for action16 in actions:
|
| 140 |
+
self._action_queue.append(self._to_env_action(action16))
|
| 141 |
+
|
| 142 |
+
self._held_action = self._action_queue.popleft()
|
| 143 |
+
self._held_remaining = self._action_repeat - 1
|
| 144 |
+
return self._held_action
|
| 145 |
+
|
| 146 |
+
def predicts(self, obs, current_score):
|
| 147 |
+
if not isinstance(obs, dict) or "proprio" not in obs:
|
| 148 |
+
raise ValueError("Expected obs dict with 'proprio' key.")
|
| 149 |
+
|
| 150 |
+
proprio = obs["proprio"].to(self.device)
|
| 151 |
+
num_envs = proprio.shape[0]
|
| 152 |
+
if num_envs != 1:
|
| 153 |
+
raise ValueError("solution_pi05 currently supports num_envs=1 for websocket inference.")
|
| 154 |
+
|
| 155 |
+
if self._startup_step < self._startup_zero_steps:
|
| 156 |
+
self._startup_step += 1
|
| 157 |
+
return {"action": np.zeros((1, 8), dtype=np.float32).tolist(), "giveup": False}
|
| 158 |
+
|
| 159 |
+
if not self._home_done:
|
| 160 |
+
home_action, home_reached = self._compute_home_action(proprio)
|
| 161 |
+
if home_reached:
|
| 162 |
+
self._home_done = True
|
| 163 |
+
self._action_queue.clear()
|
| 164 |
+
self._held_action = None
|
| 165 |
+
self._held_remaining = 0
|
| 166 |
+
return {"action": home_action.detach().cpu().numpy().tolist(), "giveup": False}
|
| 167 |
+
|
| 168 |
+
action = self._next_pi05_action(obs, proprio)
|
| 169 |
+
return {"action": action.reshape(1, -1).tolist(), "giveup": False}
|
demo/solution_pi05_native8.py
ADDED
|
@@ -0,0 +1,181 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""ATEC Task E pi0.5 native-8D websocket policy bridge."""
|
| 2 |
+
|
| 3 |
+
from __future__ import annotations
|
| 4 |
+
|
| 5 |
+
from collections import deque
|
| 6 |
+
import os
|
| 7 |
+
import sys
|
| 8 |
+
from pathlib import Path
|
| 9 |
+
|
| 10 |
+
import numpy as np
|
| 11 |
+
import torch
|
| 12 |
+
import torchvision.transforms.functional as TF
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
_OPENPI_REPO = Path(os.environ.get("OPENPI_REPO", "/home/ubuntu/src/openpi-ebench-clean"))
|
| 16 |
+
_OPENPI_CLIENT = _OPENPI_REPO / "packages" / "openpi-client" / "src"
|
| 17 |
+
if str(_OPENPI_CLIENT) not in sys.path:
|
| 18 |
+
sys.path.insert(0, str(_OPENPI_CLIENT))
|
| 19 |
+
|
| 20 |
+
from openpi_client import websocket_client_policy # noqa: E402
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
class AlgSolution:
|
| 24 |
+
_QPOS_SLICE = slice(0, 8)
|
| 25 |
+
_DEFAULT_PROMPT = "identify all objects, pick them up, and place them into the target basket"
|
| 26 |
+
|
| 27 |
+
def __init__(self):
|
| 28 |
+
self.device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 29 |
+
host = os.environ.get("ATEC_PI05_HOST", "127.0.0.1")
|
| 30 |
+
port = int(os.environ.get("ATEC_PI05_PORT", "8000"))
|
| 31 |
+
self.policy = websocket_client_policy.WebsocketClientPolicy(host=host, port=port)
|
| 32 |
+
self.prompt = os.environ.get("ATEC_PI05_PROMPT", self._DEFAULT_PROMPT)
|
| 33 |
+
|
| 34 |
+
self.default_joint_pos = torch.tensor(
|
| 35 |
+
[[0.0, 1.2, -1.5, 0.0, 1.2, 0.0, 0.035, -0.035]],
|
| 36 |
+
dtype=torch.float32,
|
| 37 |
+
device=self.device,
|
| 38 |
+
)
|
| 39 |
+
self.teleop_home_joint_pos = torch.tensor(
|
| 40 |
+
[[-0.000033, 0.924525, -1.514983, 0.000011, 1.219900, -0.000033, 0.035000, -0.035000]],
|
| 41 |
+
dtype=torch.float32,
|
| 42 |
+
device=self.device,
|
| 43 |
+
)
|
| 44 |
+
self._home_action = torch.clamp(
|
| 45 |
+
(self.teleop_home_joint_pos - self.default_joint_pos) / 0.5,
|
| 46 |
+
-1.0,
|
| 47 |
+
1.0,
|
| 48 |
+
)
|
| 49 |
+
self._startup_zero_steps = int(os.environ.get("ATEC_PI05_STARTUP_ZERO_STEPS", "25"))
|
| 50 |
+
self._home_qpos_tolerance = float(os.environ.get("ATEC_PI05_HOME_QPOS_TOLERANCE", "0.10"))
|
| 51 |
+
self._home_hold_steps = int(os.environ.get("ATEC_PI05_HOME_HOLD_STEPS", "5"))
|
| 52 |
+
self._action_repeat = max(1, int(os.environ.get("ATEC_PI05_ACTION_REPEAT", "1")))
|
| 53 |
+
self._action_clip = float(os.environ.get("ATEC_PI05_ACTION_CLIP", "5.0"))
|
| 54 |
+
self._chunk_exec_steps = max(1, int(os.environ.get("ATEC_PI05_CHUNK_EXEC_STEPS", "10")))
|
| 55 |
+
self._zero_noise = os.environ.get("ATEC_PI05_ZERO_NOISE", "0").lower() in ("1", "true", "yes")
|
| 56 |
+
self._action_horizon = max(1, int(os.environ.get("ATEC_PI05_ACTION_HORIZON", "10")))
|
| 57 |
+
self._model_action_dim = max(8, int(os.environ.get("ATEC_PI05_MODEL_ACTION_DIM", "32")))
|
| 58 |
+
self._debug = os.environ.get("ATEC_PI05_DEBUG", "0").lower() in ("1", "true", "yes")
|
| 59 |
+
self._resize_size = (224, 224)
|
| 60 |
+
self.reset_episode()
|
| 61 |
+
|
| 62 |
+
def reset_episode(self):
|
| 63 |
+
self._startup_step = 0
|
| 64 |
+
self._home_stable_steps = 0
|
| 65 |
+
self._home_done = False
|
| 66 |
+
self._action_queue: deque[np.ndarray] = deque()
|
| 67 |
+
self._held_action: np.ndarray | None = None
|
| 68 |
+
self._held_remaining = 0
|
| 69 |
+
self._debug_step = 0
|
| 70 |
+
self._policy_calls = 0
|
| 71 |
+
|
| 72 |
+
def _compute_home_action(self, proprio: torch.Tensor) -> tuple[torch.Tensor, bool]:
|
| 73 |
+
qpos = proprio[:, self._QPOS_SLICE] + self.default_joint_pos
|
| 74 |
+
qerr = self.teleop_home_joint_pos - qpos
|
| 75 |
+
within_tolerance = torch.all(torch.abs(qerr) <= self._home_qpos_tolerance, dim=1)
|
| 76 |
+
self._home_stable_steps = self._home_stable_steps + 1 if bool(torch.all(within_tolerance)) else 0
|
| 77 |
+
home_reached = self._home_stable_steps >= self._home_hold_steps
|
| 78 |
+
if self._debug and self._debug_step % 50 == 0:
|
| 79 |
+
print(
|
| 80 |
+
"[PI05_DEBUG] "
|
| 81 |
+
f"home step={self._debug_step} max_abs_qerr={torch.max(torch.abs(qerr)).item():.4f} "
|
| 82 |
+
f"stable={self._home_stable_steps}/{self._home_hold_steps} "
|
| 83 |
+
f"qpos={qpos[0].detach().cpu().numpy()[:8]}",
|
| 84 |
+
flush=True,
|
| 85 |
+
)
|
| 86 |
+
return self._home_action.repeat(proprio.shape[0], 1), home_reached
|
| 87 |
+
|
| 88 |
+
def _rgb_from_obs(self, obs: dict) -> np.ndarray:
|
| 89 |
+
rgb = obs["image"]["video_rgb"]
|
| 90 |
+
if isinstance(rgb, torch.Tensor):
|
| 91 |
+
rgb = rgb[0].detach().cpu()
|
| 92 |
+
if rgb.ndim == 3 and rgb.shape[0] in (3, 4):
|
| 93 |
+
rgb = rgb[:3].permute(1, 2, 0)
|
| 94 |
+
if rgb.ndim == 3 and rgb.shape[-1] == 4:
|
| 95 |
+
rgb = rgb[..., :3]
|
| 96 |
+
if rgb.dtype != torch.uint8:
|
| 97 |
+
rgb = (rgb.float() * 255.0).clamp(0, 255).to(torch.uint8)
|
| 98 |
+
if tuple(rgb.shape[:2]) != self._resize_size:
|
| 99 |
+
rgb = TF.resize(
|
| 100 |
+
rgb.permute(2, 0, 1),
|
| 101 |
+
list(self._resize_size),
|
| 102 |
+
interpolation=TF.InterpolationMode.BILINEAR,
|
| 103 |
+
antialias=True,
|
| 104 |
+
).permute(1, 2, 0)
|
| 105 |
+
return rgb.numpy()
|
| 106 |
+
|
| 107 |
+
rgb = np.asarray(rgb[0])
|
| 108 |
+
if rgb.shape[-1] == 4:
|
| 109 |
+
rgb = rgb[..., :3]
|
| 110 |
+
if np.issubdtype(rgb.dtype, np.floating):
|
| 111 |
+
rgb = (rgb * 255.0).clip(0, 255).astype(np.uint8)
|
| 112 |
+
return rgb.astype(np.uint8, copy=False)
|
| 113 |
+
|
| 114 |
+
def _openpi_obs(self, obs: dict, proprio: torch.Tensor) -> dict:
|
| 115 |
+
qpos = (proprio[:, self._QPOS_SLICE] + self.default_joint_pos).detach().cpu().numpy()[0]
|
| 116 |
+
openpi_obs = {
|
| 117 |
+
"state": qpos.astype(np.float32, copy=False),
|
| 118 |
+
"image": self._rgb_from_obs(obs),
|
| 119 |
+
"prompt": self.prompt,
|
| 120 |
+
}
|
| 121 |
+
if self._zero_noise:
|
| 122 |
+
openpi_obs["noise"] = np.zeros((self._action_horizon, self._model_action_dim), dtype=np.float32)
|
| 123 |
+
return openpi_obs
|
| 124 |
+
|
| 125 |
+
def _next_pi05_action(self, obs: dict, proprio: torch.Tensor) -> np.ndarray:
|
| 126 |
+
if self._held_action is not None and self._held_remaining > 0:
|
| 127 |
+
self._held_remaining -= 1
|
| 128 |
+
return self._held_action
|
| 129 |
+
|
| 130 |
+
if not self._action_queue:
|
| 131 |
+
response = self.policy.infer(self._openpi_obs(obs, proprio))
|
| 132 |
+
actions = np.asarray(response["actions"], dtype=np.float32)
|
| 133 |
+
if actions.ndim != 2 or actions.shape[-1] < 8:
|
| 134 |
+
raise ValueError(f"Expected OpenPI native8 actions with shape (T, >=8), got {actions.shape}")
|
| 135 |
+
self._policy_calls += 1
|
| 136 |
+
if self._debug:
|
| 137 |
+
print(
|
| 138 |
+
"[PI05_DEBUG] "
|
| 139 |
+
f"policy_call={self._policy_calls} actions_shape={actions.shape} "
|
| 140 |
+
f"first_action={actions[0, :8]}",
|
| 141 |
+
flush=True,
|
| 142 |
+
)
|
| 143 |
+
for action8 in actions[: self._chunk_exec_steps]:
|
| 144 |
+
self._action_queue.append(np.clip(action8[:8], -self._action_clip, self._action_clip))
|
| 145 |
+
|
| 146 |
+
self._held_action = self._action_queue.popleft()
|
| 147 |
+
self._held_remaining = self._action_repeat - 1
|
| 148 |
+
return self._held_action
|
| 149 |
+
|
| 150 |
+
def predicts(self, obs, current_score):
|
| 151 |
+
if not isinstance(obs, dict) or "proprio" not in obs:
|
| 152 |
+
raise ValueError("Expected obs dict with 'proprio' key.")
|
| 153 |
+
|
| 154 |
+
proprio = obs["proprio"].to(self.device)
|
| 155 |
+
if proprio.shape[0] != 1:
|
| 156 |
+
raise ValueError("solution_pi05_native8 supports num_envs=1.")
|
| 157 |
+
|
| 158 |
+
if self._startup_step < self._startup_zero_steps:
|
| 159 |
+
self._startup_step += 1
|
| 160 |
+
self._debug_step += 1
|
| 161 |
+
if self._debug and self._startup_step in (1, self._startup_zero_steps):
|
| 162 |
+
print(f"[PI05_DEBUG] startup step={self._startup_step}/{self._startup_zero_steps}", flush=True)
|
| 163 |
+
return {"action": np.zeros((1, 8), dtype=np.float32).tolist(), "giveup": False}
|
| 164 |
+
|
| 165 |
+
if not self._home_done:
|
| 166 |
+
home_action, home_reached = self._compute_home_action(proprio)
|
| 167 |
+
if home_reached:
|
| 168 |
+
self._home_done = True
|
| 169 |
+
self._action_queue.clear()
|
| 170 |
+
self._held_action = None
|
| 171 |
+
self._held_remaining = 0
|
| 172 |
+
if self._debug:
|
| 173 |
+
print(f"[PI05_DEBUG] home_done at step={self._debug_step}", flush=True)
|
| 174 |
+
self._debug_step += 1
|
| 175 |
+
return {"action": home_action.detach().cpu().numpy().tolist(), "giveup": False}
|
| 176 |
+
|
| 177 |
+
action = self._next_pi05_action(obs, proprio)
|
| 178 |
+
if self._debug and self._debug_step % 50 == 0:
|
| 179 |
+
print(f"[PI05_DEBUG] execute step={self._debug_step} action={action[:8]}", flush=True)
|
| 180 |
+
self._debug_step += 1
|
| 181 |
+
return {"action": action.reshape(1, -1).tolist(), "giveup": False}
|
demo/solution_rl.py
ADDED
|
@@ -0,0 +1,210 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import torch
|
| 3 |
+
|
| 4 |
+
class AlgSolution:
|
| 5 |
+
|
| 6 |
+
ACTION_SCALE = 0.5
|
| 7 |
+
EE_BODY_NAME_CANDIDATES = ("gripper_base", "piper_gripper_base")
|
| 8 |
+
ARM_JOINT_NAME_CANDIDATES = (
|
| 9 |
+
["joint1", "joint2", "joint3", "joint4", "joint5", "joint6"],
|
| 10 |
+
["arm_joint1", "arm_joint2", "arm_joint3", "arm_joint4", "arm_joint5", "arm_joint6"],
|
| 11 |
+
)
|
| 12 |
+
|
| 13 |
+
def __init__(self):
|
| 14 |
+
policy_path = os.path.dirname(os.path.abspath(__file__)) + '/policy.pt'
|
| 15 |
+
self.device = 'cuda'
|
| 16 |
+
|
| 17 |
+
self.policy = torch.jit.load(policy_path, map_location=self.device)
|
| 18 |
+
self.policy.eval()
|
| 19 |
+
|
| 20 |
+
self.leg_action_dim = 12
|
| 21 |
+
self.arm_action_dim = 8
|
| 22 |
+
|
| 23 |
+
self.leg_joint_indices = list(range(12))
|
| 24 |
+
self.arm_joint_indices = list(range(12, 20))
|
| 25 |
+
|
| 26 |
+
self.train_to_env_action_scale = torch.tensor(
|
| 27 |
+
[
|
| 28 |
+
0.25, 0.5, 0.5,
|
| 29 |
+
0.25, 0.5, 0.5,
|
| 30 |
+
0.25, 0.5, 0.5,
|
| 31 |
+
0.25, 0.5, 0.5,
|
| 32 |
+
],
|
| 33 |
+
device=self.device,
|
| 34 |
+
dtype=torch.float32,
|
| 35 |
+
).view(1, -1)
|
| 36 |
+
|
| 37 |
+
self.env_to_train_action_scale = torch.tensor(
|
| 38 |
+
[
|
| 39 |
+
4.0, 2.0, 2.0,
|
| 40 |
+
4.0, 2.0, 2.0,
|
| 41 |
+
4.0, 2.0, 2.0,
|
| 42 |
+
4.0, 2.0, 2.0,
|
| 43 |
+
],
|
| 44 |
+
device=self.device,
|
| 45 |
+
dtype=torch.float32,
|
| 46 |
+
).view(1, -1)
|
| 47 |
+
|
| 48 |
+
# Fixed zero base velocity command for policy input.
|
| 49 |
+
self.fixed_velocity_commands = torch.tensor(
|
| 50 |
+
[0.5, 0.0, 0.0],
|
| 51 |
+
device=self.device,
|
| 52 |
+
dtype=torch.float32,
|
| 53 |
+
).view(1, 3)
|
| 54 |
+
|
| 55 |
+
self.arm_default_action = torch.zeros(
|
| 56 |
+
(1, self.arm_action_dim),
|
| 57 |
+
device=self.device,
|
| 58 |
+
dtype=torch.float32,
|
| 59 |
+
)
|
| 60 |
+
|
| 61 |
+
|
| 62 |
+
def _resolve_joint_ids(self, candidates: tuple[list[str], ...]) -> list[int]:
|
| 63 |
+
last_error = None
|
| 64 |
+
for names in candidates:
|
| 65 |
+
try:
|
| 66 |
+
ids, found_names = self.robot.find_joints(names)
|
| 67 |
+
except ValueError as err:
|
| 68 |
+
last_error = err
|
| 69 |
+
continue
|
| 70 |
+
if len(ids) == len(names):
|
| 71 |
+
if candidates is self.ARM_JOINT_NAME_CANDIDATES:
|
| 72 |
+
self.arm_joint_names = list(found_names)
|
| 73 |
+
return list(ids)
|
| 74 |
+
raise ValueError(
|
| 75 |
+
f"Cannot resolve required joints from candidates: {candidates}. Last error: {last_error}"
|
| 76 |
+
)
|
| 77 |
+
|
| 78 |
+
def _resolve_ee_body_name(self) -> str:
|
| 79 |
+
last_error = None
|
| 80 |
+
for name in self.EE_BODY_NAME_CANDIDATES:
|
| 81 |
+
try:
|
| 82 |
+
body_ids, _ = self.robot.find_bodies(name)
|
| 83 |
+
except ValueError as err:
|
| 84 |
+
last_error = err
|
| 85 |
+
continue
|
| 86 |
+
if len(body_ids) == 1:
|
| 87 |
+
return name
|
| 88 |
+
raise ValueError(
|
| 89 |
+
f"Cannot resolve EE body from candidates: {self.EE_BODY_NAME_CANDIDATES}. Last error: {last_error}"
|
| 90 |
+
)
|
| 91 |
+
|
| 92 |
+
def _ensure_cartesian_targets(self):
|
| 93 |
+
self.cartesian_ctrl.reset()
|
| 94 |
+
|
| 95 |
+
def _compute_arm_overlay_action(self) -> torch.Tensor:
|
| 96 |
+
self._ensure_cartesian_targets()
|
| 97 |
+
|
| 98 |
+
arm_jpos_des = self.cartesian_ctrl.compute_base(
|
| 99 |
+
self.ee_pos_target_b,
|
| 100 |
+
self.ee_quat_target_b,
|
| 101 |
+
)
|
| 102 |
+
|
| 103 |
+
full_target = self.robot.data.joint_pos.clone()
|
| 104 |
+
full_target[:, self.arm_ids] = arm_jpos_des
|
| 105 |
+
full_target[:, self.gripper_ids] = self.gripper_open_pos.repeat(full_target.shape[0], 1)
|
| 106 |
+
|
| 107 |
+
return (full_target - self.default_joint_pos) / self.ACTION_SCALE
|
| 108 |
+
|
| 109 |
+
def _get_velocity_commands(self, proprio: torch.Tensor) -> torch.Tensor:
|
| 110 |
+
"""Return fixed velocity commands for policy input."""
|
| 111 |
+
num_envs = proprio.shape[0]
|
| 112 |
+
|
| 113 |
+
cmd = self.fixed_velocity_commands.to(dtype=proprio.dtype, device=self.device)
|
| 114 |
+
if num_envs > 1:
|
| 115 |
+
cmd = cmd.repeat(num_envs, 1)
|
| 116 |
+
return cmd
|
| 117 |
+
|
| 118 |
+
def _extract_policy_obs(self, obs, action_dim) -> torch.Tensor:
|
| 119 |
+
proprio = obs["proprio"].to(self.device)
|
| 120 |
+
|
| 121 |
+
expected_dim = 3 + 3 + 3 + 3 + action_dim + action_dim + action_dim
|
| 122 |
+
|
| 123 |
+
idx = 0
|
| 124 |
+
_base_lin_vel = proprio[:, idx:idx + 3]
|
| 125 |
+
idx += 3
|
| 126 |
+
|
| 127 |
+
base_ang_vel = proprio[:, idx:idx + 3]
|
| 128 |
+
idx += 3
|
| 129 |
+
|
| 130 |
+
_velocity_commands_env = proprio[:, idx:idx + 3]
|
| 131 |
+
idx += 3
|
| 132 |
+
|
| 133 |
+
projected_gravity = proprio[:, idx:idx + 3]
|
| 134 |
+
idx += 3
|
| 135 |
+
|
| 136 |
+
joint_pos_all = proprio[:, idx:idx + action_dim]
|
| 137 |
+
idx += action_dim
|
| 138 |
+
|
| 139 |
+
joint_vel_all = proprio[:, idx:idx + action_dim]
|
| 140 |
+
idx += action_dim
|
| 141 |
+
|
| 142 |
+
actions_all = proprio[:, idx:idx + action_dim]
|
| 143 |
+
|
| 144 |
+
joint_pos_leg = joint_pos_all[:, self.leg_joint_indices]
|
| 145 |
+
joint_vel_leg = joint_vel_all[:, self.leg_joint_indices]
|
| 146 |
+
actions_env_leg = actions_all[:, self.leg_joint_indices]
|
| 147 |
+
|
| 148 |
+
actions_train_leg = actions_env_leg * self.env_to_train_action_scale.to(dtype=proprio.dtype)
|
| 149 |
+
velocity_commands = self._get_velocity_commands(proprio)
|
| 150 |
+
|
| 151 |
+
policy_obs = torch.cat(
|
| 152 |
+
[
|
| 153 |
+
base_ang_vel * 0.25,
|
| 154 |
+
projected_gravity,
|
| 155 |
+
velocity_commands,
|
| 156 |
+
joint_pos_leg,
|
| 157 |
+
joint_vel_leg * 0.05,
|
| 158 |
+
actions_train_leg,
|
| 159 |
+
],
|
| 160 |
+
dim=-1,
|
| 161 |
+
)
|
| 162 |
+
|
| 163 |
+
return policy_obs
|
| 164 |
+
|
| 165 |
+
def _map_policy_action_to_env_action(self, action_train: torch.Tensor, action_dim: int) -> torch.Tensor:
|
| 166 |
+
"""Map training-time 12D leg action to current env 20D full-body action."""
|
| 167 |
+
if action_train.shape[-1] != self.leg_action_dim:
|
| 168 |
+
raise ValueError(
|
| 169 |
+
f"Policy output dim mismatch: got {action_train.shape[-1]}, expected {self.leg_action_dim}"
|
| 170 |
+
)
|
| 171 |
+
|
| 172 |
+
num_envs = action_train.shape[0]
|
| 173 |
+
leg_action_env = action_train * self.train_to_env_action_scale
|
| 174 |
+
|
| 175 |
+
action_env = torch.zeros(
|
| 176 |
+
(num_envs, action_dim),
|
| 177 |
+
device=self.device,
|
| 178 |
+
dtype=torch.float32,
|
| 179 |
+
)
|
| 180 |
+
|
| 181 |
+
action_env[:, self.leg_joint_indices] = leg_action_env
|
| 182 |
+
action_env[:, self.arm_joint_indices] = self.arm_default_action.repeat(num_envs, 1)
|
| 183 |
+
|
| 184 |
+
return action_env
|
| 185 |
+
|
| 186 |
+
def predicts(self, obs, current_score):
|
| 187 |
+
"""Run policy inference and return current-env full-body action."""
|
| 188 |
+
if current_score > 1:
|
| 189 |
+
return {'action': [], 'giveup': True}
|
| 190 |
+
proprio = obs["proprio"].to(self.device)
|
| 191 |
+
action_dim = (int(proprio.shape[-1]) - 12) // 3
|
| 192 |
+
policy_obs = self._extract_policy_obs(obs, action_dim)
|
| 193 |
+
|
| 194 |
+
with torch.inference_mode():
|
| 195 |
+
action_train = self.policy(policy_obs)
|
| 196 |
+
|
| 197 |
+
if not isinstance(action_train, torch.Tensor):
|
| 198 |
+
action_train = torch.as_tensor(
|
| 199 |
+
action_train, device=self.device, dtype=torch.float32
|
| 200 |
+
)
|
| 201 |
+
|
| 202 |
+
action_train = action_train.to(device=self.device, dtype=torch.float32)
|
| 203 |
+
|
| 204 |
+
if action_train.ndim == 1:
|
| 205 |
+
action_train = action_train.unsqueeze(0)
|
| 206 |
+
|
| 207 |
+
action_env = self._map_policy_action_to_env_action(action_train, action_dim)
|
| 208 |
+
action_env = action_env.cpu().numpy().tolist()
|
| 209 |
+
return {'action': action_env, 'giveup': False}
|
| 210 |
+
|
demo/solution_zero.py
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch
|
| 2 |
+
|
| 3 |
+
class AlgSolution:
|
| 4 |
+
|
| 5 |
+
def __init__(self):
|
| 6 |
+
pass
|
| 7 |
+
|
| 8 |
+
def predicts(self, obs, current_score):
|
| 9 |
+
proprio = obs['proprio']
|
| 10 |
+
action_dim = (int(proprio.shape[-1]) - 12) // 3
|
| 11 |
+
action = [0 for _ in range(action_dim)]
|
| 12 |
+
return {'action': action, 'giveup': False}
|
docs/ATEC2026_TaskE_规则物理配置与提交说明_20260604.md
ADDED
|
@@ -0,0 +1,273 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# ATEC2026 L0 Task E:规则、物理配置与当前抓取问题说明
|
| 2 |
+
|
| 3 |
+
更新时间:2026-06-04
|
| 4 |
+
工作目录:`/home/ubuntu/Documents/01Proj/13atec/ATEC2026_Simulation_Challenge`
|
| 5 |
+
|
| 6 |
+
## 1. 结论先行
|
| 7 |
+
|
| 8 |
+
1. 当前我们调试的确实是 ATEC2026 官方仿真包里的 `ATEC-TaskE-Piper` 桌面抓取任务,不是 L1 足式/轮腿任务,也不是自定义机械臂任务。
|
| 9 |
+
2. 本地物理配置基本来自官方仓库:Isaac Lab v2.3.2、AgileX Piper、三种 YCB 风格物体、桌面、篮筐、固定 RGB-D 观测与 end-effector RGB-D 观测。Piper/物体/地面摩擦和 solver 参数在源码中可查。
|
| 10 |
+
3. “夹住后滑落”不是一个可以简单甩给 Isaac Sim 的单点 bug。更准确地说:官方物理配置对二指夹爪的摩擦夹持比较敏感,而我们当前 GraspGen-style/PCA submit-side primitive 对香蕉这类非凸弯曲物体仍在依赖摩擦保持;一旦 finger-center、闭合高度、夹爪开度、运输高度或速度有偏差,就会出现短暂抬起后滑落。
|
| 11 |
+
4. 不能通过修改比赛评测环境物理参数来提交。提高 solver iteration、摩擦、接触参数可以作为本地诊断,但最终提交必须在官方 judge 环境下靠 `demo/solution.py` 的观测与动作输出成功。
|
| 12 |
+
5. 当前最强可部署基线仍是 `demo/solution.py` 中的 ACT/XSA 方案;`demo/solution_pca.py` 是实验分支,不应覆盖部署,除非三物体多 seed 连续评估明显超过 ACT/XSA。
|
| 13 |
+
|
| 14 |
+
## 2. 已下载/整理的官方资料
|
| 15 |
+
|
| 16 |
+
本次已下载官方 GitHub README 快照:
|
| 17 |
+
|
| 18 |
+
- 本地快照:`docs/sources/ATEC2026_Simulation_Challenge_official_readme_20260604.md`
|
| 19 |
+
- 官方源链接:<https://github.com/atecup/ATEC2026_Simulation_Challenge>
|
| 20 |
+
- 官方 raw README:<https://raw.githubusercontent.com/atecup/ATEC2026_Simulation_Challenge/main/readme.md>
|
| 21 |
+
|
| 22 |
+
2026-06-04 进一步做了官方 fresh clone 对照,临时目录:
|
| 23 |
+
|
| 24 |
+
- `/tmp/ATEC2026_Simulation_Challenge_official_check`
|
| 25 |
+
- 官方 HEAD:`dbe7c251f680b02f357a6db67430b18d3ba45ea1`
|
| 26 |
+
- 最新提交:`dbe7c25 2026-06-04 10:10:16 +0800 Merge pull request #8 from atecup/fix/tron2a_joint_configuration`
|
| 27 |
+
|
| 28 |
+
对照结论:
|
| 29 |
+
|
| 30 |
+
- 与 Task E 抓取物理强相关的文件,本地与官方最新版 SHA 完全一致:
|
| 31 |
+
- `source/atec_rl_lab/atec_rl_lab/assets/robots/piper.py`
|
| 32 |
+
- `source/atec_rl_lab/atec_rl_lab/assets/objects/task_b/object.py`
|
| 33 |
+
- `source/atec_rl_lab/atec_rl_lab/tasks/task_e/terrain.py`
|
| 34 |
+
- `source/atec_rl_lab/atec_rl_lab/tasks/task_e/mdp/rewards.py`
|
| 35 |
+
- `source/atec_rl_lab/atec_rl_lab/tasks/task_e/mdp/terminations.py`
|
| 36 |
+
- `source/atec_rl_lab/atec_rl_lab/tasks/task_e/env_cfg.py` 只有 action group 字段名差异:官方最新版使用 `joint_leg` / `joint_wheel` / `joint_arm`,本地使用 `joint_pos_leg` / `joint_vel_wheel` / `joint_pos_arm`;Task E 物体、篮筐、相机、随机 Y-band、reward/termination 和 physics material 逻辑一致。
|
| 37 |
+
- `source/atec_rl_lab/atec_rl_lab/tasks/task_base/envs_base_cfg.py` 有两类差异:action group 字段名差异,以及 base reset joint randomization 从官方 `(1.0, 1.0)` 到本地 `(0.5, 1.5)`;Task E Piper 在 `TaskEEnvPiperCfg` 中关闭了相关 reset events,因此这不是香蕉滑落的原因。
|
| 38 |
+
- `demo/server.py` 官方最新版新增 `/get_action_spec` 接口;本地 server 还没有这个接口。这个只影响选手是否能在提交服务里自定义 action mode/scale/clip,不改变官方仿真物理。
|
| 39 |
+
- `demo/Dockerfile` 本地改成 ACT/XSA 提交模板,官方默认仍是 `solution_zero.py` 示例。这是我们自己的提交镜像选择,不是物理环境差异。
|
| 40 |
+
|
| 41 |
+
同日再次核对官方更新与 issue/PR:
|
| 42 |
+
|
| 43 |
+
- `git fetch origin` 后,`origin/main` 仍是 `dbe7c251f680b02f357a6db67430b18d3ba45ea1`,没有比 2026-06-04 10:10:16 更新的 commit。
|
| 44 |
+
- GitHub issues/PR 网页搜索未发现公开 issue 提到 Task E / Piper / grasp / physics / friction / banana 滑落问题。
|
| 45 |
+
- `Piper` 搜索命中的是 PR #2:eye-in-hand camera configuration for B2Piper/B2WPiper/G1,不是 Task E 固定 Piper,也不是夹爪滑落。
|
| 46 |
+
- PR #5 是 participant action spec;PR #8 是 Tron2A joint configuration reset bug,和 Task E 抓取物理无关。
|
| 47 |
+
- 已同步唯一低风险兼容修复:在本地 `demo/server.py` 加入官方 `/get_action_spec` endpoint。若 solution 不实现该方法,返回 `{}`,即沿用默认 action 配置。
|
| 48 |
+
|
| 49 |
+
本地 `readme.md` 与官方 raw README 有少量差异:官方新版 README 增加了 `AlgSolution.get_action_spec()` 可选接口说明;本地文件仍可用于当前代码运行,但提交前应留意官方是否启用了该新接口。
|
| 50 |
+
|
| 51 |
+
另外,用户此前提供的赛事说明包含:
|
| 52 |
+
|
| 53 |
+
- L0 Task E:桌面随机摆放三种不同类型物体,桌面级机械臂完成识别、抓取、放置到指定区域。
|
| 54 |
+
- 核心流程:识别、规划、抓取、放置。
|
| 55 |
+
- 代码审查:最高分镜像对应代码需要可复现、合规;技术报告需说明实现思路、代码组织结构、执行流程,使用开源模型需提供下���链接,额外训练模型需提供训练代码和数据来源。
|
| 56 |
+
- 预测阶段只能使用上传镜像中的代码和模型,禁止利用测试集挖掘或外部信息。
|
| 57 |
+
|
| 58 |
+
## 3. 官方仓库对 Task E 的关键要求
|
| 59 |
+
|
| 60 |
+
官方 README 明确该仓库提供仿真资产、任务定义和提交脚本,环境基于 Isaac Lab;Task E 在环境矩阵中对应 `ATEC-TaskE-Piper`。参考:
|
| 61 |
+
|
| 62 |
+
- `readme.md` / 官方 README:Task E 使用 `ATEC-TaskE-Piper`。
|
| 63 |
+
- `readme.md`:仓库开发/测试版本为 Isaac Lab v2.3.2。
|
| 64 |
+
- `readme.md`:参赛者必须实现 `demo/solution.py`,类名为 `AlgSolution`,核心函数为 `predicts(obs, current_score)`,返回 `{"action": action, "giveup": False}`。
|
| 65 |
+
|
| 66 |
+
本地 Dockerfile 当前提交布局:
|
| 67 |
+
|
| 68 |
+
- `demo/Dockerfile` 将 `solution_act.py` 复制为镜像内 `solution.py`,并带上 `policy_act.pt`。
|
| 69 |
+
- 这说明当前默认提交镜像仍是 ACT/XSA 路线,不是 PCA/AnyGrasp 路线。
|
| 70 |
+
- 若以后要切换到 GraspGen-style/PCA,必须先改 Dockerfile 复制目标,并完成多 seed 稳定评估。
|
| 71 |
+
|
| 72 |
+
## 4. Task E 本地评分逻辑
|
| 73 |
+
|
| 74 |
+
源码位置:`source/atec_rl_lab/atec_rl_lab/tasks/task_e/env_cfg.py` 与 `source/atec_rl_lab/atec_rl_lab/tasks/task_e/mdp/rewards.py`。
|
| 75 |
+
|
| 76 |
+
本地 Task E 有两类奖励:
|
| 77 |
+
|
| 78 |
+
1. `grasped_objects_once`:物体被末端执行器接近并抬高到桌面上方一定高度,单物体一次性奖励约 3 分。
|
| 79 |
+
2. `objects_in_basket`:物体进入篮筐成功区域,单物体一次性奖励约 3 分。
|
| 80 |
+
|
| 81 |
+
因此三物体理论满分通常对应:
|
| 82 |
+
|
| 83 |
+
- 3 个物体各自“被抓起/抬起”一次:约 9 分。
|
| 84 |
+
- 3 个物体最终入篮:约 9 分。
|
| 85 |
+
- 合计约 18 分。
|
| 86 |
+
|
| 87 |
+
篮筐成功区域在源码中定义为:
|
| 88 |
+
|
| 89 |
+
- 成功中心:`BASKET_SUCCESS_CENTER = (1.08, -0.30, TABLE_TOP_Z + 0.15)`
|
| 90 |
+
- XY 半宽:`half_x = 0.20`,`half_y = 0.11`
|
| 91 |
+
- Z 范围:`TABLE_TOP_Z <= object_z <= TABLE_TOP_Z + 0.15`
|
| 92 |
+
|
| 93 |
+
这解释了一个重要现象:视频里看起来“抓到过”只能拿到抓取/抬升分;真正冲榜需要三个物体都稳定落在篮筐成功区域内。
|
| 94 |
+
|
| 95 |
+
## 5. 官方/本地物理配置证据
|
| 96 |
+
|
| 97 |
+
### 5.1 Piper 机械臂配置
|
| 98 |
+
|
| 99 |
+
源码:`source/atec_rl_lab/atec_rl_lab/assets/robots/piper.py`
|
| 100 |
+
|
| 101 |
+
关键参数:
|
| 102 |
+
|
| 103 |
+
- 机器人资产:`robot/piper/piper.usd`
|
| 104 |
+
- 关节:`joint1` 到 `joint8`,其中 `joint7/joint8` 是两指夹爪。
|
| 105 |
+
- 接触传感器:`activate_contact_sensors=True`
|
| 106 |
+
- 关节隐式执行器:`effort_limit=100.0`、`velocity_limit=100.0`、`stiffness=800.0`、`damping=80.0`
|
| 107 |
+
- articulation solver:`solver_position_iteration_count=4`、`solver_velocity_iteration_count=0`
|
| 108 |
+
|
| 109 |
+
源码:`source/atec_rl_lab/atec_rl_lab/tasks/task_e/env_cfg.py`
|
| 110 |
+
|
| 111 |
+
Task E Piper 初始状态:
|
| 112 |
+
|
| 113 |
+
- 机械臂固定在桌子右侧:`pos=(TABLE_CENTER_X + TABLE_HALF_X, TABLE_CENTER_Y, TABLE_TOP_Z)`
|
| 114 |
+
- Task E 中 `piper_cfg.spawn.rigid_props.disable_gravity = True`
|
| 115 |
+
- 夹爪初始张开:`joint7=0.035`、`joint8=-0.035`
|
| 116 |
+
|
| 117 |
+
这里的 solver iteration 偏低,尤其 `velocity_iteration_count=0` 对接触稳定性不算友好。它不是我们抓取代码改出来的,而是仓库里的 Piper 默认配置。
|
| 118 |
+
|
| 119 |
+
### 5.2 三个物体配置
|
| 120 |
+
|
| 121 |
+
源码:`source/atec_rl_lab/atec_rl_lab/assets/objects/task_b/object.py`
|
| 122 |
+
|
| 123 |
+
三种物体:
|
| 124 |
+
|
| 125 |
+
- `object_1`:`004_sugar_box.usd`
|
| 126 |
+
- `object_2`:`006_mustard_bottle.usd`
|
| 127 |
+
- `object_3`:`011_banana.usd`
|
| 128 |
+
|
| 129 |
+
共同物理参数:
|
| 130 |
+
|
| 131 |
+
- `rigid_body_enabled=True`
|
| 132 |
+
- `kinematic_enabled=False`
|
| 133 |
+
- `linear_damping=2.0`
|
| 134 |
+
- `angular_damping=4.0`
|
| 135 |
+
- `max_depenetration_velocity=0.5`
|
| 136 |
+
- `mass=0.5`
|
| 137 |
+
- `contact_offset=0.01`
|
| 138 |
+
- `rest_offset=0.0`
|
| 139 |
+
|
| 140 |
+
质量统一 0.5kg 对小香蕉/小盒子来说偏重,会放大二指夹爪靠摩擦夹持时的难度。
|
| 141 |
+
|
| 142 |
+
### 5.3 地面/桌面物理材料
|
| 143 |
+
|
| 144 |
+
源码:`source/atec_rl_lab/atec_rl_lab/tasks/task_e/terrain.py`
|
| 145 |
+
|
| 146 |
+
Task E terrain 物理材料:
|
| 147 |
+
|
| 148 |
+
- `friction_combine_mode="multiply"`
|
| 149 |
+
- `restitution_combine_mode="multiply"`
|
| 150 |
+
- `static_friction=1.0`
|
| 151 |
+
- `dynamic_friction=1.0`
|
| 152 |
+
- `restitution=0.0`
|
| 153 |
+
|
| 154 |
+
源码:`source/atec_rl_lab/atec_rl_lab/tasks/task_e/env_cfg.py`
|
| 155 |
+
|
| 156 |
+
Task E 在 `__post_init__()` 中执行:
|
| 157 |
+
|
| 158 |
+
- `self.scene.terrain = TASK_E_TERRAIN_CFG`
|
| 159 |
+
- `self.sim.physics_material = self.scene.terrain.physics_material`
|
| 160 |
+
- `self.events.physics_material = None`
|
| 161 |
+
|
| 162 |
+
这说明 Task E 关闭了默认的 physics material 随机化,使用固定物理材料。对提交而言,这是好事:不是每次都随机摩擦;但对香蕉这种接触几何,固定摩擦也不保证稳抓。
|
| 163 |
+
|
| 164 |
+
### 5.4 物体随机摆放
|
| 165 |
+
|
| 166 |
+
源码:`source/atec_rl_lab/atec_rl_lab/tasks/task_e/env_cfg.py`
|
| 167 |
+
|
| 168 |
+
三个物体在桌面不同 Y-band 中随机:
|
| 169 |
+
|
| 170 |
+
- `object_1`:`Y in [0.25, 0.29]`
|
| 171 |
+
- `object_2`:`Y in [0.14, 0.20]`
|
| 172 |
+
- `object_3`:`Y in [0.03, 0.09]`
|
| 173 |
+
- `X in [0.90, 1.10]`
|
| 174 |
+
|
| 175 |
+
这与我们后续做 RGB-D band mask、按物体区域分割是一致的;但最终提交不能读 object root,只能从观测估计位置。
|
| 176 |
+
|
| 177 |
+
## 6. 为什么香蕉会“夹住又滑落”
|
| 178 |
+
|
| 179 |
+
当前最合理判断不是“完全没有抓取模型”,也不是“Isaac Sim 完全��了”,而是以下几个因素叠加:
|
| 180 |
+
|
| 181 |
+
1. 香蕉是弯曲、非凸、局部接触很窄的物体,Piper 二指夹爪如果只夹在局部曲面上,很容易形成滚动/滑动接触。
|
| 182 |
+
2. 当前物体质量统一 0.5kg,香蕉被设置得和盒子一样重,这对 friction-only pinch 很不友好。
|
| 183 |
+
3. Piper solver 参数 `position=4, velocity=0` 对稳定接触不是很强;NVIDIA/Isaac Sim 文档和论坛中也常见“二指夹爪夹物体滑落、需要调接触/solver/摩擦或控制方式”的讨论。
|
| 184 |
+
4. 我们 submit-style PCA 控制器只能用 RGB-D 和 proprio,不读真实 object root;从单视角点云估计出的 grasp center/yaw/闭合高度稍有偏差,就可能出现“看起来夹得很深,但实际 finger contact normal 不足”的情况。
|
| 185 |
+
5. 旧 runner/采集器有时成功,是因为它能更接近官方 scripted primitive:使用更准确的物体状态/动态 servo/真实 finger-center trace。这个能力迁移到 `demo/solution_pca.py` 的 observation-only 控制时会损失。
|
| 186 |
+
|
| 187 |
+
一句话:这不是“夹爪力不够”这么简单,而是接触几何、闭合高度、夹爪开度、运输阶段轨迹和官方 PhysX 接触参数共同作用。
|
| 188 |
+
|
| 189 |
+
## 7. 能不能改物理配置
|
| 190 |
+
|
| 191 |
+
### 可以做的
|
| 192 |
+
|
| 193 |
+
可以做本地诊断:
|
| 194 |
+
|
| 195 |
+
- 临时提高 Piper articulation solver iteration,例如 position 从 4 提到 16、velocity 从 0 提到 4。
|
| 196 |
+
- 临时提高物体/夹爪摩擦、检查 contact offset/rest offset。
|
| 197 |
+
- 用这些实验判断“滑落是否主要来自 PhysX 接触求解敏感性”。
|
| 198 |
+
|
| 199 |
+
### 不建议作为提交依赖
|
| 200 |
+
|
| 201 |
+
最终提交不应依赖修改官方评测物理:
|
| 202 |
+
|
| 203 |
+
- 代码审查要求最高分镜像在组委会给定环境上可复现。
|
| 204 |
+
- 如果我们靠本地改物理才能稳,线上 judge 不一定会加载这些修改。
|
| 205 |
+
- 合规路线应是:在官方物理配置下,通过更稳的运动 primitive、低位搬运、under-scoop、慢速稳定、篮筐中心上方再释放等方式完成任务。
|
| 206 |
+
|
| 207 |
+
## 8. 当前方案状态
|
| 208 |
+
|
| 209 |
+
### 8.1 ACT/XSA
|
| 210 |
+
|
| 211 |
+
当前默认可部署基线仍是 ACT/XSA:
|
| 212 |
+
|
| 213 |
+
- Dockerfile 当前复制 `solution_act.py` 为提交 `solution.py`。
|
| 214 |
+
- 历史评估中 XSA final 曾在 seeds 11/12/13 得到过高分,但也出现过非确定性波动。
|
| 215 |
+
- 这是当前最成熟的镜像路线,但还不能说稳定满分。
|
| 216 |
+
|
| 217 |
+
### 8.2 pi0.5
|
| 218 |
+
|
| 219 |
+
pi0.5 已试过 20-demo 和 100-demo 分支,当前效果差:
|
| 220 |
+
|
| 221 |
+
- 20-demo 快速分支 seeds 11/12/13 均为 0。
|
| 222 |
+
- 100-demo 分支 seeds 11/12/13 约为 `0/0/6`,均值约 2。
|
| 223 |
+
- 主要问题更像适配层/数据表示不对,而不是 pi0.5 模型本身弱。
|
| 224 |
+
|
| 225 |
+
### 8.3 AnyGrasp
|
| 226 |
+
|
| 227 |
+
AnyGrasp SDK 已接入并可推理,但有 license/不可分发限制:
|
| 228 |
+
|
| 229 |
+
- 作为本地 candidate generator 很有价值。
|
| 230 |
+
- 但如果最终提交镜像包含不可分发 SDK 或权重,代码审查风险很高。
|
| 231 |
+
- 可借鉴它的 grasp candidate 思路,但最终最好落成可复现、可分发的几何/PCA/GraspNet-style 方法,或在技术报告中完整说明合法来源和许可。
|
| 232 |
+
|
| 233 |
+
### 8.4 GraspGen-style PCA/AABB
|
| 234 |
+
|
| 235 |
+
这是用户要求重点冲刺的真正规划抓取路线:
|
| 236 |
+
|
| 237 |
+
- `object_1` 在 `demo/solution_pca.py` 中已有 seed11/12/13 单物体成功证据。
|
| 238 |
+
- `object_2` 在 runner 中有单物体成功证据,但 submit-style 还没有完成稳定迁移。
|
| 239 |
+
- `object_3` 当前已能在部分场景短暂强抬,但 mid/transport/release 阶段仍会滑落,尚未达到可提交稳定性。
|
| 240 |
+
|
| 241 |
+
不能宣称 PCA/AABB 已经满分。它是正确方向之一,但还需要把香蕉运输保持问题和 object_2 submit-side 对齐彻底解决。
|
| 242 |
+
|
| 243 |
+
## 9. 推荐的后续技术路线
|
| 244 |
+
|
| 245 |
+
1. 不要再回退到“只训练 ACT/pi0.5”等黑盒路线;继续保留 ACT/XSA 作为提交底线,同时推进 GraspGen-style/PCA 作为冲榜路线。
|
| 246 |
+
2. 对 object_3 做两个分支:
|
| 247 |
+
- 本地物理增强诊断:提高 solver iteration 看是否立刻不滑,以确认接触求解敏感性。
|
| 248 |
+
- 官方物理可提交修复:低位转移、under-scoop、缩短高空纯竖直 lift、抓住后沿篮筐方向慢速保持接触移动、篮筐中心高于边缘处稳定后再开爪。
|
| 249 |
+
3. 对 object_2 单独迁移 runner 成功参数,不要套 object_1/object_3 的补偿。
|
| 250 |
+
4. 所有成功证据必须按多 seed 记录:至少 seeds 11/12/13,最好再加 21/22/23。
|
| 251 |
+
5. 最终切换 Dockerfile 前,必须满足:
|
| 252 |
+
- 三物体同一 episode 得分稳定接近或等于 18。
|
| 253 |
+
- 有视频证据。
|
| 254 |
+
- 不读取 env root/object state。
|
| 255 |
+
- 不依赖 AnyGrasp SDK 不可分发权重,或已完成合规说明。
|
| 256 |
+
- 技术报告中能解释模型/算法/开源链接/训练或无训练流程。
|
| 257 |
+
|
| 258 |
+
## 10. 参考链接
|
| 259 |
+
|
| 260 |
+
- ATEC2026 Simulation Challenge 官方仓库:<https://github.com/atecup/ATEC2026_Simulation_Challenge>
|
| 261 |
+
- 官方 README raw 快照源:<https://raw.githubusercontent.com/atecup/ATEC2026_Simulation_Challenge/main/readme.md>
|
| 262 |
+
- Isaac Lab pip installation 文档:<https://isaac-sim.github.io/IsaacLab/main/source/setup/installation/pip_installation.html>
|
| 263 |
+
- Isaac Sim Physics Simulation Fundamentals:<https://docs.isaacsim.omniverse.nvidia.com/latest/physics/simulation_fundamentals.html>
|
| 264 |
+
- NVIDIA 论坛,Object Gripping and picking:<https://forums.developer.nvidia.com/t/object-gripping-and-picking/291963>
|
| 265 |
+
- NVIDIA 论坛,Stable grasping in Isaac Sim:<https://forums.developer.nvidia.com/t/stable-grasping-in-isaac-sim/354866>
|
| 266 |
+
|
| 267 |
+
## 11. 给团队的交接提醒
|
| 268 |
+
|
| 269 |
+
1. 不要把 `demo/solution_pca.py` 直接当最终提交;它是实验控制器。
|
| 270 |
+
2. 不要把 AnyGrasp SDK 直接塞进最终镜像,除非许可证/技术报告/复现检查全部确认无风险。
|
| 271 |
+
3. 不要修改官方物理参数后宣称线上可复现;改物理只能用于定位问题。
|
| 272 |
+
4. 真正要冲榜,必须把“观测估计中心 -> finger-center 控制 -> 闭合 -> 低位运输 -> 篮筐中心上方稳定释放”串成同一条稳定轨迹。
|
| 273 |
+
5. 当前最该解决的是 object_3 香蕉运输阶段滑落,而不是重新换大模型。
|
example.md
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
## 1. Example Code Guide
|
| 2 |
+
|
| 3 |
+
This document provides a minimal end-to-end example for training, evaluating, and submitting a policy.
|
| 4 |
+
|
| 5 |
+
## 2. RL for Locomotion
|
| 6 |
+
|
| 7 |
+
### 2.1 Train a PPO Policy (Example)
|
| 8 |
+
|
| 9 |
+
The baseline workflow references: https://github.com/fan-ziqi/robot_lab
|
| 10 |
+
|
| 11 |
+
Run the following command from the repository root:
|
| 12 |
+
|
| 13 |
+
```bash
|
| 14 |
+
python scripts/rsl_rl/train.py --task ATEC-Isaac-Velocity-Flat-Unitree-B2-v0 --headless --video
|
| 15 |
+
```
|
| 16 |
+
|
| 17 |
+
On an **NVIDIA RTX 5090**, this example typically takes around **90 minutes**.
|
| 18 |
+
|
| 19 |
+
Actual training time depends on driver/runtime version, CPU performance, and current GPU load.
|
| 20 |
+
|
| 21 |
+
### 2.2 Evaluate the Trained Policy
|
| 22 |
+
|
| 23 |
+
After training, evaluate with:
|
| 24 |
+
|
| 25 |
+
```bash
|
| 26 |
+
python scripts/rsl_rl/play.py --task ATEC-Isaac-Velocity-Flat-Unitree-B2-v0
|
| 27 |
+
```
|
| 28 |
+
|
| 29 |
+
This loads the trained checkpoint and runs rollout in the same task setting.
|
| 30 |
+
|
| 31 |
+
### 2.3 Test Locally
|
| 32 |
+
|
| 33 |
+
The file `demo/solution.py` is the only entrance for locally testing and online submission.
|
| 34 |
+
Use the test command:
|
| 35 |
+
|
| 36 |
+
```bash
|
| 37 |
+
cd ATEC2026_Simulation_Challenge
|
| 38 |
+
python scripts/play_atec_task.py --task ATEC-TaskA-B2Piper --enable_cameras
|
| 39 |
+
```
|
| 40 |
+
|
| 41 |
+
Notes:
|
| 42 |
+
|
| 43 |
+
- `--task` selects the arena and robot. See the Environment Matrix in `readme.md`.
|
| 44 |
+
- Use `--debug` to print runtime status and score.
|
| 45 |
+
|
| 46 |
+
Pretrained baseline checkpoint:
|
| 47 |
+
|
| 48 |
+
- `./atec_robot_model/baseline/unitree_b2_flat/policy.pt`
|
| 49 |
+
This checkpoint path can be modified in `demo/solution.py`.
|
| 50 |
+
|
| 51 |
+

|
| 52 |
+
|
| 53 |
+
## 3. IL for Manipoulation
|
| 54 |
+
|
| 55 |
+
This section follows the core idea of ACT (Action Chunking with Transformers).
|
| 56 |
+
|
| 57 |
+
Reference implementation: https://github.com/tonyzhaozh/act
|
| 58 |
+
|
| 59 |
+
### 3.1 Collect Demonstrations
|
| 60 |
+
|
| 61 |
+
Collect expert trajectories for Task E:
|
| 62 |
+
|
| 63 |
+
```bash
|
| 64 |
+
python scripts/act/collect_demos_task_e.py --pick_objects 3 --num_demos 100 --headless --enable_cameras --save_images
|
| 65 |
+
```
|
| 66 |
+
|
| 67 |
+
Filter out near-zero actions from the collected dataset:
|
| 68 |
+
|
| 69 |
+
```bash
|
| 70 |
+
python scripts/act/filter_demos.py \
|
| 71 |
+
--input datasets/atec_task_e/trajectory.hdf5 \
|
| 72 |
+
--output datasets/atec_task_e/trajectory_filtered.hdf5 \
|
| 73 |
+
--threshold 0.001
|
| 74 |
+
```
|
| 75 |
+
|
| 76 |
+
### 3.2 Train ACT Policy
|
| 77 |
+
|
| 78 |
+
Run ACT baseline training from the `scripts/act` directory:
|
| 79 |
+
|
| 80 |
+
```bash
|
| 81 |
+
cd scripts/act
|
| 82 |
+
bash baseline.sh
|
| 83 |
+
```
|
| 84 |
+
|
| 85 |
+
### 3.3 Run the Trained Policy
|
| 86 |
+
|
| 87 |
+
Use the test command:
|
| 88 |
+
|
| 89 |
+
```bash
|
| 90 |
+
python scripts/play_atec_task.py --task ATEC-TaskE-Piper --enable_cameras
|
| 91 |
+
```
|
| 92 |
+
|
| 93 |
+
Note: `./atec_robot_model/baseline/act/policy.pt` is the provided baseline checkpoint. You can replace it with your own trained policy path in `demo/solution`.
|
| 94 |
+
|
| 95 |
+

|
readme.md
ADDED
|
@@ -0,0 +1,238 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
## 1. Introduction
|
| 2 |
+
|
| 3 |
+
The ATEC 2026 Simulation Challenge provides a standardized suite of robot simulation environments built on IsaacLab, designed to evaluate both locomotion and loco-manipulation capabilities. Participants may select one or multiple legged robot platforms to complete a set of representative tasks, including *Off-road Navigation*, *Tabletop Manipulation*, *Garbage Collection*, and *Obstacle Traversal*.
|
| 4 |
+
|
| 5 |
+
This repository includes simulation assets, task definitions, and reference scripts to support development, evaluation, and submission.
|
| 6 |
+
|
| 7 |
+
---
|
| 8 |
+
|
| 9 |
+
### 1.2 Robots and Sensors
|
| 10 |
+
|
| 11 |
+
- **Robot platforms**
|
| 12 |
+
- Humanoid: Unitree G1 (with two-finger gripper)
|
| 13 |
+
- Dual-wheel legged + manipulator: Tron1 + AgileX Piper
|
| 14 |
+
- Tron2A legged / wheel + manipulator
|
| 15 |
+
- Quadruped + manipulator: Unitree B2 + AgileX Piper
|
| 16 |
+
- Wheel-legged quadruped + manipulator: Unitree B2W + AgileX Piper
|
| 17 |
+
- Manipulator-only: AgileX Piper
|
| 18 |
+
- **Sensor suite** (standardized across platforms)
|
| 19 |
+
- 1 × LiDAR
|
| 20 |
+
- 1 × eye-to-hand RGB-D camera
|
| 21 |
+
- 1 × eye-in-hand RGB-D camera *(humanoids use a stereo pair)*
|
| 22 |
+
|
| 23 |
+
## Robot Platforms
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
| Humanoid | Dual-wheel legged + manipulator | Tron2A legged + manipulator | Tron2A wheel + manipulator | Quadruped + manipulator | Wheel-legged quadruped + manipulator | Manipulator |
|
| 27 |
+
| :----------------------------------------------------: | :-------------------------------------------------------: | :-----------------------------------------------------------: | :----------------------------------------------------------: | :----------------------------------------------------: | :-----------------------------------------------------: | :-------------------------------------------------------: |
|
| 28 |
+
| <p align="center"><img src="./doc/G1.png" width="180"> | <p align="center"><img src="./doc/Tron1.png" width="180"> | <p align="center"><img src="./doc/Tron2Legged.png" width="180"> | <p align="center"><img src="./doc/Tron2Wheel.png" width="180"> | <p align="center"><img src="./doc/B2.png" width="180"> | <p align="center"><img src="./doc/b2w.png" width="180"> | <p align="center"><img src="./doc/piper.png" width="180"> |
|
| 29 |
+
|
| 30 |
+
> **Note:** Users may modify or optimize assets (e.g., collision geometry simplification) for training purposes. The provided assets serve as reference models for evaluation.
|
| 31 |
+
|
| 32 |
+
---
|
| 33 |
+
|
| 34 |
+
### 1.3 Challenge Arenas
|
| 35 |
+
|
| 36 |
+
| Arena | Video | Arena | Video |
|
| 37 |
+
| --- | --- | --- | --- |
|
| 38 |
+
| Task A · Off-road Navigation | <p align="center"><img src="./doc/task_a.gif" width="180"> | Task E · Tabletop Manipulation | <p align="center"><img src="./doc/baseline_act.gif" width="180"> |
|
| 39 |
+
| Task B · Garbage Collection | <p align="center"><img src="./doc/task_b.gif" width="180"> | Task D · Obstacle Traversal | <p align="center"><img src="./doc/task_d.gif" width="180"> |
|
| 40 |
+
|
| 41 |
+
> **Note:** For each task, participants are free to select any supported robot morphology.
|
| 42 |
+
|
| 43 |
+
---
|
| 44 |
+
|
| 45 |
+
### 1.4 Environment Matrix
|
| 46 |
+
|
| 47 |
+
The `atec_rl_lab.tasks` module registers all **arena–robot combinations** as Gym-compatible environments, enabling unified interfaces for evaluation and submission.
|
| 48 |
+
|
| 49 |
+
|
| 50 |
+
| Arena \ Robot | G1 | Tron1Piper | Tron2ALegged | Tron2AWheel | B2Piper | B2wPiper | Piper |
|
| 51 |
+
| ------------- | --------------- | ----------------------- | ------------------------- | ------------------------ | -------------------- | --------------------- | ------------------ |
|
| 52 |
+
| Task A | `ATEC-TaskA-G1` | `ATEC-TaskA-Tron1Piper` | `ATEC-TaskA-Tron2ALegged` | `ATEC-TaskA-Tron2AWheel` | `ATEC-TaskA-B2Piper` | `ATEC-TaskA-B2wPiper` | |
|
| 53 |
+
| Task B | `ATEC-TaskB-G1` | `ATEC-TaskB-Tron1Piper` | `ATEC-TaskB-Tron2ALegged` | `ATEC-TaskB-Tron2AWheel` | `ATEC-TaskB-B2Piper` | `ATEC-TaskB-B2wPiper` | |
|
| 54 |
+
| Task D | `ATEC-TaskD-G1` | `ATEC-TaskD-Tron1Piper` | `ATEC-TaskD-Tron2ALegged` | `ATEC-TaskD-Tron2AWheel` | `ATEC-TaskD-B2Piper` | `ATEC-TaskD-B2wPiper` | |
|
| 55 |
+
| Task E | | | | | | | `ATEC-TaskE-Piper` |
|
| 56 |
+
|
| 57 |
+
> **Note:** The provided environments are designed for evaluation and submission only and do not support parallelized training. For training, users should implement custom wrappers or leverage external frameworks for efficient learning.
|
| 58 |
+
|
| 59 |
+
---
|
| 60 |
+
|
| 61 |
+
## 2. Installation
|
| 62 |
+
|
| 63 |
+
This repository is developed and tested with **Isaac Lab v2.3.2**. Earlier versions (e.g., v1.4.1) are not validated and may require modification.
|
| 64 |
+
|
| 65 |
+
Follow the official Isaac Lab installation [guide](https://isaac-sim.github.io/IsaacLab/main/source/setup/installation/pip_installation.html).
|
| 66 |
+
|
| 67 |
+
### 2.1 Setup
|
| 68 |
+
|
| 69 |
+
Clone repository
|
| 70 |
+
```bash
|
| 71 |
+
git clone https://github.com/atecup/ATEC2026_Simulation_Challenge.git
|
| 72 |
+
cd ATEC2026_Simulation_Challenge
|
| 73 |
+
```
|
| 74 |
+
|
| 75 |
+
Activate Isaac Lab Environment
|
| 76 |
+
|
| 77 |
+
```bash
|
| 78 |
+
conda activate isaaclab
|
| 79 |
+
```
|
| 80 |
+
|
| 81 |
+
Install ATEC Extension
|
| 82 |
+
```bash
|
| 83 |
+
cd source/atec_rl_lab
|
| 84 |
+
pip install -e .
|
| 85 |
+
```
|
| 86 |
+
|
| 87 |
+
After installation, all `ATEC-*` environments will be available in the active Python environment.
|
| 88 |
+
|
| 89 |
+
Download Robot Models
|
| 90 |
+
```bash
|
| 91 |
+
cd ATEC2026_Simulation_Challenge
|
| 92 |
+
curl https://static.atecup.com/atec2026/atec_robot_model.zip -o atec_robot_model.zip
|
| 93 |
+
unzip atec_robot_model.zip -d atec_robot_model
|
| 94 |
+
```
|
| 95 |
+
|
| 96 |
+
---
|
| 97 |
+
|
| 98 |
+
## 3. Running the Environments
|
| 99 |
+
|
| 100 |
+
### 3.1 Environment Check
|
| 101 |
+
|
| 102 |
+
```bash
|
| 103 |
+
cd ATEC2026_Simulation_Challenge
|
| 104 |
+
python scripts/list_envs.py
|
| 105 |
+
```
|
| 106 |
+
|
| 107 |
+
Successful execution will list all registered environments, confirming correct module loading.
|
| 108 |
+
|
| 109 |
+
---
|
| 110 |
+
|
| 111 |
+
### 3.2 Visualization Utilities
|
| 112 |
+
|
| 113 |
+
```bash
|
| 114 |
+
scripts/view_robots.py – inspect robot models
|
| 115 |
+
scripts/view_task_a.py – Task A visualization
|
| 116 |
+
scripts/view_task_b.py – Task B visualization
|
| 117 |
+
scripts/view_task_d.py – Task D visualization
|
| 118 |
+
scripts/view_task_e.py – Task E visualization
|
| 119 |
+
```
|
| 120 |
+
|
| 121 |
+
Example:
|
| 122 |
+
|
| 123 |
+
```
|
| 124 |
+
python scripts/view_task_a.py --enable_cameras
|
| 125 |
+
```
|
| 126 |
+
|
| 127 |
+
---
|
| 128 |
+
|
| 129 |
+
### 3.3 Submission and Evaluation
|
| 130 |
+
|
| 131 |
+
Participants can test their solutions using:
|
| 132 |
+
```bash
|
| 133 |
+
cd ATEC2026_Simulation_Challenge
|
| 134 |
+
|
| 135 |
+
python scripts/play_atec_task.py --task ATEC-TaskA-G1 --enable_cameras
|
| 136 |
+
```
|
| 137 |
+
|
| 138 |
+
#### Implementation Requirement
|
| 139 |
+
|
| 140 |
+
Participants must implement demo/solution.py, and this file name can not be changed.
|
| 141 |
+
* Class: AlgSolution
|
| 142 |
+
* Function: predicts(obs, current_score), where **obs** is the observation, and **current_score** is the current score
|
| 143 |
+
* Return: {"action": action, "giveup": False}, where action is the prediction action represented by List, and **giveup** is the giveup flag. if **giveup** is True, the scoring job will be terminated.
|
| 144 |
+
|
| 145 |
+
|
| 146 |
+
### 3.4 Observations and Actions
|
| 147 |
+
|
| 148 |
+
#### Tasks A / B / D
|
| 149 |
+
|
| 150 |
+
Observations are grouped into:
|
| 151 |
+
|
| 152 |
+
- `Proprioception`: base velocity, joint states, previous actions
|
| 153 |
+
- `Exteroception`: LiDAR-based height scan
|
| 154 |
+
- `Vision`: RGB-D images from head and end-effector cameras
|
| 155 |
+
|
| 156 |
+
All observation terms are:
|
| 157 |
+
|
| 158 |
+
- noise-injected
|
| 159 |
+
- order-preserved
|
| 160 |
+
- concatenated per group
|
| 161 |
+
|
| 162 |
+
#### Task E (Manipulation-only)
|
| 163 |
+
|
| 164 |
+
Observations include:
|
| 165 |
+
|
| 166 |
+
- `Proprioception`: joint states (position + velocity)
|
| 167 |
+
|
| 168 |
+
- `Vision`: RGB-D images from end-effector and external camera
|
| 169 |
+
|
| 170 |
+
|
| 171 |
+
|
| 172 |
+
**Note:** Joint indices follow fixed ordering per robot (critical for policy deployment).
|
| 173 |
+
|
| 174 |
+
- b2_piper (20 DoF)
|
| 175 |
+
- b2w_piper (24 DoF)
|
| 176 |
+
- G1 (33 DoF)
|
| 177 |
+
- tron1a_piper (16 DoF)
|
| 178 |
+
- piper (8 DoF)
|
| 179 |
+
|
| 180 |
+
#### Action Space
|
| 181 |
+
|
| 182 |
+
Robot control actions are organized by joint type.
|
| 183 |
+
|
| 184 |
+
- Leg joints and manipulator joints are controlled by joint position commands.
|
| 185 |
+
- Wheel joints of wheeled robots are controlled by joint velocity commands.
|
| 186 |
+
|
| 187 |
+
The action configuration is as follows:
|
| 188 |
+
|
| 189 |
+
```
|
| 190 |
+
joint_pos_leg = mdp.JointPositionActionCfg(
|
| 191 |
+
asset_name="robot",
|
| 192 |
+
joint_names=[""],
|
| 193 |
+
scale=0.5,
|
| 194 |
+
use_default_offset=True,
|
| 195 |
+
clip=None,
|
| 196 |
+
preserve_order=True,
|
| 197 |
+
)
|
| 198 |
+
|
| 199 |
+
joint_vel_wheel = mdp.JointVelocityActionCfg(
|
| 200 |
+
asset_name="robot",
|
| 201 |
+
joint_names=[""],
|
| 202 |
+
scale=5.0,
|
| 203 |
+
use_default_offset=True,
|
| 204 |
+
clip=None,
|
| 205 |
+
preserve_order=True,
|
| 206 |
+
)
|
| 207 |
+
|
| 208 |
+
joint_pos_arm = mdp.JointPositionActionCfg(
|
| 209 |
+
asset_name="robot",
|
| 210 |
+
joint_names=[""],
|
| 211 |
+
scale=0.5,
|
| 212 |
+
use_default_offset=True,
|
| 213 |
+
clip=None,
|
| 214 |
+
preserve_order=True,
|
| 215 |
+
)
|
| 216 |
+
```
|
| 217 |
+
|
| 218 |
+
##### Scaling rules
|
| 219 |
+
|
| 220 |
+
- Leg position commands are scaled by 0.5 before being applied to the robot.
|
| 221 |
+
- Arm position commands are scaled by 0.5 before being applied to the robot.
|
| 222 |
+
- Wheel velocity commands are scaled by 5.0 before being applied to the robot.
|
| 223 |
+
|
| 224 |
+
Different robots enable different action items according to their structure:
|
| 225 |
+
|
| 226 |
+
- Standard legged robots
|
| 227 |
+
(humanoid robots, quadruped mobile manipulator robots, manipulator) do not enable wheel velocity control.
|
| 228 |
+
- Wheeled legged robots
|
| 229 |
+
(Dual-wheel legged mobile manipulator robots, quadruped-wheel legged mobile manipulator robots)
|
| 230 |
+
enable wheel velocity control.
|
| 231 |
+
|
| 232 |
+
## Contributors
|
| 233 |
+
- **[CUHK Legged Robot Lab](https://cuhkleggedrobotlab.github.io/)**
|
| 234 |
+
- **[曾兆阳](https://zengzhaoyang.com/)**
|
| 235 |
+
- **[ATEC (Advanced Technology Exploration Community)](https://www.atecup.com)**
|
| 236 |
+
|
| 237 |
+
## License
|
| 238 |
+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
scripts/list_envs.py
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""List all Gym environments registered under ``atec_rl_lab.tasks`` without importing Isaac Sim/Kit.
|
| 3 |
+
|
| 4 |
+
This script avoids `import atec_rl_lab.tasks` because that may import IsaacLab/Omniverse modules (e.g., `carb`)
|
| 5 |
+
in a pure Python environment. Instead, it scans task modules and executes only `gym.register(...)` statements.
|
| 6 |
+
"""
|
| 7 |
+
|
| 8 |
+
from __future__ import annotations
|
| 9 |
+
|
| 10 |
+
import ast
|
| 11 |
+
import sys
|
| 12 |
+
from pathlib import Path
|
| 13 |
+
|
| 14 |
+
import gymnasium as gym
|
| 15 |
+
from prettytable import PrettyTable
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
def _project_root() -> Path:
|
| 19 |
+
return Path(__file__).resolve().parents[1]
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
def _find_python_files(pkg_dir: Path) -> list[Path]:
|
| 23 |
+
return [
|
| 24 |
+
p for p in pkg_dir.rglob("*.py")
|
| 25 |
+
if p.name != "__pycache__"
|
| 26 |
+
]
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
def _exec_only_gym_register(py_file: Path) -> bool:
|
| 30 |
+
"""Parse a python file and execute only top-level `gym.register(...)` calls.
|
| 31 |
+
|
| 32 |
+
Returns True if at least one register call was executed.
|
| 33 |
+
"""
|
| 34 |
+
src = py_file.read_text(encoding="utf-8")
|
| 35 |
+
tree = ast.parse(src, filename=str(py_file))
|
| 36 |
+
|
| 37 |
+
register_calls: list[ast.stmt] = []
|
| 38 |
+
for node in tree.body:
|
| 39 |
+
|
| 40 |
+
if isinstance(node, (ast.Import, ast.ImportFrom)):
|
| 41 |
+
names = []
|
| 42 |
+
if isinstance(node, ast.Import):
|
| 43 |
+
names = [n.name for n in node.names]
|
| 44 |
+
else:
|
| 45 |
+
mod = node.module or ""
|
| 46 |
+
names = [mod]
|
| 47 |
+
if any("gym" in n for n in names):
|
| 48 |
+
register_calls.append(node)
|
| 49 |
+
elif isinstance(node, ast.Expr) and isinstance(node.value, ast.Call):
|
| 50 |
+
call = node.value
|
| 51 |
+
# detect gym.register(...)
|
| 52 |
+
if isinstance(call.func, ast.Attribute) and call.func.attr == "register":
|
| 53 |
+
if isinstance(call.func.value, ast.Name) and call.func.value.id == "gym":
|
| 54 |
+
register_calls.append(node)
|
| 55 |
+
|
| 56 |
+
if not register_calls:
|
| 57 |
+
return False
|
| 58 |
+
|
| 59 |
+
mod = ast.Module(body=register_calls, type_ignores=[])
|
| 60 |
+
code = compile(mod, filename=str(py_file), mode="exec")
|
| 61 |
+
|
| 62 |
+
# Execute in a controlled namespace: provide gymnasium as gym
|
| 63 |
+
ns: dict = {"gym": gym}
|
| 64 |
+
try:
|
| 65 |
+
exec(code, ns, ns)
|
| 66 |
+
return True
|
| 67 |
+
except Exception as e:
|
| 68 |
+
print(f"[WARN] Failed executing gym.register in {py_file}: {e}", file=sys.stderr)
|
| 69 |
+
return False
|
| 70 |
+
|
| 71 |
+
|
| 72 |
+
def discover_tasks_without_import() -> int:
|
| 73 |
+
root = _project_root()
|
| 74 |
+
pkg_dir = root / "source" / "atec_rl_lab" / "atec_rl_lab" / "tasks"
|
| 75 |
+
if not pkg_dir.exists():
|
| 76 |
+
pkg_dir = root / "atec_rl_lab" / "tasks"
|
| 77 |
+
|
| 78 |
+
if not pkg_dir.exists():
|
| 79 |
+
raise FileNotFoundError(f"Cannot find tasks package dir under: {root}")
|
| 80 |
+
|
| 81 |
+
count = 0
|
| 82 |
+
for py in _find_python_files(pkg_dir):
|
| 83 |
+
if py.name in {"env_cfg.py", "scene_cfg.py", "envs_base_cfg.py"}:
|
| 84 |
+
continue
|
| 85 |
+
if _exec_only_gym_register(py):
|
| 86 |
+
count += 1
|
| 87 |
+
return count
|
| 88 |
+
|
| 89 |
+
|
| 90 |
+
def main() -> None:
|
| 91 |
+
executed_files = discover_tasks_without_import()
|
| 92 |
+
|
| 93 |
+
table = PrettyTable(["S. No.", "Task Name", "Entry Point"])
|
| 94 |
+
table.title = f"Available Environments in ATEC RL Lab (scanned {executed_files} files)"
|
| 95 |
+
table.align["Task Name"] = "l"
|
| 96 |
+
table.align["Entry Point"] = "l"
|
| 97 |
+
|
| 98 |
+
index = 0
|
| 99 |
+
for task_spec in gym.registry.values():
|
| 100 |
+
if "ATEC" in task_spec.id and "Isaac" not in task_spec.id:
|
| 101 |
+
table.add_row([index + 1, task_spec.id, str(task_spec.entry_point)])
|
| 102 |
+
index += 1
|
| 103 |
+
|
| 104 |
+
print(table)
|
| 105 |
+
|
| 106 |
+
|
| 107 |
+
if __name__ == "__main__":
|
| 108 |
+
try:
|
| 109 |
+
main()
|
| 110 |
+
except ModuleNotFoundError as exc:
|
| 111 |
+
print(f"Failed to import dependencies while discovering tasks: {exc}")
|
| 112 |
+
raise
|
scripts/play_atec_task.py
ADDED
|
@@ -0,0 +1,168 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Created by skywoodsz on 2026/02/07.
|
| 2 |
+
|
| 3 |
+
import argparse
|
| 4 |
+
import os
|
| 5 |
+
import time
|
| 6 |
+
import json
|
| 7 |
+
|
| 8 |
+
from isaaclab.app import AppLauncher
|
| 9 |
+
|
| 10 |
+
from demo.solution import AlgSolution
|
| 11 |
+
solution = AlgSolution()
|
| 12 |
+
|
| 13 |
+
# -----------------------------------------------------------------------------
|
| 14 |
+
# CLI
|
| 15 |
+
# -----------------------------------------------------------------------------
|
| 16 |
+
parser = argparse.ArgumentParser(description="Play Atec Tasks (ENV only, no RL).")
|
| 17 |
+
parser.add_argument("--video", action="store_true", default=False, help="Record videos during play.")
|
| 18 |
+
parser.add_argument("--video_length", type=int, default=200, help="Length of the recorded video (in steps).")
|
| 19 |
+
parser.add_argument(
|
| 20 |
+
"--disable_fabric", action="store_true", default=False, help="Disable fabric and use USD I/O operations."
|
| 21 |
+
)
|
| 22 |
+
parser.add_argument("--num_envs", type=int, default=1, help="Number of environments to simulate.")
|
| 23 |
+
parser.add_argument("--task", type=str, default=None, help="Name of the task.")
|
| 24 |
+
parser.add_argument("--real-time", action="store_true", default=False, help="Run in real-time, if possible.")
|
| 25 |
+
parser.add_argument(
|
| 26 |
+
"--debug",
|
| 27 |
+
action="store_true",
|
| 28 |
+
default=False,
|
| 29 |
+
help="Enable debug prints for per-step reward/time metrics.",
|
| 30 |
+
)
|
| 31 |
+
|
| 32 |
+
# Isaac Sim / Kit args
|
| 33 |
+
AppLauncher.add_app_launcher_args(parser)
|
| 34 |
+
|
| 35 |
+
args_cli = parser.parse_args()
|
| 36 |
+
|
| 37 |
+
# If recording video, need cameras enabled in IsaacLab/Kit
|
| 38 |
+
if args_cli.video:
|
| 39 |
+
args_cli.enable_cameras = True
|
| 40 |
+
|
| 41 |
+
# -----------------------------------------------------------------------------
|
| 42 |
+
# Launch Isaac Sim / Kit
|
| 43 |
+
# -----------------------------------------------------------------------------
|
| 44 |
+
app_launcher = AppLauncher(args_cli)
|
| 45 |
+
simulation_app = app_launcher.app
|
| 46 |
+
|
| 47 |
+
# -----------------------------------------------------------------------------
|
| 48 |
+
# Imports AFTER simulation_app is created (IsaacLab pattern)
|
| 49 |
+
# -----------------------------------------------------------------------------
|
| 50 |
+
import gymnasium as gym # noqa: E402
|
| 51 |
+
import torch # noqa: E402
|
| 52 |
+
|
| 53 |
+
from isaaclab.envs import DirectMARLEnv, multi_agent_to_single_agent # noqa: E402
|
| 54 |
+
from isaaclab.utils.dict import print_dict # noqa: E402
|
| 55 |
+
|
| 56 |
+
import atec_rl_lab.tasks # noqa: F401, E402 (register your tasks)
|
| 57 |
+
from isaaclab_tasks.utils import parse_env_cfg
|
| 58 |
+
from rl_utils import camera_follow
|
| 59 |
+
|
| 60 |
+
|
| 61 |
+
def play() -> tuple[float, float]:
|
| 62 |
+
if args_cli.task is None:
|
| 63 |
+
raise ValueError("Please provide --task, e.g. --task ATEC-TaskA-G1")
|
| 64 |
+
|
| 65 |
+
is_task_e = isinstance(args_cli.task, str) and args_cli.task.startswith("ATEC-TaskE")
|
| 66 |
+
# -------------------------------------------------------------------------
|
| 67 |
+
# Create env (plain Gym env)
|
| 68 |
+
# -------------------------------------------------------------------------
|
| 69 |
+
env_cfg = parse_env_cfg(
|
| 70 |
+
args_cli.task,
|
| 71 |
+
device=args_cli.device,
|
| 72 |
+
num_envs=args_cli.num_envs,
|
| 73 |
+
use_fabric=not args_cli.disable_fabric
|
| 74 |
+
)
|
| 75 |
+
|
| 76 |
+
env = gym.make(args_cli.task, cfg=env_cfg, render_mode="rgb_array" if args_cli.video else None)
|
| 77 |
+
|
| 78 |
+
# Convert MARL -> single agent if needed (kept from your original script)
|
| 79 |
+
if isinstance(env.unwrapped, DirectMARLEnv):
|
| 80 |
+
env = multi_agent_to_single_agent(env)
|
| 81 |
+
|
| 82 |
+
# -------------------------------------------------------------------------
|
| 83 |
+
# Optional: video wrapper
|
| 84 |
+
# -------------------------------------------------------------------------
|
| 85 |
+
if args_cli.video:
|
| 86 |
+
# Put videos in ./logs/videos/play by default (edit as you like)
|
| 87 |
+
video_kwargs = {
|
| 88 |
+
"video_folder": os.path.abspath(os.path.join("logs", "videos", args_cli.task, "play")),
|
| 89 |
+
"step_trigger": lambda step: step == 0,
|
| 90 |
+
"video_length": args_cli.video_length,
|
| 91 |
+
"disable_logger": True,
|
| 92 |
+
}
|
| 93 |
+
print("[INFO] Recording videos during play.")
|
| 94 |
+
print_dict(video_kwargs, nesting=4)
|
| 95 |
+
env = gym.wrappers.RecordVideo(env, **video_kwargs)
|
| 96 |
+
|
| 97 |
+
|
| 98 |
+
# -------------------------------------------------------------------------
|
| 99 |
+
# Reset
|
| 100 |
+
# -------------------------------------------------------------------------
|
| 101 |
+
obs, _ = env.reset()
|
| 102 |
+
|
| 103 |
+
dt = env.unwrapped.step_dt if hasattr(env.unwrapped, "step_dt") else None
|
| 104 |
+
timestep = 0
|
| 105 |
+
|
| 106 |
+
# -------------------------------------------------------------------------
|
| 107 |
+
# Play loop
|
| 108 |
+
# -------------------------------------------------------------------------
|
| 109 |
+
total_episode_reward = 0.0
|
| 110 |
+
total_elapsed_time = 0.0
|
| 111 |
+
while simulation_app.is_running():
|
| 112 |
+
with torch.inference_mode():
|
| 113 |
+
start_time = time.time()
|
| 114 |
+
|
| 115 |
+
# ===== Your controller goes here =====
|
| 116 |
+
resp = solution.predicts(obs, total_episode_reward)
|
| 117 |
+
giveup = resp["giveup"]
|
| 118 |
+
if giveup:
|
| 119 |
+
break
|
| 120 |
+
actions = resp["action"]
|
| 121 |
+
actions = torch.tensor(actions, dtype=torch.float32, device='cuda').view(1, -1)
|
| 122 |
+
obs, reward, terminated, truncated, info = env.step(actions)
|
| 123 |
+
if not is_task_e:
|
| 124 |
+
camera_follow(env)
|
| 125 |
+
|
| 126 |
+
sim_dt = info["Step_dt"]
|
| 127 |
+
if isinstance(reward, torch.Tensor):
|
| 128 |
+
total_episode_reward += reward.mean().item() / sim_dt
|
| 129 |
+
else:
|
| 130 |
+
total_episode_reward += float(reward) / sim_dt
|
| 131 |
+
|
| 132 |
+
if isinstance(info, dict) and "Elapsed_Time" in info:
|
| 133 |
+
elapsed = info["Elapsed_Time"] # simulation time from env as primary source
|
| 134 |
+
total_elapsed_time = elapsed.item() if hasattr(elapsed, "item") else float(elapsed)
|
| 135 |
+
elif dt is not None:
|
| 136 |
+
total_elapsed_time += dt # wall clock time as fallback
|
| 137 |
+
|
| 138 |
+
if args_cli.debug:
|
| 139 |
+
print(f"total_episode_reward:{total_episode_reward: .2f}")
|
| 140 |
+
print(f"total_elapsed_time:{total_elapsed_time: .2f}")
|
| 141 |
+
|
| 142 |
+
done = (terminated.item() or truncated.item())
|
| 143 |
+
if done:
|
| 144 |
+
break
|
| 145 |
+
|
| 146 |
+
timestep += 1
|
| 147 |
+
# If recording one video, exit after video_length steps
|
| 148 |
+
if args_cli.video and timestep >= args_cli.video_length:
|
| 149 |
+
break
|
| 150 |
+
|
| 151 |
+
# Real-time pacing
|
| 152 |
+
if args_cli.real_time and dt is not None:
|
| 153 |
+
sleep_time = dt - (time.time() - start_time)
|
| 154 |
+
if sleep_time > 0:
|
| 155 |
+
time.sleep(sleep_time)
|
| 156 |
+
|
| 157 |
+
env.close()
|
| 158 |
+
|
| 159 |
+
return total_episode_reward, total_elapsed_time
|
| 160 |
+
|
| 161 |
+
|
| 162 |
+
if __name__ == "__main__":
|
| 163 |
+
score, elapsed_time = play()
|
| 164 |
+
print(f"score: {score:.2f}, elapsed_time: {elapsed_time:.2f} seconds")
|
| 165 |
+
|
| 166 |
+
# Finally, close the simulation app
|
| 167 |
+
print("Closing simulation app...")
|
| 168 |
+
simulation_app.close()
|
scripts/rl_utils.py
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch
|
| 2 |
+
import isaaclab.utils.math as math_utils
|
| 3 |
+
|
| 4 |
+
def camera_follow(env, robot_name: str = "robot", env_index: int = 0, alpha: float = 0.15):
|
| 5 |
+
unwrapped = env.unwrapped
|
| 6 |
+
|
| 7 |
+
if not hasattr(unwrapped, "viewport_camera_controller"):
|
| 8 |
+
return
|
| 9 |
+
|
| 10 |
+
try:
|
| 11 |
+
robot = unwrapped.scene[robot_name]
|
| 12 |
+
except KeyError as e:
|
| 13 |
+
raise KeyError(
|
| 14 |
+
f"Robot asset '{robot_name}' not found in env.unwrapped.scene."
|
| 15 |
+
) from e
|
| 16 |
+
|
| 17 |
+
device = unwrapped.device
|
| 18 |
+
|
| 19 |
+
robot_pos = robot.data.root_pos_w[env_index]
|
| 20 |
+
robot_quat = robot.data.root_quat_w[env_index]
|
| 21 |
+
|
| 22 |
+
camera_offset = torch.tensor([-6.0, 0.0, 0.8], dtype=torch.float32, device=device)
|
| 23 |
+
|
| 24 |
+
target_camera_pos = math_utils.transform_points(
|
| 25 |
+
camera_offset.unsqueeze(0),
|
| 26 |
+
pos=robot_pos.unsqueeze(0),
|
| 27 |
+
quat=robot_quat.unsqueeze(0),
|
| 28 |
+
).squeeze(0)
|
| 29 |
+
|
| 30 |
+
target_camera_pos[2] = torch.clamp(target_camera_pos[2], min=0.2)
|
| 31 |
+
|
| 32 |
+
if not hasattr(camera_follow, "_smooth_pos"):
|
| 33 |
+
camera_follow._smooth_pos = {}
|
| 34 |
+
|
| 35 |
+
if env_index not in camera_follow._smooth_pos:
|
| 36 |
+
camera_follow._smooth_pos[env_index] = target_camera_pos.clone()
|
| 37 |
+
|
| 38 |
+
smooth_camera_pos = camera_follow._smooth_pos[env_index]
|
| 39 |
+
smooth_camera_pos = (1.0 - alpha) * smooth_camera_pos + alpha * target_camera_pos
|
| 40 |
+
camera_follow._smooth_pos[env_index] = smooth_camera_pos
|
| 41 |
+
|
| 42 |
+
unwrapped.viewport_camera_controller.set_view_env_index(env_index=env_index)
|
| 43 |
+
unwrapped.viewport_camera_controller.update_view_location(
|
| 44 |
+
eye=smooth_camera_pos.detach().cpu().numpy(),
|
| 45 |
+
lookat=robot_pos.detach().cpu().numpy(),
|
| 46 |
+
)
|
scripts/view_robots.py
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Created by skywoodsz on 2026/01/28.
|
| 2 |
+
import argparse
|
| 3 |
+
import itertools
|
| 4 |
+
from isaaclab.app import AppLauncher
|
| 5 |
+
|
| 6 |
+
# create argparser
|
| 7 |
+
parser = argparse.ArgumentParser(description="View ATEC Robots.")
|
| 8 |
+
parser.add_argument("--num_envs", type=int, default=1, help="Number of environments to spawn.")
|
| 9 |
+
# append AppLauncher cli args
|
| 10 |
+
AppLauncher.add_app_launcher_args(parser)
|
| 11 |
+
# parse the arguments
|
| 12 |
+
args_cli = parser.parse_args()
|
| 13 |
+
# launch omniverse app
|
| 14 |
+
app_launcher = AppLauncher(args_cli)
|
| 15 |
+
simulation_app = app_launcher.app
|
| 16 |
+
|
| 17 |
+
"""Rest everything follows."""
|
| 18 |
+
import isaaclab.sim as sim_utils
|
| 19 |
+
from isaaclab.assets import AssetBaseCfg
|
| 20 |
+
from isaaclab.scene import InteractiveScene, InteractiveSceneCfg
|
| 21 |
+
from dataclasses import replace
|
| 22 |
+
from atec_rl_lab.assets.robots import (
|
| 23 |
+
UNITREE_B2_CFG,
|
| 24 |
+
UNITREE_B2_PIPER_CFG,
|
| 25 |
+
UNITREE_B2W_CFG,
|
| 26 |
+
UNITREE_B2W_PIPER_CFG,
|
| 27 |
+
TRON1A_WHEEL_CFG,
|
| 28 |
+
TRON1A_PIPER_CFG,
|
| 29 |
+
TRON2A_LEGGED_CFG,
|
| 30 |
+
TRON2A_WHEEL_CFG,
|
| 31 |
+
PIPER_CFG,
|
| 32 |
+
UNITREE_G1_29DOF_DEX1_CFG
|
| 33 |
+
)
|
| 34 |
+
|
| 35 |
+
class ATECSceneCfg(InteractiveSceneCfg):
|
| 36 |
+
ground = AssetBaseCfg(
|
| 37 |
+
prim_path="/World/defaultGroundPlane", spawn=sim_utils.GroundPlaneCfg()
|
| 38 |
+
)
|
| 39 |
+
|
| 40 |
+
# lights
|
| 41 |
+
dome_light = AssetBaseCfg(
|
| 42 |
+
prim_path="/World/Light",
|
| 43 |
+
spawn=sim_utils.DomeLightCfg(intensity=3000.0, color=(0.75, 0.75, 0.75)),
|
| 44 |
+
)
|
| 45 |
+
|
| 46 |
+
b2 = replace(UNITREE_B2_CFG, prim_path="{ENV_REGEX_NS}/b2")
|
| 47 |
+
|
| 48 |
+
b2w = replace(UNITREE_B2W_CFG, prim_path="{ENV_REGEX_NS}/b2w")
|
| 49 |
+
b2w.init_state.pos = (b2w.init_state.pos[0], b2w.init_state.pos[1] + 1.0, b2w.init_state.pos[2] + 0.166)
|
| 50 |
+
|
| 51 |
+
b2w_piper = replace(UNITREE_B2W_PIPER_CFG, prim_path="{ENV_REGEX_NS}/b2w_piper")
|
| 52 |
+
b2w_piper.init_state.pos = (b2w_piper.init_state.pos[0], b2w_piper.init_state.pos[1] + 2.0, b2w_piper.init_state.pos[2] + 0.166)
|
| 53 |
+
|
| 54 |
+
b2_piper = replace(UNITREE_B2_PIPER_CFG, prim_path="{ENV_REGEX_NS}/b2_piper")
|
| 55 |
+
b2_piper.init_state.pos = (b2_piper.init_state.pos[0], b2_piper.init_state.pos[1] + 3.0, b2_piper.init_state.pos[2] + 0.166)
|
| 56 |
+
|
| 57 |
+
tron1a = replace(TRON1A_WHEEL_CFG, prim_path="{ENV_REGEX_NS}/tron1a")
|
| 58 |
+
tron1a.init_state.pos = (tron1a.init_state.pos[0], tron1a.init_state.pos[1] + 4.0, tron1a.init_state.pos[2] + 0.166)
|
| 59 |
+
|
| 60 |
+
tron1a_piper = replace(TRON1A_PIPER_CFG, prim_path="{ENV_REGEX_NS}/tron1a_piper")
|
| 61 |
+
tron1a_piper.init_state.pos = (tron1a_piper.init_state.pos[0], tron1a_piper.init_state.pos[1] + 5.0, tron1a_piper.init_state.pos[2] + 0.166)
|
| 62 |
+
|
| 63 |
+
tron2a_legged = replace(TRON2A_LEGGED_CFG, prim_path="{ENV_REGEX_NS}/tron2a_legged")
|
| 64 |
+
tron2a_legged.init_state.pos = (tron2a_legged.init_state.pos[0], tron2a_legged.init_state.pos[1] + 6.0, tron2a_legged.init_state.pos[2] + 0.166)
|
| 65 |
+
|
| 66 |
+
tron2a_wheel = replace(TRON2A_WHEEL_CFG, prim_path="{ENV_REGEX_NS}/tron2a_wheel")
|
| 67 |
+
tron2a_wheel.init_state.pos = (tron2a_wheel.init_state.pos[0], tron2a_wheel.init_state.pos[1] + 7.0, tron2a_wheel.init_state.pos[2] + 0.166)
|
| 68 |
+
|
| 69 |
+
piper = replace(PIPER_CFG, prim_path="{ENV_REGEX_NS}/piper")
|
| 70 |
+
piper.init_state.pos = (piper.init_state.pos[0], piper.init_state.pos[1] + 8.0, piper.init_state.pos[2])
|
| 71 |
+
|
| 72 |
+
g1 = replace(UNITREE_G1_29DOF_DEX1_CFG, prim_path="{ENV_REGEX_NS}/g1")
|
| 73 |
+
g1.init_state.pos = (g1.init_state.pos[0], g1.init_state.pos[1] + 9.0, g1.init_state.pos[2])
|
| 74 |
+
|
| 75 |
+
def main():
|
| 76 |
+
# Initialize the simulation context
|
| 77 |
+
sim_cfg = sim_utils.SimulationCfg(dt=0.01, device=args_cli.device)
|
| 78 |
+
sim = sim_utils.SimulationContext(sim_cfg)
|
| 79 |
+
# Set main camera
|
| 80 |
+
sim.set_camera_view([2.0, 0.0, 2.5], [-0.5, 0.0, 0.5])
|
| 81 |
+
|
| 82 |
+
scene_cfg = ATECSceneCfg(
|
| 83 |
+
num_envs=args_cli.num_envs,
|
| 84 |
+
env_spacing=4.0,
|
| 85 |
+
replicate_physics=True
|
| 86 |
+
)
|
| 87 |
+
scene = InteractiveScene(scene_cfg)
|
| 88 |
+
# Play the simulator
|
| 89 |
+
sim.reset()
|
| 90 |
+
scene.reset()
|
| 91 |
+
|
| 92 |
+
for name, articulation in scene.articulations.items():
|
| 93 |
+
print("-"*100)
|
| 94 |
+
print("Robot name:", name)
|
| 95 |
+
print("Bodies:", articulation.num_bodies, "->", articulation.body_names)
|
| 96 |
+
print("Joints:", articulation.num_joints, "->", articulation.joint_names)
|
| 97 |
+
articulation.set_joint_position_target(articulation.data.default_joint_pos)
|
| 98 |
+
|
| 99 |
+
for i in itertools.count():
|
| 100 |
+
if not simulation_app.is_running():
|
| 101 |
+
break
|
| 102 |
+
scene.write_data_to_sim()
|
| 103 |
+
sim.step()
|
| 104 |
+
scene.update(sim.get_physics_dt())
|
| 105 |
+
|
| 106 |
+
if __name__ == "__main__":
|
| 107 |
+
main()
|
| 108 |
+
# close sim app
|
| 109 |
+
simulation_app.close()
|
scripts/view_task_a.py
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Created by skywoodsz on 2026/01/28.
|
| 2 |
+
import argparse
|
| 3 |
+
import itertools
|
| 4 |
+
import torch
|
| 5 |
+
from isaaclab.app import AppLauncher
|
| 6 |
+
|
| 7 |
+
# create argparser
|
| 8 |
+
parser = argparse.ArgumentParser(description="View ATEC Task A.")
|
| 9 |
+
parser.add_argument(
|
| 10 |
+
"--num_envs", type=int, default=1, help="Number of environments to spawn."
|
| 11 |
+
)
|
| 12 |
+
# append AppLauncher cli args
|
| 13 |
+
AppLauncher.add_app_launcher_args(parser)
|
| 14 |
+
# parse the arguments
|
| 15 |
+
args_cli = parser.parse_args()
|
| 16 |
+
# launch omniverse app
|
| 17 |
+
app_launcher = AppLauncher(args_cli)
|
| 18 |
+
simulation_app = app_launcher.app
|
| 19 |
+
|
| 20 |
+
"""Rest everything follows."""
|
| 21 |
+
from isaaclab.envs import ManagerBasedRLEnv
|
| 22 |
+
|
| 23 |
+
from atec_rl_lab.tasks.task_a import TaskAEnvB2Cfg
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
def main():
|
| 27 |
+
env_cfg = TaskAEnvB2Cfg()
|
| 28 |
+
env_cfg.scene.num_envs = args_cli.num_envs
|
| 29 |
+
|
| 30 |
+
env = ManagerBasedRLEnv(env_cfg)
|
| 31 |
+
|
| 32 |
+
for name, articulation in env.scene.articulations.items():
|
| 33 |
+
print("-" * 100)
|
| 34 |
+
print("Robot name:", name)
|
| 35 |
+
print("Bodies:", articulation.num_bodies, "->", articulation.body_names)
|
| 36 |
+
print("Joints:", articulation.num_joints, "->", articulation.joint_names)
|
| 37 |
+
articulation.set_joint_position_target(articulation.data.default_joint_pos)
|
| 38 |
+
|
| 39 |
+
action_space = env.action_space
|
| 40 |
+
obs, info = env.reset()
|
| 41 |
+
|
| 42 |
+
for i in itertools.count():
|
| 43 |
+
if not simulation_app.is_running():
|
| 44 |
+
break
|
| 45 |
+
action = torch.zeros(action_space.shape, device=env.device)
|
| 46 |
+
obs, reward, terminated, truncated, info = env.step(action)
|
| 47 |
+
done = terminated | truncated
|
| 48 |
+
|
| 49 |
+
if done.any():
|
| 50 |
+
env_ids = done.nonzero(as_tuple=False).squeeze(-1)
|
| 51 |
+
env.reset(env_ids=env_ids)
|
| 52 |
+
|
| 53 |
+
|
| 54 |
+
if __name__ == "__main__":
|
| 55 |
+
main()
|
| 56 |
+
# close sim app
|
| 57 |
+
simulation_app.close()
|
scripts/view_task_b.py
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Created by skywoodsz on 2026/01/28.
|
| 2 |
+
import argparse
|
| 3 |
+
import itertools
|
| 4 |
+
import torch
|
| 5 |
+
from isaaclab.app import AppLauncher
|
| 6 |
+
|
| 7 |
+
# create argparser
|
| 8 |
+
parser = argparse.ArgumentParser(description="View ATEC Task A.")
|
| 9 |
+
parser.add_argument(
|
| 10 |
+
"--num_envs", type=int, default=1, help="Number of environments to spawn."
|
| 11 |
+
)
|
| 12 |
+
# append AppLauncher cli args
|
| 13 |
+
AppLauncher.add_app_launcher_args(parser)
|
| 14 |
+
# parse the arguments
|
| 15 |
+
args_cli = parser.parse_args()
|
| 16 |
+
# launch omniverse app
|
| 17 |
+
app_launcher = AppLauncher(args_cli)
|
| 18 |
+
simulation_app = app_launcher.app
|
| 19 |
+
|
| 20 |
+
"""Rest everything follows."""
|
| 21 |
+
from isaaclab.envs import ManagerBasedRLEnv
|
| 22 |
+
|
| 23 |
+
from atec_rl_lab.tasks.task_b import TaskBEnvB2Cfg
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
def main():
|
| 27 |
+
env_cfg = TaskBEnvB2Cfg()
|
| 28 |
+
env_cfg.scene.num_envs = args_cli.num_envs
|
| 29 |
+
|
| 30 |
+
env = ManagerBasedRLEnv(env_cfg)
|
| 31 |
+
|
| 32 |
+
for name, articulation in env.scene.articulations.items():
|
| 33 |
+
print("-" * 100)
|
| 34 |
+
print("Robot name:", name)
|
| 35 |
+
print("Bodies:", articulation.num_bodies, "->", articulation.body_names)
|
| 36 |
+
print("Joints:", articulation.num_joints, "->", articulation.joint_names)
|
| 37 |
+
articulation.set_joint_position_target(articulation.data.default_joint_pos)
|
| 38 |
+
|
| 39 |
+
action_space = env.action_space
|
| 40 |
+
obs, info = env.reset()
|
| 41 |
+
|
| 42 |
+
for i in itertools.count():
|
| 43 |
+
if not simulation_app.is_running():
|
| 44 |
+
break
|
| 45 |
+
action = torch.zeros(action_space.shape, device=env.device)
|
| 46 |
+
obs, reward, terminated, truncated, info = env.step(action)
|
| 47 |
+
done = terminated | truncated
|
| 48 |
+
|
| 49 |
+
if done.any():
|
| 50 |
+
env_ids = done.nonzero(as_tuple=False).squeeze(-1)
|
| 51 |
+
env.reset(env_ids=env_ids)
|
| 52 |
+
|
| 53 |
+
|
| 54 |
+
if __name__ == "__main__":
|
| 55 |
+
main()
|
| 56 |
+
# close sim app
|
| 57 |
+
simulation_app.close()
|
| 58 |
+
|
scripts/view_task_d.py
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Created by skywoodsz on 2026/01/28.
|
| 2 |
+
import argparse
|
| 3 |
+
import itertools
|
| 4 |
+
import torch
|
| 5 |
+
from isaaclab.app import AppLauncher
|
| 6 |
+
|
| 7 |
+
# create argparser
|
| 8 |
+
parser = argparse.ArgumentParser(description="View ATEC Task D.")
|
| 9 |
+
parser.add_argument(
|
| 10 |
+
"--num_envs", type=int, default=1, help="Number of environments to spawn."
|
| 11 |
+
)
|
| 12 |
+
# append AppLauncher cli args
|
| 13 |
+
AppLauncher.add_app_launcher_args(parser)
|
| 14 |
+
# parse the arguments
|
| 15 |
+
args_cli = parser.parse_args()
|
| 16 |
+
# launch omniverse app
|
| 17 |
+
app_launcher = AppLauncher(args_cli)
|
| 18 |
+
simulation_app = app_launcher.app
|
| 19 |
+
|
| 20 |
+
"""Rest everything follows."""
|
| 21 |
+
|
| 22 |
+
from isaaclab.envs import ManagerBasedRLEnv
|
| 23 |
+
|
| 24 |
+
from atec_rl_lab.tasks.task_d import TaskDEnvB2Cfg
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
def main():
|
| 28 |
+
env_cfg = TaskDEnvB2Cfg()
|
| 29 |
+
env_cfg.scene.num_envs = args_cli.num_envs
|
| 30 |
+
|
| 31 |
+
env = ManagerBasedRLEnv(env_cfg)
|
| 32 |
+
|
| 33 |
+
for name, articulation in env.scene.articulations.items():
|
| 34 |
+
print("-" * 100)
|
| 35 |
+
print("Robot name:", name)
|
| 36 |
+
print("Bodies:", articulation.num_bodies, "->", articulation.body_names)
|
| 37 |
+
print("Joints:", articulation.num_joints, "->", articulation.joint_names)
|
| 38 |
+
articulation.set_joint_position_target(articulation.data.default_joint_pos)
|
| 39 |
+
|
| 40 |
+
action_space = env.action_space
|
| 41 |
+
obs, info = env.reset()
|
| 42 |
+
|
| 43 |
+
for i in itertools.count():
|
| 44 |
+
if not simulation_app.is_running():
|
| 45 |
+
break
|
| 46 |
+
action = torch.zeros(action_space.shape, device=env.device)
|
| 47 |
+
obs, reward, terminated, truncated, info = env.step(action)
|
| 48 |
+
done = terminated | truncated
|
| 49 |
+
|
| 50 |
+
if done.any():
|
| 51 |
+
env_ids = done.nonzero(as_tuple=False).squeeze(-1)
|
| 52 |
+
env.reset(env_ids=env_ids)
|
| 53 |
+
|
| 54 |
+
|
| 55 |
+
if __name__ == "__main__":
|
| 56 |
+
main()
|
| 57 |
+
# close sim app
|
| 58 |
+
simulation_app.close()
|
scripts/view_task_e.py
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import argparse
|
| 2 |
+
import itertools
|
| 3 |
+
import torch
|
| 4 |
+
from isaaclab.app import AppLauncher
|
| 5 |
+
|
| 6 |
+
# create argparser
|
| 7 |
+
parser = argparse.ArgumentParser(description="View ATEC Task E.")
|
| 8 |
+
parser.add_argument(
|
| 9 |
+
"--num_envs", type=int, default=1, help="Number of environments to spawn."
|
| 10 |
+
)
|
| 11 |
+
# append AppLauncher cli args
|
| 12 |
+
AppLauncher.add_app_launcher_args(parser)
|
| 13 |
+
# parse the arguments
|
| 14 |
+
args_cli = parser.parse_args()
|
| 15 |
+
# launch omniverse app
|
| 16 |
+
app_launcher = AppLauncher(args_cli)
|
| 17 |
+
simulation_app = app_launcher.app
|
| 18 |
+
|
| 19 |
+
"""Rest everything follows."""
|
| 20 |
+
import isaaclab.sim as sim_utils
|
| 21 |
+
from isaaclab.envs import ManagerBasedRLEnv
|
| 22 |
+
from atec_rl_lab.tasks.task_e.env_cfg import TaskEEnvPiperCfg
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
def main():
|
| 26 |
+
env_cfg = TaskEEnvPiperCfg()
|
| 27 |
+
env_cfg.scene.num_envs = args_cli.num_envs
|
| 28 |
+
|
| 29 |
+
env = ManagerBasedRLEnv(env_cfg)
|
| 30 |
+
|
| 31 |
+
for name, articulation in env.scene.articulations.items():
|
| 32 |
+
print("-" * 100)
|
| 33 |
+
print("Robot name:", name)
|
| 34 |
+
print("Bodies:", articulation.num_bodies, "->", articulation.body_names)
|
| 35 |
+
print("Joints:", articulation.num_joints, "->", articulation.joint_names)
|
| 36 |
+
articulation.set_joint_position_target(articulation.data.default_joint_pos)
|
| 37 |
+
|
| 38 |
+
action_space = env.action_space
|
| 39 |
+
obs, info = env.reset()
|
| 40 |
+
|
| 41 |
+
for i in itertools.count():
|
| 42 |
+
if not simulation_app.is_running():
|
| 43 |
+
break
|
| 44 |
+
action = torch.zeros(action_space.shape, device=env.device)
|
| 45 |
+
obs, reward, terminated, truncated, info = env.step(action)
|
| 46 |
+
done = terminated | truncated
|
| 47 |
+
|
| 48 |
+
if done.any():
|
| 49 |
+
env_ids = done.nonzero(as_tuple=False).squeeze(-1)
|
| 50 |
+
env.reset(env_ids=env_ids)
|
| 51 |
+
|
| 52 |
+
|
| 53 |
+
if __name__ == "__main__":
|
| 54 |
+
main()
|
| 55 |
+
# close sim app
|
| 56 |
+
simulation_app.close()
|
| 57 |
+
|
source/__init__.py
ADDED
|
File without changes
|
source/atec_rl_lab/__init__.py
ADDED
|
File without changes
|
source/atec_rl_lab/atec_rl_lab.egg-info/PKG-INFO
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Metadata-Version: 2.4
|
| 2 |
+
Name: atec_rl_lab
|
| 3 |
+
Version: 0.2.1
|
| 4 |
+
Summary: Reinforcement Learning Lab for ATEC 2026.
|
| 5 |
+
Home-page: https://github.com/skywoodsz/ATEC2026_Simulation_Challenge
|
| 6 |
+
Author: CUHK LRL
|
| 7 |
+
Maintainer: CUHK LRL
|
| 8 |
+
License: Apache 2.0
|
| 9 |
+
Classifier: Programming Language :: Python :: 3
|
| 10 |
+
Classifier: License :: OSI Approved :: Apache Software License
|
| 11 |
+
Classifier: Operating System :: POSIX :: Linux
|
| 12 |
+
Requires-Python: >=3.10
|
| 13 |
+
Requires-Dist: argcomplete
|
| 14 |
+
Dynamic: home-page
|
| 15 |
+
Dynamic: requires-python
|
source/atec_rl_lab/atec_rl_lab.egg-info/SOURCES.txt
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
pyproject.toml
|
| 2 |
+
setup.py
|
| 3 |
+
atec_rl_lab/__init__.py
|
| 4 |
+
atec_rl_lab.egg-info/PKG-INFO
|
| 5 |
+
atec_rl_lab.egg-info/SOURCES.txt
|
| 6 |
+
atec_rl_lab.egg-info/dependency_links.txt
|
| 7 |
+
atec_rl_lab.egg-info/not-zip-safe
|
| 8 |
+
atec_rl_lab.egg-info/requires.txt
|
| 9 |
+
atec_rl_lab.egg-info/top_level.txt
|
source/atec_rl_lab/atec_rl_lab.egg-info/dependency_links.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
|
source/atec_rl_lab/atec_rl_lab.egg-info/not-zip-safe
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
|
source/atec_rl_lab/atec_rl_lab.egg-info/requires.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
argcomplete
|
source/atec_rl_lab/atec_rl_lab.egg-info/top_level.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
atec_rl_lab
|