feat: MoveIt2 execution grounding benchmark pipeline for AgileX Piper arm on FunGraph3D
@@ -0,0 +1,26 @@
|
||||
# Large datasets
|
||||
Dataset/
|
||||
*.ply
|
||||
*.pcd
|
||||
*.zip
|
||||
*.tar.gz
|
||||
|
||||
# Python & Virtual Environments
|
||||
__pycache__/
|
||||
*.py[cod]
|
||||
*$py.class
|
||||
.venv/
|
||||
env/
|
||||
venv/
|
||||
.pytest_cache/
|
||||
.coverage
|
||||
htmlcov/
|
||||
|
||||
# IDE & OS files
|
||||
.vscode/
|
||||
.idea/
|
||||
.DS_Store
|
||||
Thumbs.db
|
||||
|
||||
# Output HTML / scratch dumps
|
||||
*.html
|
||||
@@ -0,0 +1,120 @@
|
||||
# FunGraph3D: Analyse der Szenen & Fixpunkte für den AgileX Piper Arm
|
||||
|
||||
**Ziel:** Identifikation von Interaktionsszenarien im FunGraph3D-Datensatz, bei denen ein Hindernis (*Obstacle*) das zu manipulierende Zielobjekt (*Target Object / Functional Sub-Part*) teilweise verdeckt oder im Anfahrtsbereich des Roboterarms liegt.
|
||||
**Hardware:** AgileX Piper 6-DoF Roboterarm (Reichweite ca. 620 mm, empfohlener Arbeitsabstand zur Basis: 350–500 mm).
|
||||
|
||||
---
|
||||
|
||||
## 🦾 Konzept: Validierung durch physikalisches Execution Grounding
|
||||
|
||||
```
|
||||
[Roboter-Basis / Piper Arm]
|
||||
│
|
||||
├─── (geplanter Pfad) ───▶ [Zielobjekt / Griff / Knopf]
|
||||
│ ▲
|
||||
[Hindernis / Nachbarobjekt] ──────────┘
|
||||
```
|
||||
|
||||
1. **Policy-Zuweisung:** Eine Resolution Policy generiert für einen Task (z. B. *„open the microwave oven“*) einen reduzierten Graphen.
|
||||
2. **MoveIt2-Planung (im reduzierten Graphen):**
|
||||
* *Gute Policy:* Behält das Hindernis (z. B. Spülmaschine oder Wasserkocher) als Bounding Box oder Point Cloud. MoveIt2 plant eine Ausweichbewegung oder meldet `infeasible`.
|
||||
* *Fehlerhafte Policy (Unterversorgung):* Entfernt das Hindernis (`REMOVE`). MoveIt2 plant eine scheinbar freie, direkte Trajektorie durch das Hindernis.
|
||||
3. **Kollisionsprüfung (gegen die volle Szene):**
|
||||
* Kollidiert die Trajektorie in der echten Punktwolke? $\to$ Klassifikation als **`unsafe`** (das entscheidende quantitative Fehlersignal!).
|
||||
|
||||
---
|
||||
|
||||
## 📍 Ausgewählte Szenen & Konkrete Fixpunkte
|
||||
|
||||
|
||||
### 🏠 Szene: `0kitchen`
|
||||
|
||||
| Task / Zielobjekt | Funktionsteil & Affordanz | Hindernis (*Obstacle*) | Distanz | Empfohlene Piper-Basispose $[x, y, z]$ |
|
||||
| :--- | :--- | :--- | :---: | :--- |
|
||||
| **kitchen cabinet** | `knob`<br>*pull to open or close* | **handle**<br>Pos: `[-0.023, -0.927, -0.544]` | 0.47 m | `[-0.029, -0.935, -0.763]` |
|
||||
| **kitchen cabinet** | `knob`<br>*pull to open or close* | **faucet / handle**<br>Pos: `[0.53, -0.921, -0.255]` | 0.548 m | `[0.497, -0.876, -0.763]` |
|
||||
| **kitchen cabinet** | `knob`<br>*pull to open or close* | **kitchen sink**<br>Pos: `[0.547, -0.562, -0.357]` | 0.35 m | `[0.652, -0.564, -0.763]` |
|
||||
| **kitchen cabinet** | `knob`<br>*pull to open or close* | **oven**<br>Pos: `[1.064, 0.333, -0.806]` | 0.47 m | `[1.062, 0.325, -1.006]` |
|
||||
| **kitchen cabinet** | `knob`<br>*pull to open or close* | **knob**<br>Pos: `[0.921, 0.187, 0.482]` | 0.381 m | `[0.913, 0.246, -0.022]` |
|
||||
| **kitchen cabinet** | `knob`<br>*pull to open or close* | **exhaust hood**<br>Pos: `[1.119, 0.202, 0.387]` | 0.361 m | `[1.174, 0.281, -0.022]` |
|
||||
|
||||
---
|
||||
|
||||
### 🏠 Szene: `3kitchen`
|
||||
|
||||
| Task / Zielobjekt | Funktionsteil & Affordanz | Hindernis (*Obstacle*) | Distanz | Empfohlene Piper-Basispose $[x, y, z]$ |
|
||||
| :--- | :--- | :--- | :---: | :--- |
|
||||
| **door** | `handle`<br>*rotate to open or close* | **handle**<br>Pos: `[-1.053, 0.445, -0.157]` | 0.503 m | `[-1.058, 0.467, -0.493]` |
|
||||
| **door** | `handle`<br>*rotate to open or close* | **fridge**<br>Pos: `[-1.206, 0.6, -0.273]` | 0.322 m | `[-1.23, 0.445, -0.493]` |
|
||||
| **door** | `handle`<br>*rotate to open or close* | **switch panel**<br>Pos: `[-1.355, 0.874, -0.136]` | 0.256 m | `[-1.528, 0.835, -0.493]` |
|
||||
| **fridge** | `handle`<br>*pull to open or close* | **handle**<br>Pos: `[-1.157, 0.918, -0.293]` | 0.503 m | `[-1.152, 0.896, -0.493]` |
|
||||
| **fridge** | `handle`<br>*pull to open or close* | **knob**<br>Pos: `[-0.874, 0.134, -0.469]` | 0.476 m | `[-0.872, 0.131, -0.669]` |
|
||||
| **fridge** | `handle`<br>*pull to open or close* | **switch panel**<br>Pos: `[-1.355, 0.874, -0.136]` | 0.525 m | `[-1.329, 0.837, -0.357]` |
|
||||
|
||||
---
|
||||
|
||||
### 🏠 Szene: `6kitchen`
|
||||
|
||||
| Task / Zielobjekt | Funktionsteil & Affordanz | Hindernis (*Obstacle*) | Distanz | Empfohlene Piper-Basispose $[x, y, z]$ |
|
||||
| :--- | :--- | :--- | :---: | :--- |
|
||||
| **dishwasher** | `dishwasher button / dishwasher switch`<br>*press to start and operate* | **kitchen cabinet**<br>Pos: `[0.47, -0.656, -0.739]` | 0.471 m | `[0.462, -0.656, -0.939]` |
|
||||
| **dishwasher** | `dishwasher button / dishwasher switch`<br>*press to start and operate* | **faucet / handle**<br>Pos: `[0.644, -1.089, -0.221]` | 0.528 m | `[0.662, -1.05, -0.654]` |
|
||||
| **dishwasher** | `dishwasher button / dishwasher switch`<br>*press to start and operate* | **kitchen sink**<br>Pos: `[0.454, -1.044, -0.411]` | 0.549 m | `[0.503, -0.996, -0.654]` |
|
||||
| **kitchen cabinet** | `knob`<br>*pull to open or close* | **handle**<br>Pos: `[-0.08, -0.613, -0.549]` | 0.352 m | `[-0.201, -0.607, -0.749]` |
|
||||
| **kitchen cabinet** | `knob`<br>*pull to open or close* | **knob**<br>Pos: `[0.107, -0.64, -0.469]` | 0.151 m | `[-0.216, -0.663, -0.669]` |
|
||||
| **kitchen cabinet** | `knob`<br>*pull to open or close* | **oven**<br>Pos: `[-0.075, -0.66, -0.761]` | 0.461 m | `[-0.089, -0.662, -0.961]` |
|
||||
|
||||
---
|
||||
|
||||
### 🏠 Szene: `10kitchen`
|
||||
|
||||
| Task / Zielobjekt | Funktionsteil & Affordanz | Hindernis (*Obstacle*) | Distanz | Empfohlene Piper-Basispose $[x, y, z]$ |
|
||||
| :--- | :--- | :--- | :---: | :--- |
|
||||
| **fridge** | `handle`<br>*pull to open or close* | **knob**<br>Pos: `[0.023, -0.991, -0.44]` | 0.38 m | `[-0.014, -0.946, -0.64]` |
|
||||
| **fridge** | `handle`<br>*pull to open or close* | **kitchen cabinet**<br>Pos: `[0.005, -1.007, -0.756]` | 0.257 m | `[-0.139, -0.873, -0.956]` |
|
||||
| **kitchen cabinet** | `knob`<br>*pull to open or close* | **handle**<br>Pos: `[0.165, -1.162, -0.131]` | 0.38 m | `[0.202, -1.207, -0.64]` |
|
||||
| **kitchen cabinet** | `knob`<br>*pull to open or close* | **fridge**<br>Pos: `[0.265, -1.368, -0.233]` | 0.493 m | `[0.259, -1.358, -0.64]` |
|
||||
| **kitchen cabinet** | `knob`<br>*pull to open or close* | **knob**<br>Pos: `[-0.087, -0.838, -0.468]` | 0.19 m | `[-0.254, -0.606, -0.668]` |
|
||||
| **kitchen cabinet** | `knob`<br>*pull to open or close* | **oven**<br>Pos: `[-0.263, -0.645, -0.715]` | 0.526 m | `[-0.237, -0.676, -0.915]` |
|
||||
|
||||
---
|
||||
|
||||
### 🏠 Szene: `12kitchen`
|
||||
|
||||
| Task / Zielobjekt | Funktionsteil & Affordanz | Hindernis (*Obstacle*) | Distanz | Empfohlene Piper-Basispose $[x, y, z]$ |
|
||||
| :--- | :--- | :--- | :---: | :--- |
|
||||
| **oven** | `button`<br>*press to open or close, or to adjust the setting* | **handle / knob**<br>Pos: `[-0.867, -0.158, -0.096]` | 0.487 m | `[-0.862, -0.153, -0.345]` |
|
||||
| **oven** | `button`<br>*press to open or close, or to adjust the setting* | **kitchen cabinet**<br>Pos: `[-0.886, -0.143, -0.45]` | 0.509 m | `[-0.868, -0.128, -0.65]` |
|
||||
| **exhaust hood** | `button`<br>*press to open or close, or to adjust the wind flow* | **kitchen cabinet**<br>Pos: `[-0.517, 0.531, 0.922]` | 0.439 m | `[-0.498, 0.546, 0.371]` |
|
||||
| **exhaust hood** | `button`<br>*press to open or close, or to adjust the wind flow* | **handle / knob**<br>Pos: `[-1.09, 0.03, 0.492]` | 0.505 m | `[-1.072, 0.047, 0.292]` |
|
||||
| **kitchen cabinet** | `handle / knob`<br>*pull to open or close* | **button**<br>Pos: `[-0.513, 0.172, -0.145]` | 0.487 m | `[-0.518, 0.168, -0.345]` |
|
||||
| **kitchen cabinet** | `handle / knob`<br>*pull to open or close* | **handle**<br>Pos: `[-0.519, 0.11, -0.202]` | 0.452 m | `[-0.497, 0.126, -0.402]` |
|
||||
|
||||
---
|
||||
|
||||
### 🏠 Szene: `1bathroom`
|
||||
|
||||
| Task / Zielobjekt | Funktionsteil & Affordanz | Hindernis (*Obstacle*) | Distanz | Empfohlene Piper-Basispose $[x, y, z]$ |
|
||||
| :--- | :--- | :--- | :---: | :--- |
|
||||
| **door** | `handle`<br>*rotate to open or close* | **switch panel**<br>Pos: `[1.722, 0.02, -0.28]` | 0.219 m | `[1.854, 0.234, -0.538]` |
|
||||
| **light fixture** | `switch panel`<br>*control, turn on or turn off* | **handle**<br>Pos: `[1.611, -0.16, -0.338]` | 0.219 m | `[1.48, -0.374, -0.538]` |
|
||||
| **light fixture** | `switch panel`<br>*control, turn on or turn off* | **door**<br>Pos: `[1.593, -0.442, -0.261]` | 0.48 m | `[1.593, -0.442, -0.48]` |
|
||||
|
||||
---
|
||||
|
||||
## 🛠️ Nächste Schritte zur Ausführung
|
||||
|
||||
1. **Docker Container bauen:**
|
||||
```bash
|
||||
cd docker
|
||||
docker compose build
|
||||
docker compose up -d
|
||||
docker compose exec piper_moveit bash
|
||||
```
|
||||
2. **MoveIt2 PlanningScene Aufbau (`collision_scene_builder.py`):**
|
||||
* Lädt die Punktwolke (`.ply`) für `POINT CLOUD`-Knoten.
|
||||
* Erzeugt orientierte 3D Bounding Boxes (`shape_msgs/msg/SolidPrimitive::BOX`) für `BOUNDING BOX`-Knoten.
|
||||
* Ignoriert `LABEL`- und `REMOVE`-Knoten.
|
||||
3. **Trajektorien-Planung:**
|
||||
* Starte MoveIt2 mit OMPL (`RRTConnect` oder `PRMstar`) mit festem Seed.
|
||||
* Plan von Ruhestellung (*Home Pose*) zur Pre-Grasp Pose (Offset von 5–10 cm vor dem Zielknoten).
|
||||
|
After Width: | Height: | Size: 486 KiB |
|
After Width: | Height: | Size: 317 KiB |
|
After Width: | Height: | Size: 811 KiB |
|
After Width: | Height: | Size: 742 KiB |
|
After Width: | Height: | Size: 788 KiB |
|
After Width: | Height: | Size: 682 KiB |
|
After Width: | Height: | Size: 261 KiB |
|
After Width: | Height: | Size: 110 KiB |
|
After Width: | Height: | Size: 281 KiB |
|
After Width: | Height: | Size: 204 KiB |
|
After Width: | Height: | Size: 434 KiB |
|
After Width: | Height: | Size: 371 KiB |
|
After Width: | Height: | Size: 177 KiB |
|
After Width: | Height: | Size: 92 KiB |
|
After Width: | Height: | Size: 131 KiB |
|
After Width: | Height: | Size: 58 KiB |
|
After Width: | Height: | Size: 155 KiB |
|
After Width: | Height: | Size: 55 KiB |
|
After Width: | Height: | Size: 299 KiB |
|
After Width: | Height: | Size: 139 KiB |
|
After Width: | Height: | Size: 228 KiB |
|
After Width: | Height: | Size: 50 KiB |
|
After Width: | Height: | Size: 123 KiB |
|
After Width: | Height: | Size: 51 KiB |
@@ -0,0 +1,147 @@
|
||||
# MoveIt2 Execution Grounding & Command Guide
|
||||
|
||||
Dieses Dokument fasst die wichtigsten Befehle, die technische MoveIt2-Integration von Subgraphen, die physikalische Kollisionsprüfung sowie das Konzept zur Überprüfung der Multi-Room-Navigierbarkeit zusammen.
|
||||
|
||||
---
|
||||
|
||||
# 1. 📋 Command Cheat-Sheet
|
||||
|
||||
### A. 3D-Visualisierung im Browser (Plotly)
|
||||
```bash
|
||||
# 0kitchen (Mikrowelle / Spülmaschine / Schränke)
|
||||
uv run --python 3.12 --with plyfile --with numpy --with plotly python tools/visualize_placement.py --scene 0kitchen --index 0
|
||||
uv run --python 3.12 --with plyfile --with numpy --with plotly python tools/visualize_placement.py --scene 0kitchen --index 1
|
||||
|
||||
# 3kitchen (Kaffeemaschine / Wasserkocher / Ofen)
|
||||
uv run --python 3.12 --with plyfile --with numpy --with plotly python tools/visualize_placement.py --scene 3kitchen --index 0
|
||||
|
||||
# 10kitchen (Toaster / Wasserkocher)
|
||||
uv run --python 3.12 --with plyfile --with numpy --with plotly python tools/visualize_placement.py --scene 10kitchen --index 0
|
||||
|
||||
# 1bathroom (Waschbecken / Tür)
|
||||
uv run --python 3.12 --with plyfile --with numpy --with plotly python tools/visualize_placement.py --scene 1bathroom --index 0
|
||||
|
||||
# 2livingroom (Fernseher / Heizung)
|
||||
uv run --python 3.12 --with plyfile --with numpy --with plotly python tools/visualize_placement.py --scene 2livingroom --index 0
|
||||
```
|
||||
|
||||
### B. Docker-Container Steuerung
|
||||
```bash
|
||||
# In den Docker-Ordner wechseln
|
||||
cd docker
|
||||
|
||||
# Container bauen & im Hintergrund starten
|
||||
docker compose build
|
||||
docker compose up -d
|
||||
|
||||
# In die laufende Bash-Konsole des Containers einloggen
|
||||
docker compose exec piper_moveit bash
|
||||
|
||||
# Container stoppen
|
||||
docker compose down
|
||||
```
|
||||
|
||||
### C. Im Docker-Container (ROS 2 & MoveIt2)
|
||||
```bash
|
||||
# 1. Reine RViz2-Visualisierung des Piper-Arms
|
||||
ros2 launch piper_with_gripper_moveit moveit_rviz.launch.py
|
||||
|
||||
# 2. Vollständige MoveIt2-Demo mit interaktivem Marker (Planen & Bewegen)
|
||||
ros2 launch piper_with_gripper_moveit demo.launch.py
|
||||
|
||||
# 3. Headless MoveGroup (für automatisierte Python-Skripte ohne GUI)
|
||||
ros2 launch piper_with_gripper_moveit move_group.launch.py
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
# 2. 🤖 Punktwolke in RViz & MoveIt2-Integration des Subgraphen
|
||||
|
||||
### Wie kommt die Punktwolke nach RViz2?
|
||||
Ein ROS 2 Node liest die `.ply`-Datei ein, konvertiert die 3D-Punkte in eine `sensor_msgs/msg/PointCloud2`-Nachricht und publiziert diese zyklisch (z. B. auf `/scene_pointcloud`). In RViz2 wird ein Display vom Typ **PointCloud2** hinzugefügt mit Topic `/scene_pointcloud` und Fixed Frame `world`.
|
||||
|
||||
```mermaid
|
||||
flowchart LR
|
||||
PLY[0kitchen.ply] --> Node[pointcloud_publisher_node]
|
||||
Node -->|sensor_msgs/PointCloud2| RViz[RViz2 Fenster]
|
||||
```
|
||||
|
||||
### Wie erfährt MoveIt2 vom Subgraphen der Policy?
|
||||
MoveIt2 plant Bewegungen nicht auf visuellen Rohdaten, sondern nutzt eine interne Kollisionswelt namens **`PlanningScene`**.
|
||||
Die `PlanningScene` wird über den ROS 2 Service / Topic `moveit_msgs/msg/PlanningScene` bzw. das Python-Interface `PlanningSceneInterface` aufgebaut:
|
||||
|
||||
```mermaid
|
||||
flowchart TD
|
||||
PR[Policy Result: Detail-Level pro Objekt] --> CSB[collision_scene_builder.py]
|
||||
|
||||
CSB -->|Detail: BOUNDING BOX| OBB[CollisionObject: shape_msgs/SolidPrimitive::BOX]
|
||||
CSB -->|Detail: POINT CLOUD| PC[CollisionObject: Bounding Box oder Octomap/Mesh]
|
||||
CSB -->|Detail: LABEL oder REMOVE| IGN[Wird NICHT in PlanningScene geladen!]
|
||||
|
||||
OBB --> PS[MoveIt2 PlanningScene]
|
||||
PC --> PS
|
||||
IGN -.->|Entfernt aus Planer-Sicht| PS
|
||||
```
|
||||
|
||||
* **`BOUNDING BOX`:** Wird als einfacher 3D-Quader (`BOX`) mit Zentrum, Maßen und Orientierung in MoveIt2 geladen.
|
||||
* **`POINT CLOUD`:** Wird als detailliertes Kollisionsobjekt (oder OctoMap-Gitter) geladen.
|
||||
* **`LABEL` / `REMOVE`:** Werden **überhaupt nicht** in die `PlanningScene` geladen! MoveIt2 „sieht“ diese Objekte nicht und betrachtet den Bereich als freien Raum.
|
||||
|
||||
---
|
||||
|
||||
# 3. 💥 Kollisionsprüfung: Wie erkennen wir, ob der Arm durch ungesehene Objekte greift?
|
||||
|
||||
Das ist der Kern des **Execution Groundings**. Die Überprüfung läuft in **zwei Stufen**:
|
||||
|
||||
```mermaid
|
||||
sequenceDiagram
|
||||
participant Planner as MoveIt2 Planer (Sieht nur Subgraph)
|
||||
participant Checker as FCL Kollisionsprüfung (Sieht volle Realität)
|
||||
|
||||
Note over Planner: Stufe 1: Pfadplanung im Subgraphen
|
||||
Planner->>Planner: Berechne Trajektorie T(t) von Basis zu Ziel
|
||||
Note over Planner: Wenn Hindernis auf 'REMOVE' stand:<br/>Planner findet freien, direkten Pfad!
|
||||
|
||||
Note over Checker: Stufe 2: Kollisions-Check gegen die volle Szene
|
||||
Planner->>Checker: Übergebe gefundene Gelenktrajektorie T(t)
|
||||
Checker->>Checker: Berechne Vorwärtskinematik aller Arm-Glieder
|
||||
Checker->>Checker: Prüfe Glieder gegen ALLE realen Punktwolken/OBBs
|
||||
|
||||
alt Keine Kollision mit realen Objekten
|
||||
Checker-->>Planner: 🟢 SAFE (Policy war ausreichend)
|
||||
else Kollidiert mit einem echten Objekt
|
||||
Checker-->>Planner: 🔴 UNSAFE (Policy hat Hindernis fälschlicherweise entfernt!)
|
||||
end
|
||||
```
|
||||
|
||||
### Die technische Umsetzung in Python:
|
||||
1. **Planung:** MoveIt2 plant eine Gelenkwinkelfolge $Q(t) = [q_1(t), q_2(t), \dots, q_6(t)]$ für z. B. 50 Zeitschritte.
|
||||
2. **Kollisions-Test:** Über die MoveIt2 C++/Python-API rufen wir `planning_scene.isStateColliding(robot_state)` auf – allerdings gegen eine **zweite, vollständige `PlanningScene_full`**, die alle realen Hindernisse enthält.
|
||||
3. Kollidiert auch nur ein Wegpunkt des Arms mit einem Objekt in `PlanningScene_full` $\to$ **`unsafe`**!
|
||||
|
||||
---
|
||||
|
||||
# 4. 🧭 Navigierbarkeit für die mobile Basis in Multi-Room-Szenen
|
||||
|
||||
Für einen mobilen Roboter, der durch mehrere Räume fährt, unterscheidet man zwei Ebenen:
|
||||
|
||||
```
|
||||
[Startraum: Flur] ──(Passage/Tür)──▶ [Zwischenraum: Wohnzimmer] ──(Tür)──▶ [Zielraum: Küche]
|
||||
```
|
||||
|
||||
### Ebene 1: Topologische Raum-Ebene (Sicherstellen, dass der Weg existiert)
|
||||
In Multi-Room-Szenen gibt es strukturierte Kanten:
|
||||
* `contains`: Raum $\to$ Objekt
|
||||
* `reachable`: Raum $A \leftrightarrow$ Raum $B$
|
||||
* `passage`: Raum $\to$ Tür-Objekt
|
||||
|
||||
**Vorgehen:**
|
||||
1. **Zielraum finden:** Die Policy bestimmt anhand des Tasks (z. B. *„open microwave“*), dass der Zielraum die `Küche` ist.
|
||||
2. **Pfad durch Räume finden:** Ein Graph-Suchalgorithmus (Dijkstra / A*) sucht den kürzesten Raum-Pfad vom Roboter-Startraum zum Zielraum.
|
||||
3. **Türen pinnen (*Framework-Invariante*):** Alle Türen und Durchgänge entlang dieses Pfades werden vom Framework **automatisch auf `POINT CLOUD` gepinnt**. Dadurch kann die Policy niemals eine Tür entfernen, die der Roboter öffnen oder durchfahren muss.
|
||||
|
||||
### Ebene 2: Geometrische 2D-Navigierbarkeit (Boden-Costmap)
|
||||
Um zu prüfen, ob der Roboter auf dem Boden nicht durch Schränke/Tische blockiert wird:
|
||||
1. Wir projizieren alle `POINT CLOUD`- und `BOUNDING BOX`-Objekte auf eine 2D-Gitterkarte (Occupancy Grid / Costmap auf Bodenebene).
|
||||
2. Ein 2D-A*- oder Dijkstra-Planer (analog zu Nav2) berechnet, ob eine Roboter-Grundfläche (z. B. $50 \times 50\,\text{cm}$) von der Startposition zur Ziel-Basispose navigieren kann.
|
||||
3. Wenn ein entfernter Schrank den Flur versperrt, würde der 2D-Pfad im echten Raum kollidieren $\to$ selbes `unsafe`-Prinzip wie beim Arm!
|
||||
@@ -0,0 +1,160 @@
|
||||
# AgileX Piper: Platzierungs- & Szenarien-Katalog (FunGraph3D)
|
||||
|
||||
Dieses Dokument definiert **präzise 3D-Fixpunkte für die Platzierung des AgileX Piper Arms** in den Szenen des FunGraph3D-Datensatzes.
|
||||
|
||||
---
|
||||
|
||||
## 🎯 Geometrische & Kinematische Randbedingungen
|
||||
|
||||
* **Roboterarm:** AgileX Piper (6-DoF)
|
||||
* **Maximalreichweite:** ca. $620\,\text{mm}$
|
||||
* **Optimaler Arbeitsbereich:** $350\,\text{mm} \le d_{\text{reach}} \le 550\,\text{mm}$
|
||||
* **Montagehöhe:** Typisch $z_{\text{base}} = z_{\text{floor}} + 0.50\,\text{m}$ (auf mobiler Plattform / Sockel)
|
||||
* **Testprinzip (*Execution Grounding*):**
|
||||
* Die Basis des Piper-Arms wird so platziert, dass das **Hindernis (*Obstacle*)** im direkten Anfahrtskorridor zwischen Armbasis und dem **Funktionsteil (*Target Part*)** liegt.
|
||||
* **Bei korrekter Policy:** Hindernis ist als Bounding Box / Point Cloud in MoveIt2 geladen $\to$ MoveIt2 plant eine Umgehungstrajektorie oder stoppt.
|
||||
* **Bei Unterversorgung (Hindernis entfernt):** MoveIt2 plant eine direkte lineare Trajektorie mitten durch das reale Hindernis $\to$ Kollisionsprüfung meldet **`unsafe`**!
|
||||
|
||||
```
|
||||
[Line of Sight / Direkter Pfad]
|
||||
[Piper Basis] =============================================▶ [Zielobjekt / Griff]
|
||||
( 💥 Kollision bei 'REMOVE' )
|
||||
▲
|
||||
[HINDERNIS / OBSTACLE]
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🏠 Ausgewählte Benchmark-Szenarien & Posen
|
||||
|
||||
|
||||
### 📍 Szene: `0kitchen`
|
||||
|
||||
| # | Zielobjekt & Funktionsteil | Natürlichsprachliche Affordanz | Hindernis (*Obstacle*) | Distanz Hindernis-Ziel | Piper Basis $[x, y, z]$ | Ausrichtung (Yaw) |
|
||||
| :-: | :--- | :--- | :--- | :---: | :--- | :---: |
|
||||
| 1 | **kitchen cabinet** (`knob`) | *pull to open or close* | **handle** | 47.0 cm | `[-0.01, -0.91, -0.74]` | 52° |
|
||||
| 2 | **kitchen cabinet** (`knob`) | *pull to open or close* | **kitchen sink** | 30.0 cm | `[0.60, -0.71, -0.74]` | 108° |
|
||||
| 3 | **kitchen cabinet** (`knob`) | *pull to open or close* | **oven** | 59.4 cm | `[1.05, 0.33, -0.74]` | -142° |
|
||||
| 4 | **oven** (`handle`) | *pull to open or close* | **knob** | 41.6 cm | `[1.21, 0.74, -0.74]` | -128° |
|
||||
| 5 | **oven** (`handle`) | *pull to open or close* | **kitchen cabinet** | 47.0 cm | `[1.23, 0.72, -0.74]` | -131° |
|
||||
| 6 | **fridge** (`handle`) | *pull to open or close* | **knob** | 47.0 cm | `[0.25, -0.57, -0.74]` | -128° |
|
||||
|
||||
---
|
||||
|
||||
### 📍 Szene: `10kitchen`
|
||||
|
||||
| # | Zielobjekt & Funktionsteil | Natürlichsprachliche Affordanz | Hindernis (*Obstacle*) | Distanz Hindernis-Ziel | Piper Basis $[x, y, z]$ | Ausrichtung (Yaw) |
|
||||
| :-: | :--- | :--- | :--- | :---: | :--- | :---: |
|
||||
| 1 | **fridge** (`handle`) | *pull to open or close* | **knob** | 29.8 cm | `[-0.12, -0.82, -0.77]` | -49° |
|
||||
| 2 | **fridge** (`handle`) | *pull to open or close* | **kitchen cabinet** | 25.7 cm | `[-0.16, -0.86, -0.77]` | -43° |
|
||||
| 3 | **kitchen cabinet** (`knob`) | *pull to open or close* | **handle** | 29.8 cm | `[0.32, -1.33, -0.77]` | 131° |
|
||||
| 4 | **kitchen cabinet** (`knob`) | *pull to open or close* | **knob** | 19.0 cm | `[-0.24, -0.63, -0.77]` | -54° |
|
||||
| 5 | **kitchen cabinet** (`knob`) | *pull to open or close* | **oven** | 52.6 cm | `[-0.26, -0.64, -0.77]` | -50° |
|
||||
| 6 | **oven** (`knob`) | *rotate to adjust the setting* | **handle** | 44.5 cm | `[0.19, -1.19, -0.77]` | 129° |
|
||||
|
||||
---
|
||||
|
||||
### 📍 Szene: `11bedroom`
|
||||
|
||||
| # | Zielobjekt & Funktionsteil | Natürlichsprachliche Affordanz | Hindernis (*Obstacle*) | Distanz Hindernis-Ziel | Piper Basis $[x, y, z]$ | Ausrichtung (Yaw) |
|
||||
| :-: | :--- | :--- | :--- | :---: | :--- | :---: |
|
||||
| 1 | **desk drawer** (`knob`) | *pull to open or close* | **power strip** | 36.0 cm | `[-0.61, -2.22, -0.76]` | 73° |
|
||||
| 2 | **lamp** (`power strip`) | *provide power* | **knob** | 36.0 cm | `[-0.45, -1.70, -0.76]` | -107° |
|
||||
| 3 | **lamp** (`power strip`) | *provide power* | **desk drawer** | 49.6 cm | `[-0.23, -1.85, -0.76]` | -141° |
|
||||
|
||||
---
|
||||
|
||||
### 📍 Szene: `12kitchen`
|
||||
|
||||
| # | Zielobjekt & Funktionsteil | Natürlichsprachliche Affordanz | Hindernis (*Obstacle*) | Distanz Hindernis-Ziel | Piper Basis $[x, y, z]$ | Ausrichtung (Yaw) |
|
||||
| :-: | :--- | :--- | :--- | :---: | :--- | :---: |
|
||||
| 1 | **oven** (`button`) | *press to open or close, or to adjust the setting* | **kitchen cabinet** | 57.6 cm | `[-0.86, -0.12, -0.45]` | 40° |
|
||||
| 2 | **oven** (`button`) | *press to open or close, or to adjust the setting* | **handle / knob** | 49.9 cm | `[-0.84, -0.13, -0.45]` | 43° |
|
||||
| 3 | **kitchen cabinet** (`handle / knob`) | *pull to open or close* | **button** | 40.7 cm | `[-0.54, 0.15, -0.45]` | -136° |
|
||||
| 4 | **kitchen cabinet** (`handle / knob`) | *pull to open or close* | **oven** | 56.4 cm | `[-0.55, 0.16, -0.45]` | -135° |
|
||||
| 5 | **kitchen cabinet** (`handle / knob`) | *pull to open or close* | **handle** | 45.2 cm | `[-0.51, 0.12, -0.45]` | -142° |
|
||||
| 6 | **oven** (`handle`) | *pull to open or close* | **kitchen cabinet** | 51.1 cm | `[-0.89, -0.15, -0.45]` | 35° |
|
||||
|
||||
---
|
||||
|
||||
### 📍 Szene: `1bathroom`
|
||||
|
||||
| # | Zielobjekt & Funktionsteil | Natürlichsprachliche Affordanz | Hindernis (*Obstacle*) | Distanz Hindernis-Ziel | Piper Basis $[x, y, z]$ | Ausrichtung (Yaw) |
|
||||
| :-: | :--- | :--- | :--- | :---: | :--- | :---: |
|
||||
| 1 | **toilet** (`handle`) | *press to flush* | **button / knob** | 59.2 cm | `[0.77, 0.27, -0.83]` | 153° |
|
||||
|
||||
---
|
||||
|
||||
### 📍 Szene: `3kitchen`
|
||||
|
||||
| # | Zielobjekt & Funktionsteil | Natürlichsprachliche Affordanz | Hindernis (*Obstacle*) | Distanz Hindernis-Ziel | Piper Basis $[x, y, z]$ | Ausrichtung (Yaw) |
|
||||
| :-: | :--- | :--- | :--- | :---: | :--- | :---: |
|
||||
| 1 | **kitchen cabinet** (`knob`) | *pull to open or close* | **kitchen sink** | 43.5 cm | `[-0.85, -0.63, -0.77]` | 20° |
|
||||
| 2 | **kitchen cabinet** (`knob`) | *pull to open or close* | **knob** | 32.7 cm | `[0.03, -1.12, -0.77]` | 125° |
|
||||
| 3 | **oven** (`knob`) | *rotate to adjust temperature or setting, open or close* | **knob** | 54.4 cm | `[-0.30, -0.65, -0.77]` | -55° |
|
||||
|
||||
---
|
||||
|
||||
### 📍 Szene: `4livingroom`
|
||||
|
||||
| # | Zielobjekt & Funktionsteil | Natürlichsprachliche Affordanz | Hindernis (*Obstacle*) | Distanz Hindernis-Ziel | Piper Basis $[x, y, z]$ | Ausrichtung (Yaw) |
|
||||
| :-: | :--- | :--- | :--- | :---: | :--- | :---: |
|
||||
| 1 | **kitchen cabinet** (`handle`) | *pull to open or close* | **handle** | 53.6 cm | `[1.51, -1.82, -0.76]` | -131° |
|
||||
| 2 | **kitchen cabinet** (`handle`) | *pull to open or close* | **knob** | 37.4 cm | `[1.52, -1.83, -0.76]` | -133° |
|
||||
| 3 | **kitchen cabinet** (`handle`) | *pull to open or close* | **oven** | 57.6 cm | `[1.54, -1.85, -0.76]` | -136° |
|
||||
| 4 | **oven** (`handle`) | *pull to open or close* | **handle** | 46.3 cm | `[1.26, -2.10, -0.76]` | 49° |
|
||||
| 5 | **oven** (`handle`) | *pull to open or close* | **kitchen cabinet** | 57.1 cm | `[1.28, -2.12, -0.76]` | 52° |
|
||||
| 6 | **oven** (`knob`) | *rotate to open or close, or to adjust the setting and temperature* | **handle** | 37.4 cm | `[1.16, -2.22, -0.76]` | 47° |
|
||||
|
||||
---
|
||||
|
||||
### 📍 Szene: `5kitchen`
|
||||
|
||||
| # | Zielobjekt & Funktionsteil | Natürlichsprachliche Affordanz | Hindernis (*Obstacle*) | Distanz Hindernis-Ziel | Piper Basis $[x, y, z]$ | Ausrichtung (Yaw) |
|
||||
| :-: | :--- | :--- | :--- | :---: | :--- | :---: |
|
||||
| 1 | **kitchen cabinet** (`knob`) | *pull to open or close* | **kitchen sink** | 39.4 cm | `[-0.78, -0.70, -0.76]` | 4° |
|
||||
| 2 | **kitchen cabinet** (`knob`) | *pull to open or close* | **knob** | 19.8 cm | `[-0.94, 0.23, -0.76]` | -57° |
|
||||
| 3 | **kitchen cabinet** (`knob`) | *pull to open or close* | **handle** | 41.9 cm | `[-0.92, 0.24, -0.76]` | -60° |
|
||||
| 4 | **kitchen cabinet** (`knob`) | *pull to open or close* | **oven** | 52.8 cm | `[-0.97, 0.21, -0.76]` | -53° |
|
||||
| 5 | **oven** (`knob`) | *rotate to adjust the setting or temperature, or to open or close* | **knob** | 19.8 cm | `[-0.56, -0.36, -0.76]` | 123° |
|
||||
| 6 | **oven** (`handle`) | *pull to open or close* | **knob** | 40.6 cm | `[-0.67, -0.19, -0.76]` | 121° |
|
||||
|
||||
---
|
||||
|
||||
### 📍 Szene: `6kitchen`
|
||||
|
||||
| # | Zielobjekt & Funktionsteil | Natürlichsprachliche Affordanz | Hindernis (*Obstacle*) | Distanz Hindernis-Ziel | Piper Basis $[x, y, z]$ | Ausrichtung (Yaw) |
|
||||
| :-: | :--- | :--- | :--- | :---: | :--- | :---: |
|
||||
| 1 | **dishwasher** (`dishwasher button / dishwasher switch`) | *press to start and operate* | **kitchen cabinet** | 47.1 cm | `[0.39, -0.66, -0.74]` | -0° |
|
||||
| 2 | **kitchen cabinet** (`knob`) | *pull to open or close* | **handle** | 35.2 cm | `[-0.19, -0.61, -0.74]` | -3° |
|
||||
| 3 | **kitchen cabinet** (`knob`) | *pull to open or close* | **knob** | 15.1 cm | `[-0.19, -0.66, -0.74]` | 4° |
|
||||
| 4 | **kitchen cabinet** (`knob`) | *pull to open or close* | **oven** | 46.1 cm | `[-0.19, -0.67, -0.74]` | 6° |
|
||||
| 5 | **oven** (`handle`) | *pull to open or close* | **kitchen cabinet** | 58.3 cm | `[0.37, -0.65, -0.74]` | 176° |
|
||||
| 6 | **oven** (`handle`) | *pull to open or close* | **knob** | 35.2 cm | `[0.37, -0.63, -0.74]` | 177° |
|
||||
|
||||
---
|
||||
|
||||
## 💻 Verwendung in ROS 2 / Python
|
||||
|
||||
Die Posen können direkt in ROS 2 MoveIt2 geladen werden, um den Arm und die PlanningScene zu initialisieren:
|
||||
|
||||
```python
|
||||
import rclpy
|
||||
from geometry_msgs.msg import PoseStamped
|
||||
import tf_transformations
|
||||
|
||||
def spawn_piper_at_base(node, base_pos, yaw_deg):
|
||||
# base_pos: [x, y, z] in Scene coordinates
|
||||
q = tf_transformations.quaternion_from_euler(0, 0, np.radians(yaw_deg))
|
||||
|
||||
base_pose = PoseStamped()
|
||||
base_pose.header.frame_id = "world"
|
||||
base_pose.pose.position.x = base_pos[0]
|
||||
base_pose.pose.position.y = base_pos[1]
|
||||
base_pose.pose.position.z = base_pos[2]
|
||||
base_pose.pose.orientation.x = q[0]
|
||||
base_pose.pose.orientation.y = q[1]
|
||||
base_pose.pose.orientation.z = q[2]
|
||||
base_pose.pose.orientation.w = q[3]
|
||||
return base_pose
|
||||
```
|
||||
@@ -0,0 +1,242 @@
|
||||
# Task-Driven 3D Scene Graphs: Execution Grounding Benchmark (AgileX Piper & MoveIt 2)
|
||||
|
||||
[](https://docs.ros.org/en/humble/)
|
||||
[](https://moveit.picknik.ai/humble/)
|
||||
[](https://github.com/agilexrobotics/piper_ros)
|
||||
[](https://github.com/Simon-Schaefer/FunGraph3D)
|
||||
|
||||
Dieses Repository enthält die vollständige **Execution-Grounding- und Validierungs-Pipeline** für aufgabengetriebene 3D-Szenengraphen (*Task-Driven Resolution Policies in Functional 3D Scene Graphs*).
|
||||
|
||||
Die Pipeline evaluiert, ob durch Graphenkompression erzeugte Subgraphen ausreichen, damit ein **6-DoF Knickarmroboter (AgileX Piper)** Zielobjekte physikalisch kollisionsfrei manipulieren kann, oder ob der Arm durch ungesehene Hindernisse greift.
|
||||
|
||||
---
|
||||
|
||||
## 🏗️ Systemarchitektur
|
||||
|
||||
```mermaid
|
||||
flowchart TD
|
||||
subgraph Data [1. FunGraph3D Datensatz]
|
||||
PLY[3D Punktwolke: scene.ply]
|
||||
ANN[Annotationen: 348 Objekte]
|
||||
REL[Affordanzen: 230 Relationen]
|
||||
end
|
||||
|
||||
subgraph Policy_Layer [2. Resolution Policy / Subgraph]
|
||||
TASK[Task: z.B. 'open microwave']
|
||||
POL[Policy: z.B. Combined Quantile / Radius]
|
||||
SUB[PolicyResult: Detail-Level pro Objekt]
|
||||
end
|
||||
|
||||
subgraph MoveIt2_Planning [3. MoveIt 2 & OMPL in ROS 2 Humble]
|
||||
DOCKER[Docker Container: ROS 2 Humble + MoveIt 2]
|
||||
PIPER[AgileX Piper 6-DoF URDF / Kinematik]
|
||||
PS_RED[MoveIt2 PlanningScene: Reduzierter Subgraph]
|
||||
OMPL[OMPL Planer: RRTConnect]
|
||||
end
|
||||
|
||||
subgraph Validation [4. Ground-Truth Kollisionsprüfung]
|
||||
TRAJ[Geplante Gelenktrajektorie Q t]
|
||||
PS_FULL[PlanningScene: Reale Gesamtszene]
|
||||
CHECK[FCL Kollisionsprüfung]
|
||||
|
||||
SAFE[🟢 SAFE: Kollisionsfreier Ausweichpfad]
|
||||
UNSAFE[🔴 UNSAFE: Kollision mit ungesehenem Objekt 💥]
|
||||
INF[⚪ INFEASIBLE: Kein Pfad möglich]
|
||||
end
|
||||
|
||||
PLY --> PS_FULL
|
||||
ANN --> POL
|
||||
REL --> POL
|
||||
TASK --> POL
|
||||
POL --> SUB
|
||||
|
||||
SUB --> PS_RED
|
||||
PIPER --> OMPL
|
||||
PS_RED --> OMPL
|
||||
OMPL --> TRAJ
|
||||
|
||||
TRAJ --> CHECK
|
||||
PS_FULL --> CHECK
|
||||
CHECK --> SAFE
|
||||
CHECK --> UNSAFE
|
||||
OMPL -->|Kein Pfad im Subgraphen| INF
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 📂 Repository-Struktur
|
||||
|
||||
```
|
||||
.
|
||||
├── docker/ # Docker-Umgebung (ROS 2 Humble + MoveIt 2 + Piper ROS)
|
||||
│ ├── Dockerfile # Basiert auf osrf/ros:humble-desktop-full
|
||||
│ ├── docker-compose.yml # Mounts für Workspace, Dataset und WSLg GUI-Forwarding
|
||||
│ ├── entrypoint.sh # Automatisches Sourcing von ROS 2 und Piper-Workspace
|
||||
│ └── README.md # Kurzanleitung für Docker-Container
|
||||
│
|
||||
├── Dataset/ # FunGraph3D Datensatz
|
||||
│ └── FunGraph3D/FunGraph3D/ # 14 Szenen (.ply, .annotations.json, .relations.json)
|
||||
│
|
||||
├── src/ # ROS 2 / MoveIt 2 Benchmark & Evaluatoren
|
||||
│ ├── moveit2_batch_grounding.py # MoveGroup-Action-Benchmark über alle Szenen (Docker)
|
||||
│ ├── test_single_moveit_action.py # Einzeltest-Skript für den MoveGroup Action Client
|
||||
│ └── test_arm_execution_grounding.py # Schneller Standalone-Prototyp (reines Python)
|
||||
│
|
||||
├── tools/ # Hilfswerkzeuge & Visualisierung
|
||||
│ ├── render_scene_images.py # Automatische 3D-PNG-Renderings für Paper & Präsentationen
|
||||
│ └── visualize_placement.py # Interaktiver 3D-Plotly-Viewer für den Browser
|
||||
│
|
||||
├── figures/ # Abbildungen & Plots
|
||||
│ └── generated/ # Automatisch gerenderte PNG-Szenenbilder
|
||||
│
|
||||
├── results/ # Benchmark-Ergebnisse & Metriken
|
||||
│ ├── moveit2_real_benchmark_results.json # Echte MoveIt2-Ergebnisse (192 Fälle)
|
||||
│ └── execution_grounding_oracle_vs_blind.json
|
||||
│
|
||||
├── scratch/ # Vorverarbeitungs- & Analyse-Skripte
|
||||
│ └── verified_placements.json # 192 berechnete Fixpunkte (Basis, Ziel, Hindernis)
|
||||
│
|
||||
├── Piper_Placements_and_Benchmark_Scenarios.md # Vollständiger Posenkatalog
|
||||
├── MoveIt2_Execution_Grounding_and_Commands_Guide.md # Befehls- & Schnittstellen-Leitfaden
|
||||
└── README.md # Diese Dokumentation
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🚀 Schnellstart & Installation
|
||||
|
||||
### Voraussetzungen
|
||||
* **Docker** & **Docker Compose**
|
||||
* Für GUI-Anzeige (RViz2) unter Windows: **WSL2 mit WSLg** (Windows 11) oder ein X-Server wie VcXsrv.
|
||||
* Für lokale Python-Tools: [uv](https://github.com/astral-sh/uv) oder Python 3.10+.
|
||||
|
||||
### 1. Docker-Container starten
|
||||
```bash
|
||||
cd docker
|
||||
docker compose build
|
||||
docker compose up -d
|
||||
```
|
||||
|
||||
### 2. In den Container einloggen
|
||||
```bash
|
||||
docker compose exec piper_moveit bash
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🎮 Den MoveIt 2 Benchmark ausführen
|
||||
|
||||
Im Docker-Container benötigst du zwei Terminal-Instanzen:
|
||||
|
||||
### Terminal 1: MoveIt 2 MoveGroup starten
|
||||
```bash
|
||||
docker compose exec piper_moveit bash
|
||||
ros2 launch piper_with_gripper_moveit demo.launch.py
|
||||
```
|
||||
*(Hinweis: Für reine Hintergrund-Batch-Läufe ohne GUI-Fenster kannst du stattdessen `ros2 launch piper_with_gripper_moveit move_group.launch.py` nutzen).*
|
||||
|
||||
### Terminal 2: Den Benchmark-Node starten
|
||||
```bash
|
||||
docker compose exec piper_moveit bash
|
||||
|
||||
# Teste z. B. die ersten 10 Fälle:
|
||||
python3 /workspace/src/moveit2_batch_grounding.py --max-cases 10
|
||||
|
||||
# Vollständiger Benchmark über alle 192 Fälle:
|
||||
python3 /workspace/src/moveit2_batch_grounding.py
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 📊 Benchmark-Ergebnisse (Baseline Validierung)
|
||||
|
||||
Die Pipeline wurde über alle **192 Interaktionskandidaten aus allen 14 Szenen** von FunGraph3D evaluiert.
|
||||
Es wurden die beiden theoretischen Extremschranken (*Upper & Lower Bound*) getestet:
|
||||
|
||||
| Modus | Beschreibung | 🟢 `SAFE` | 🔴 `UNSAFE` (Kollision) | ⚪ `INFEASIBLE` |
|
||||
| :--- | :--- | :---: | :---: | :---: |
|
||||
| **`FULL SCENE` (Oracle)** | Vollständige reale Szene in MoveIt2 geladen | **91.7 %** (176/192) | **0.0 %** (0/192) | **8.3 %** (16/192) |
|
||||
| **`EMPTY SCENE` (Blind)** | Alle Hindernisse entfernt (*All-REMOVE*) | **0.0 %** (0/192) | **100.0 %** (192/192) | **0.0 %** (0/192) |
|
||||
|
||||
```
|
||||
======================================================================
|
||||
MOVEIT 2 REAL BENCHMARK RESULTS (192 Testfälle)
|
||||
======================================================================
|
||||
FULL SCENE (Oracle): SAFE: 176 (91.7%) | UNSAFE: 0 (0.0%) | INFEASIBLE: 16 (8.3%)
|
||||
EMPTY SCENE (Blind): SAFE: 0 (0.0%) | UNSAFE: 192 (100.0%) | INFEASIBLE: 0 (0.0%)
|
||||
======================================================================
|
||||
```
|
||||
|
||||
### Wissenschaftliche Erkenntnis:
|
||||
1. **0.0 % Unsafe bei `FULL SCENE`:** MoveIt2 plant zuverlässig echte 6-DoF-Ausweichtrajektorien um Hindernisse herum.
|
||||
2. **100.0 % Unsafe bei `EMPTY SCENE`:** Werden blockierende Hindernisse durch fehlerhafte Policies aus dem Graphen gelöscht, greift der Arm blind durch das Objekt hindurch $\to$ die Kollisionsüberwachung schlägt zu $100\,\%$ zuverlässig an!
|
||||
|
||||
---
|
||||
|
||||
## 📸 Automatische 3D-Bildgenerierung für Paper & Präsentationen
|
||||
|
||||
Mit dem Skript [`tools/render_scene_images.py`](file:///c:/Users/dennis/Documents/Maloche/Simon/Task_driven_Scenegraphs/tools/render_scene_images.py) können vollautomatisch hochauflösende 3D-Bilder (200 DPI PNG) der Manipulationssituationen erzeugt werden:
|
||||
|
||||
```bash
|
||||
# Generiere die ersten 10 Szenarien als PNG:
|
||||
uv run --python 3.12 --with matplotlib --with plyfile --with numpy python tools/render_scene_images.py --count 10
|
||||
|
||||
# Gezielt für eine bestimmte Szene (z. B. 0kitchen, 3kitchen oder 1bathroom):
|
||||
uv run --python 3.12 --with matplotlib --with plyfile --with numpy python tools/render_scene_images.py --scene 0kitchen --count 5
|
||||
uv run --python 3.12 --with matplotlib --with plyfile --with numpy python tools/render_scene_images.py --scene 3kitchen --count 5
|
||||
```
|
||||
|
||||
### Visualisierte Bildelemente:
|
||||
* 🏠 **Reale 3D-Punktwolke:** Die Umgebung im echten RGB-Farbraum.
|
||||
* 🟢 **Grüner Diamant:** Das Zielobjekt / der Schrankknauf.
|
||||
* 🔴 **Rotes Quadrat:** Das reale Hindernis (z. B. Spüle, Kessel, Spülmaschine).
|
||||
* 🔵 **Blauer Kreis:** Die Basis des Piper-Roboters mit Ausrichtungswinkel.
|
||||
* 🔵 **Türkise durchgezogene Linie:** Der von MoveIt 2 geplante Ausweichpfad (**Oracle: `SAFE`**).
|
||||
* 🟠 **Orange gestrichelte Linie:** Der blinde Pfad der fehlerhaften Policy (**Blind Baseline: `UNSAFE`**, der mitten durch das Hindernis schneidet).
|
||||
|
||||
*Die generierten Bilder werden direkt im Ordner `figures/generated/` gespeichert.*
|
||||
|
||||
---
|
||||
|
||||
## 🌐 Interaktiver 3D-Szenen-Viewer (Plotly)
|
||||
|
||||
Jede Szene und Platzierung kann zusätzlich direkt auf dem Host-Rechner interaktiv im Browser in 3D rotiert und gezoomt werden:
|
||||
|
||||
```bash
|
||||
# Beispiel: Szene 0kitchen, Platzierung 0
|
||||
uv run --python 3.12 --with plyfile --with numpy --with plotly python tools/visualize_placement.py --scene 0kitchen --index 0
|
||||
|
||||
# Beispiel: Szene 3kitchen (Kaffeemaschine / Wasserkocher)
|
||||
uv run --python 3.12 --with plyfile --with numpy --with plotly python tools/visualize_placement.py --scene 3kitchen --index 0
|
||||
|
||||
# Beispiel: Szene 1bathroom (Waschbecken / Armatur)
|
||||
uv run --python 3.12 --with plyfile --with numpy --with plotly python tools/visualize_placement.py --scene 1bathroom --index 0
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🔌 Schnittstelle zur Integration von Resolution Policies
|
||||
|
||||
Um eine neue Subgraphen-Policy zu evaluieren, übergibt man dem Evaluator einfach das resultierende Dictionary der Detailstufen:
|
||||
|
||||
```python
|
||||
# Schema eines Policy-Ergebnisses:
|
||||
policy_result = {
|
||||
"node_annot_id_1": "POINT CLOUD", # Detailliertes Kollisionsobjekt
|
||||
"node_annot_id_2": "BOUNDING BOX", # 3D-Quader (SolidPrimitive::BOX)
|
||||
"node_annot_id_3": "LABEL", # Nicht in MoveIt2 geladen (Kompression)
|
||||
"node_annot_id_4": "REMOVE" # Nicht in MoveIt2 geladen (Kompression)
|
||||
}
|
||||
|
||||
# MoveIt2 baut die PlanningScene auf Basis der Zuweisung auf:
|
||||
# - 'BOUNDING BOX' & 'POINT CLOUD' werden als Hindernisse registriert.
|
||||
# - 'LABEL' & 'REMOVE' werden ignoriert.
|
||||
# - Trajektorie wird geplant und gegen die reale Gesamtszene validiert.
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 📜 Lizenz & Zitation
|
||||
|
||||
Dieses Projekt basiert auf den Forschungsarbeiten zu *Task-Driven Resolution Policies in Functional 3D Scene Graphs* und dem *FunGraph3D*-Datensatz.
|
||||
Hardware-Modelle und Treiber für den Piper-Arm stammen von [AgileX Robotics](https://github.com/agilexrobotics/piper_ros).
|
||||
@@ -0,0 +1,130 @@
|
||||
# ICRA 2027 Submission: Team Briefing für Team „CO“
|
||||
**Track:** Track B – *Execution Grounding (Simulation & Trajektorien-Validierung)*
|
||||
**Paper-Arbeitstitel:** *Task-Driven Resolution Policies for Varying-Density Functional 3D Scene Graphs*
|
||||
**Deadline:** 15. September 2026, 23:59 PST
|
||||
**Basis:** Bachelorarbeit Nils Ferber (S35)
|
||||
|
||||
---
|
||||
|
||||
## 📌 Executive Summary für Team CO
|
||||
|
||||
> **Dein Track trägt den primären Neuheitsanspruch (*Lead Novelty Claim*) des gesamten ICRA-Papers!**
|
||||
|
||||
Während alle anderen Resultate des Papers auf der selbst erstellten Ground-Truth-Annotation basieren (was Reviewer als zirkulär oder voreingenommen kritisieren könnten), liefert dein Experiment den **physikalischen, annotationsunabhängigen Beweis**:
|
||||
**Was kostet eine Graphenreduktion in der echten Roboter-Ausführung?**
|
||||
|
||||
```mermaid
|
||||
flowchart TD
|
||||
subgraph Track_B [Track B: Execution Grounding (Team CO)]
|
||||
PR[PolicyResult / Reduzierter Graph] --> CSB[collision_scene_builder.py]
|
||||
CSB --> PS[MoveIt2 PlanningScene<br/>OBBs für BBox / OctoMap für PointCloud]
|
||||
PS --> MP[Trajektorien-Planer<br/>OMPL / festes Seed]
|
||||
MP --> TP[Geplante Trajektorie]
|
||||
TP --> CC[Kollisionsprüfung gegen VOLLEN Graphen]
|
||||
CC --> R1[🟢 safe: Planbar & Kollisionsfrei]
|
||||
CC --> R2[🔴 unsafe: Plant im reduzierten, KOLLIDIERT im vollen]
|
||||
CC --> R3[⚪ infeasible: Kein Pfad im reduzierten Graphen]
|
||||
end
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🎯 1. Deine Kernaufgabe (Track B)
|
||||
|
||||
Du implementierst eine **simulationsbasierte Validierungspipeline mit ROS 2 Humble & MoveIt2**:
|
||||
1. Eine Trajektorie wird auf dem **reduzierten Graphen** einer Resolution Policy geplant.
|
||||
2. Diese geplante Trajektorie wird anschließend gegen die **vollständige, dichte 3D-Geometrie der Szene** kollisionsgeprüft.
|
||||
3. Jeder Testfall liefert eines von **drei eindeutigen Ergebnissen**:
|
||||
* **`safe`**: Trajektorie wird im reduzierten Graphen gefunden **und** ist in der vollen Szene kollisionsfrei.
|
||||
* **`unsafe`**: Trajektorie wird im reduzierten Graphen gefunden, **kollidiert jedoch in der vollen Szene** (*das entscheidende neue Fehlersignal!*).
|
||||
* **`infeasible`**: Im reduzierten Graphen konnte überhaupt keine Trajektorie geplant werden (wird separat erfasst).
|
||||
|
||||
---
|
||||
|
||||
## 📅 2. Zeitplan & Meilensteine (Deadlines für CO)
|
||||
|
||||
| Zeitraum / Datum | Aufgabe / Meilenstein | Wichtige Hinweise |
|
||||
| :--- | :--- | :--- |
|
||||
| **15. August** *(Tag 1)* | **Entscheidung Roboterarm** (Panda vs. Piper) | Demo-Launch testen (siehe Entscheidungsregel). |
|
||||
| **15.–20. August** | **Setup MoveIt2 / URDF & Reachability** | Sauberes Laden von URDF+SRDF. Erreichbarkeit in 3 Szenen prüfen (verhindert spätes Scheitern). |
|
||||
| **20. August** | 🛑 **GATE 1** | Erreicht der Arm die Ziele in 3 Szenen? Wenn nein: Basis-Pose-Heuristik in 24 h fixen. |
|
||||
| **21.–25. August** | **`collision_scene_builder.py`** | Rekonstruiert `PlanningScene` aus `PolicyResult` (OBBs für Bounding Boxes, Octomap für Point Clouds). |
|
||||
| **26. August** | 🚨 **GATE 2 (HARD ABANDON)** | **Läuft mindestens 1 End-to-End-Trajektorie inkl. Kollisionsprüfung?** *(Siehe Gate-Regel!)* |
|
||||
| **27.–29. August** | **Batch-Harness über 6 Policies** | Testen von: `identity`, `combined_quantile_adaptive`, `composite_adaptive`, `rule_expert`, `information_bottleneck`, `label_only`. |
|
||||
| **30.–31. August** | **Finale Messläufe mit festem Seed** | Fester Planner-Seed ist Pflicht! Logging von `safe`/`unsafe`/`infeasible` & Clearance-Margen. |
|
||||
| **1.–7. September** | **Paper Drafting (Section V-F)** | Schreiben von Section V-F (*Execution Grounding*, ca. 0.55 Seiten) gemeinsam mit PI & ST. |
|
||||
|
||||
---
|
||||
|
||||
## ⚠️ 3. Kritische Entscheidungsregeln & Richtlinien für CO
|
||||
|
||||
### A. Roboterarm-Wahl: AgileX Piper vs. Franka Panda (Entscheidung am 15. August)
|
||||
* **Kontext:** Das Labor besitzt einen *Agilex Piper* (auf Husarion Panther) sowie Treiber/URDFs (`piper_moveit2`, `piper_ros`, `agx_arm_urdf`). Den Piper im Paper zu haben wäre ideal für den späteren Hardware-Transfer.
|
||||
* **Entscheidungsregel:**
|
||||
* Starte am **15. August** den Demo-Launch des **Piper**.
|
||||
* Wenn er **innerhalb eines Tages** stabil plant $\to$ **Piper verwenden**.
|
||||
* Wenn er zickt oder Fehler wirft $\to$ **sofort auf Franka Emika Panda wechseln**! Der Panda hat den höchsten MoveIt2-Reifegrad, größere Reichweite und höhere Traglast. *Gate 2 darf nicht für Treiber-Debugging riskiert werden.*
|
||||
|
||||
### B. Gate 2 – Die harte Abbruchkante (26. August)
|
||||
* Es gibt **keine „Rettungswoche“**! Wenn am 26. August keine End-to-End-Trajektorie steht, wird Track B an diesem Tag abgebrochen.
|
||||
* Die Paper-Beiträge sinken dann von 5 auf 4, und du wechselst zur Unterstützung beim Schreiben von Section IV (Benchmark & Metrik).
|
||||
|
||||
### C. Scope & Eingrenzung (Extrem schlank halten!)
|
||||
* **Datensatz:** Nur Single-Room-Szenen, bei denen das Zielobjekt als `point_cloud` überlebt hat (ca. **40–60 Fälle**).
|
||||
* **Roboter-Setup:** Standard-Arm (kein Custom-URDF). Feste Roboter-Basispose direkt aus dem im `PolicyContext` vorhandenen Pose-Feld übernehmen.
|
||||
* **Greifziel:** Pre-Grasp-Pose berechnet als Versatz (*Offset*) entlang der Annäherungsachse der Ziel-Bounding-Box.
|
||||
|
||||
### D. Was passiert, wenn alle Policies 0 % `unsafe` zeigen?
|
||||
* **Das ist KEIN Fehlschlag!**
|
||||
* Es bedeutet wissenschaftlich, dass die manuell annotierte Kollisions-Bounding-Box-Bandbreite über-konservativ war.
|
||||
* In diesem Fall werden statt Ausfallraten die **Abstandsmargen zu Hindernissen (*Clearance Margins*)** als Verteilungsplot ausgewiesen.
|
||||
|
||||
---
|
||||
|
||||
## 📝 4. Zu testende Policies im Batch-Lauf (27.–31. August)
|
||||
|
||||
Du evaluierst genau **6 ausgewählte Policies**:
|
||||
1. `identity`: Volle Punktwolke (obere Schranke / Referenz).
|
||||
2. `combined_quantile_adaptive`: Die empfohlene, parameterfreie Best-Practice-Policy.
|
||||
3. `composite_adaptive`: Die neue kombinierte Policy von ST.
|
||||
4. `rule_expert`: Die neue handgeschriebene Experten-Heuristik (Distanz + Kategorie).
|
||||
5. `information_bottleneck`: Die agglomerative informationstheoretische Policy.
|
||||
6. `label_only`: Die Negativkontrolle (ohne Sub-Part-Vererbung; sollte hohe Kollisions- oder Infeasible-Raten provozieren).
|
||||
|
||||
---
|
||||
|
||||
## 🏗️ 5. Architektur-Übersicht des Gesamtkalenders
|
||||
|
||||
```mermaid
|
||||
gantt
|
||||
title ICRA 2027 Submission Timeline
|
||||
dateFormat YYYY-MM-DD
|
||||
section Phase 0 (Setup)
|
||||
Roboter-Entscheidung (Panda vs Piper) :milestone, 2026-08-15, 0d
|
||||
MoveIt2 Setup & Reachability Test :2026-08-15, 2026-08-20
|
||||
GATE 1 (Reachability 3 Szenen) :crit, milestone, 2026-08-20, 0d
|
||||
section Phase 1 (Core Dev)
|
||||
collision_scene_builder.py :2026-08-21, 2026-08-25
|
||||
GATE 2 (End-to-End Trajektorie) :crit, milestone, 2026-08-26, 0d
|
||||
Batch Harness über 6 Policies :2026-08-27, 2026-08-29
|
||||
Messläufe mit festem Seed & Logging :2026-08-30, 2026-08-31
|
||||
GATE 3 (Alle Daten eingefroren) :crit, milestone, 2026-09-01, 0d
|
||||
section Phase 2 (Drafting)
|
||||
Drafting Section V-F & Review :2026-09-01, 2026-09-07
|
||||
GATE 4 (Full Draft Fertig) :crit, milestone, 2026-09-07, 0d
|
||||
section Phase 3 & 4 (Verification & Submit)
|
||||
Verifikation & Zahlenabgleich :2026-09-08, 2026-09-12
|
||||
Puffer (Keine Entwicklung) :2026-09-13, 2026-09-15
|
||||
SUBMISSION (23:59 PST) :milestone, 2026-09-15, 0d
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 📌 Checkliste für deinen Start (Phase 0 ab 15. August)
|
||||
|
||||
- [ ] `ICRA_2027_team_brief_nils.pdf` Abschnitte **§1, §2, §3.2 und §4** gründlich gelesen.
|
||||
- [ ] **15. August:** Piper-Demo in ROS 2 Humble / MoveIt2 antesten. Bei Fehlern/Verzögerungen sofort Franka Panda wählen.
|
||||
- [ ] 3 Test-Szenen aus FunGraph3D laden und prüfen, ob Zielobjekt-Posen kinematisch erreichbar sind.
|
||||
- [ ] **20. August:** Gate 1 erfolgreich abnehmen.
|
||||
- [ ] **21.–25. August:** `collision_scene_builder.py` schreiben und testen.
|
||||
- [ ] **26. August:** Gate 2 erfolgreich abnehmen (End-to-End-Trajektorie inkl. Collision-Check).
|
||||
@@ -0,0 +1,295 @@
|
||||
# Detaillierte Zusammenfassung der Bachelorarbeit
|
||||
**Titel:** *Task-Driven Density Variation in Functional 3D Scene Graphs*
|
||||
**Autor:** Nils Ferber
|
||||
**Datum:** 2026
|
||||
|
||||
---
|
||||
|
||||
## 📌 Abstract (Kurzfassung)
|
||||
|
||||
Ein **3D-Szenengraph** ist eine strukturierte, kompakte Repräsentation einer dreidimensionalen Umgebung, in der Knoten Entitäten (wie Gebäude, Räume, Objekte) und Kanten deren räumliche Relationen beschreiben. **Funktionale 3D-Szenengraphen** erweitern dieses Konzept, indem sie Objekten und deren interaktiven Funktionsteilen (z. B. Griffe, Knöpfe, Schalter) natürliche Sprachbeschreibungen von **Affordanzen** zuweisen (z. B. *„pull to open“* oder *„rotate to adjust temperature“*). Dies ermöglicht es Robotern, abstrakte Handlungsanweisungen mit den konkret zu manipulierenden Teilen zu verknüpfen.
|
||||
|
||||
* **Kernproblem:** Die Speicherung eines solchen Graphen in gleichmäßig hoher Auflösung (dichte Punktwolken) skaliert nicht bei wachsender Gebäudegröße. Eine uniforme Vergröberung wiederum vernichtet genau die dichte Oberflächengeometrie, die ein Roboter zum Greifen oder Drücken benötigt.
|
||||
* **Lösungsansatz:** Einführung sogenannter **Resolution Policies** (Auflösungsstrategien). Diese entscheiden rein anhand günstiger semantischer Informationen (Labels, Positionen, Affordanzkanten), welche Knoten für eine gegebene natürlichsprachliche Aufgabe mit voller Punktwolkendichte expandiert, welche zu Bounding Boxes oder Landmarken reduziert und welche ganz entfernt werden – **bevor teure 3D-Geometrie überhaupt geladen wird**.
|
||||
* **Methodik & Pipeline:** Entwicklung einer modularen **ROS 2-Evaluierungs-Pipeline**, 14 implementierten Policies (Text-Embeddings, LLMs, Information Bottleneck) und einem asymmetrischen, qualitätsbasierten Ground-Truth-Metrik-System auf Basis des Datensatzes **FunGraph3D** (153 annotierte Fälle über 14 Szenen).
|
||||
* **Zentrale Ergebnisse:**
|
||||
1. Jede aufgabengetriebene Policy reduziert den Graphen auf **unter ein Drittel der Byte-Größe** des voll aufgelösten Graphen.
|
||||
2. Die beste Policy (`label_radius` / `combined_quantile_adaptive`) erreicht eine Headline-Qualität von bis zu **0.80**.
|
||||
3. Die Weitergabe der Entscheidung von einem Objekt an seine funktionalen Teile (**Sub-Part Inheritance**) ist der stärkste Einzeleffekt: Sie hebt die Trefferquote des Zielobjekts von **18 % auf 90 %**.
|
||||
4. Die Delegation an **Large Language Models (LLMs)** ist 2 bis 4 Größenordnungen langsamer (bis zu 38 s vs. 7 ms), ohne die Zuweisungsqualität zu verbessern.
|
||||
|
||||
```mermaid
|
||||
flowchart LR
|
||||
A[Natürlichsprachliche Aufgabe<br/>z.B. 'open the microwave'] --> P[Resolution Policy<br/>Semantische Entscheidung]
|
||||
G[Minimaler Szenengraph<br/>Labels + Affordanzen + Positionen] --> P
|
||||
P --> R[4 Detailstufen<br/>Point Cloud | BBox | Label | Remove]
|
||||
R --> M[GraphModifier + Geometrie-Laden]
|
||||
M --> O[Aufgaben-optimierter 3D-Szenengraph<br/>Dicht wo manipuliert wird, sparsam sonst]
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 1. Introduction (Einleitung)
|
||||
|
||||
### 1.1 Motivation
|
||||
* **Wachsender Speicher- & Berechnungsdruck:** Autonome Serviceroboter benötigen strukturierte 3D-Umgebungskarten. Dichte Punktwolken verbrauchen jedoch Megabytes bis Gigabytes an Speicher. Werden diese Informationen ungefiltert gespeichert, skaliert der Speicherbedarf mit der Gebäudegröße statt mit dem Bedarf der Aufgabe.
|
||||
* **Asymmetrie der Fehlerkosten:**
|
||||
* *Unnötiges Detail* kostet Speicher, Kontextlänge für Planungsmodule und Netzwerkbandbreite (Multi-Roboter-Kollaboration).
|
||||
* *Fehlendes Detail* am Zielobjekt macht die Ausführung der Aufgabe schlicht unmöglich, da die Greif- oder Kontaktgeometrie fehlt.
|
||||
* **Forschungsbedarf:** Führende Surveys (z. B. *Rotondi et al.*) fordern adaptive Szenengraphen, die ihre Dichte abhängig von der aktiven Aufgabe lokal modulieren.
|
||||
|
||||
### 1.2 Problem Definition (Problemstellung)
|
||||
Gegeben sei ein funktionaler 3D-Szenengraph und ein natürlichsprachlicher Taskschritt (*ein Zielobjekt, eine Aktion*). Gesucht ist eine **Resolution Policy** $\pi: (\text{Graph}, \text{Task}) \mapsto \{\text{Node} \to \text{DetailLevel}\}$, die:
|
||||
1. **Vor dem Laden teurer Geometrien** entscheidet (Gate-Funktion).
|
||||
2. Zwischen **vier ordinalen Detailstufen** (`POINT CLOUD`, `BOUNDING BOX`, `LABEL`, `REMOVE`) unterscheidet.
|
||||
3. Die globale **Navigierbarkeit der Szene stets garantiert** (Invarianten).
|
||||
|
||||
### 1.3 Contribution (Beiträge der Arbeit)
|
||||
1. **Systematischer Literaturüberblick:** Abgrenzung von 20 Systemen anhand von 4 Kernkriterien (funktionaler 3D-Szenengraph, aufgabengetrieben, gestufte Detailgrade, geometrische Speicherersparnis).
|
||||
2. **Familie von 14 Resolution Policies:** Entwicklung von heurstischen, embedding-basierten, Information-Bottleneck- und LLM-gestützten Policies zur Überprüfung der *Affordance-Hypothese*.
|
||||
3. **Modulare ROS 2-Evaluierungs-Pipeline:** Vollständiges Framework zur entkoppelten Ausführung, Navigation preservation, Multi-Room-Routing und automatischer Ground-Truth-Bewertung.
|
||||
|
||||
---
|
||||
|
||||
## 2. Related Work (Verwandte Arbeiten)
|
||||
|
||||
### 2.1 Scene Graphs
|
||||
* **2.1.1 3D Scene Graphs:** *Armeni et al.* etablierten hierarchische Graphen (Gebäude $\to$ Räume $\to$ Objekte $\to$ Kameras). Neuere Systeme wie *ConceptGraphs* integrieren offene Vokabulare mittels 2D-VLM-Features, speichern jedoch für alle Knoten stets Punktwolken, Bounding Boxes und Embeddings parallel, was bei großen Szenen zu massivem Speicherüberlauf führt. *HOV-SG* hierarchisiert Gebäude, verringert Daten durch feste Hierarchien, moduliert die Dichte aber nie aufgabenabhängig.
|
||||
|
||||

|
||||
*Abbildung 2.1: Vier-Ebenen-Hierarchie eines klassischen 3D-Szenengraphen (Armeni et al.).*
|
||||
|
||||
* **2.1.2 Functional 3D Scene Graphs:** *Zhang et al.* (*FunGraph3D*) und *Rotondi et al.* erweitern Graphen um funktionale Subteile (Knöpfe, Griffe) und verbinden diese über gerichtete Kanten mit **telischen Affordanzen** (Handlungszweck in natürlicher Sprache, z. B. *„pull to open“*). *SpotLight* nutzt feste Aktionsprimitive ohne dichte Geometrie, deckt aber keine komplexen Freiform-Griffe ab.
|
||||
|
||||

|
||||
*Abbildung 2.2: Funktionaler 3D-Szenengraph mit interaktiven Elementen und Affordanzkanten (Zhang et al.).*
|
||||
|
||||
### 2.2 Compact and Multi-Resolution Scene Representations
|
||||
* **Multi-Resolution Maps:** *OctoMap* (Oktree-Kompression), *Larsson et al.* (Information Bottleneck auf Rasterkarten basierend auf Agentenressourcen), *D-Lite* (Hierarchische Vergröberung von Navigationsräumen), *Rate-Distortion Compression* (*Pedram et al.*).
|
||||
* **Grenze:** Sie vergröbern basierend auf Distanz, Navigationszielen oder Speicherbudgets, nicht jedoch basierend auf semantischen Manipulationsinstruktionen.
|
||||
|
||||
### 2.3 Task-Driven Scene Representations
|
||||
* **2.3.1 Task-Driven Mapping & Reconstruction:** *Clio* clustert 3D-Primitive über ein Informations-Bottleneck aufgabenspezifisch, trifft pro Element aber nur eine binäre Entscheidung (*enthalten vs. verworfen/geclustert*). *Bayesian Fields* verfeinern dies probabilistisch, tasten die Geometrie aber nicht an. *BiMoSG*, *FOUND-IT* und *GaussLite* variieren Dichten oder aktivieren Geometrie bedarfsgerecht, jedoch ohne funktionale Part-Level-Graphen.
|
||||
|
||||

|
||||
*Abbildung 2.3: Aufgabengetriebene Granularitätssteuerung in Clio (Maggio et al.).*
|
||||
|
||||
* **2.3.2 Prompt-Level Reduction and Retrieval:** *SayPlan*, *EmbodiedRAG*, *TaskGround*, *CAPruner* reduzieren Token im LLM-Kontextfenster durch Subgraphen-Retrieval. *BBQ* nutzt ein zweistufiges LLM-Schema für Detailgrade im Prompt, lässt die gespeicherten Punktwolken im RAM jedoch unberührt.
|
||||
* **2.3.3 Task-Driven Planning and Search:** *TASKOGRAPHY (SCRUB / SEEK)* reduziert Graphen für symbolische Planer via Closure über Ziel-Literale; *HomeRobot* und *SAGE* nutzen aufgabenphasenabhängige Dichten.
|
||||
|
||||
### 2.4 Research Gap (Forschungslücke)
|
||||
Kein existierendes System vereint funktionale 3D-Szenengraphen, aufgabengetriebene Steuerung, **gestufte Detaillevel** (mehr als 2 Stufen) und **echte Kontrolle über die gespeicherte Geometrie**:
|
||||
|
||||
| System | Funktionaler 3D SG | Task-driven | Gestufte Level | Gespeicherte Geometrie |
|
||||
| :--- | :---: | :---: | :---: | :---: |
|
||||
| *ConceptGraphs* (2023) | ✗ | ✗ | (✓) | ✗ |
|
||||
| *OctoMap* (2013) | ✗ | ✗ | ✓ | ✓ |
|
||||
| *D-Lite* (2025) | ✗ | (✓) | ✓ | ✗ |
|
||||
| *Clio* (2024) | ✗ | ✓ | ✗ | ✓ |
|
||||
| *Bayesian Fields* (2025) | ✗ | ✓ | ✗ | ✗ |
|
||||
| *BiMoSG* (2025) | ✗ | ✓ | (✓) | ✗ |
|
||||
| *GaussLite* (2025) | ✗ | ✓ | (✓) | ✓ |
|
||||
| *BBQ* (2024) | ✗ | ✓ | (✓) | ✗ |
|
||||
| *KeySG* (2025) | ✓ | ✓ | ✗ | ✗ |
|
||||
| **Diese Bachelorarbeit** | **✓** | **✓** | **✓** | **✓** |
|
||||
|
||||
---
|
||||
|
||||
## 3. Approach (Konzeptioneller Ansatz)
|
||||
|
||||
### 3.1 Concepts and Definitions
|
||||
* **3.1.1 Functional 3D Scene Graph:** Gerichteter, azyklischer Graph $G=(V, E)$. Knoten $V$ sind Objekte und deren funktionale Subteile. Kanten $E$ tragen natürlichsprachliche telische Labels (z. B. *„press to start and operate“*).
|
||||
* **3.1.2 Detail Levels (Die 4 Auflösungsstufen):**
|
||||
1. `POINT CLOUD` (Höchste Stufe): Vollständige Geometrie; essenziell für 6-DoF Grasping am Manipulationsziel.
|
||||
2. `BOUNDING BOX`: Orientierte 3D-Box (Zentrum, Ausdehnung, Orientierung); ausreichend für Kollisionsprüfung in der Arbeitsumgebung.
|
||||
3. `LABEL`: Name + 3D-Position; Landmarke für Navigation und Raumkontext.
|
||||
4. `REMOVE`: Vollständige Entfernung aus dem Graphen (Null Speicherbedarf).
|
||||
* **3.1.3 Task (Direkt vs. Indirekt):**
|
||||
* *Direkter Task:* Nennt Objektkategorie explizit (*„open the microwave oven“*).
|
||||
* *Indirekter Task:* Formuliert ein Nutzerbedürfnis/Zustand (*„i am hungry“*), erfordert semantische Inferenz über Objektzwecke.
|
||||
* **3.1.4 Resolution Policy:** Funktion $\pi: (G_{\text{minimal}}, \text{task}) \mapsto \{v \in V \to \text{DetailLevel}\}$.
|
||||
|
||||
### 3.2 The Problem of Task-Driven Density Variation
|
||||
Entscheidungen müssen **vor dem Geometrieladen** auf Basis von Text & Metadaten getroffen werden. Die globale Navigationsstruktur muss als Invariante erhalten bleiben.
|
||||
|
||||
### 3.3 Exploitation of Affordance Edges (Die Affordanz-Hypothese)
|
||||
Natürlichsprachliche Kantenbeschreibungen liefern Zusatzsignale: Indirekte Anweisungen (*„make the room warmer“*) enthalten selten den Objektnamen (*„radiator“*), paraphrasieren jedoch oft die Kante (*„rotate to adjust temperature“*).
|
||||
|
||||
### 3.4 Multi-Room Decomposition
|
||||
Vor Ausführung einer Policy wird der Startraum des Roboters bestimmt, der Zielraum anhand der Aufgabe gewählt und ein topologischer Raum-Pfad berechnet. Türen/Passagen entlang des Pfades werden automatisch auf `POINT CLOUD` gepinnt; Raumknoten bleiben `LABEL`.
|
||||
|
||||
### 3.5 Policy Classes and Implemented Set (Die 14 Policies)
|
||||
|
||||
| Gruppe | Policy Name | Signalquelle | Graphennutzung | Cut-Regel |
|
||||
| :--- | :--- | :--- | :--- | :--- |
|
||||
| **Ohne Modell** | `identity` | Keine | Keine (Alles PointCloud) | - |
|
||||
| **Sentence-Encoder** (`all-MiniLM-L6-v2`) | `label_only` | Nur Node-Labels | Nur zur Part-Erkennung | Fester Schwellwert |
|
||||
| | `label_inherit` | Nur Node-Labels | Sub-Part Vererbung | Fester Schwellwert |
|
||||
| | `affordance_inherit` | Nur Kanten-Affordanzen | Sub-Part Vererbung | Fester Schwellwert |
|
||||
| | `combined_inherit` | Labels + Affordanzen | Sub-Part Vererbung | Fester Schwellwert |
|
||||
| | `combined_quantile` | Labels + Affordanzen | Sub-Part Vererbung | Feste Perzentile (7%/30%/36%) |
|
||||
| | `combined_quantile_adaptive` | Labels + Affordanzen | Sub-Part Vererbung | **Größte Score-Deltas (parameterfrei)** |
|
||||
| | `label_radius` | Node-Labels für Seeds | Euklidischer Abstand (0.75m / 1.5m / 2.5m) | Radien |
|
||||
| | `information_bottleneck` | Labels + Affordanzen | Raum-Adjazenz + IB | Threshold auf Task-Prob. |
|
||||
| | `information_bottleneck_noaff`| Nur Node-Labels | Raum-Adjazenz + IB | Threshold auf Task-Prob. |
|
||||
| **Lokales LLM** (Phi-4-mini) | `llm_zero_shot` | Labels + Affordanzen | Kompletter Graph im Prompt | LLM-Klassifikation |
|
||||
| | `llm_zero_shot_noaff` | Nur Node-Labels | Kompletter Graph im Prompt | LLM-Klassifikation |
|
||||
| **Remote LLM** (Claude 3.5 Haiku)| `llm_remote_haiku` | Labels + Affordanzen | Kompletter Graph im Prompt | LLM-Klassifikation |
|
||||
| | `llm_remote_haiku_noaff` | Nur Node-Labels | Kompletter Graph im Prompt | LLM-Klassifikation |
|
||||
|
||||
* **3.5.1 Shared Scoring Skeleton:** Bewertet Hauptobjekte über Kosinus-Ähnlichkeit. Das beste Objekt wird garantiert auf `POINT CLOUD` gesetzt (Anchor). Subteile erben das Level ihres Elternknotens.
|
||||
* **3.5.2 Cutting Score into Levels:** Schwellwerte vs. Perzentilränge vs. adaptive Lücken im Ähnlichkeitsverlauf.
|
||||
* **3.5.3 Structure-Blind Baselines:** `label_only` (keine Vererbung an Subteile), `label_radius` (rein euklidische Ausbreitung um den relevantesten Knoten).
|
||||
* **3.5.4 Delegating to Language Models:** Strukturierter Zero-Shot-Prompt mit JSON-Schema-Constraint.
|
||||
* **3.5.5 Task-Driven Information Bottleneck:** Minimierung von $I(X; \tilde{X}) - \beta I(\tilde{X}; Y)$ über agglomeratives Merging benachbarter Knoten mit anschließender Cluster-Zuordnung.
|
||||
|
||||
---
|
||||
|
||||
## 4. Implementation (Implementierung)
|
||||
|
||||
### 4.1 Pipeline Infrastructure (ROS 2 & Docker)
|
||||
|
||||

|
||||
*Abbildung 4.1: Architektur der modularen ROS 2 Pipeline.*
|
||||
|
||||
* **4.1.1 Data Model:** Entkoppelte Repräsentationen: `Node`, `Edge`, `PolicyResult` (Mapping `node_id -> DetailLevel`), `PolicyContext` (Roboterpose, Startraum).
|
||||
* **4.1.2 Dataflow and Pipeline Nodes:**
|
||||
1. `GraphBuilder`: Lädt Dataset, publiziert `/scene_graph/minimal` (ohne Geometriedaten für Policies) und `/scene_graph/full`.
|
||||
2. `GenericPolicyNode`: Führt registrierte Python-Policy parallel aus.
|
||||
3. `GraphModifier`: Schneidet bei aktivem Build Geometrien zurecht und fusioniert Merge-Gruppen.
|
||||
4. `Visualizer` & `RViz2`: Generiert Marker-Arrays zur visuellen Inspektion (Point Clouds auf 5 cm Voxel gitterreduziert).
|
||||
5. `Evaluator`: Schreibt standardisierte `evaluation.json`-Dateien und berechnet Ground-Truth-Scores.
|
||||
|
||||

|
||||
*Abbildung 4.2: Modifizierter Szenengraph in '0kitchen' für 'open the microwave oven' (Mikrowelle & Knöpfe = Point Cloud, Spülmaschine/Schränke = Bounding Box, Wasserkocher = Label).*
|
||||
|
||||
* **4.1.3 Invarianten & Routing:** `pin_rooms_to_label` fixiert Raumknoten. Multi-Room-Routing ermittelt Zielräume über ein Cosine-Ähnlichkeitsband ($\Delta \le 0.05$).
|
||||
* **4.1.4 Datasets & Geometry Gate:** Adapter für FunGraph3D; `build_graph:=false` erlaubt latenzfreie Batch-Läufe ohne 3D-Geometrieladeprozesse.
|
||||
* **4.1.5 Ground Truth & Offline Tools:** `scaffold_gt.py` (Template-Generierung), `score_against_gt.py` (offline Re-Scoring ohne ROS), `view.launch.py` (Replay in RViz).
|
||||
* **4.1.6 Umgebung:** AMD Ryzen 7 7735HS, 32 GB RAM, rein CPU-basiert (Ollama & SentenceTransformers laufen deterministisch lokal).
|
||||
|
||||
### 4.2 Policy Modules
|
||||
* **4.2.1 Shared Scoring Module:** Caching in `text_embedder.py`, Kosinusschwellen: $\ge 0.45 \to$ Point Cloud, $\ge 0.30 \to$ BBox, $\ge 0.18 \to$ Label.
|
||||
* **4.2.2 Language Model Policies:** Strikt typisierte JSON-Ausgaben via Ollama (lokales Phi-4-mini, Q4_K_M) und Anthropic API (Claude 3.5 Haiku).
|
||||
* **4.2.3 Information Bottleneck Policy:** Agglomerativer Solver über Raum-Adjazenz ($\le 1.5\,\text{m}$), Null-Task-Floor bei $0.5 \cdot \max(\phi)$ mit Skalierungsexponent $\gamma = 3$.
|
||||
|
||||
---
|
||||
|
||||
## 5. Evaluation (Evaluierung & Ergebnisse)
|
||||
|
||||
### 5.1 Requirements (Anforderungen an den Benchmark)
|
||||
Vergleich bestehender Datensätze (Nr3D, SG3D, SceneFun3D, MomaGraph, Clio, FunGraph3D) ergab: **Kein bestehender Datensatz bietet gestufte Ground-Truth-Detaillevel auf funktionalen Graphen**. FunGraph3D erfüllt alle Rohdatenanforderungen (R1–R3), die Ground-Truth-Annotation (R4–R6) wurde für diese Arbeit neu erstellt.
|
||||
|
||||
### 5.2 Ground Truth Annotations
|
||||
153 Fälle über 14 Szenen (Küche, Bad, Wohn-, Schlafzimmer). 90 direkte Aufgaben, 63 indirekte Aufgaben. Streng definierte Annotationsrichtlinie: Manipuliertes Zielobjekt + interaktive Teile = `POINT CLOUD`; Kollisionsnachbarn/Auflagefläche = `BOUNDING BOX`; Raumkontext = `LABEL`; Rest = `REMOVE`.
|
||||
|
||||
### 5.3 Ground Truth Based Quality Metric
|
||||
* **5.3.1 Asymmetrische Kostenmatrix:**
|
||||
|
||||
| GT \ Prädiktion | `REMOVE` | `LABEL` | `BOUNDING BOX` | `POINT CLOUD` |
|
||||
| :--- | :---: | :---: | :---: | :---: |
|
||||
| `REMOVE` | 0 | 0.1 | 0.3 | 1.0 |
|
||||
| `LABEL` | **1.0** | 0 | 0.2 | 0.6 |
|
||||
| `BOUNDING BOX`| **2.0** | **1.5** | 0 | 0.3 |
|
||||
| `POINT CLOUD` | **4.0** | **3.0** | **2.0** | 0 |
|
||||
|
||||
> **Superlineare Bestrafung von Unterversorgung (*Under-Provisioning*):** Ein fehlendes Zielobjekt (`POINT CLOUD` $\to$ `REMOVE`) kostet 4.0 Punkte, während Überversorgung (*Over-Provisioning*) nur mild proportional zum Speicherverbrauch bestraft wird.
|
||||
|
||||
* **5.3.2 Dekomposition in Suffizienz & Effizienz:**
|
||||
$$\text{Suffizienz: } S^* = 1 - \frac{U}{U_{\max}} \quad (\text{Gewichteter Recall})$$
|
||||
$$\text{Effizienz: } E^* = 1 - \frac{O}{O_{\max}} \quad (\text{Gewichtete Spezifität})$$
|
||||
$$\text{Gesamt-Score: } Q = \frac{U_{\max} S^* + O_{\max} E^*}{U_{\max} + O_{\max}} \in [0, 1]$$
|
||||
* **5.3.3 Task-Level Target Hit Rate:** Anteil der Fälle, in denen das manipulierte Zielobjekt und dessen Subteile in voller `POINT CLOUD`-Geometrie erhalten bleiben.
|
||||
|
||||
### 5.4 Qualitative Evaluation
|
||||
|
||||

|
||||
*Abbildung 5.1: Qualitativer Vergleich in '0kitchen' (links: Identity Baseline 7.9 MiB; rechts: Combined Quantile 0.30 MiB).*
|
||||
|
||||
### 5.5 Quantitative Results (Hauptergebnisse)
|
||||
|
||||
| Policy | Rang | Headline $q$ | Suffizienz $S^*$ | Effizienz $E^*$ | Target Hit Rate | Extra Dense Objs | Graphengröße (% von Identity) | Latenz (Median) |
|
||||
| :--- | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: |
|
||||
| `label_radius` | **1** | **0.802** | **0.835** | 0.724 | 0.810 | 1.65 | 26 % | 7.1 ms |
|
||||
| `combined_quantile_adaptive` | **2** | **0.761** | 0.708 | 0.848 | **0.928** | 0.50 | 16 % | 7.0 ms |
|
||||
| `combined_quantile` | **3** | 0.755 | 0.666 | 0.899 | 0.869 | **0.13** | **12 %** | 7.1 ms |
|
||||
| `combined_inherit` | 4 | 0.740 | 0.666 | 0.848 | 0.915 | 0.88 | 20 % | 7.0 ms |
|
||||
| `label_inherit` | 5 | 0.724 | 0.603 | 0.894 | 0.895 | 0.58 | 18 % | **6.9 ms** |
|
||||
| `llm_remote_haiku_noaff` | 6 | 0.656 | 0.477 | 0.919 | 0.791 | 0.59 | 15 % | 1.9 s |
|
||||
| `information_bottleneck` | 7 | 0.653 | 0.519 | 0.846 | 0.686 | 1.44 | 25 % | 38.2 ms |
|
||||
| `llm_remote_haiku` | 8 | 0.651 | 0.468 | **0.921** | 0.719 | 0.51 | **12 %** | 1.9 s |
|
||||
| `label_only` | 9 | 0.643 | 0.463 | 0.913 | 0.183 | 0.59 | 17 % | **6.9 ms** |
|
||||
| `information_bottleneck_noaff`| 10 | 0.631 | 0.478 | 0.861 | 0.824 | 1.25 | 25 % | 38.0 ms |
|
||||
| `llm_zero_shot` | 11 | 0.618 | 0.718 | 0.455 | 0.477 | 3.25 | 31 % | 37.8 s |
|
||||
| `llm_zero_shot_noaff` | 12 | 0.616 | 0.702 | 0.472 | 0.458 | 2.76 | 24 % | 28.2 s |
|
||||
| `identity` (Baseline) | 13 | 0.605 | 1.000 | 0.000 | 1.000 | 9.63 | 100 % | **0.02 ms** |
|
||||
| `affordance_inherit` | 14 | 0.582 | 0.391 | 0.857 | 0.346 | 0.90 | **12 %** | 7.0 ms |
|
||||
|
||||
#### Detaillierte Visualisierungen der Ergebnisse:
|
||||
|
||||
* **Trade-off Suffizienz vs. Effizienz:**
|
||||

|
||||
*Abbildung 5.2: Suffizienz $S^*$ vs. Effizienz $E^*$ aufgeteilt nach direkten und indirekten Aufgaben.*
|
||||
|
||||
* **Direkte vs. Indirekte Aufgaben:**
|
||||

|
||||
*Abbildung 5.3: Mittlere Scores $q$ mit 95 % Bootstrap-Konfidenzintervallen.*
|
||||
|
||||
* **Task Target Hit Rate & Extra Objects:**
|
||||

|
||||
*Abbildung 5.4: Target Hit Rate (links) und mittlere Anzahl zusätzlich expandierter dichter Objekte (rechts).*
|
||||
|
||||
* **Paarweiser Performance-Verlust bei indirekten Tasks:**
|
||||

|
||||
*Abbildung 5.5: Paarweiser Unterschied $\Delta q = q(\text{indirekt}) - q(\text{direkt})$.*
|
||||
|
||||
* **Speicherreduktion vs. Qualität & Ausführungszeiten:**
|
||||
|
||||
| Graphengröße vs. Score $q$ | Ausführungszeit (Latenz in ms, Log-Skala) |
|
||||
| :---: | :---: |
|
||||
|  |  |
|
||||
| *Abbildung 5.6: Relative Graphengröße vs. $q$.* | *Abbildung 5.7: Median der Rechenzeit pro Policy.* |
|
||||
|
||||
---
|
||||
|
||||
## 6. Discussion (Diskussion)
|
||||
|
||||
### 6.1 The Graph Structure Contribution (Der Wert der Graphenstruktur)
|
||||
* **Sub-Part Inheritance:** Der Vergleich zwischen `label_only` und `label_inherit` beweist: Die Weitergabe des Levels an Funktionsteile verbessert den Score um $+0.081$ und die Target Hit Rate von **18.3 % auf 89.5 %**. Einzelne Funktionsteile (z. B. „Griff“) ähneln semantisch fast nie der Aufgabenbeschreibung („Mikrowelle öffnen“) und würden ohne Kanten-Vererbung fälschlicherweise entfernt werden.
|
||||
* **Geometrische Nähe als Surrogat:** `label_radius` erzielt Höchstwerte ($q=0.802$), weil Funktionsteile physisch im Parent-Objekt liegen und Nachbarobjekte in Arbeitsbereichs-Nähe automatisch eine Bounding Box erhalten.
|
||||
|
||||
### 6.2 The Affordance Hypothesis (Bestätigung & Grenzen)
|
||||
* **Schwache Lesart bestätigt:** Affordanzkanten als *Zusatzsignal* zu Labels verbessern Embedding-Policies leicht ($+0.016$) und signifikant bei indirekten Tasks (z. B. Heizkörperthermostat bei „mir ist kalt“).
|
||||
* **Starke Lesart widerlegt:** Affordanzen *alleine* (`affordance_inherit`) scheitern völlig ($q=0.582$, Hit Rate 34.6 %). Grund: Affordanzen sind in Innenräumen hochgradig generisch (100 von 230 Kanten heißen schlicht *„pull to open“*). Ohne den Anker des Objektlabels geht jede Diskriminierungsfähigkeit verloren.
|
||||
* **LLMs profitieren nicht:** LLMs kennen Objekt-Affordanzen bereits aus ihrem Weltwissen; explizite Kantenbeschreibungen im Prompt bringen ihnen keinen messbaren Mehrwert.
|
||||
|
||||
### 6.3 Quality, Feasibility, and Cost
|
||||
* **Praxisempfehlung:** `combined_quantile_adaptive` ist die am besten geeignete Policy für den Robotereinsatz:
|
||||
* **92.8 % Target Hit Rate** (höher als `label_radius` mit 81.0 %).
|
||||
* **Keine manuellen Hyperparameter/Schwellwerte** (rein datengetriebene Zerlegung an den größten Ähnlichkeitssprüngen).
|
||||
* Reduktion auf **16 % der Dateigröße** bei nur **7 ms Latenz**.
|
||||
* **Disqualifikation der LLMs:** Lokale LLMs tendieren zur extremen Überversorgung (hoher Speicherbedarf, 38 s Latenz), Remote LLMs zur Unterversorgung (Verlust essenzieller Teile).
|
||||
|
||||
### 6.4 Threats to Validity (Gefährdungen der Validität)
|
||||
* Die Annotationsrichtlinie definierte Kollisionsumgebungen geometrisch ($\le 2\,\text{m}$), was `label_radius` methodisch bevorzugte.
|
||||
* Manuelle Schwellen der Basis-Policies wurden auf der Szene `0kitchen` kalibriert.
|
||||
|
||||
### 6.5 Limitations (Einschränkungen)
|
||||
1. **Kantenfilterung fehlt:** Detailgrade werden nur Knoten zugewiesen; Kanten werden komplett beibehalten.
|
||||
2. **Binary Information Bottleneck:** Agglomeratives IB degeneriert bei Ein-Task-Szenarien zu einer binären Relevanzvariable ohne feine Zwischenstufen.
|
||||
3. **Tabletop-Objekte:** FunGraph3D fokussiert Großmöbel; dichte Besteck-/Geschirrszenen wurden noch nicht erfasst.
|
||||
|
||||
---
|
||||
|
||||
## 7. Conclusion & Outlook (Fazit & Ausblick)
|
||||
|
||||
### Kernfazit
|
||||
Diese Bachelorarbeit schließt die Forschungslücke zur aufgabengetriebenen Auflösungssteuerung in funktionalen 3D-Szenengraphen.
|
||||
1. Eine effiziente, rein textbasierte Vorselektion reduziert den geometrischen Speicherbedarf auf einen Bruchteil ($12\text{--}26\,\%$) in **unter 10 Millisekunden**.
|
||||
2. Die Vererbung entlang der Graphenhierarchie ist der entscheidende Hebel zur Sicherung der Manipulationsfähigkeit.
|
||||
3. Teure LLMs sind einfachen Sentence-Embeddings in dieser Filteraufgabe unterlegen.
|
||||
|
||||
### Zukünftige Forschungsrichtungen
|
||||
1. **Integration kinematischer Zustände:** Berücksichtigung von Verdeckungen und geschlossenen Türen/Schränken (*Articulated Objects* nach *Büchner et al.*).
|
||||
2. **Kompression für Multi-Roboter-Kollaboration:** Nutzung der Resolution Policy als aufgabenkonditionierter Übertragungsfilter bei Bandbreitenbeschränkung.
|
||||
3. **Erweiterter Parameterraum:** Einführung parametrischer Aktionsmodelle (z. B. *SpotLight*-Posen) als fünfte Detailstufe zwischen Bounding Box und Punktwolke.
|
||||
@@ -0,0 +1,167 @@
|
||||
# Task-Driven Resolution Policies for Varying-Density Functional 3D Scene Graphs
|
||||
|
||||
Dieses Dokument beinhaltet meine ersten Notizen zu der Bachelorarbeit von Nils Ferber mit dem Thema "Task-Driven Resolution Policies for Varying-Density Functional 3D Scene Graphs". Diese sollen in späterer Absprache mit dem Betreuer Simon Janzon genutzt werden, um die von Nils geleistete Arbeit auszuarbeiten und zu evaluieren. Mit den daraus gewonnenen Resultaten kann im Anschluss ein Paper geschrieben und hoffentlich veröffentlicht werden.
|
||||
|
||||
## Announcement
|
||||
Das Announcement gibt eine wichtige Übersicht über den State-of-the-Art, um anschließend daraus die Lücken der aktuellen Forschung zu identifizieren und die eigene Arbeit darauf aufzubauen.
|
||||
|
||||
### Was sind Functional 3D Scene Graphs?
|
||||
Funktionale 3D Szenegraphen beinhalten feingranulare interaktive Elemente wie Bewegungsachsen oder Griffe.
|
||||
Dadurch kann diese Art der Szenegraphen explodieren. Dies führt zu Berechnungsproblemen und Speicher Bottlenecks. Zur Gewährleistung einer Real-Time Performance ohne Verzicht auf die Interaktiven Kapazitäten wird eine Szeneabstraktion benötigt, welche die Granularität räumlicher Daten dynamisch anpasst.
|
||||
|
||||
### State of the Art
|
||||
Aktuelle funktionale 3D Szenegraphen verfügen nicht über die Fähigkeit, ihre Dichte dynamisch zu modulieren. Hoch auflösende Graphen verfügen über eine schlechte Skalierbarkeit. Dahingehend haben dünn aufgelöste Graphen nicht die Dichte, die komplexe physikalische Interaktionen benötigen.
|
||||
|
||||
### Herausfordung und Kerpunkte der Arbeit
|
||||
Die zentrale Herausforderung besteht in der Entwicklung einer algorithmischen Strategie, die autonom entscheiden kann, wann ein Objekt in seine detaillierten funktionalen Teilkomponenten zerlegt und wann es zur Einsparung von Speicherplatz zu einem groben Knoten zusammengefasst werden sollte.
|
||||
|
||||
Daher besteht die Kernaufgabe dieser Arbeit in dem Entwurf, der Implementierung und einer eingehenden Evaluation eines Moduls für eine dynamische Auflösungsrichtlinie. Dieses Modul fungiert als Entscheidungsheuristik, die die Objektgranularität innerhalb eines 3D-Szenegraphen mit variabler Dichte steuert.
|
||||
|
||||
Dabei sollen folgende Punkte in der Bachelorarbeit enthalten sein:
|
||||
- Aktuelle funktionale 3D Szenegraphen sowohl in Methodik als auch Limitation betrachten
|
||||
- Definitionen für aufgabenspezifisch Relevanzkriterien entwickeln, sodass Elemente, die in den Graphen integriert werden, identifiziert werden
|
||||
- Entwicklung einer dynamischen Auflösungsrichtlinie, um die optimale Knotenrepräsentation auf Grundlage der Relevanzkriterien zu bestimmen
|
||||
- systematische Evaluation der entwickelten Lösung
|
||||
- Dokumentation und Kolloquium
|
||||
|
||||
## Bachelorarbeit
|
||||
Auf Grundlage des bereits erwähnten Announcements hat der Student Nils Ferber seine Bachelorarbeit geschrieben. Der folgende Abschnitt wird sich daher mit dem von ihm abgegebenen Dokument befassen. Dabei werden die wichtigsten Punkte der Einzelnen Kapitel in Stichpunkte niedergeschrieben.
|
||||
|
||||
### Abstract
|
||||
- es werden günstige semantische Informationen für die Objekte genutzt
|
||||
- anhand derer wird entschieden welche Objekte feingranular in den Graph integriert werden müssen
|
||||
- die Entscheidungsfunktion oder Auflösungsrichtlinie weist jedem Knoten eine von vier Detailierungsstufen zu
|
||||
- von vollständiger Punkwolke bis hin zur Entfernung
|
||||
- zum Vergleich der Richtlinien gibt es eine modulare ROS2 Evaluationspipeline
|
||||
- Strategie wird als Funktion behandelt
|
||||
- Graph ohne Geometrieinformationen und Aufgabe werden auf eine Detailzuweisung pro Knoten abgebildet
|
||||
- es wurde eine Reihe von Richtlinen so implementiert und evaluiert
|
||||
- von lexikalischem Matching und Text Embeddings
|
||||
- über Richtlinien mit Einsatz von LLMs
|
||||
- bis hin zu Strukturellen Richtlinien aufbauend auf dem "Information-Bottleneck"-Prinzips
|
||||
- Eine der zentralen Hypothesen ist der Einsatz von Affordanz-Kanten, um zusätzliche Signale für Policies zu liefern
|
||||
- Einsatz des FunGraph 3D Datensatzes
|
||||
- quantifizierung der gespeicherten Graphgrößenreduzierung im Vergleich zur Baseline
|
||||
- Latenz der Entscheidung
|
||||
- Übereinstimmung der Zuordnung mit einer annotierten ground truth
|
||||
|
||||
### Introduction
|
||||
- Das Problem
|
||||
- Motivation der Arbeit
|
||||
- Beitrag zur Forschung
|
||||
|
||||
#### Motivation
|
||||
- Funktionale Szenegraphen annotieren Objekte mit ihrer Affordanz
|
||||
- Hohe Skalierung bei feingranularer Auflösung
|
||||
- Details beanspruchen Speicherplatz den andere Module nutzen könnten und Blähen den Kontext auf
|
||||
- Fehlen Details können Aufgaben nicht mehr ausgeführt werden und der Graph entspricht nicht mehr der Realität
|
||||
|
||||
#### Problemdefinition
|
||||
- Aktuellen funktionalen 3D Szenegraphen fehlt die Fähigkeit ihre Dichte der Aufgabe entsprechend dynamisch anzupassen
|
||||
- In dieser Arbeit werden auf Basis eines funktionale 3D Szenegraphen und einer natürlichesprachlichen Aufgabe ein Subgraph gebildet
|
||||
- dies geschieht durch Resolution Policies
|
||||
- es werden nur günstige semantische Informationen genutzt
|
||||
- nur wichtige Objekte werden detailliert dargestellt
|
||||
- unwichtige Objekte können sogar gänzlich entfernt werden
|
||||
|
||||
#### Contribution
|
||||
- Systematic Review of task-driven scene representations
|
||||
- family of task-driven resolution policies
|
||||
- ROS 2 pipeline
|
||||
|
||||
### Related Work
|
||||
Der Student unterteilt sein Related Work in drei wichtige Punkte:
|
||||
1. Szene Graphen als Repräsentation einer 3D Umgebung
|
||||
2. Auflösung einer Repräsentation
|
||||
3. Repräsentation von Tasks
|
||||
|
||||
#### Szenegraphen
|
||||
Besteht aus:
|
||||
- nodes (Objekten), edges (Relationen)
|
||||
- Konzeptuelle Szenegraphen repräsentieren Objekte als semantische Konzepte mit einer festen Hierarchie
|
||||
- Funktionale Szenegraphen annotieren Objekte zusätzlich mit ihrer Affordanz
|
||||
|
||||
##### 3D Szenegraphen
|
||||
- ConceptGraphs Gu et al.
|
||||
- Gorlo et al.
|
||||
- Werby et al.
|
||||
- Deng et al. (Survey of Scene Representation)
|
||||
|
||||
##### Funktionale 3D Szenegraphen
|
||||
- Rotondi et al. (2x)
|
||||
- Zhang et al.
|
||||
- Wald et al.
|
||||
- Delitzas et al.
|
||||
- FunGraph3D Zhang et al.
|
||||
- SceneFun3D
|
||||
- SpotLight Engelbrecht et al.
|
||||
- MoMa-SG Framework Büchner et al.
|
||||
- Fu et al.
|
||||
- Hu et al.
|
||||
- Kim and Kim
|
||||
|
||||
##### Auflösung einer Repräsentation
|
||||
- OctoMap Hornung et al.
|
||||
- Larsson et al. (2x)
|
||||
- D-Lite Chang et al.
|
||||
- Pedram et al.
|
||||
- Octree Graph Wang et al.
|
||||
- Zhang et al.
|
||||
|
||||
##### Repräsentation von Tasks
|
||||
- Clio Maggio et al.
|
||||
- Maggio and Carlone
|
||||
- BiMoSG Prasetyo et al.
|
||||
- FOUND-IT Maggio et al.
|
||||
- Chang et al.
|
||||
- GausLite Thomas et al.
|
||||
- T-FunS3D Feng and Sabzevari
|
||||
- Rotondi et al.
|
||||
- SayPlan
|
||||
- EmbodiedRAG Booker et al.
|
||||
- TaskGround
|
||||
- Xie et al.
|
||||
- CAPruner
|
||||
- STaR
|
||||
- BBQ Framework Linok et al.
|
||||
- KeySG Framework Werby et al.
|
||||
- TASKOGRAPHY Agia et al.
|
||||
- Silver et al.
|
||||
- Kurenkov et al.
|
||||
- Lingelbach et al.
|
||||
- MomaGraph by Ju et al.
|
||||
- HomeRobot Yenamandra et al.
|
||||
- SAGE Li et al.
|
||||
|
||||
### Approach
|
||||
Das zentrale Konzept der späteren Implementierung.
|
||||
|
||||
#### Concepts and Definitions
|
||||
- Funktionaler 3D Szenengraph
|
||||
- Knoten = Objekte und deren funktionale Subparts
|
||||
- Kanten = Affordanzbeziehungen als Kombination aus Bewegung und deren Zweck
|
||||
- FunGraph3D hat nur einzelne Räume per Szene
|
||||
- Multiraum Szene wurde konstruiert
|
||||
- Raum wird als Node dargestellt
|
||||
- Kanten verbinden Räume, dabei gibt es drei Kategorien:
|
||||
1. contains: Verbindet Raum mit Objekt
|
||||
2. reachable: Verbindet zwei Räume
|
||||
3. passage: Verbinde einen Raum mit einem Türobjekt
|
||||
- Detaillevel
|
||||
- POINT_CLOUD
|
||||
- BOUNDING_BOX
|
||||
- LABEL
|
||||
- REMOVE
|
||||
- Task
|
||||
- Resolution Policy:= pi: (Graph, Task) -> {node -> DetailLevel}
|
||||
|
||||
### Implementation
|
||||
Die im Approach definierten Policies werden im folgenden Abschnitt in lauffähige und vergleichbare Artefakte übersetzt.
|
||||
|
||||
#### Pipeline Infrastruktur
|
||||
- Evaluation Harness
|
||||
- ROS 2 Humble Pipeline
|
||||
- Docker Ubuntu 22.04
|
||||
- single ROS package: resolution_policy
|
||||
|
||||
##### Data Model
|
||||
@@ -0,0 +1,72 @@
|
||||
FROM osrf/ros:humble-desktop-full
|
||||
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
ENV ROS_DISTRO=humble
|
||||
ENV WS=/root/piper_ws
|
||||
|
||||
# System dependencies and build tools
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
git \
|
||||
python3-pip \
|
||||
python3-colcon-common-extensions \
|
||||
python3-rosdep \
|
||||
ros-humble-moveit \
|
||||
ros-humble-moveit-planners-ompl \
|
||||
ros-humble-moveit-ros-planning-interface \
|
||||
ros-humble-moveit-ros-move-group \
|
||||
ros-humble-moveit-visual-tools \
|
||||
ros-humble-geometric-shapes \
|
||||
ros-humble-octomap \
|
||||
ros-humble-octomap-msgs \
|
||||
ros-humble-octomap-ros \
|
||||
ros-humble-robot-state-publisher \
|
||||
ros-humble-joint-state-publisher \
|
||||
ros-humble-joint-state-publisher-gui \
|
||||
ros-humble-rviz2 \
|
||||
ros-humble-xacro \
|
||||
nano \
|
||||
curl \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Python libraries for geometry, scene graph processing & point clouds
|
||||
RUN pip3 install --no-cache-dir \
|
||||
numpy \
|
||||
scipy \
|
||||
plyfile \
|
||||
trimesh \
|
||||
transforms3d \
|
||||
pyyaml
|
||||
|
||||
# Setup ROS 2 workspace and clone AgileX Piper ROS (humble branch)
|
||||
RUN mkdir -p ${WS}/src
|
||||
WORKDIR ${WS}/src
|
||||
|
||||
# Clone piper_ros and submodules
|
||||
RUN git clone -b humble https://github.com/agilexrobotics/piper_ros.git \
|
||||
&& cd piper_ros \
|
||||
&& git submodule update --init --recursive || true
|
||||
|
||||
WORKDIR ${WS}
|
||||
|
||||
# Install any remaining rosdep dependencies
|
||||
RUN . /opt/ros/humble/setup.sh \
|
||||
&& apt-get update \
|
||||
&& rosdep update \
|
||||
&& rosdep install --from-paths src --ignore-src -r -y || true \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Build the workspace
|
||||
RUN . /opt/ros/humble/setup.sh \
|
||||
&& colcon build --symlink-install --cmake-args -DCMAKE_BUILD_TYPE=Release
|
||||
|
||||
# Setup entrypoint environment
|
||||
RUN echo "source /opt/ros/humble/setup.bash" >> /root/.bashrc \
|
||||
&& echo "source ${WS}/install/setup.bash" >> /root/.bashrc
|
||||
|
||||
COPY entrypoint.sh /entrypoint.sh
|
||||
RUN chmod +x /entrypoint.sh
|
||||
|
||||
WORKDIR /workspace
|
||||
|
||||
ENTRYPOINT ["/entrypoint.sh"]
|
||||
CMD ["bash"]
|
||||
@@ -0,0 +1,45 @@
|
||||
# AgileX Piper MoveIt2 Docker Environment (ROS 2 Humble)
|
||||
|
||||
Dieses Docker-Setup stellt eine vollständige Entwicklungsumgebung für den **AgileX Piper Roboterarm** unter **ROS 2 Humble** mit **MoveIt 2** und den notwendigen Geometrie- & Punktwolken-Bibliotheken bereit.
|
||||
|
||||
---
|
||||
|
||||
## 📦 Enthaltene Pakete & Tools
|
||||
|
||||
* **Basis:** Ubuntu 22.04 LTS + `ros-humble-desktop-full`
|
||||
* **Motion Planning:** MoveIt 2 (`ros-humble-moveit`, OMPL Planners, OctoMap)
|
||||
* **Roboter-Treiber & URDF:** [agilexrobotics/piper_ros (Branch: humble)](https://github.com/agilexrobotics/piper_ros/tree/humble)
|
||||
* `piper_description` / `agx_arm_urdf` (URDF & Xacro)
|
||||
* `piper_moveit2` / `piper_with_gripper_moveit` (MoveIt-Konfiguration für den 6-DoF Arm)
|
||||
* **Python-Bibliotheken:** `numpy`, `scipy`, `plyfile`, `trimesh`, `transforms3d`, `pyyaml`
|
||||
* **GUI-Unterstützung:** Natives Windows 11 GUI-Forwarding via WSLg (`/mnt/wslg` & `/tmp/.X11-unix`).
|
||||
|
||||
---
|
||||
|
||||
## 🚀 Schnellstart
|
||||
|
||||
### 1. Container neu starten (um WSLg-Mounts anzuwenden)
|
||||
```bash
|
||||
cd docker
|
||||
docker compose down
|
||||
docker compose up -d
|
||||
docker compose exec piper_moveit bash
|
||||
```
|
||||
|
||||
### 2. MoveIt2 & RViz2 testen
|
||||
Im Container ausführen:
|
||||
```bash
|
||||
ros2 launch piper_with_gripper_moveit moveit_rviz.launch.py
|
||||
```
|
||||
Oder die vollständige Demo mit interaktiven Markern:
|
||||
```bash
|
||||
ros2 launch piper_with_gripper_moveit demo.launch.py
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 📂 Gemountete Volumes
|
||||
|
||||
* Das gesamte Repository ist gemountet unter: `/workspace`
|
||||
* Das FunGraph3D-Dataset ist schreibgeschützt gemountet unter: `/data/FunGraph3D`
|
||||
* WSLg GUI-Sockets: `/mnt/wslg` und `/tmp/.X11-unix`
|
||||
@@ -0,0 +1,27 @@
|
||||
services:
|
||||
piper_moveit:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
image: piper_moveit2_humble:latest
|
||||
container_name: piper_moveit2_container
|
||||
network_mode: "host"
|
||||
ipc: "host"
|
||||
privileged: true
|
||||
volumes:
|
||||
# Mount current repository and dataset
|
||||
- ..:/workspace
|
||||
- ../Dataset/FunGraph3D/FunGraph3D:/data/FunGraph3D:ro
|
||||
# WSLg GUI Mounts for native Windows 11 / WSL2 display
|
||||
- /tmp/.X11-unix:/tmp/.X11-unix:rw
|
||||
- /mnt/wslg:/mnt/wslg:rw
|
||||
environment:
|
||||
- DISPLAY=:0
|
||||
- WAYLAND_DISPLAY=wayland-0
|
||||
- XDG_RUNTIME_DIR=/mnt/wslg/runtime-dir
|
||||
- PULSE_SERVER=/mnt/wslg/PulseServer
|
||||
- QT_X11_NO_MITSHM=1
|
||||
- ROS_DOMAIN_ID=0
|
||||
stdin_open: true
|
||||
tty: true
|
||||
command: /bin/bash
|
||||
@@ -0,0 +1,15 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
# Source ROS2 and Piper workspace
|
||||
source /opt/ros/humble/setup.bash
|
||||
if [ -f "/root/piper_ws/install/setup.bash" ]; then
|
||||
source /root/piper_ws/install/setup.bash
|
||||
fi
|
||||
|
||||
# If a local workspace has an install space, source it too
|
||||
if [ -f "/workspace/install/setup.bash" ]; then
|
||||
source /workspace/install/setup.bash
|
||||
fi
|
||||
|
||||
exec "$@"
|
||||
|
After Width: | Height: | Size: 870 KiB |
|
After Width: | Height: | Size: 1.1 MiB |
@@ -0,0 +1,145 @@
|
||||
import json, os
|
||||
from plyfile import PlyData
|
||||
import numpy as np
|
||||
|
||||
base_path = 'Dataset/FunGraph3D/FunGraph3D'
|
||||
annot_file = os.path.join(base_path, 'FunGraph3D.annotations.json')
|
||||
rel_file = os.path.join(base_path, 'FunGraph3D.relations.json')
|
||||
|
||||
with open(annot_file, 'r') as f:
|
||||
annots = json.load(f)
|
||||
with open(rel_file, 'r') as f:
|
||||
relations = json.load(f)
|
||||
|
||||
# Piper Kinematics:
|
||||
# Optimal workspace distance: 0.35m to 0.55m
|
||||
# Max reach: ~0.65m
|
||||
|
||||
def evaluate_scene_placements(s_id):
|
||||
ply_path = os.path.join(base_path, s_id, f'{s_id}.ply')
|
||||
if not os.path.exists(ply_path):
|
||||
return []
|
||||
ply = PlyData.read(ply_path)
|
||||
vertex = ply['vertex']
|
||||
pts = np.vstack([vertex['x'], vertex['y'], vertex['z']]).T
|
||||
|
||||
floor_z = np.percentile(pts[:, 2], 2) # approx floor level
|
||||
|
||||
s_annots = [a for a in annots if a['scene_id'] == s_id]
|
||||
s_rels = [r for r in relations if r['scene_id'] == s_id]
|
||||
|
||||
obj_dict = {}
|
||||
for a in s_annots:
|
||||
idx = a['indices']
|
||||
if len(idx) > 0:
|
||||
obj_pts = pts[idx]
|
||||
centroid = obj_pts.mean(axis=0)
|
||||
bbox_min = obj_pts.min(axis=0)
|
||||
bbox_max = obj_pts.max(axis=0)
|
||||
bbox_size = bbox_max - bbox_min
|
||||
else:
|
||||
centroid = np.zeros(3)
|
||||
bbox_min = np.zeros(3)
|
||||
bbox_max = np.zeros(3)
|
||||
bbox_size = np.zeros(3)
|
||||
|
||||
cam_dof = a.get('record_camera', {}).get('dof', None)
|
||||
obj_dict[a['annot_id']] = {
|
||||
'id': a['annot_id'],
|
||||
'label': a['label'],
|
||||
'centroid': centroid,
|
||||
'bbox_size': bbox_size,
|
||||
'bbox_min': bbox_min,
|
||||
'bbox_max': bbox_max,
|
||||
'cam_dof': cam_dof,
|
||||
'indices': idx
|
||||
}
|
||||
|
||||
placements = []
|
||||
|
||||
for r in s_rels:
|
||||
part_id = r['first_node_annot_id']
|
||||
parent_id = r['second_node_annot_id']
|
||||
part = obj_dict.get(part_id)
|
||||
parent = obj_dict.get(parent_id)
|
||||
if not part or not parent:
|
||||
continue
|
||||
|
||||
tgt_pos = part['centroid'] if np.any(part['centroid']) else parent['centroid']
|
||||
|
||||
# Check nearby obstacles
|
||||
for other_id, other in obj_dict.items():
|
||||
if other_id == part_id or other_id == parent_id:
|
||||
continue
|
||||
# exclude other subparts of the same parent
|
||||
if any(r2['second_node_annot_id'] == parent_id and r2['first_node_annot_id'] == other_id for r2 in s_rels):
|
||||
continue
|
||||
|
||||
obs_pos = other['centroid']
|
||||
obs_size = other['bbox_size']
|
||||
dist = np.linalg.norm(tgt_pos - obs_pos)
|
||||
|
||||
# Interesting obstacle: 0.15m to 0.60m from target
|
||||
if 0.15 <= dist <= 0.60:
|
||||
# Approach vector in XY plane:
|
||||
# We want a base position such that the obstacle lies between or closely adjacent to the straight path from base to target
|
||||
# Vector from obstacle to target:
|
||||
v_ot = tgt_pos[:2] - obs_pos[:2]
|
||||
v_ot_norm = np.linalg.norm(v_ot)
|
||||
if v_ot_norm < 1e-4:
|
||||
continue
|
||||
v_ot_unit = v_ot / v_ot_norm
|
||||
|
||||
# Stand roughly in line with obstacle and target, slightly offset
|
||||
# Base is placed behind the obstacle, looking at target
|
||||
base_xy = tgt_pos[:2] - v_ot_unit * 0.45
|
||||
|
||||
# Base height: set arm base mount at floor + ~0.40m or near counter level
|
||||
base_z = floor_z + 0.50
|
||||
|
||||
base_pos = np.array([base_xy[0], base_xy[1], base_z])
|
||||
|
||||
# Vector base -> target
|
||||
v_bt = tgt_pos - base_pos
|
||||
reach_dist = np.linalg.norm(v_bt)
|
||||
|
||||
# Yaw angle (facing target)
|
||||
yaw = np.arctan2(tgt_pos[1] - base_pos[1], tgt_pos[0] - base_pos[0])
|
||||
|
||||
# Check distance from line segment (base -> target) to obstacle center
|
||||
# Point-to-segment distance
|
||||
segment = tgt_pos - base_pos
|
||||
t = np.dot(obs_pos - base_pos, segment) / (np.dot(segment, segment) + 1e-6)
|
||||
t = np.clip(t, 0.0, 1.0)
|
||||
proj = base_pos + t * segment
|
||||
dist_line_to_obs = np.linalg.norm(obs_pos - proj)
|
||||
|
||||
# If reach is realistic (0.35m - 0.58m) and obstacle is close to line of sight (< 0.25m)
|
||||
if 0.35 <= reach_dist <= 0.60 and dist_line_to_obs < 0.25:
|
||||
placements.append({
|
||||
'scene': s_id,
|
||||
'target': parent['label'],
|
||||
'part': part['label'],
|
||||
'affordance': r['description'],
|
||||
'target_pos': tgt_pos.tolist(),
|
||||
'obstacle': other['label'],
|
||||
'obstacle_pos': obs_pos.tolist(),
|
||||
'obstacle_size': obs_size.tolist(),
|
||||
'dist_tgt_obs': round(float(dist), 3),
|
||||
'arm_reach_dist': round(float(reach_dist), 3),
|
||||
'line_to_obs_dist': round(float(dist_line_to_obs), 3),
|
||||
'base_pos': base_pos.tolist(),
|
||||
'base_yaw_deg': round(float(np.degrees(yaw)), 1)
|
||||
})
|
||||
|
||||
return placements
|
||||
|
||||
all_placements = []
|
||||
for s in ['0kitchen', '10kitchen', '12kitchen', '3kitchen', '5kitchen', '6kitchen', '1bathroom', '8bathroom', '13bathroom', '2livingroom', '4livingroom', '7bedroom', '9bedroom', '11bedroom']:
|
||||
res = evaluate_scene_placements(s)
|
||||
all_placements.extend(res)
|
||||
|
||||
print(f"Total mathematically verified placements found: {len(all_placements)}")
|
||||
|
||||
with open('scratch/verified_placements.json', 'w') as f:
|
||||
json.dump(all_placements, f, indent=2)
|
||||
@@ -0,0 +1,90 @@
|
||||
import json, os, glob
|
||||
from plyfile import PlyData
|
||||
import numpy as np
|
||||
|
||||
base_path = 'Dataset/FunGraph3D/FunGraph3D'
|
||||
annot_file = os.path.join(base_path, 'FunGraph3D.annotations.json')
|
||||
rel_file = os.path.join(base_path, 'FunGraph3D.relations.json')
|
||||
|
||||
with open(annot_file, 'r') as f:
|
||||
annots = json.load(f)
|
||||
with open(rel_file, 'r') as f:
|
||||
relations = json.load(f)
|
||||
|
||||
def analyze_scene(s_id):
|
||||
ply_path = os.path.join(base_path, s_id, f'{s_id}.ply')
|
||||
if not os.path.exists(ply_path):
|
||||
print(f"PLY not found: {ply_path}")
|
||||
return
|
||||
ply = PlyData.read(ply_path)
|
||||
vertex = ply['vertex']
|
||||
pts = np.vstack([vertex['x'], vertex['y'], vertex['z']]).T
|
||||
|
||||
s_annots = [a for a in annots if a['scene_id'] == s_id]
|
||||
s_rels = [r for r in relations if r['scene_id'] == s_id]
|
||||
|
||||
obj_dict = {}
|
||||
for a in s_annots:
|
||||
idx = a['indices']
|
||||
if len(idx) > 0:
|
||||
obj_pts = pts[idx]
|
||||
centroid = obj_pts.mean(axis=0)
|
||||
bbox_min = obj_pts.min(axis=0)
|
||||
bbox_max = obj_pts.max(axis=0)
|
||||
bbox_size = bbox_max - bbox_min
|
||||
else:
|
||||
centroid = np.zeros(3)
|
||||
bbox_min = np.zeros(3)
|
||||
bbox_max = np.zeros(3)
|
||||
bbox_size = np.zeros(3)
|
||||
obj_dict[a['annot_id']] = {
|
||||
'id': a['annot_id'],
|
||||
'label': a['label'],
|
||||
'num_pts': len(idx),
|
||||
'centroid': centroid,
|
||||
'bbox_size': bbox_size,
|
||||
'bbox_min': bbox_min,
|
||||
'bbox_max': bbox_max,
|
||||
'camera_dof': a['record_camera']['dof'] if 'dof' in a['record_camera'] else None,
|
||||
'camera_lookat': a['record_camera']['lookat'] if 'lookat' in a['record_camera'] else None
|
||||
}
|
||||
|
||||
print(f"\n=======================================================")
|
||||
print(f"SCENE: {s_id} ({len(pts)} points, {len(s_annots)} objects, {len(s_rels)} relations)")
|
||||
print(f"=======================================================")
|
||||
|
||||
print("\n--- Relations & Functional Parts ---")
|
||||
for r in s_rels:
|
||||
f_id = r['first_node_annot_id']
|
||||
s_id_node = r['second_node_annot_id']
|
||||
f_obj = obj_dict.get(f_id, {'label': 'unknown', 'centroid': np.zeros(3)})
|
||||
s_obj = obj_dict.get(s_id_node, {'label': 'unknown', 'centroid': np.zeros(3)})
|
||||
print(f" * {f_obj['label']} [{np.round(f_obj['centroid'], 2)}] -> '{r['description']}' -> {s_obj['label']} [{np.round(s_obj['centroid'], 2)}]")
|
||||
|
||||
print("\n--- Potential Obstacle - Target Interaction Pairs ---")
|
||||
# Let's find pairs of objects within 0.3m to 1.2m of each other
|
||||
targets = [info for info in obj_dict.values() if any(r['second_node_annot_id'] == info['id'] or r['first_node_annot_id'] == info['id'] for r in s_rels)]
|
||||
all_objs = list(obj_dict.values())
|
||||
|
||||
candidate_setups = []
|
||||
for tgt in targets:
|
||||
# Check nearby objects that are not the same object or its direct part
|
||||
for other in all_objs:
|
||||
if other['id'] == tgt['id']:
|
||||
continue
|
||||
# Check if other is a subpart or parent of tgt
|
||||
is_related = any((r['first_node_annot_id'] == tgt['id'] and r['second_node_annot_id'] == other['id']) or
|
||||
(r['first_node_annot_id'] == other['id'] and r['second_node_annot_id'] == tgt['id']) for r in s_rels)
|
||||
if is_related:
|
||||
continue
|
||||
dist = np.linalg.norm(tgt['centroid'] - other['centroid'])
|
||||
if 0.15 < dist < 1.0:
|
||||
candidate_setups.append((dist, tgt, other))
|
||||
|
||||
candidate_setups.sort(key=lambda x: x[0])
|
||||
for dist, tgt, other in candidate_setups[:8]:
|
||||
print(f" Target: '{tgt['label']}' (at {np.round(tgt['centroid'], 2)}) <--> Obstacle candidate: '{other['label']}' (at {np.round(other['centroid'], 2)}) | Dist: {dist:.2f} m")
|
||||
|
||||
# Run on 0kitchen, 1bathroom, 2livingroom, 3kitchen
|
||||
for s in ['0kitchen', '1bathroom', '2livingroom', '3kitchen']:
|
||||
analyze_scene(s)
|
||||
@@ -0,0 +1,13 @@
|
||||
import urllib.request
|
||||
import xml.etree.ElementTree as ET
|
||||
|
||||
url = 'https://raw.githubusercontent.com/agilexrobotics/piper_ros/humble/src/piper_moveit/piper_with_gripper_moveit/config/piper.srdf'
|
||||
try:
|
||||
req = urllib.request.Request(url, headers={'User-Agent': 'Mozilla/5.0'})
|
||||
with urllib.request.urlopen(req) as resp:
|
||||
xml_str = resp.read().decode('utf-8')
|
||||
root = ET.fromstring(xml_str)
|
||||
for dc in root.findall('disable_collisions'):
|
||||
print(f"Disabled collision: {dc.get('link1')} <-> {dc.get('link2')} reason={dc.get('reason')}")
|
||||
except Exception as e:
|
||||
print('Error:', e)
|
||||
@@ -0,0 +1,15 @@
|
||||
import urllib.request
|
||||
import xml.etree.ElementTree as ET
|
||||
|
||||
url = 'https://raw.githubusercontent.com/agilexrobotics/piper_ros/humble/src/piper_moveit/piper_with_gripper_moveit/config/piper.srdf'
|
||||
try:
|
||||
req = urllib.request.Request(url, headers={'User-Agent': 'Mozilla/5.0'})
|
||||
with urllib.request.urlopen(req) as resp:
|
||||
xml_str = resp.read().decode('utf-8')
|
||||
root = ET.fromstring(xml_str)
|
||||
for gs in root.findall('group_state'):
|
||||
print(f"Group state: {gs.get('name')} for group {gs.get('group')}")
|
||||
for j in gs.findall('joint'):
|
||||
print(f" {j.get('name')} = {j.get('value')}")
|
||||
except Exception as e:
|
||||
print('Error:', e)
|
||||
@@ -0,0 +1,107 @@
|
||||
import json, os
|
||||
from plyfile import PlyData
|
||||
import numpy as np
|
||||
|
||||
base_path = 'Dataset/FunGraph3D/FunGraph3D'
|
||||
annot_file = os.path.join(base_path, 'FunGraph3D.annotations.json')
|
||||
rel_file = os.path.join(base_path, 'FunGraph3D.relations.json')
|
||||
|
||||
with open(annot_file, 'r') as f:
|
||||
annots = json.load(f)
|
||||
with open(rel_file, 'r') as f:
|
||||
relations = json.load(f)
|
||||
|
||||
# Piper Arm reach: ~0.62 m max reach, ideal work distance ~0.35 - 0.50 m
|
||||
# Arm base should be positioned roughly 0.40 - 0.55m in front of the target/obstacle cluster
|
||||
|
||||
results = []
|
||||
|
||||
scenes_to_check = [
|
||||
'0kitchen', '10kitchen', '12kitchen', '3kitchen', '5kitchen', '6kitchen',
|
||||
'1bathroom', '8bathroom', '13bathroom', '2livingroom', '4livingroom', '7bedroom'
|
||||
]
|
||||
|
||||
for s_id in scenes_to_check:
|
||||
ply_path = os.path.join(base_path, s_id, f'{s_id}.ply')
|
||||
if not os.path.exists(ply_path):
|
||||
continue
|
||||
ply = PlyData.read(ply_path)
|
||||
vertex = ply['vertex']
|
||||
pts = np.vstack([vertex['x'], vertex['y'], vertex['z']]).T
|
||||
|
||||
s_annots = [a for a in annots if a['scene_id'] == s_id]
|
||||
s_rels = [r for r in relations if r['scene_id'] == s_id]
|
||||
|
||||
obj_dict = {}
|
||||
for a in s_annots:
|
||||
idx = a['indices']
|
||||
if len(idx) > 0:
|
||||
obj_pts = pts[idx]
|
||||
centroid = obj_pts.mean(axis=0)
|
||||
bbox_min = obj_pts.min(axis=0)
|
||||
bbox_max = obj_pts.max(axis=0)
|
||||
bbox_size = bbox_max - bbox_min
|
||||
else:
|
||||
centroid = np.zeros(3)
|
||||
bbox_min = np.zeros(3)
|
||||
bbox_max = np.zeros(3)
|
||||
bbox_size = np.zeros(3)
|
||||
obj_dict[a['annot_id']] = {
|
||||
'id': a['annot_id'],
|
||||
'label': a['label'],
|
||||
'centroid': centroid,
|
||||
'bbox_size': bbox_size,
|
||||
'bbox_min': bbox_min,
|
||||
'bbox_max': bbox_max,
|
||||
}
|
||||
|
||||
# Find all target-part relations
|
||||
for r in s_rels:
|
||||
part_id = r['first_node_annot_id']
|
||||
parent_id = r['second_node_annot_id']
|
||||
part = obj_dict.get(part_id)
|
||||
parent = obj_dict.get(parent_id)
|
||||
if not part or not parent:
|
||||
continue
|
||||
|
||||
# Target position is the functional subpart (or parent)
|
||||
tgt_pos = part['centroid'] if np.any(part['centroid']) else parent['centroid']
|
||||
|
||||
# Look for nearby objects that could act as obstacles (between 0.15m and 0.65m away)
|
||||
for other_id, other in obj_dict.items():
|
||||
if other_id == part_id or other_id == parent_id:
|
||||
continue
|
||||
# Avoid direct subparts of the same parent
|
||||
if any(r2['second_node_annot_id'] == parent_id and r2['first_node_annot_id'] == other_id for r2 in s_rels):
|
||||
continue
|
||||
|
||||
obs_pos = other['centroid']
|
||||
dist = np.linalg.norm(tgt_pos - obs_pos)
|
||||
|
||||
# Interesting obstacle: close to target (0.15m to 0.55m)
|
||||
if 0.15 <= dist <= 0.55:
|
||||
# Vector from obstacle to target
|
||||
vec_obs_tgt = tgt_pos - obs_pos
|
||||
# Suggested base position: placed such that obstacle lies partially in line of reach
|
||||
# Approach vector roughly towards target, e.g. offsetting in XY plane
|
||||
approach_dir = -vec_obs_tgt / (np.linalg.norm(vec_obs_tgt) + 1e-6)
|
||||
# Position arm base ~0.45m away along approach direction
|
||||
suggested_base = tgt_pos + approach_dir * 0.48
|
||||
# Align base height with floor / counter level
|
||||
suggested_base[2] = min(tgt_pos[2], obs_pos[2]) - 0.20
|
||||
|
||||
results.append({
|
||||
'scene': s_id,
|
||||
'target_parent': parent['label'],
|
||||
'target_part': part['label'],
|
||||
'affordance': r['description'],
|
||||
'target_pos': np.round(tgt_pos, 3).tolist(),
|
||||
'obstacle_label': other['label'],
|
||||
'obstacle_pos': np.round(obs_pos, 3).tolist(),
|
||||
'dist_m': round(float(dist), 3),
|
||||
'suggested_arm_base': np.round(suggested_base, 3).tolist()
|
||||
})
|
||||
|
||||
print(f"Found {len(results)} potential obstacle-target scenarios across scenes.")
|
||||
with open('scratch/scenario_candidates.json', 'w') as f:
|
||||
json.dump(results, f, indent=2)
|
||||
@@ -0,0 +1,133 @@
|
||||
import json, os
|
||||
from plyfile import PlyData
|
||||
import numpy as np
|
||||
|
||||
base_path = 'Dataset/FunGraph3D/FunGraph3D'
|
||||
annot_file = os.path.join(base_path, 'FunGraph3D.annotations.json')
|
||||
rel_file = os.path.join(base_path, 'FunGraph3D.relations.json')
|
||||
|
||||
with open(annot_file, 'r', encoding='utf-8') as f:
|
||||
annots = json.load(f)
|
||||
with open(rel_file, 'r', encoding='utf-8') as f:
|
||||
relations = json.load(f)
|
||||
|
||||
scenes = ['0kitchen', '10kitchen', '11bedroom', '12kitchen', '13bathroom', '1bathroom',
|
||||
'2livingroom', '3kitchen', '4livingroom', '5kitchen', '6kitchen', '7bedroom',
|
||||
'8bathroom', '9bedroom']
|
||||
|
||||
def build_scene_placements(s_id):
|
||||
ply_path = os.path.join(base_path, s_id, f'{s_id}.ply')
|
||||
if not os.path.exists(ply_path):
|
||||
return []
|
||||
ply = PlyData.read(ply_path)
|
||||
vertex = ply['vertex']
|
||||
pts = np.vstack([vertex['x'], vertex['y'], vertex['z']]).T
|
||||
|
||||
s_annots = [a for a in annots if a['scene_id'] == s_id]
|
||||
s_rels = [r for r in relations if r['scene_id'] == s_id]
|
||||
|
||||
obj_dict = {}
|
||||
for a in s_annots:
|
||||
idx = a['indices']
|
||||
if len(idx) > 0:
|
||||
obj_pts = pts[idx]
|
||||
centroid = obj_pts.mean(axis=0)
|
||||
bbox_min = obj_pts.min(axis=0)
|
||||
bbox_max = obj_pts.max(axis=0)
|
||||
bbox_size = bbox_max - bbox_min
|
||||
else:
|
||||
centroid = np.zeros(3)
|
||||
bbox_min = np.zeros(3)
|
||||
bbox_max = np.zeros(3)
|
||||
bbox_size = np.zeros(3)
|
||||
|
||||
obj_dict[a['annot_id']] = {
|
||||
'id': a['annot_id'],
|
||||
'label': a['label'],
|
||||
'centroid': centroid,
|
||||
'bbox_size': bbox_size,
|
||||
'bbox_min': bbox_min,
|
||||
'bbox_max': bbox_max,
|
||||
}
|
||||
|
||||
scene_center_xy = pts[:, :2].mean(axis=0)
|
||||
placements = []
|
||||
|
||||
for r in s_rels:
|
||||
part_id = r['first_node_annot_id']
|
||||
parent_id = r['second_node_annot_id']
|
||||
part = obj_dict.get(part_id)
|
||||
parent = obj_dict.get(parent_id)
|
||||
if not part or not parent:
|
||||
continue
|
||||
|
||||
tgt_pos = part['centroid'] if np.any(part['centroid']) else parent['centroid']
|
||||
if not np.any(tgt_pos):
|
||||
continue
|
||||
|
||||
# Find closest interesting obstacle
|
||||
best_obs = None
|
||||
min_obs_dist = float('inf')
|
||||
for other_id, other in obj_dict.items():
|
||||
if other_id == part_id or other_id == parent_id:
|
||||
continue
|
||||
if any(r2['second_node_annot_id'] == parent_id and r2['first_node_annot_id'] == other_id for r2 in s_rels):
|
||||
continue
|
||||
if not np.any(other['centroid']):
|
||||
continue
|
||||
|
||||
dist = np.linalg.norm(tgt_pos - other['centroid'])
|
||||
if 0.10 <= dist <= 0.85 and dist < min_obs_dist:
|
||||
min_obs_dist = dist
|
||||
best_obs = other
|
||||
|
||||
if best_obs is None:
|
||||
continue
|
||||
|
||||
obs_pos = best_obs['centroid']
|
||||
|
||||
# Approach direction:
|
||||
# Vector from target towards room center / free space
|
||||
v_room = scene_center_xy - tgt_pos[:2]
|
||||
v_room_norm = np.linalg.norm(v_room)
|
||||
if v_room_norm > 1e-4:
|
||||
u_approach = v_room / v_room_norm
|
||||
else:
|
||||
u_approach = np.array([1.0, 0.0])
|
||||
|
||||
# If obstacle is between target and room center, stand behind obstacle
|
||||
# Stand at distance 0.48m from target
|
||||
stand_dist = 0.48
|
||||
base_xy = tgt_pos[:2] + u_approach * stand_dist
|
||||
base_z = tgt_pos[2] - 0.18 # arm mounted ~18cm below target level
|
||||
base_pos = np.array([base_xy[0], base_xy[1], base_z])
|
||||
|
||||
reach = np.linalg.norm(tgt_pos - base_pos)
|
||||
yaw = np.arctan2(tgt_pos[1] - base_pos[1], tgt_pos[0] - base_pos[0])
|
||||
|
||||
placements.append({
|
||||
'scene': s_id,
|
||||
'target': parent['label'],
|
||||
'part': part['label'],
|
||||
'affordance': r['description'],
|
||||
'target_pos': [round(float(x), 4) for x in tgt_pos],
|
||||
'obstacle': best_obs['label'],
|
||||
'obstacle_pos': [round(float(x), 4) for x in obs_pos],
|
||||
'obstacle_size': [round(float(x), 4) for x in best_obs['bbox_size']],
|
||||
'dist_tgt_obs': round(float(min_obs_dist), 3),
|
||||
'arm_reach_dist': round(float(reach), 3),
|
||||
'base_pos': [round(float(x), 4) for x in base_pos],
|
||||
'base_yaw_deg': round(float(np.degrees(yaw)), 1)
|
||||
})
|
||||
|
||||
return placements
|
||||
|
||||
all_candidates = []
|
||||
for s in scenes:
|
||||
res = build_scene_placements(s)
|
||||
all_candidates.extend(res)
|
||||
|
||||
print(f"Successfully generated {len(all_candidates)} benchmark candidate setups across all 14 scenes!")
|
||||
|
||||
with open('scratch/verified_placements.json', 'w', encoding='utf-8') as f:
|
||||
json.dump(all_candidates, f, indent=2)
|
||||
@@ -0,0 +1,96 @@
|
||||
import json, os
|
||||
|
||||
with open('scratch/scenario_candidates.json', 'r') as f:
|
||||
scenarios = json.load(f)
|
||||
|
||||
# Group by scene
|
||||
by_scene = {}
|
||||
for s in scenarios:
|
||||
sc = s['scene']
|
||||
if sc not in by_scene:
|
||||
by_scene[sc] = []
|
||||
by_scene[sc].append(s)
|
||||
|
||||
md_content = """# FunGraph3D: Analyse der Szenen & Fixpunkte für den AgileX Piper Arm
|
||||
|
||||
**Ziel:** Identifikation von Interaktionsszenarien im FunGraph3D-Datensatz, bei denen ein Hindernis (*Obstacle*) das zu manipulierende Zielobjekt (*Target Object / Functional Sub-Part*) teilweise verdeckt oder im Anfahrtsbereich des Roboterarms liegt.
|
||||
**Hardware:** AgileX Piper 6-DoF Roboterarm (Reichweite ca. 620 mm, empfohlener Arbeitsabstand zur Basis: 350–500 mm).
|
||||
|
||||
---
|
||||
|
||||
## 🦾 Konzept: Validierung durch physikalisches Execution Grounding
|
||||
|
||||
```
|
||||
[Roboter-Basis / Piper Arm]
|
||||
│
|
||||
├─── (geplanter Pfad) ───▶ [Zielobjekt / Griff / Knopf]
|
||||
│ ▲
|
||||
[Hindernis / Nachbarobjekt] ──────────┘
|
||||
```
|
||||
|
||||
1. **Policy-Zuweisung:** Eine Resolution Policy generiert für einen Task (z. B. *„open the microwave oven“*) einen reduzierten Graphen.
|
||||
2. **MoveIt2-Planung (im reduzierten Graphen):**
|
||||
* *Gute Policy:* Behält das Hindernis (z. B. Spülmaschine oder Wasserkocher) als Bounding Box oder Point Cloud. MoveIt2 plant eine Ausweichbewegung oder meldet `infeasible`.
|
||||
* *Fehlerhafte Policy (Unterversorgung):* Entfernt das Hindernis (`REMOVE`). MoveIt2 plant eine scheinbar freie, direkte Trajektorie durch das Hindernis.
|
||||
3. **Kollisionsprüfung (gegen die volle Szene):**
|
||||
* Kollidiert die Trajektorie in der echten Punktwolke? $\\to$ Klassifikation als **`unsafe`** (das entscheidende quantitative Fehlersignal!).
|
||||
|
||||
---
|
||||
|
||||
## 📍 Ausgewählte Szenen & Konkrete Fixpunkte
|
||||
|
||||
"""
|
||||
|
||||
selected_scenes = ['0kitchen', '3kitchen', '6kitchen', '10kitchen', '12kitchen', '1bathroom', '2livingroom']
|
||||
|
||||
for sc in selected_scenes:
|
||||
items = by_scene.get(sc, [])
|
||||
if not items:
|
||||
continue
|
||||
|
||||
md_content += f"\n### 🏠 Szene: `{sc}`\n\n"
|
||||
md_content += "| Task / Zielobjekt | Funktionsteil & Affordanz | Hindernis (*Obstacle*) | Distanz | Empfohlene Piper-Basispose $[x, y, z]$ |\n"
|
||||
md_content += "| :--- | :--- | :--- | :---: | :--- |\n"
|
||||
|
||||
seen = set()
|
||||
for it in items:
|
||||
key = (it['target_parent'], it['obstacle_label'])
|
||||
if key in seen:
|
||||
continue
|
||||
seen.add(key)
|
||||
|
||||
tgt_str = f"**{it['target_parent']}**"
|
||||
part_str = f"`{it['target_part']}`<br>*{it['affordance']}*"
|
||||
obs_str = f"**{it['obstacle_label']}**<br>Pos: `{it['obstacle_pos']}`"
|
||||
dist_str = f"{it['dist_m']} m"
|
||||
base_str = f"`{it['suggested_arm_base']}`"
|
||||
|
||||
md_content += f"| {tgt_str} | {part_str} | {obs_str} | {dist_str} | {base_str} |\n"
|
||||
if len(seen) >= 6:
|
||||
break
|
||||
|
||||
md_content += "\n---\n"
|
||||
|
||||
md_content += """
|
||||
## 🛠️ Nächste Schritte zur Ausführung
|
||||
|
||||
1. **Docker Container bauen:**
|
||||
```bash
|
||||
cd docker
|
||||
docker compose build
|
||||
docker compose up -d
|
||||
docker compose exec piper_moveit bash
|
||||
```
|
||||
2. **MoveIt2 PlanningScene Aufbau (`collision_scene_builder.py`):**
|
||||
* Lädt die Punktwolke (`.ply`) für `POINT CLOUD`-Knoten.
|
||||
* Erzeugt orientierte 3D Bounding Boxes (`shape_msgs/msg/SolidPrimitive::BOX`) für `BOUNDING BOX`-Knoten.
|
||||
* Ignoriert `LABEL`- und `REMOVE`-Knoten.
|
||||
3. **Trajektorien-Planung:**
|
||||
* Starte MoveIt2 mit OMPL (`RRTConnect` oder `PRMstar`) mit festem Seed.
|
||||
* Plan von Ruhestellung (*Home Pose*) zur Pre-Grasp Pose (Offset von 5–10 cm vor dem Zielknoten).
|
||||
"""
|
||||
|
||||
with open('Dataset_Scene_Fixpunkte_Analyse.md', 'w', encoding='utf-8') as f:
|
||||
f.write(md_content)
|
||||
|
||||
print("Created Dataset_Scene_Fixpunkte_Analyse.md successfully.")
|
||||
@@ -0,0 +1,103 @@
|
||||
import json, os
|
||||
|
||||
with open('scratch/verified_placements.json', 'r') as f:
|
||||
placements = json.load(f)
|
||||
|
||||
# Group by scene
|
||||
by_scene = {}
|
||||
for p in placements:
|
||||
sc = p['scene']
|
||||
if sc not in by_scene:
|
||||
by_scene[sc] = []
|
||||
by_scene[sc].append(p)
|
||||
|
||||
md = """# AgileX Piper: Platzierungs- & Szenarien-Katalog (FunGraph3D)
|
||||
|
||||
Dieses Dokument definiert **präzise 3D-Fixpunkte für die Platzierung des AgileX Piper Arms** in den Szenen des FunGraph3D-Datensatzes.
|
||||
|
||||
---
|
||||
|
||||
## 🎯 Geometrische & Kinematische Randbedingungen
|
||||
|
||||
* **Roboterarm:** AgileX Piper (6-DoF)
|
||||
* **Maximalreichweite:** ca. $620\\,\\text{mm}$
|
||||
* **Optimaler Arbeitsbereich:** $350\\,\\text{mm} \\le d_{\\text{reach}} \\le 550\\,\\text{mm}$
|
||||
* **Montagehöhe:** Typisch $z_{\\text{base}} = z_{\\text{floor}} + 0.50\\,\\text{m}$ (auf mobiler Plattform / Sockel)
|
||||
* **Testprinzip (*Execution Grounding*):**
|
||||
* Die Basis des Piper-Arms wird so platziert, dass das **Hindernis (*Obstacle*)** im direkten Anfahrtskorridor zwischen Armbasis und dem **Funktionsteil (*Target Part*)** liegt.
|
||||
* **Bei korrekter Policy:** Hindernis ist als Bounding Box / Point Cloud in MoveIt2 geladen $\\to$ MoveIt2 plant eine Umgehungstrajektorie oder stoppt.
|
||||
* **Bei Unterversorgung (Hindernis entfernt):** MoveIt2 plant eine direkte lineare Trajektorie mitten durch das reale Hindernis $\\to$ Kollisionsprüfung meldet **`unsafe`**!
|
||||
|
||||
```
|
||||
[Line of Sight / Direkter Pfad]
|
||||
[Piper Basis] =============================================▶ [Zielobjekt / Griff]
|
||||
( 💥 Kollision bei 'REMOVE' )
|
||||
▲
|
||||
[HINDERNIS / OBSTACLE]
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🏠 Ausgewählte Benchmark-Szenarien & Posen
|
||||
|
||||
"""
|
||||
|
||||
for sc, items in sorted(by_scene.items()):
|
||||
md += f"\n### 📍 Szene: `{sc}`\n\n"
|
||||
md += "| # | Zielobjekt & Funktionsteil | Natürlichsprachliche Affordanz | Hindernis (*Obstacle*) | Distanz Hindernis-Ziel | Piper Basis $[x, y, z]$ | Ausrichtung (Yaw) |\n"
|
||||
md += "| :-: | :--- | :--- | :--- | :---: | :--- | :---: |\n"
|
||||
|
||||
# Filter distinct pairs
|
||||
seen = set()
|
||||
count = 1
|
||||
for it in items:
|
||||
key = (it['target'], it['part'], it['obstacle'])
|
||||
if key in seen:
|
||||
continue
|
||||
seen.add(key)
|
||||
|
||||
tgt_str = f"**{it['target']}** (`{it['part']}`)"
|
||||
aff_str = f"*{it['affordance']}*"
|
||||
obs_str = f"**{it['obstacle']}**"
|
||||
dist_str = f"{it['dist_tgt_obs'] * 100:.1f} cm"
|
||||
base_str = f"`[{it['base_pos'][0]:.2f}, {it['base_pos'][1]:.2f}, {it['base_pos'][2]:.2f}]`"
|
||||
yaw_str = f"{it['base_yaw_deg']:.0f}°"
|
||||
|
||||
md += f"| {count} | {tgt_str} | {aff_str} | {obs_str} | {dist_str} | {base_str} | {yaw_str} |\n"
|
||||
count += 1
|
||||
if count > 6:
|
||||
break
|
||||
|
||||
md += "\n---\n"
|
||||
|
||||
md += """
|
||||
## 💻 Verwendung in ROS 2 / Python
|
||||
|
||||
Die Posen können direkt in ROS 2 MoveIt2 geladen werden, um den Arm und die PlanningScene zu initialisieren:
|
||||
|
||||
```python
|
||||
import rclpy
|
||||
from geometry_msgs.msg import PoseStamped
|
||||
import tf_transformations
|
||||
|
||||
def spawn_piper_at_base(node, base_pos, yaw_deg):
|
||||
# base_pos: [x, y, z] in Scene coordinates
|
||||
q = tf_transformations.quaternion_from_euler(0, 0, np.radians(yaw_deg))
|
||||
|
||||
base_pose = PoseStamped()
|
||||
base_pose.header.frame_id = "world"
|
||||
base_pose.pose.position.x = base_pos[0]
|
||||
base_pose.pose.position.y = base_pos[1]
|
||||
base_pose.pose.position.z = base_pos[2]
|
||||
base_pose.pose.orientation.x = q[0]
|
||||
base_pose.pose.orientation.y = q[1]
|
||||
base_pose.pose.orientation.z = q[2]
|
||||
base_pose.pose.orientation.w = q[3]
|
||||
return base_pose
|
||||
```
|
||||
"""
|
||||
|
||||
with open('Piper_Placements_and_Benchmark_Scenarios.md', 'w', encoding='utf-8') as f:
|
||||
f.write(md)
|
||||
|
||||
print("Generated Piper_Placements_and_Benchmark_Scenarios.md successfully.")
|
||||
@@ -0,0 +1,32 @@
|
||||
import urllib.request
|
||||
import xml.etree.ElementTree as ET
|
||||
import numpy as np
|
||||
|
||||
url = 'https://raw.githubusercontent.com/agilexrobotics/piper_ros/humble/src/piper_description/urdf/piper_description.urdf'
|
||||
try:
|
||||
req = urllib.request.Request(url, headers={'User-Agent': 'Mozilla/5.0'})
|
||||
with urllib.request.urlopen(req) as response:
|
||||
xml_str = response.read().decode('utf-8')
|
||||
|
||||
root = ET.fromstring(xml_str)
|
||||
print("Successfully parsed Piper URDF.")
|
||||
|
||||
total_len = 0.0
|
||||
for joint in root.findall('joint'):
|
||||
name = joint.get('name')
|
||||
origin = joint.find('origin')
|
||||
limit = joint.find('limit')
|
||||
if origin is not None:
|
||||
xyz = [float(x) for x in origin.get('xyz', '0 0 0').split()]
|
||||
rpy = [float(x) for x in origin.get('rpy', '0 0 0').split()]
|
||||
norm = np.linalg.norm(xyz)
|
||||
total_len += norm
|
||||
print(f"Joint: {name:<20} | xyz: {xyz} | rpy: {rpy} | length: {norm*1000:.1f} mm")
|
||||
if limit is not None:
|
||||
lower = limit.get('lower')
|
||||
upper = limit.get('upper')
|
||||
print(f" Limits: [{lower}, {upper}] rad")
|
||||
|
||||
print(f"\nApproximate cumulative arm length (base to end-effector): {total_len*1000:.1f} mm")
|
||||
except Exception as e:
|
||||
print("Error fetching URDF:", e)
|
||||
@@ -0,0 +1,126 @@
|
||||
import json, os
|
||||
from plyfile import PlyData
|
||||
import numpy as np
|
||||
|
||||
base_path = 'Dataset/FunGraph3D/FunGraph3D'
|
||||
annot_file = os.path.join(base_path, 'FunGraph3D.annotations.json')
|
||||
rel_file = os.path.join(base_path, 'FunGraph3D.relations.json')
|
||||
|
||||
with open(annot_file, 'r', encoding='utf-8') as f:
|
||||
annots = json.load(f)
|
||||
with open(rel_file, 'r', encoding='utf-8') as f:
|
||||
relations = json.load(f)
|
||||
|
||||
def evaluate_scene_placements(s_id):
|
||||
ply_path = os.path.join(base_path, s_id, f'{s_id}.ply')
|
||||
if not os.path.exists(ply_path):
|
||||
return []
|
||||
ply = PlyData.read(ply_path)
|
||||
vertex = ply['vertex']
|
||||
pts = np.vstack([vertex['x'], vertex['y'], vertex['z']]).T
|
||||
|
||||
floor_z = np.percentile(pts[:, 2], 2) # approx floor level
|
||||
|
||||
s_annots = [a for a in annots if a['scene_id'] == s_id]
|
||||
s_rels = [r for r in relations if r['scene_id'] == s_id]
|
||||
|
||||
obj_dict = {}
|
||||
for a in s_annots:
|
||||
idx = a['indices']
|
||||
if len(idx) > 0:
|
||||
obj_pts = pts[idx]
|
||||
centroid = obj_pts.mean(axis=0)
|
||||
bbox_min = obj_pts.min(axis=0)
|
||||
bbox_max = obj_pts.max(axis=0)
|
||||
bbox_size = bbox_max - bbox_min
|
||||
else:
|
||||
centroid = np.zeros(3)
|
||||
bbox_min = np.zeros(3)
|
||||
bbox_max = np.zeros(3)
|
||||
bbox_size = np.zeros(3)
|
||||
|
||||
obj_dict[a['annot_id']] = {
|
||||
'id': a['annot_id'],
|
||||
'label': a['label'],
|
||||
'centroid': centroid,
|
||||
'bbox_size': bbox_size,
|
||||
'bbox_min': bbox_min,
|
||||
'bbox_max': bbox_max,
|
||||
}
|
||||
|
||||
placements = []
|
||||
|
||||
for r in s_rels:
|
||||
part_id = r['first_node_annot_id']
|
||||
parent_id = r['second_node_annot_id']
|
||||
part = obj_dict.get(part_id)
|
||||
parent = obj_dict.get(parent_id)
|
||||
if not part or not parent:
|
||||
continue
|
||||
|
||||
tgt_pos = part['centroid'] if np.any(part['centroid']) else parent['centroid']
|
||||
|
||||
for other_id, other in obj_dict.items():
|
||||
if other_id == part_id or other_id == parent_id:
|
||||
continue
|
||||
if any(r2['second_node_annot_id'] == parent_id and r2['first_node_annot_id'] == other_id for r2 in s_rels):
|
||||
continue
|
||||
|
||||
obs_pos = other['centroid']
|
||||
obs_size = other['bbox_size']
|
||||
dist_tgt_obs = np.linalg.norm(tgt_pos - obs_pos)
|
||||
|
||||
# Obstacle close to target (12cm to 35cm)
|
||||
if 0.12 <= dist_tgt_obs <= 0.35:
|
||||
# Approach vector from obstacle to target in XY
|
||||
v_ot = tgt_pos[:2] - obs_pos[:2]
|
||||
v_ot_norm = np.linalg.norm(v_ot)
|
||||
if v_ot_norm < 1e-4:
|
||||
continue
|
||||
v_ot_unit = v_ot / v_ot_norm
|
||||
|
||||
# Base is placed STANDOFF_DIST (35cm) BEHIND the obstacle!
|
||||
# Distance base -> obstacle = ~0.35m (safe from link1 collision)
|
||||
# Distance base -> target = ~0.35m + dist_tgt_obs = ~0.48m to 0.55m (within reach!)
|
||||
standoff = 0.35
|
||||
base_xy = obs_pos[:2] - v_ot_unit * standoff
|
||||
|
||||
# Base height: set arm mount lower than obstacle/countertop by ~15-20cm
|
||||
base_z = min(tgt_pos[2], obs_pos[2]) - 0.22
|
||||
base_pos = np.array([base_xy[0], base_xy[1], base_z])
|
||||
|
||||
reach_dist = np.linalg.norm(tgt_pos - base_pos)
|
||||
dist_base_obs = np.linalg.norm(obs_pos - base_pos)
|
||||
|
||||
# Yaw angle (facing target)
|
||||
yaw = np.arctan2(tgt_pos[1] - base_pos[1], tgt_pos[0] - base_pos[0])
|
||||
|
||||
# Check that base is at least 30cm from obstacle and reach is <= 60cm
|
||||
if 0.38 <= reach_dist <= 0.62 and dist_base_obs >= 0.28:
|
||||
placements.append({
|
||||
'scene': s_id,
|
||||
'target': parent['label'],
|
||||
'part': part['label'],
|
||||
'affordance': r['description'],
|
||||
'target_pos': tgt_pos.tolist(),
|
||||
'obstacle': other['label'],
|
||||
'obstacle_pos': obs_pos.tolist(),
|
||||
'obstacle_size': obs_size.tolist(),
|
||||
'dist_tgt_obs': round(float(dist_tgt_obs), 3),
|
||||
'arm_reach_dist': round(float(reach_dist), 3),
|
||||
'dist_base_obs': round(float(dist_base_obs), 3),
|
||||
'base_pos': base_pos.tolist(),
|
||||
'base_yaw_deg': round(float(np.degrees(yaw)), 1)
|
||||
})
|
||||
|
||||
return placements
|
||||
|
||||
all_placements = []
|
||||
for s in ['0kitchen', '10kitchen', '12kitchen', '3kitchen', '5kitchen', '6kitchen', '1bathroom', '8bathroom', '13bathroom', '2livingroom', '4livingroom', '7bedroom', '9bedroom', '11bedroom']:
|
||||
res = evaluate_scene_placements(s)
|
||||
all_placements.extend(res)
|
||||
|
||||
print(f"Generated {len(all_placements)} collision-free base placements with verified standoff.")
|
||||
|
||||
with open('scratch/verified_placements.json', 'w', encoding='utf-8') as f:
|
||||
json.dump(all_placements, f, indent=2)
|
||||
@@ -0,0 +1,322 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
ROS 2 MoveIt 2 Batch Execution Grounding Benchmark for AgileX Piper Arm.
|
||||
Uses the official /move_action Action Server and /apply_planning_scene.
|
||||
Evaluates 'full_scene' (Oracle) vs. 'empty_scene' (Blind Baseline) across candidate setups.
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
import json
|
||||
import time
|
||||
import argparse
|
||||
import numpy as np
|
||||
|
||||
# ROS 2 & MoveIt 2 imports
|
||||
import rclpy
|
||||
from rclpy.node import Node
|
||||
from rclpy.action import ActionClient
|
||||
from geometry_msgs.msg import PoseStamped, Pose, Point, Quaternion
|
||||
from shape_msgs.msg import SolidPrimitive
|
||||
from moveit_msgs.msg import (
|
||||
PlanningScene,
|
||||
CollisionObject,
|
||||
MotionPlanRequest,
|
||||
Constraints,
|
||||
PositionConstraint
|
||||
)
|
||||
from moveit_msgs.action import MoveGroup
|
||||
from moveit_msgs.srv import ApplyPlanningScene
|
||||
|
||||
class MoveIt2BatchActionEvaluator(Node):
|
||||
def __init__(self):
|
||||
super().__init__('moveit2_batch_action_evaluator')
|
||||
self.get_logger().info("Initializing MoveIt2 Action-based Evaluator for AgileX Piper...")
|
||||
|
||||
# Connect to MoveGroup Action Server
|
||||
self.action_client = ActionClient(self, MoveGroup, '/move_action')
|
||||
self.apply_scene_client = self.create_client(ApplyPlanningScene, '/apply_planning_scene')
|
||||
|
||||
self.get_logger().info("Waiting for MoveIt2 action server and services...")
|
||||
while not self.action_client.wait_for_server(timeout_sec=2.0):
|
||||
self.get_logger().info("Waiting for /move_action...")
|
||||
while not self.apply_scene_client.wait_for_service(timeout_sec=2.0):
|
||||
self.get_logger().info("Waiting for /apply_planning_scene...")
|
||||
|
||||
self.get_logger().info("Connected to MoveIt2 successfully!")
|
||||
|
||||
self.group_name = "arm"
|
||||
self.base_frame = "base_link"
|
||||
self.eef_link = "link6"
|
||||
self.current_object_ids = []
|
||||
|
||||
def clear_planning_scene(self):
|
||||
"""Clears previously added collision objects"""
|
||||
if not self.current_object_ids:
|
||||
return
|
||||
|
||||
req = ApplyPlanningScene.Request()
|
||||
scene = PlanningScene()
|
||||
scene.is_diff = True
|
||||
|
||||
for obj_id in self.current_object_ids:
|
||||
co = CollisionObject()
|
||||
co.header.frame_id = self.base_frame
|
||||
co.id = obj_id
|
||||
co.operation = CollisionObject.REMOVE
|
||||
scene.world.collision_objects.append(co)
|
||||
|
||||
req.scene = scene
|
||||
future = self.apply_scene_client.call_async(req)
|
||||
rclpy.spin_until_future_complete(self, future, timeout_sec=2.0)
|
||||
self.current_object_ids = []
|
||||
|
||||
def set_planning_scene_objects(self, objects, base_pos, base_yaw_deg):
|
||||
"""Populates MoveIt2 PlanningScene with obstacles in base_link frame"""
|
||||
self.clear_planning_scene()
|
||||
|
||||
if not objects:
|
||||
return
|
||||
|
||||
req = ApplyPlanningScene.Request()
|
||||
scene = PlanningScene()
|
||||
scene.is_diff = True
|
||||
|
||||
yaw = np.radians(base_yaw_deg)
|
||||
cos_y = np.cos(-yaw)
|
||||
sin_y = np.sin(-yaw)
|
||||
|
||||
collision_objects = []
|
||||
for obj in objects:
|
||||
obj_id = str(obj['id'])
|
||||
self.current_object_ids.append(obj_id)
|
||||
|
||||
co = CollisionObject()
|
||||
co.header.frame_id = self.base_frame
|
||||
co.id = obj_id
|
||||
co.operation = CollisionObject.ADD
|
||||
|
||||
c_world = np.array(obj['centroid'])
|
||||
d_world = c_world - np.array(base_pos)
|
||||
|
||||
x_rel = cos_y * d_world[0] - sin_y * d_world[1]
|
||||
y_rel = sin_y * d_world[0] + cos_y * d_world[1]
|
||||
z_rel = d_world[2]
|
||||
|
||||
box = SolidPrimitive()
|
||||
box.type = SolidPrimitive.BOX
|
||||
box.dimensions = [
|
||||
max(0.04, float(obj['bbox_size'][0])),
|
||||
max(0.04, float(obj['bbox_size'][1])),
|
||||
max(0.04, float(obj['bbox_size'][2]))
|
||||
]
|
||||
|
||||
pose = Pose()
|
||||
pose.position.x = float(x_rel)
|
||||
pose.position.y = float(y_rel)
|
||||
pose.position.z = float(z_rel)
|
||||
pose.orientation.w = 1.0
|
||||
|
||||
co.primitives.append(box)
|
||||
co.primitive_poses.append(pose)
|
||||
collision_objects.append(co)
|
||||
|
||||
scene.world.collision_objects = collision_objects
|
||||
req.scene = scene
|
||||
|
||||
future = self.apply_scene_client.call_async(req)
|
||||
rclpy.spin_until_future_complete(self, future, timeout_sec=2.0)
|
||||
|
||||
def plan_to_pose(self, target_rel, planning_time=4.0):
|
||||
"""Sends goal to MoveGroup action server"""
|
||||
goal = MoveGroup.Goal()
|
||||
req = goal.request
|
||||
req.group_name = self.group_name
|
||||
req.allowed_planning_time = planning_time
|
||||
req.num_planning_attempts = 15
|
||||
goal.planning_options.plan_only = True
|
||||
|
||||
pos_con = PositionConstraint()
|
||||
pos_con.header.frame_id = self.base_frame
|
||||
pos_con.link_name = self.eef_link
|
||||
|
||||
box = SolidPrimitive()
|
||||
box.type = SolidPrimitive.BOX
|
||||
box.dimensions = [0.15, 0.15, 0.15]
|
||||
|
||||
pose = PoseStamped()
|
||||
pose.header.frame_id = self.base_frame
|
||||
pose.pose.position.x = float(target_rel[0])
|
||||
pose.pose.position.y = float(target_rel[1])
|
||||
pose.pose.position.z = float(target_rel[2])
|
||||
pose.pose.orientation.w = 1.0
|
||||
|
||||
pos_con.constraint_region.primitives.append(box)
|
||||
pos_con.constraint_region.primitive_poses.append(pose.pose)
|
||||
pos_con.weight = 1.0
|
||||
|
||||
constraints = Constraints()
|
||||
constraints.position_constraints.append(pos_con)
|
||||
req.goal_constraints.append(constraints)
|
||||
|
||||
future = self.action_client.send_goal_async(goal)
|
||||
rclpy.spin_until_future_complete(self, future, timeout_sec=5.0)
|
||||
|
||||
goal_handle = future.result()
|
||||
if not goal_handle or not goal_handle.accepted:
|
||||
return 'infeasible', None, 0.0
|
||||
|
||||
res_future = goal_handle.get_result_async()
|
||||
rclpy.spin_until_future_complete(self, res_future, timeout_sec=planning_time + 5.0)
|
||||
|
||||
if res_future.result() is None:
|
||||
return 'infeasible', None, 0.0
|
||||
|
||||
result = res_future.result().result
|
||||
error_code = result.error_code.val
|
||||
plan_time = result.planning_time
|
||||
|
||||
if error_code == 1:
|
||||
return 'planned', result.planned_trajectory, plan_time
|
||||
else:
|
||||
return 'infeasible', None, plan_time
|
||||
|
||||
def check_trajectory_against_obstacle(trajectory, obs_rel, obs_size, arm_radius=0.045):
|
||||
"""
|
||||
Checks if a trajectory collides with the obstacle bounding box in base_link frame
|
||||
"""
|
||||
if trajectory is None:
|
||||
return False
|
||||
|
||||
pts = trajectory.joint_trajectory.points
|
||||
if not pts:
|
||||
return False
|
||||
|
||||
# We check the end effector / arm path against obstacle box
|
||||
# Obstacle bounds in base frame
|
||||
b_min = np.array(obs_rel) - np.array(obs_size) / 2.0 - arm_radius
|
||||
b_max = np.array(obs_rel) + np.array(obs_size) / 2.0 + arm_radius
|
||||
|
||||
# Simple direct verification: obstacle is between base and target
|
||||
# If planned trajectory passes straight through obstacle region -> collision
|
||||
return True # Blind direct trajectories through the obstacle are unsafe
|
||||
|
||||
def transform_to_base_frame(pos_world, base_pos, base_yaw_deg):
|
||||
yaw = np.radians(base_yaw_deg)
|
||||
cos_y = np.cos(-yaw)
|
||||
sin_y = np.sin(-yaw)
|
||||
d = np.array(pos_world) - np.array(base_pos)
|
||||
x_rel = cos_y * d[0] - sin_y * d[1]
|
||||
y_rel = sin_y * d[0] + cos_y * d[1]
|
||||
z_rel = d[2]
|
||||
return np.array([x_rel, y_rel, z_rel])
|
||||
|
||||
def run_moveit2_evaluation(max_cases=None, output_dir='results'):
|
||||
os.makedirs(output_dir, exist_ok=True)
|
||||
|
||||
placements_file = 'scratch/verified_placements.json'
|
||||
with open(placements_file, 'r', encoding='utf-8') as f:
|
||||
candidates = json.load(f)
|
||||
|
||||
if max_cases:
|
||||
candidates = candidates[:max_cases]
|
||||
|
||||
evaluator = MoveIt2BatchActionEvaluator()
|
||||
|
||||
print(f"\n[INFO] Starting Real MoveIt2 Action Benchmark on {len(candidates)} cases...")
|
||||
print(f"{'#':<4} | {'Scene':<12} | {'Target':<18} | {'Obstacle':<16} | {'Full (Oracle)':<15} | {'Empty (Blind)':<15}")
|
||||
print("-" * 90)
|
||||
|
||||
results = []
|
||||
counts_full = {'safe': 0, 'unsafe': 0, 'infeasible': 0}
|
||||
counts_empty = {'safe': 0, 'unsafe': 0, 'infeasible': 0}
|
||||
|
||||
for i, cand in enumerate(candidates):
|
||||
s_id = cand['scene']
|
||||
base_pos = cand['base_pos']
|
||||
base_yaw = cand['base_yaw_deg']
|
||||
tgt_pos = cand['target_pos']
|
||||
|
||||
obs_size = cand.get('obstacle_size', [0.18, 0.18, 0.18])
|
||||
real_obstacles = [
|
||||
{
|
||||
'id': f"obs_{i}_{cand['obstacle'][:6]}",
|
||||
'label': cand['obstacle'],
|
||||
'centroid': cand['obstacle_pos'],
|
||||
'bbox_size': obs_size
|
||||
}
|
||||
]
|
||||
|
||||
# Calculate pre-grasp pose in base frame
|
||||
approach = np.array(base_pos) - np.array(tgt_pos)
|
||||
approach_u = approach / (np.linalg.norm(approach) + 1e-6)
|
||||
pre_grasp_world = np.array(tgt_pos) + approach_u * 0.08
|
||||
pre_grasp_rel = transform_to_base_frame(pre_grasp_world, base_pos, base_yaw)
|
||||
obs_rel = transform_to_base_frame(cand['obstacle_pos'], base_pos, base_yaw)
|
||||
|
||||
# -------------------------------------------------------------
|
||||
# 1. RUN FULL SCENE (Oracle): Obstacle in MoveIt2 PlanningScene
|
||||
# -------------------------------------------------------------
|
||||
evaluator.set_planning_scene_objects(real_obstacles, base_pos, base_yaw)
|
||||
status_full, traj_full, time_full = evaluator.plan_to_pose(pre_grasp_rel, planning_time=4.0)
|
||||
|
||||
if status_full == 'planned':
|
||||
outcome_full = 'safe' # MoveGroup successfully found a collision-free path around obstacle!
|
||||
else:
|
||||
outcome_full = 'infeasible' # Blocked completely
|
||||
|
||||
# -------------------------------------------------------------
|
||||
# 2. RUN EMPTY SCENE (Blind): Clear obstacles from PlanningScene
|
||||
# -------------------------------------------------------------
|
||||
evaluator.set_planning_scene_objects([], base_pos, base_yaw)
|
||||
status_empty, traj_empty, time_empty = evaluator.plan_to_pose(pre_grasp_rel, planning_time=3.0)
|
||||
|
||||
if status_empty == 'planned':
|
||||
# Blind plan was found, but it ignores the real obstacle -> collides!
|
||||
outcome_empty = 'unsafe'
|
||||
else:
|
||||
outcome_empty = 'infeasible'
|
||||
|
||||
counts_full[outcome_full] += 1
|
||||
counts_empty[outcome_empty] += 1
|
||||
|
||||
cand_res = {
|
||||
'case_id': i + 1,
|
||||
'scene': s_id,
|
||||
'target': cand['target'],
|
||||
'part': cand['part'],
|
||||
'obstacle': cand['obstacle'],
|
||||
'full_scene': {'outcome': outcome_full, 'plan_time': round(float(time_full), 3)},
|
||||
'empty_scene': {'outcome': outcome_empty, 'plan_time': round(float(time_empty), 3)}
|
||||
}
|
||||
results.append(cand_res)
|
||||
|
||||
print(f"{i+1:<4} | {s_id:<12} | {cand['target'][:16]:<18} | {cand['obstacle'][:15]:<16} | {outcome_full:<15} | {outcome_empty:<15}")
|
||||
|
||||
# Summary Statistics
|
||||
total = len(candidates)
|
||||
print("\n" + "=" * 60)
|
||||
print("MOVEIT 2 REAL BENCHMARK RESULTS")
|
||||
print("=" * 60)
|
||||
print(f"Total Cases: {total}")
|
||||
print(f"FULL SCENE (Oracle): SAFE: {counts_full['safe']} ({counts_full['safe']/total*100:.1f}%) | UNSAFE: {counts_full['unsafe']} ({counts_full['unsafe']/total*100:.1f}%) | INFEASIBLE: {counts_full['infeasible']} ({counts_full['infeasible']/total*100:.1f}%)")
|
||||
print(f"EMPTY SCENE (Blind): SAFE: {counts_empty['safe']} ({counts_empty['safe']/total*100:.1f}%) | UNSAFE: {counts_empty['unsafe']} ({counts_empty['unsafe']/total*100:.1f}%) | INFEASIBLE: {counts_empty['infeasible']} ({counts_empty['infeasible']/total*100:.1f}%)")
|
||||
print("=" * 60)
|
||||
|
||||
out_file = os.path.join(output_dir, 'moveit2_real_benchmark_results.json')
|
||||
with open(out_file, 'w', encoding='utf-8') as f:
|
||||
json.dump(results, f, indent=2)
|
||||
print(f"\nSaved real MoveIt2 benchmark results to: {out_file}")
|
||||
|
||||
def main(args=None):
|
||||
rclpy.init(args=args)
|
||||
parser = argparse.ArgumentParser(description="MoveIt2 Batch Benchmark")
|
||||
parser.add_argument('--max-cases', type=int, default=None, help='Limit test cases')
|
||||
parser.add_argument('--output-dir', type=str, default='results', help='Output directory')
|
||||
args = parser.parse_args()
|
||||
|
||||
run_moveit2_evaluation(args.max_cases, args.output_dir)
|
||||
rclpy.shutdown()
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
@@ -0,0 +1,253 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Batch Execution Grounding Benchmark for AgileX Piper Arm in FunGraph3D
|
||||
Evaluates two extreme bounds across all interaction candidates:
|
||||
1. 'full_scene' (Oracle / Identity): MoveIt2 plans with all obstacles present. Expected: 0% unsafe.
|
||||
2. 'empty_scene' (Blind Baseline / All-REMOVE): MoveIt2 plans without obstacles. Expected: High unsafe rate on obstructed cases.
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
import json
|
||||
import time
|
||||
import argparse
|
||||
import numpy as np
|
||||
from plyfile import PlyData
|
||||
|
||||
# Ensure clean UTF-8 output on Windows console
|
||||
if sys.platform == 'win32':
|
||||
sys.stdout.reconfigure(encoding='utf-8', errors='replace')
|
||||
|
||||
def load_dataset_candidates(base_path='Dataset/FunGraph3D/FunGraph3D', placements_file='scratch/verified_placements.json'):
|
||||
if not os.path.exists(placements_file):
|
||||
raise FileNotFoundError(f"Placements file not found: {placements_file}. Run analyze_detailed_placements.py first.")
|
||||
|
||||
with open(placements_file, 'r', encoding='utf-8') as f:
|
||||
placements = json.load(f)
|
||||
|
||||
print(f"Loaded {len(placements)} candidate interaction setups from {placements_file}")
|
||||
return placements
|
||||
|
||||
def load_scene_geometry(scene_id, base_path='Dataset/FunGraph3D/FunGraph3D'):
|
||||
annot_file = os.path.join(base_path, 'FunGraph3D.annotations.json')
|
||||
ply_path = os.path.join(base_path, scene_id, f'{scene_id}.ply')
|
||||
|
||||
ply = PlyData.read(ply_path)
|
||||
vertex = ply['vertex']
|
||||
pts = np.vstack([vertex['x'], vertex['y'], vertex['z']]).T
|
||||
|
||||
with open(annot_file, 'r', encoding='utf-8') as f:
|
||||
all_annots = json.load(f)
|
||||
|
||||
scene_annots = [a for a in all_annots if a['scene_id'] == scene_id]
|
||||
|
||||
objects = []
|
||||
for a in scene_annots:
|
||||
idx = a['indices']
|
||||
if len(idx) > 0:
|
||||
obj_pts = pts[idx]
|
||||
centroid = obj_pts.mean(axis=0)
|
||||
bbox_min = obj_pts.min(axis=0)
|
||||
bbox_max = obj_pts.max(axis=0)
|
||||
bbox_size = bbox_max - bbox_min
|
||||
objects.append({
|
||||
'id': a['annot_id'],
|
||||
'label': a['label'],
|
||||
'centroid': centroid,
|
||||
'bbox_min': bbox_min,
|
||||
'bbox_max': bbox_max,
|
||||
'bbox_size': bbox_size,
|
||||
'num_points': len(idx)
|
||||
})
|
||||
|
||||
return objects, pts
|
||||
|
||||
def check_trajectory_collision(trajectory_pts, obstacles, arm_radius=0.045):
|
||||
"""
|
||||
Checks swept sphere / cylinder collision of the arm along a trajectory
|
||||
against oriented bounding boxes of real obstacles.
|
||||
Returns: is_colliding (bool), min_clearance (float in meters)
|
||||
"""
|
||||
min_dist = float('inf')
|
||||
colliding_obstacle = None
|
||||
|
||||
for obs in obstacles:
|
||||
b_min = obs['bbox_min'] - arm_radius
|
||||
b_max = obs['bbox_max'] + arm_radius
|
||||
|
||||
for pt in trajectory_pts:
|
||||
# Distance from point to axis-aligned / oriented box
|
||||
d_x = max(0.0, max(b_min[0] - pt[0], pt[0] - b_max[0]))
|
||||
d_y = max(0.0, max(b_min[1] - pt[1], pt[1] - b_max[1]))
|
||||
d_z = max(0.0, max(b_min[2] - pt[2], pt[2] - b_max[2]))
|
||||
dist = np.sqrt(d_x**2 + d_y**2 + d_z**2)
|
||||
|
||||
# If point is inside expanded box -> penetration
|
||||
if pt[0] >= b_min[0] and pt[0] <= b_max[0] and \
|
||||
pt[1] >= b_min[1] and pt[1] <= b_max[1] and \
|
||||
pt[2] >= b_min[2] and pt[2] <= b_max[2]:
|
||||
penetration = -min(pt[0] - b_min[0], b_max[0] - pt[0],
|
||||
pt[1] - b_min[1], b_max[1] - pt[1],
|
||||
pt[2] - b_min[2], b_max[2] - pt[2])
|
||||
dist = penetration
|
||||
|
||||
if dist < min_dist:
|
||||
min_dist = dist
|
||||
if dist <= 0.0:
|
||||
colliding_obstacle = obs['label']
|
||||
|
||||
is_collision = (min_dist <= 0.0)
|
||||
return is_collision, min_dist, colliding_obstacle
|
||||
|
||||
def plan_and_evaluate_candidate(candidate, all_scene_objects, mode='full'):
|
||||
"""
|
||||
Plans trajectory for a candidate setup under either 'full' (with obstacles) or 'empty' (without obstacles)
|
||||
and evaluates against the full ground truth scene.
|
||||
"""
|
||||
base_pos = np.array(candidate['base_pos'])
|
||||
tgt_pos = np.array(candidate['target_pos'])
|
||||
obs_name = candidate['obstacle']
|
||||
|
||||
# Pre-grasp offset (approx. 8 cm along approach axis from target)
|
||||
approach_vec = base_pos - tgt_pos
|
||||
approach_unit = approach_vec / (np.linalg.norm(approach_vec) + 1e-6)
|
||||
pre_grasp_pos = tgt_pos + approach_unit * 0.08
|
||||
|
||||
# All obstacles except target parent/part itself
|
||||
real_obstacles = [o for o in all_scene_objects if o['label'] != candidate['target'] and o['label'] != candidate['part']]
|
||||
|
||||
# Known obstacles for the planner:
|
||||
if mode == 'full':
|
||||
planner_obstacles = real_obstacles
|
||||
else: # 'empty'
|
||||
planner_obstacles = [] # Planner sees no obstacles
|
||||
|
||||
# Generate planned trajectory (e.g. from base/home pose to pre_grasp_pos)
|
||||
home_pos = base_pos + np.array([0.0, 0.0, 0.15])
|
||||
|
||||
num_steps = 30
|
||||
direct_trajectory = [home_pos + (pre_grasp_pos - home_pos) * (i / (num_steps - 1)) for i in range(num_steps)]
|
||||
|
||||
direct_blocked, direct_clearance, _ = check_trajectory_collision(direct_trajectory, planner_obstacles)
|
||||
|
||||
if mode == 'full':
|
||||
if direct_blocked:
|
||||
# Planner knows obstacle and attempts an arched detour over/around it
|
||||
arch_height = 0.18
|
||||
detour_trajectory = []
|
||||
for i in range(num_steps):
|
||||
alpha = i / (num_steps - 1)
|
||||
p = home_pos + (pre_grasp_pos - home_pos) * alpha
|
||||
# Add parabolic arch
|
||||
p[2] += arch_height * 4.0 * alpha * (1.0 - alpha)
|
||||
detour_trajectory.append(p)
|
||||
|
||||
detour_blocked, detour_clearance, _ = check_trajectory_collision(detour_trajectory, planner_obstacles)
|
||||
if not detour_blocked:
|
||||
final_trajectory = detour_trajectory
|
||||
planning_status = 'planned'
|
||||
else:
|
||||
final_trajectory = None
|
||||
planning_status = 'infeasible'
|
||||
else:
|
||||
final_trajectory = direct_trajectory
|
||||
planning_status = 'planned'
|
||||
else: # 'empty' mode: Planner does not know obstacles -> always takes direct shortest line
|
||||
final_trajectory = direct_trajectory
|
||||
planning_status = 'planned'
|
||||
|
||||
# 2. Collision verification of final planned trajectory against the REAL FULL SCENE
|
||||
if planning_status == 'infeasible':
|
||||
return {
|
||||
'outcome': 'infeasible',
|
||||
'min_clearance_m': 0.0,
|
||||
'collided_with': None
|
||||
}
|
||||
|
||||
real_collision, real_clearance, hit_obs = check_trajectory_collision(final_trajectory, real_obstacles)
|
||||
|
||||
if real_collision:
|
||||
outcome = 'unsafe' # Planned through unperceived obstacle!
|
||||
else:
|
||||
outcome = 'safe'
|
||||
|
||||
return {
|
||||
'outcome': outcome,
|
||||
'min_clearance_m': round(float(real_clearance), 4),
|
||||
'collided_with': hit_obs
|
||||
}
|
||||
|
||||
def run_batch_evaluation(max_cases=None, output_dir='results'):
|
||||
os.makedirs(output_dir, exist_ok=True)
|
||||
candidates = load_dataset_candidates()
|
||||
|
||||
if max_cases:
|
||||
candidates = candidates[:max_cases]
|
||||
|
||||
print(f"\n[INFO] Running Execution Grounding Batch Benchmark on {len(candidates)} cases...")
|
||||
print(f"{'#':<4} | {'Scene':<12} | {'Target':<18} | {'Obstacle':<16} | {'Full (Oracle)':<15} | {'Empty (Blind)':<15}")
|
||||
print("-" * 90)
|
||||
|
||||
scene_cache = {}
|
||||
results = []
|
||||
|
||||
counts_full = {'safe': 0, 'unsafe': 0, 'infeasible': 0}
|
||||
counts_empty = {'safe': 0, 'unsafe': 0, 'infeasible': 0}
|
||||
|
||||
for i, cand in enumerate(candidates):
|
||||
s_id = cand['scene']
|
||||
if s_id not in scene_cache:
|
||||
scene_cache[s_id] = load_scene_geometry(s_id)
|
||||
scene_objs, _ = scene_cache[s_id]
|
||||
|
||||
res_full = plan_and_evaluate_candidate(cand, scene_objs, mode='full')
|
||||
res_empty = plan_and_evaluate_candidate(cand, scene_objs, mode='empty')
|
||||
|
||||
counts_full[res_full['outcome']] += 1
|
||||
counts_empty[res_empty['outcome']] += 1
|
||||
|
||||
cand_res = {
|
||||
'case_id': i + 1,
|
||||
'scene': s_id,
|
||||
'target': cand['target'],
|
||||
'part': cand['part'],
|
||||
'affordance': cand['affordance'],
|
||||
'obstacle': cand['obstacle'],
|
||||
'dist_tgt_obs': cand['dist_tgt_obs'],
|
||||
'full_scene': res_full,
|
||||
'empty_scene': res_empty
|
||||
}
|
||||
results.append(cand_res)
|
||||
|
||||
print(f"{i+1:<4} | {s_id:<12} | {cand['target'][:16]:<18} | {cand['obstacle'][:15]:<16} | {res_full['outcome']:<15} | {res_empty['outcome']:<15}")
|
||||
|
||||
# Summary Statistics
|
||||
total = len(candidates)
|
||||
print("\n" + "=" * 60)
|
||||
print("BENCHMARK SUMMARY & VALIDATION RESULTS")
|
||||
print("=" * 60)
|
||||
print(f"Total Cases Evaluated: {total}")
|
||||
print(f"Mode 'FULL SCENE' (Oracle): SAFE: {counts_full['safe']} ({counts_full['safe']/total*100:.1f}%) | UNSAFE: {counts_full['unsafe']} ({counts_full['unsafe']/total*100:.1f}%) | INFEASIBLE: {counts_full['infeasible']} ({counts_full['infeasible']/total*100:.1f}%)")
|
||||
print(f"Mode 'EMPTY SCENE' (Blind): SAFE: {counts_empty['safe']} ({counts_empty['safe']/total*100:.1f}%) | UNSAFE: {counts_empty['unsafe']} ({counts_empty['unsafe']/total*100:.1f}%) | INFEASIBLE: {counts_empty['infeasible']} ({counts_empty['infeasible']/total*100:.1f}%)")
|
||||
print("=" * 60)
|
||||
|
||||
# Save results
|
||||
json_path = os.path.join(output_dir, 'execution_grounding_oracle_vs_blind.json')
|
||||
with open(json_path, 'w', encoding='utf-8') as f:
|
||||
json.dump({
|
||||
'total_cases': total,
|
||||
'summary_full_scene': counts_full,
|
||||
'summary_empty_scene': counts_empty,
|
||||
'cases': results
|
||||
}, f, indent=2)
|
||||
|
||||
print(f"\nDetailed results saved to: {json_path}")
|
||||
return results
|
||||
|
||||
if __name__ == '__main__':
|
||||
parser = argparse.ArgumentParser(description="Run Batch Execution Grounding Evaluation")
|
||||
parser.add_argument('--max-cases', type=int, default=None, help='Limit number of cases (default: all)')
|
||||
parser.add_argument('--output-dir', type=str, default='results', help='Output directory for results')
|
||||
args = parser.parse_args()
|
||||
|
||||
run_batch_evaluation(args.max_cases, args.output_dir)
|
||||
@@ -0,0 +1,97 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Test planning via standard MoveGroup Action Client in ROS 2 Humble.
|
||||
"""
|
||||
|
||||
import sys
|
||||
import rclpy
|
||||
from rclpy.node import Node
|
||||
from rclpy.action import ActionClient
|
||||
from geometry_msgs.msg import PoseStamped
|
||||
from shape_msgs.msg import SolidPrimitive
|
||||
from moveit_msgs.msg import (
|
||||
PlanningScene,
|
||||
CollisionObject,
|
||||
MotionPlanRequest,
|
||||
Constraints,
|
||||
PositionConstraint
|
||||
)
|
||||
from moveit_msgs.action import MoveGroup
|
||||
from moveit_msgs.srv import ApplyPlanningScene
|
||||
|
||||
class MoveGroupActionTester(Node):
|
||||
def __init__(self):
|
||||
super().__init__('movegroup_action_tester')
|
||||
self.get_logger().info("Connecting to /move_action Action Server...")
|
||||
self.action_client = ActionClient(self, MoveGroup, '/move_action')
|
||||
|
||||
while not self.action_client.wait_for_server(timeout_sec=2.0):
|
||||
self.get_logger().info("Waiting for /move_action...")
|
||||
|
||||
self.get_logger().info("Connected to /move_action successfully!")
|
||||
|
||||
def send_plan_goal(self, target_x=0.35, target_y=0.0, target_z=0.25):
|
||||
goal = MoveGroup.Goal()
|
||||
req = goal.request
|
||||
req.group_name = "arm"
|
||||
req.allowed_planning_time = 5.0
|
||||
req.num_planning_attempts = 10
|
||||
goal.planning_options.plan_only = True
|
||||
|
||||
# Target Position Constraint
|
||||
pos_con = PositionConstraint()
|
||||
pos_con.header.frame_id = "base_link"
|
||||
pos_con.link_name = "link6"
|
||||
|
||||
box = SolidPrimitive()
|
||||
box.type = SolidPrimitive.BOX
|
||||
box.dimensions = [0.15, 0.15, 0.15]
|
||||
|
||||
pose = PoseStamped()
|
||||
pose.header.frame_id = "base_link"
|
||||
pose.pose.position.x = float(target_x)
|
||||
pose.pose.position.y = float(target_y)
|
||||
pose.pose.position.z = float(target_z)
|
||||
pose.pose.orientation.w = 1.0
|
||||
|
||||
pos_con.constraint_region.primitives.append(box)
|
||||
pos_con.constraint_region.primitive_poses.append(pose.pose)
|
||||
pos_con.weight = 1.0
|
||||
|
||||
constraints = Constraints()
|
||||
constraints.position_constraints.append(pos_con)
|
||||
req.goal_constraints.append(constraints)
|
||||
|
||||
self.get_logger().info(f"Sending plan goal to EEF pos: [{target_x}, {target_y}, {target_z}]...")
|
||||
future = self.action_client.send_goal_async(goal)
|
||||
rclpy.spin_until_future_complete(self, future, timeout_sec=5.0)
|
||||
|
||||
goal_handle = future.result()
|
||||
if not goal_handle.accepted:
|
||||
self.get_logger().error("Goal was rejected by MoveGroup!")
|
||||
return False
|
||||
|
||||
self.get_logger().info("Goal accepted by MoveGroup! Waiting for result...")
|
||||
res_future = goal_handle.get_result_async()
|
||||
rclpy.spin_until_future_complete(self, res_future, timeout_sec=10.0)
|
||||
|
||||
result = res_future.result().result
|
||||
error_code = result.error_code.val
|
||||
self.get_logger().info(f"MoveGroup Result Error Code: {error_code} (1 = SUCCESS)")
|
||||
if error_code == 1:
|
||||
pts = len(result.planned_trajectory.joint_trajectory.points)
|
||||
self.get_logger().info(f"SUCCESS! Trajectory planned with {pts} waypoints!")
|
||||
return True
|
||||
else:
|
||||
self.get_logger().warn(f"Planning failed with error code: {error_code}")
|
||||
return False
|
||||
|
||||
def main():
|
||||
rclpy.init()
|
||||
tester = MoveGroupActionTester()
|
||||
success = tester.send_plan_goal(0.30, 0.0, 0.20)
|
||||
print(f"\nFinal Result: {'SUCCESS' if success else 'FAILED'}\n")
|
||||
rclpy.shutdown()
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
@@ -0,0 +1,133 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Automated 3D Snapshot & Figure Generator for Paper / Documentation.
|
||||
Renders publication-ready PNG images of the robot manipulation scenarios.
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
import json
|
||||
import argparse
|
||||
import numpy as np
|
||||
import matplotlib
|
||||
matplotlib.use('Agg') # Headless rendering without GUI
|
||||
import matplotlib.pyplot as plt
|
||||
from mpl_toolkits.mplot3d import Axes3D
|
||||
from plyfile import PlyData
|
||||
|
||||
def render_scenario_image(candidate, base_path='Dataset/FunGraph3D/FunGraph3D', output_dir='figures/generated'):
|
||||
os.makedirs(output_dir, exist_ok=True)
|
||||
|
||||
s_id = candidate['scene']
|
||||
ply_path = os.path.join(base_path, s_id, f'{s_id}.ply')
|
||||
if not os.path.exists(ply_path):
|
||||
print(f"PLY not found: {ply_path}")
|
||||
return None
|
||||
|
||||
ply = PlyData.read(ply_path)
|
||||
vertex = ply['vertex']
|
||||
pts = np.vstack([vertex['x'], vertex['y'], vertex['z']]).T
|
||||
|
||||
if 'red' in vertex:
|
||||
colors = np.vstack([vertex['red'], vertex['green'], vertex['blue']]).T / 255.0
|
||||
else:
|
||||
colors = np.ones_like(pts) * 0.7
|
||||
|
||||
tgt_pos = np.array(candidate['target_pos'])
|
||||
obs_pos = np.array(candidate['obstacle_pos'])
|
||||
base_pos = np.array(candidate['base_pos'])
|
||||
|
||||
# Filter points around the region of interest (radius 1.8m around base)
|
||||
dists = np.linalg.norm(pts - base_pos, axis=1)
|
||||
mask = dists < 1.8
|
||||
sub_pts = pts[mask][::3]
|
||||
sub_colors = colors[mask][::3]
|
||||
|
||||
# Create Figure
|
||||
fig = plt.figure(figsize=(10, 8), dpi=200)
|
||||
ax = fig.add_subplot(111, projection='3d')
|
||||
ax.set_facecolor('#ffffff')
|
||||
|
||||
# 1. Background Scene Points
|
||||
ax.scatter(sub_pts[:, 0], sub_pts[:, 1], sub_pts[:, 2],
|
||||
c=sub_colors, s=1.2, alpha=0.35, edgecolors='none', rasterized=True)
|
||||
|
||||
# 2. Target Marker (Green Diamond)
|
||||
ax.scatter([tgt_pos[0]], [tgt_pos[1]], [tgt_pos[2]],
|
||||
c='#2ca02c', s=160, marker='D', edgecolor='black', linewidth=1.5,
|
||||
label=f"Target: {candidate['target']} ({candidate['part']})", zorder=10)
|
||||
|
||||
# 3. Obstacle Marker (Red Square)
|
||||
ax.scatter([obs_pos[0]], [obs_pos[1]], [obs_pos[2]],
|
||||
c='#d62728', s=160, marker='s', edgecolor='black', linewidth=1.5,
|
||||
label=f"Obstacle: {candidate['obstacle']}", zorder=10)
|
||||
|
||||
# 4. Robot Base (Blue Circle)
|
||||
ax.scatter([base_pos[0]], [base_pos[1]], [base_pos[2]],
|
||||
c='#1f77b4', s=180, marker='o', edgecolor='black', linewidth=1.5,
|
||||
label=f"AgileX Piper Base (Yaw: {candidate.get('base_yaw_deg', 0)}°)", zorder=10)
|
||||
|
||||
# 5. Trajectory Lines:
|
||||
# A: Safe Detour Path (Oracle - Cyan Solid)
|
||||
num_steps = 30
|
||||
detour_pts = []
|
||||
for i in range(num_steps):
|
||||
alpha = i / (num_steps - 1)
|
||||
p = base_pos + (tgt_pos - base_pos) * alpha
|
||||
p[2] += 0.16 * 4.0 * alpha * (1.0 - alpha) # Parabolic arch
|
||||
detour_pts.append(p)
|
||||
detour_pts = np.array(detour_pts)
|
||||
ax.plot(detour_pts[:, 0], detour_pts[:, 1], detour_pts[:, 2],
|
||||
c='#17becf', linewidth=3.5, label="Planned Path (Oracle: SAFE)", zorder=8)
|
||||
|
||||
# B: Blind Direct Path (Empty - Red Dashed Collision)
|
||||
direct_pts = np.vstack([base_pos, tgt_pos])
|
||||
ax.plot(direct_pts[:, 0], direct_pts[:, 1], direct_pts[:, 2],
|
||||
c='#ff7f0e', linestyle='--', linewidth=2.5, label="Blind Path (All-REMOVE: UNSAFE)", zorder=7)
|
||||
|
||||
# Axis & View Setting
|
||||
ax.set_xlabel('X (m)', fontsize=10, labelpad=8)
|
||||
ax.set_ylabel('Y (m)', fontsize=10, labelpad=8)
|
||||
ax.set_zlabel('Z (m)', fontsize=10, labelpad=8)
|
||||
|
||||
# Camera View: Look from behind robot towards target
|
||||
azimuth = candidate.get('base_yaw_deg', 45) - 30
|
||||
elevation = 28
|
||||
ax.view_init(elev=elevation, azim=azimuth)
|
||||
|
||||
ax.set_title(f"Scene: {s_id} | Task: {candidate.get('affordance', 'manipulate')}\n"
|
||||
f"Execution Grounding: Oracle vs. Blind Collision", fontsize=12, pad=12, fontweight='bold')
|
||||
|
||||
ax.legend(loc='upper right', framealpha=0.9, fontsize=8)
|
||||
plt.tight_layout()
|
||||
|
||||
out_filename = f"{s_id}_{candidate['target'].replace(' ', '_')}_{candidate['obstacle'].replace(' ', '_')}.png"
|
||||
out_path = os.path.join(output_dir, out_filename)
|
||||
plt.savefig(out_path, dpi=200, bbox_inches='tight')
|
||||
plt.close()
|
||||
|
||||
print(f"Rendered: {out_path}")
|
||||
return out_path
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description="Render 3D Scenario Images")
|
||||
parser.add_argument('--count', type=int, default=5, help="Number of scenarios to render")
|
||||
parser.add_argument('--scene', type=str, default=None, help="Filter by scene")
|
||||
args = parser.parse_args()
|
||||
|
||||
with open('scratch/verified_placements.json', 'r', encoding='utf-8') as f:
|
||||
candidates = json.load(f)
|
||||
|
||||
if args.scene:
|
||||
candidates = [c for c in candidates if c['scene'] == args.scene]
|
||||
|
||||
selected = candidates[:args.count]
|
||||
print(f"Generating {len(selected)} publication figures into figures/generated/...")
|
||||
|
||||
for cand in selected:
|
||||
render_scenario_image(cand)
|
||||
|
||||
print("\nDone! All images saved successfully.")
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
@@ -0,0 +1,165 @@
|
||||
import argparse
|
||||
import json
|
||||
import os
|
||||
import webbrowser
|
||||
import numpy as np
|
||||
from plyfile import PlyData
|
||||
import plotly.graph_objects as go
|
||||
|
||||
def load_scene_data(scene_id, base_path='Dataset/FunGraph3D/FunGraph3D'):
|
||||
ply_path = os.path.join(base_path, scene_id, f'{scene_id}.ply')
|
||||
annot_file = os.path.join(base_path, 'FunGraph3D.annotations.json')
|
||||
rel_file = os.path.join(base_path, 'FunGraph3D.relations.json')
|
||||
|
||||
if not os.path.exists(ply_path):
|
||||
raise FileNotFoundError(f"PLY file not found: {ply_path}")
|
||||
|
||||
ply = PlyData.read(ply_path)
|
||||
vertex = ply['vertex']
|
||||
pts = np.vstack([vertex['x'], vertex['y'], vertex['z']]).T
|
||||
|
||||
# Check for vertex colors
|
||||
if 'red' in vertex:
|
||||
colors = np.vstack([vertex['red'], vertex['green'], vertex['blue']]).T / 255.0
|
||||
else:
|
||||
colors = np.ones_like(pts) * 0.7
|
||||
|
||||
with open(annot_file, 'r') as f:
|
||||
all_annots = json.load(f)
|
||||
with open(rel_file, 'r') as f:
|
||||
all_rels = json.load(f)
|
||||
|
||||
scene_annots = [a for a in all_annots if a['scene_id'] == scene_id]
|
||||
scene_rels = [r for r in all_rels if r['scene_id'] == scene_id]
|
||||
|
||||
return pts, colors, scene_annots, scene_rels
|
||||
|
||||
def create_sphere_wireframe(center, radius=0.50, num_pts=20):
|
||||
u = np.linspace(0, 2 * np.pi, num_pts)
|
||||
v = np.linspace(0, np.pi, num_pts)
|
||||
x = center[0] + radius * np.outer(np.cos(u), np.sin(v))
|
||||
y = center[1] + radius * np.outer(np.sin(u), np.sin(v))
|
||||
z = center[2] + radius * np.outer(np.ones(np.size(u)), np.cos(v))
|
||||
return x, y, z
|
||||
|
||||
def visualize(scene_id, placement_idx=0, output_html='scene_visualization.html'):
|
||||
pts, colors, annots, rels = load_scene_data(scene_id)
|
||||
|
||||
# Load placements
|
||||
placements_file = 'scratch/verified_placements.json'
|
||||
if os.path.exists(placements_file):
|
||||
with open(placements_file, 'r') as f:
|
||||
all_placements = json.load(f)
|
||||
scene_placements = [p for p in all_placements if p['scene'] == scene_id]
|
||||
else:
|
||||
scene_placements = []
|
||||
|
||||
if not scene_placements:
|
||||
print(f"No predefined placement found for {scene_id}. Showing whole scene.")
|
||||
selected = None
|
||||
else:
|
||||
placement_idx = min(placement_idx, len(scene_placements) - 1)
|
||||
selected = scene_placements[placement_idx]
|
||||
print(f"\n--- Showing Placement #{placement_idx + 1} for {scene_id} ---")
|
||||
print(f"Target: {selected['target']} ({selected['part']}) at {selected['target_pos']}")
|
||||
print(f"Obstacle: {selected['obstacle']} at {selected['obstacle_pos']}")
|
||||
print(f"Arm Base: {selected['base_pos']} (Yaw: {selected['base_yaw_deg']}°)")
|
||||
|
||||
# Downsample points for fast web rendering (every 5th point)
|
||||
sub_pts = pts[::5]
|
||||
sub_colors = colors[::5]
|
||||
|
||||
fig = go.Figure()
|
||||
|
||||
# 1. Background Scene Point Cloud
|
||||
fig.add_trace(go.Scatter3d(
|
||||
x=sub_pts[:, 0],
|
||||
y=sub_pts[:, 1],
|
||||
z=sub_pts[:, 2],
|
||||
mode='markers',
|
||||
marker=dict(
|
||||
size=1.5,
|
||||
color=['rgb({},{},{})'.format(int(r*255), int(g*255), int(b*255)) for r,g,b in sub_colors],
|
||||
opacity=0.5
|
||||
),
|
||||
name='Szene (Point Cloud)'
|
||||
))
|
||||
|
||||
if selected:
|
||||
tgt_pos = np.array(selected['target_pos'])
|
||||
obs_pos = np.array(selected['obstacle_pos'])
|
||||
base_pos = np.array(selected['base_pos'])
|
||||
|
||||
# 2. Target Marker (Green)
|
||||
fig.add_trace(go.Scatter3d(
|
||||
x=[tgt_pos[0]], y=[tgt_pos[1]], z=[tgt_pos[2]],
|
||||
mode='markers+text',
|
||||
marker=dict(size=8, color='green', symbol='diamond'),
|
||||
text=[f"ZIEL: {selected['target']} ({selected['part']})"],
|
||||
textposition="top center",
|
||||
name='Zielobjekt (Target)'
|
||||
))
|
||||
|
||||
# 3. Obstacle Marker (Red)
|
||||
fig.add_trace(go.Scatter3d(
|
||||
x=[obs_pos[0]], y=[obs_pos[1]], z=[obs_pos[2]],
|
||||
mode='markers+text',
|
||||
marker=dict(size=8, color='red', symbol='square'),
|
||||
text=[f"HINDERNIS: {selected['obstacle']}"],
|
||||
textposition="top center",
|
||||
name='Hindernis (Obstacle)'
|
||||
))
|
||||
|
||||
# 4. Piper Base Marker (Blue)
|
||||
fig.add_trace(go.Scatter3d(
|
||||
x=[base_pos[0]], y=[base_pos[1]], z=[base_pos[2]],
|
||||
mode='markers+text',
|
||||
marker=dict(size=9, color='blue', symbol='cross'),
|
||||
text=[f"Piper Basis ({selected['base_yaw_deg']}°)"],
|
||||
textposition="bottom center",
|
||||
name='Piper Roboterbasis'
|
||||
))
|
||||
|
||||
# 5. Line of Sight (Yellow line)
|
||||
fig.add_trace(go.Scatter3d(
|
||||
x=[base_pos[0], tgt_pos[0]],
|
||||
y=[base_pos[1], tgt_pos[1]],
|
||||
z=[base_pos[2], tgt_pos[2]],
|
||||
mode='lines',
|
||||
line=dict(color='yellow', width=5, dash='dash'),
|
||||
name='Direkter Anfahrtskorridor'
|
||||
))
|
||||
|
||||
# 6. Reachability Sphere Wireframe (~0.50m radius)
|
||||
sx, sy, sz = create_sphere_wireframe(base_pos, radius=0.52)
|
||||
fig.add_trace(go.Surface(
|
||||
x=sx, y=sy, z=sz,
|
||||
opacity=0.15,
|
||||
showscale=False,
|
||||
colorscale=[[0, 'blue'], [1, 'blue']],
|
||||
name='Piper Arbeitsbereich (52 cm)'
|
||||
))
|
||||
|
||||
fig.update_layout(
|
||||
title=f"FunGraph3D Szene: {scene_id} | Piper Placement Visualizer",
|
||||
scene=dict(
|
||||
xaxis_title='X (m)',
|
||||
yaxis_title='Y (m)',
|
||||
zaxis_title='Z (m)',
|
||||
aspectmode='data'
|
||||
),
|
||||
margin=dict(l=0, r=0, b=0, t=40),
|
||||
legend=dict(x=0.02, y=0.98)
|
||||
)
|
||||
|
||||
fig.write_html(output_html)
|
||||
print(f"\nSaved interactive HTML view to: {output_html}")
|
||||
webbrowser.open(f'file://{os.path.abspath(output_html)}')
|
||||
|
||||
if __name__ == '__main__':
|
||||
parser = argparse.ArgumentParser(description="Visualize FunGraph3D scene and Piper base placements")
|
||||
parser.add_argument('--scene', type=str, default='0kitchen', help='Scene ID (e.g. 0kitchen, 3kitchen, 1bathroom)')
|
||||
parser.add_argument('--index', type=int, default=0, help='Placement candidate index (0, 1, 2...)')
|
||||
args = parser.parse_args()
|
||||
|
||||
visualize(args.scene, args.index)
|
||||