Document reproducibility, attribution, and unqualified physics scope
Browse files- README.md +31 -0
- baseline/release.json +193 -0
- licenses/RoboDojo-LICENSE.txt +21 -0
- reproduce/fetch_reproduction.py +48 -0
- reproduce/render_actual_lineage.py +97 -0
- reproduce/tree_manifest.py +99 -0
- v1/config/demo_v1_spec.yml +27 -0
- v1/docs/demo_versions.md +36 -0
- v1/dropperlab/experimental_sph/static_world_contact.py +105 -0
- v1/dropperlab/rack_to_rack_policy.py +130 -0
- v1/scripts/prepare_rack_to_rack_v1.py +66 -0
- v1/scripts/probe_gpu_full_transfer.py +505 -0
README.md
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# DropperLab
|
| 2 |
+
|
| 3 |
+
Auditable dual-arm pipette simulation artifacts. Public research archive, **not a physics-qualified benchmark result**.
|
| 4 |
+
|
| 5 |
+
The delivered baseline is a 75.701475-second accepted-state trajectory: approximately 1 mL aspirated, 1.008072 mL retained in the tube, both tools racked and released, and both arms home. The 75.83-second video samples real recorded states at 12 fps.
|
| 6 |
+
|
| 7 |
+
## Provenance
|
| 8 |
+
|
| 9 |
+
Thirteen frozen cases include explicit numerical/controller repairs and external instance restarts. This is not an uninterrupted single-source run. The authoritative selection and checkpoint joins are in `baseline/recording_audit.json`. Failed/slipping suffixes are excluded from that selection. Historical failure reports and manifests remain distinguishable; some superseded raw binaries were deleted with the owner's authorization after delivery.
|
| 10 |
+
|
| 11 |
+
All 232,518 water particles remain represented in the accepted trajectory, including distant spilled parcels. Full-water stability, resolution convergence, wetting/capillary calibration, complete energy accounting and complete signed port-flux history are **not certified**. The historical missing entry flag for particle 119770 is not reconstructed. Metadata host paths are normalized to `@TASK_ROOT@`; numerical arrays and their hashes are unchanged.
|
| 12 |
+
|
| 13 |
+
## Files and reproduction
|
| 14 |
+
|
| 15 |
+
`baseline/archives/` contains per-case inputs, frozen source, accepted recorded frames, and preserved terminal artifacts. `baseline/manifests/` provides per-file SHA-256 and sizes. These are published incrementally; use `baseline/release.json` to check whether publication is complete, then pin its repository commit SHA.
|
| 16 |
+
|
| 17 |
+
```shell
|
| 18 |
+
python -m pip install huggingface_hub hf_xet
|
| 19 |
+
python reproduce/fetch_reproduction.py --revision FULL_COMMIT_SHA --case all --destination ./artifacts
|
| 20 |
+
# After fetching, use the project MuJoCo/Warp environment for recorded-state replay.
|
| 21 |
+
# Set DROPPERLAB_ARTIFACT_ROOT to the artifacts directory.
|
| 22 |
+
python reproduce/render_actual_lineage.py --audit audit --out replay
|
| 23 |
+
```
|
| 24 |
+
|
| 25 |
+
The downloader verifies archive OIDs and every extracted file before exposing the local case. Rendering advances no physics and fabricates no fluid states. Glass and near-view arms are translucent only for visualization.
|
| 26 |
+
|
| 27 |
+
`v1/` contains the developing successor: empty dropper on rack A, inverted empty tube on rack B, parallel pickup, stationary receiver after initial placement, and dropper return. It must not be confused with the delivered baseline or treated as completed.
|
| 28 |
+
|
| 29 |
+
## Attribution
|
| 30 |
+
|
| 31 |
+
RoboDojo-derived assets retain the accompanying MIT attribution in `licenses/RoboDojo-LICENSE.txt`. MuJoCo, NVIDIA Warp, and other external runtime dependencies retain their own licenses and are not bundled as installed environments. Credentials, browser sessions and raw terminal logs are excluded.
|
baseline/release.json
ADDED
|
@@ -0,0 +1,193 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"publication_complete": true,
|
| 3 |
+
"objects": [
|
| 4 |
+
{
|
| 5 |
+
"path": "baseline/archives/candidate_dry_pressure_v77.tar.gz",
|
| 6 |
+
"bytes": 97703897,
|
| 7 |
+
"sha256": "b82c5a86a1ca99003ab53362d37fbe860b282779d5de63913c8244f26281e53c",
|
| 8 |
+
"revision": "82be77f7fa5248203ff29fd37be9e5ec5b671fb8"
|
| 9 |
+
},
|
| 10 |
+
{
|
| 11 |
+
"path": "baseline/manifests/candidate_dry_pressure_v77.manifest.json",
|
| 12 |
+
"bytes": 20189,
|
| 13 |
+
"sha256": "885a5302ff41e9fb8e342efaa32bff3caff92f06b439d27d0a8099372d782921",
|
| 14 |
+
"revision": "07b88f5ba0818ab44d51174fc860d94c094a1c02"
|
| 15 |
+
},
|
| 16 |
+
{
|
| 17 |
+
"path": "baseline/archives/candidate_pressure_aspiration_v78.tar.gz",
|
| 18 |
+
"bytes": 202496332,
|
| 19 |
+
"sha256": "2143d099af1a78c0e0255d49065f56bb63aad58cee414f4ea1f0f1d871d7c1d1",
|
| 20 |
+
"revision": "d2df33d098688390abf9c8932b868d6d48deebed"
|
| 21 |
+
},
|
| 22 |
+
{
|
| 23 |
+
"path": "baseline/manifests/candidate_pressure_aspiration_v78.manifest.json",
|
| 24 |
+
"bytes": 27886,
|
| 25 |
+
"sha256": "d6b1198087c59c03ba9dab167985b33907e42da78622fe3b1bdd261a515beec9",
|
| 26 |
+
"revision": "f7c2d7da18c4cb636bfff9f58d39932b242d4b1a"
|
| 27 |
+
},
|
| 28 |
+
{
|
| 29 |
+
"path": "baseline/archives/candidate_contact_normal_v81.tar.gz",
|
| 30 |
+
"bytes": 95988557,
|
| 31 |
+
"sha256": "7d8207988a9997b1810a0f49be4823b45b32878a83e01532d00aaf64e981edb9",
|
| 32 |
+
"revision": "32dc9098dd9cbeb405dc1d824f411d8e1a970b40"
|
| 33 |
+
},
|
| 34 |
+
{
|
| 35 |
+
"path": "baseline/manifests/candidate_contact_normal_v81.manifest.json",
|
| 36 |
+
"bytes": 20179,
|
| 37 |
+
"sha256": "3ed568b30b393d63fc602b1e6fcb6951253fbcbcda53da1750d13be23353e825",
|
| 38 |
+
"revision": "ef8fdfb9a4daddf2109fc9582b51776c0ddb8214"
|
| 39 |
+
},
|
| 40 |
+
{
|
| 41 |
+
"path": "baseline/archives/candidate_aspiration_v82.tar.gz",
|
| 42 |
+
"bytes": 473753876,
|
| 43 |
+
"sha256": "3afac57a6e697cd233a5cdcff08739a34b94c14f2fa8a5c1ab3e1eedda913e0f",
|
| 44 |
+
"revision": "262e3e98691796eb348398f6f1029629962d6de2"
|
| 45 |
+
},
|
| 46 |
+
{
|
| 47 |
+
"path": "baseline/manifests/candidate_aspiration_v82.manifest.json",
|
| 48 |
+
"bytes": 43624,
|
| 49 |
+
"sha256": "89b883cc6f080a4411175e5f5487cf0ed799560e3cfa1bb9090a6098de8f85e5",
|
| 50 |
+
"revision": "dff3692d699ff2181bffee766c1fcddbad1def0c"
|
| 51 |
+
},
|
| 52 |
+
{
|
| 53 |
+
"path": "baseline/archives/candidate_sequence_v83.tar.gz",
|
| 54 |
+
"bytes": 2310124200,
|
| 55 |
+
"sha256": "05848e5a7bee6cd944b7ce13b3cc111e74c06121919cb1e04fb3667d792427a8",
|
| 56 |
+
"revision": "430312d8905a421eb5ef25de409d69a5c3d74ac1"
|
| 57 |
+
},
|
| 58 |
+
{
|
| 59 |
+
"path": "baseline/manifests/candidate_sequence_v83.manifest.json",
|
| 60 |
+
"bytes": 158041,
|
| 61 |
+
"sha256": "2843292dd283ac501d07e7c724061fed833921b8ab6d42e382c6b39b8aee9897",
|
| 62 |
+
"revision": "6ac12e08a7b13b7e887dafa071dffb487faf2246"
|
| 63 |
+
},
|
| 64 |
+
{
|
| 65 |
+
"path": "baseline/archives/candidate_support_v84.tar.gz",
|
| 66 |
+
"bytes": 146123703,
|
| 67 |
+
"sha256": "faf77199f08a110a977e529b80212eb84dfc5ace87f0a3c60c553d1c1ba7e6ff",
|
| 68 |
+
"revision": "31d57592f2782ac796a2fb80d0fd1c6b5ba81aee"
|
| 69 |
+
},
|
| 70 |
+
{
|
| 71 |
+
"path": "baseline/manifests/candidate_support_v84.manifest.json",
|
| 72 |
+
"bytes": 23148,
|
| 73 |
+
"sha256": "39dd60aa36d1768f760d4698dbc5ff53b07d7e973a8cc511c15e4d3044b07778",
|
| 74 |
+
"revision": "c658ba97f6c390102920f6ba3905abcbdeedbde7"
|
| 75 |
+
},
|
| 76 |
+
{
|
| 77 |
+
"path": "baseline/archives/candidate_sequence_v85.tar.gz",
|
| 78 |
+
"bytes": 648052041,
|
| 79 |
+
"sha256": "03b47871cbb0419605d0206e47f1e79fe6417e196714005ece6952ad336a87b3",
|
| 80 |
+
"revision": "b55a90c42f824aac2617d2364c2e3f8bd45e6f20"
|
| 81 |
+
},
|
| 82 |
+
{
|
| 83 |
+
"path": "baseline/manifests/candidate_sequence_v85.manifest.json",
|
| 84 |
+
"bytes": 54663,
|
| 85 |
+
"sha256": "43f2a7db9acbd0947c45551a1d35388faaddbdacffb6c45f32ad62832b670b89",
|
| 86 |
+
"revision": "07622ae6f7fe322d413c284666215413d632a66b"
|
| 87 |
+
},
|
| 88 |
+
{
|
| 89 |
+
"path": "baseline/archives/candidate_preclose_v87.tar.gz",
|
| 90 |
+
"bytes": 1873406710,
|
| 91 |
+
"sha256": "b3c368e49c9ca84698203d9b948e9793eda54e0b1ecaae9042af13cb72032f16",
|
| 92 |
+
"revision": "83ff778caae523241ba84b205639379230ad12b5"
|
| 93 |
+
},
|
| 94 |
+
{
|
| 95 |
+
"path": "baseline/manifests/candidate_preclose_v87.manifest.json",
|
| 96 |
+
"bytes": 131538,
|
| 97 |
+
"sha256": "156265e594b84c243368f047fddce51cdd67ff6489f11723e9daf40e62692d4c",
|
| 98 |
+
"revision": "9c5c5c1bb595a16b72bede16a77d69bd9931df5d"
|
| 99 |
+
},
|
| 100 |
+
{
|
| 101 |
+
"path": "baseline/archives/candidate_recovery_v88.tar.gz",
|
| 102 |
+
"bytes": 8997132553,
|
| 103 |
+
"sha256": "923facd6cd952b03ef2ff4a5bc5de162851d0e1544e271fb9fefb3368ed40937",
|
| 104 |
+
"revision": "38965ccf64a9cb6a5d681624dd8d8d1f034bbf5a"
|
| 105 |
+
},
|
| 106 |
+
{
|
| 107 |
+
"path": "baseline/manifests/candidate_recovery_v88.manifest.json",
|
| 108 |
+
"bytes": 577069,
|
| 109 |
+
"sha256": "e802c2e0a4cc53af4e102741dd6424f103f3757d2130642c77288d3ad405273b",
|
| 110 |
+
"revision": "da56ebadf1689fae07819150f8285a8aae6e4bf6"
|
| 111 |
+
},
|
| 112 |
+
{
|
| 113 |
+
"path": "baseline/archives/candidate_paired_contact_v90.tar.gz",
|
| 114 |
+
"bytes": 83730316,
|
| 115 |
+
"sha256": "929b5d2a418da671975dbbf43a95063bb6f3b5855ce8855b48a0dcc0e5255e37",
|
| 116 |
+
"revision": "13b97908bcd61f8792941e29924bedf3fc093e77"
|
| 117 |
+
},
|
| 118 |
+
{
|
| 119 |
+
"path": "baseline/manifests/candidate_paired_contact_v90.manifest.json",
|
| 120 |
+
"bytes": 20771,
|
| 121 |
+
"sha256": "be50097906f3e4ddcf75aebd2c2d4fe4c204353ba0e4256bde48acafef6a10d2",
|
| 122 |
+
"revision": "d3fb8154b6fdc57e3e819d924d96517a90a63e4f"
|
| 123 |
+
},
|
| 124 |
+
{
|
| 125 |
+
"path": "baseline/archives/candidate_seating_contact_v91.tar.gz",
|
| 126 |
+
"bytes": 227199705,
|
| 127 |
+
"sha256": "9341927be02fae01086439314bcee72d8a4b6bc22d415a4a203ac16ffce0e3ad",
|
| 128 |
+
"revision": "6b7fbbc8df4d0b2525d7bd5942f1144cf55f6a26"
|
| 129 |
+
},
|
| 130 |
+
{
|
| 131 |
+
"path": "baseline/manifests/candidate_seating_contact_v91.manifest.json",
|
| 132 |
+
"bytes": 30168,
|
| 133 |
+
"sha256": "2bfb0637b70335b670de15e56c07385c5ed04e0c55b05916120ea40f255463ac",
|
| 134 |
+
"revision": "44ff2fb2fd0189a235a7cc2e6057549dcc44c970"
|
| 135 |
+
},
|
| 136 |
+
{
|
| 137 |
+
"path": "baseline/archives/candidate_sequence_v92.tar.gz",
|
| 138 |
+
"bytes": 1263487988,
|
| 139 |
+
"sha256": "53abf38073155243a389a3c45a7d235ddc7311b569117a5fa6d7edcb5b3220ee",
|
| 140 |
+
"revision": "5a12163aff4d7f6dd210bb815f2eb16f6cc1aa68"
|
| 141 |
+
},
|
| 142 |
+
{
|
| 143 |
+
"path": "baseline/manifests/candidate_sequence_v92.manifest.json",
|
| 144 |
+
"bytes": 93726,
|
| 145 |
+
"sha256": "6f99e456f5a73482daa241b2f5c41fe417c9c28d5539b17c61cde077c0d05a14",
|
| 146 |
+
"revision": "5b2c50afb38071003fdb136c98c2fbbb88370603"
|
| 147 |
+
},
|
| 148 |
+
{
|
| 149 |
+
"path": "baseline/archives/candidate_recovery_v93.tar.gz",
|
| 150 |
+
"bytes": 3698057792,
|
| 151 |
+
"sha256": "cdea51f1163fa2062203ea82a4e3e68f9e5ad986e3700daa604ac29503202563",
|
| 152 |
+
"revision": "cf23eaf723c72b04c5d7734d7939559eae742cd4"
|
| 153 |
+
},
|
| 154 |
+
{
|
| 155 |
+
"path": "baseline/manifests/candidate_recovery_v93.manifest.json",
|
| 156 |
+
"bytes": 245978,
|
| 157 |
+
"sha256": "1526c3267cc10290218374820a31f84c2b35191facc5f9ed330de7aeb0038cb7",
|
| 158 |
+
"revision": "318e14f8fdfaba9b678adb389bb5f3641bfc9410"
|
| 159 |
+
},
|
| 160 |
+
{
|
| 161 |
+
"path": "baseline/archives/shared_checkpoints.tar.gz",
|
| 162 |
+
"bytes": 11883077,
|
| 163 |
+
"sha256": "3334a377b644fd73b7b147198df65393e5a8da4c5e809c4174cf82e24fcad808",
|
| 164 |
+
"revision": "8242cf3e35f0475f57522e4745b3144d7f9b81c7"
|
| 165 |
+
},
|
| 166 |
+
{
|
| 167 |
+
"path": "baseline/manifests/shared_checkpoints.manifest.json",
|
| 168 |
+
"bytes": 496,
|
| 169 |
+
"sha256": "f9dc7f284e4e252b30f2b5ad40d9b018ff23abf008818d5138cc5738b49c86e7",
|
| 170 |
+
"revision": "61146e5d3ab789eb3826c42f5db5d65a4b1e4f51"
|
| 171 |
+
},
|
| 172 |
+
{
|
| 173 |
+
"path": "baseline/recording_audit.json",
|
| 174 |
+
"bytes": 1588848,
|
| 175 |
+
"sha256": "355bd64a792725cac76fe39d53da36e575be9a13ababd99ce4b4e186762482a3",
|
| 176 |
+
"revision": "2ba4d59148fa53cd67180e1d5864ae373e68bd52"
|
| 177 |
+
},
|
| 178 |
+
{
|
| 179 |
+
"path": "baseline/terminal_audit.json",
|
| 180 |
+
"bytes": 2603,
|
| 181 |
+
"sha256": "0e3008f8e6a70feaeaec9b5f3c4008dc812e25686ca237681b388c116c8bae98",
|
| 182 |
+
"revision": "c2100a031eaf9372b1b0bba027670c2264369629"
|
| 183 |
+
},
|
| 184 |
+
{
|
| 185 |
+
"path": "baseline/dropperlab_actual_trajectory.mp4",
|
| 186 |
+
"bytes": 3934039,
|
| 187 |
+
"sha256": "0b62381d3a4e9e52ebe42855493a1d9c3ff237a100111f6b14ac4764cac4974a",
|
| 188 |
+
"revision": "25426dcc3bd0abc176f68c6b3239f81b8ffc42b1"
|
| 189 |
+
}
|
| 190 |
+
],
|
| 191 |
+
"physics_qualified": false,
|
| 192 |
+
"cleanup_allowed": false
|
| 193 |
+
}
|
licenses/RoboDojo-LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
MIT License
|
| 2 |
+
|
| 3 |
+
Copyright (c) 2025 Yue Chen <yuechen020614@gmail.com>
|
| 4 |
+
|
| 5 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
| 6 |
+
of this software and associated documentation files (the "Software"), to deal
|
| 7 |
+
in the Software without restriction, including without limitation the rights
|
| 8 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 9 |
+
copies of the Software, and to permit persons to whom the Software is
|
| 10 |
+
furnished to do so, subject to the following conditions:
|
| 11 |
+
|
| 12 |
+
The above copyright notice and this permission notice shall be included in all
|
| 13 |
+
copies or substantial portions of the Software.
|
| 14 |
+
|
| 15 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
| 16 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
| 17 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
| 18 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
| 19 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
| 20 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
| 21 |
+
SOFTWARE.
|
reproduce/fetch_reproduction.py
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Fetch immutable public baseline inputs; verify bytes before exposing local cases.
|
| 2 |
+
Full payloads go Qizhi -> HF. This optional destination downloader is not an upload relay.
|
| 3 |
+
Use the project environment for replay; no physics simulation is launched by this tool.
|
| 4 |
+
"""
|
| 5 |
+
import argparse,hashlib,json,os,shutil,tarfile,sys
|
| 6 |
+
from pathlib import Path
|
| 7 |
+
from huggingface_hub import HfApi,hf_hub_download
|
| 8 |
+
ROOT=Path(__file__).resolve().parents[1]
|
| 9 |
+
sys.path.insert(0,str(ROOT/'scripts'))
|
| 10 |
+
from tree_manifest import create_manifest,compare,sha256
|
| 11 |
+
p=argparse.ArgumentParser();p.add_argument('--revision',required=True);p.add_argument('--case',default='all');p.add_argument('--destination',type=Path,default=ROOT/'reproduction/baseline');a=p.parse_args()
|
| 12 |
+
dest=a.destination.resolve();dest.mkdir(parents=True,exist_ok=True);repo='Travor278/DropperLab';api=HfApi(token=False);info=api.repo_info(repo,repo_type='dataset',revision=a.revision);revision=info.sha
|
| 13 |
+
if revision!=a.revision:raise ValueError('Use an immutable full revision SHA, not a moving branch name')
|
| 14 |
+
names=api.list_repo_files(repo,repo_type='dataset',revision=revision)
|
| 15 |
+
if a.case=='all' and 'baseline/recording_audit.json' not in names:raise RuntimeError('Whole baseline publication not yet complete')
|
| 16 |
+
manifests=[n for n in names if n.startswith('baseline/manifests/') and n.endswith('.manifest.json')]
|
| 17 |
+
if a.case!='all':manifests=[n for n in manifests if Path(n).name==a.case+'.manifest.json']
|
| 18 |
+
if not manifests:raise RuntimeError('Requested case not available at this revision')
|
| 19 |
+
receipts=[]
|
| 20 |
+
for name in manifests:
|
| 21 |
+
case=Path(name).name.removesuffix('.manifest.json');stage=dest/'.transfer'/case;stage.mkdir(parents=True,exist_ok=True)
|
| 22 |
+
mf=Path(hf_hub_download(repo,name,repo_type='dataset',revision=revision,local_dir=stage,token=False));expected=json.loads(mf.read_text())
|
| 23 |
+
archive_name='baseline/archives/'+case+'.tar.gz';metadata=list(api.get_paths_info(repo,[archive_name],repo_type='dataset',revision=revision))[0]
|
| 24 |
+
if shutil.disk_usage(dest).free<metadata.size+expected['total_bytes']+1024**3:raise RuntimeError('Insufficient space for verified staged extraction')
|
| 25 |
+
archive=Path(hf_hub_download(repo,archive_name,repo_type='dataset',revision=revision,local_dir=stage,token=False))
|
| 26 |
+
digest=sha256(archive);assert metadata.lfs and metadata.lfs.sha256==digest
|
| 27 |
+
extracted=stage/'extracted';extracted.mkdir(exist_ok=True)
|
| 28 |
+
with tarfile.open(archive) as tar:
|
| 29 |
+
for member in tar.getmembers():
|
| 30 |
+
target=(extracted/member.name).resolve();assert target.is_relative_to(extracted.resolve()) and member.isfile() and not member.issym() and not member.islnk()
|
| 31 |
+
tar.extractall(extracted,filter='data')
|
| 32 |
+
actual=create_manifest(extracted,());errors=compare(expected,actual);assert not errors,errors[:10]
|
| 33 |
+
# Shared checkpoints can coexist with existing case directories; normal cases
|
| 34 |
+
# use an atomic directory rename on the destination filesystem.
|
| 35 |
+
for top in extracted.iterdir():
|
| 36 |
+
final=dest/top.name;assert final.resolve().is_relative_to(dest)
|
| 37 |
+
if not final.exists():top.rename(final)
|
| 38 |
+
else:
|
| 39 |
+
for f in top.rglob('*'):
|
| 40 |
+
if not f.is_file():continue
|
| 41 |
+
target=final/f.relative_to(top);target.parent.mkdir(parents=True,exist_ok=True)
|
| 42 |
+
if target.exists():assert sha256(target)==sha256(f)
|
| 43 |
+
else:f.rename(target)
|
| 44 |
+
receipt=dict(case=case,revision=revision,archive_sha256=digest,verified_files=actual['file_count'],verified_bytes=actual['total_bytes']);receipts.append(receipt)
|
| 45 |
+
(dest/(case+'.verified.json')).write_text(json.dumps(receipt,indent=2));archive.unlink()
|
| 46 |
+
if a.case=='all':
|
| 47 |
+
file=Path(hf_hub_download(repo,'baseline/recording_audit.json',repo_type='dataset',revision=revision,local_dir=dest/'.transfer',token=False));audit=json.loads(file.read_text().replace('@TASK_ROOT@',dest.as_posix()));(dest/'audit').mkdir(exist_ok=True);(dest/'audit/report.json').write_text(json.dumps(audit,indent=2))
|
| 48 |
+
(dest/'download_receipts.json').write_text(json.dumps(receipts,indent=2));print(json.dumps(receipts,indent=2))
|
reproduce/render_actual_lineage.py
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Render audited recorded states only. No physics stepping or interpolated water."""
|
| 2 |
+
import os
|
| 3 |
+
os.environ.setdefault('MUJOCO_GL','glfw' if os.name=='nt' else 'egl')
|
| 4 |
+
import argparse,bisect,hashlib,json,subprocess,shutil,time
|
| 5 |
+
from pathlib import Path
|
| 6 |
+
import numpy as np,mujoco
|
| 7 |
+
from PIL import Image,ImageDraw,ImageFont
|
| 8 |
+
BASE=Path(os.environ.get('DROPPERLAB_ARTIFACT_ROOT','.')).resolve()
|
| 9 |
+
p=argparse.ArgumentParser();p.add_argument('--audit',required=True);p.add_argument('--out',required=True);p.add_argument('--preview',action='store_true');a=p.parse_args()
|
| 10 |
+
audit=json.loads((BASE/a.audit/'report.json').read_text());assert audit['passed']
|
| 11 |
+
if audit.get('preview_samples_only'):assert a.preview, 'Full video requires completed full lineage audit'
|
| 12 |
+
out=(BASE/a.out).resolve();assert out.is_relative_to(BASE);out.mkdir(exist_ok=False)
|
| 13 |
+
frames=audit['frames'];times=[x['time'] for x in frames];fps=12;end=times[-1]
|
| 14 |
+
terminal=json.loads((BASE/'candidate_recovery_v93/result/report.json').read_text());events=terminal['phase_events']
|
| 15 |
+
m=mujoco.MjModel.from_binary_path(audit['model_path']);d=mujoco.MjData(m)
|
| 16 |
+
m.vis.global_.offwidth=1280;m.vis.global_.offheight=720
|
| 17 |
+
m.vis.headlight.ambient[:]=[.5,.5,.5]
|
| 18 |
+
# Rendering-only transparency reveals the actual stored liquid coordinates.
|
| 19 |
+
# Collision meshes and all physical state remain untouched.
|
| 20 |
+
for gid in range(m.ngeom):
|
| 21 |
+
name=mujoco.mj_id2name(m,mujoco.mjtObj.mjOBJ_GEOM,gid) or ''
|
| 22 |
+
body=mujoco.mj_id2name(m,mujoco.mjtObj.mjOBJ_BODY,int(m.geom_bodyid[gid]))
|
| 23 |
+
if body in ('Dropper','Tube','Beaker') and 'bulb' not in name.lower() and int(m.geom_group[gid])!=3:
|
| 24 |
+
m.geom_matid[gid]=-1;m.geom_rgba[gid]=[.65,.82,.92,.12]
|
| 25 |
+
renderer=mujoco.Renderer(m,720,1280,max_geom=240000);opt=mujoco.MjvOption();opt.geomgroup[3]=0
|
| 26 |
+
camera=mujoco.MjvCamera();camera.type=mujoco.mjtCamera.mjCAMERA_FREE
|
| 27 |
+
fontpath='C:/Windows/Fonts/arial.ttf' if os.name=='nt' else '/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf'
|
| 28 |
+
font=ImageFont.truetype(fontpath,25);small=ImageFont.truetype(fontpath,18)
|
| 29 |
+
ffmpeg=shutil.which('ffmpeg');assert ffmpeg
|
| 30 |
+
sampletimes=[0.,1.6,26.8,56.07,end] if a.preview else list(np.arange(0,end,1/fps))+[end]
|
| 31 |
+
waterlo,waterhi=np.asarray(audit['water_world_bounds']);extent=np.maximum(waterhi-waterlo,.01)
|
| 32 |
+
entries=[];started=time.monotonic();process=None
|
| 33 |
+
if not a.preview:
|
| 34 |
+
process=subprocess.Popen([ffmpeg,'-y','-f','rawvideo','-pix_fmt','rgb24','-s','1680x900','-r',str(fps),'-i','pipe:0','-an','-c:v','libx264','-threads','4','-crf','19','-pix_fmt','yuv420p','-movflags','+faststart',str(out/'dropperlab_actual_trajectory.mp4')],stdin=subprocess.PIPE,stdout=subprocess.DEVNULL,stderr=(out/'encode.log').open('w'))
|
| 35 |
+
eye=np.eye(3).ravel();colour=np.array([.03,.40,.94,1.],np.float32)
|
| 36 |
+
def render_view(points,lookat,distance,elevation,azimuth):
|
| 37 |
+
camera.lookat[:]=lookat;camera.distance=distance;camera.azimuth=azimuth;camera.elevation=elevation
|
| 38 |
+
renderer.update_scene(d,camera=camera,scene_option=opt)
|
| 39 |
+
assert renderer.scene.ngeom+len(points)<=renderer.scene.maxgeom
|
| 40 |
+
for point in points:
|
| 41 |
+
g=renderer.scene.geoms[renderer.scene.ngeom];mujoco.mjv_initGeom(g,mujoco.mjtGeom.mjGEOM_SPHERE,np.full(3,.00027),point,eye,colour);renderer.scene.ngeom+=1
|
| 42 |
+
return Image.fromarray(renderer.render().copy())
|
| 43 |
+
try:
|
| 44 |
+
for i,displaytime in enumerate(sampletimes):
|
| 45 |
+
index=max(0,bisect.bisect_right(times,displaytime)-1);fr=frames[index]
|
| 46 |
+
if a.preview:fr=frames[i]
|
| 47 |
+
if i==len(sampletimes)-1:fr=frames[-1]
|
| 48 |
+
assert hashlib.sha256(Path(fr['path']).read_bytes()).hexdigest()==fr['sha256']
|
| 49 |
+
with np.load(fr['path']) as z:
|
| 50 |
+
m.actuator_forcerange[:]=z['force_ranges'];m.opt.timestep=float(z['native_timestep']);m.opt.ccd_tolerance=float(z['ccd_tolerance']);m.opt.ccd_iterations=int(z['ccd_iterations'])
|
| 51 |
+
mujoco.mj_setState(m,d,z['native_integration'],mujoco.mjtState.mjSTATE_INTEGRATION);mujoco.mj_forward(m,d)
|
| 52 |
+
assert abs(d.time-fr['time'])<1e-9;points=z['water_position'].copy();assert len(points)==232518
|
| 53 |
+
im=Image.new('RGB',(1680,900),(18,26,36));im.paste(render_view(points,[0.,-.10,.78],1.4,-48.,110.),(0,105))
|
| 54 |
+
focus=d.body('Dropper').xpos.copy() if fr['time']<56.5 else d.body('Tube').xpos.copy();focus[2]+=.045
|
| 55 |
+
# The context close-up makes robot visual meshes translucent, so an arm
|
| 56 |
+
# cannot hide the real nozzle/meniscus. Main view keeps opaque robots.
|
| 57 |
+
saved_rgba=m.geom_rgba.copy();saved_mat=m.geom_matid.copy()
|
| 58 |
+
for gid in range(m.ngeom):
|
| 59 |
+
body=mujoco.mj_id2name(m,mujoco.mjtObj.mjOBJ_BODY,int(m.geom_bodyid[gid])) or ''
|
| 60 |
+
if body.startswith(('left_','right_')):
|
| 61 |
+
m.geom_matid[gid]=-1;m.geom_rgba[gid]=[.28,.33,.38,.09]
|
| 62 |
+
im.paste(render_view(points,focus,.29,-22.,90.).resize((384,216)),(1288,130))
|
| 63 |
+
m.geom_rgba[:]=saved_rgba;m.geom_matid[:]=saved_mat
|
| 64 |
+
draw=ImageDraw.Draw(im);stage='initial / aspiration'
|
| 65 |
+
for event in events:
|
| 66 |
+
if event['time']<=fr['time']:stage=event['stage']
|
| 67 |
+
draw.text((24,15),'DropperLab | recorded 3D-water trajectory',font=font,fill='white')
|
| 68 |
+
draw.text((24,53),f'Actual state: {fr["time"]:08.4f} s | {stage} | {fr["case"]}',font=small,fill=(174,211,241))
|
| 69 |
+
draw.text((1294,108),'Close-up | translucent glass + arms',font=small,fill='white')
|
| 70 |
+
# A fixed full-domain map keeps distant ejected parcels visible. Point glyphs
|
| 71 |
+
# are enlarged for legibility; all original coordinates are retained.
|
| 72 |
+
x0,y0,w,h=1295,415,365,240;draw.rectangle((x0,y0,x0+w,y0+h),fill=(29,39,51),outline=(100,125,150))
|
| 73 |
+
uv=(points[:,:2]-waterlo[:2])/extent[:2];pix=np.rint(uv*np.array([w-8,h-8])).astype(int)
|
| 74 |
+
cloud=Image.new('RGB',(w,h),(29,39,51));arr=np.asarray(cloud).copy();arr[h-5-np.clip(pix[:,1],0,h-9),4+np.clip(pix[:,0],0,w-9)]=[65,159,245];cloud=Image.fromarray(arr)
|
| 75 |
+
dot=ImageDraw.Draw(cloud)
|
| 76 |
+
far=(np.linalg.norm(points[:,:2],axis=1)>.55)
|
| 77 |
+
for x,y in pix[far]:dot.ellipse((x+2,h-7-y,x+6,h-3-y),fill=(255,181,66))
|
| 78 |
+
im.paste(cloud,(x0,y0));draw=ImageDraw.Draw(im)
|
| 79 |
+
draw.text((1294,365),'All-water XY footprint',font=small,fill='white');draw.text((1294,389),'Fixed domain; distant parcels in amber',font=small,fill=(212,220,230))
|
| 80 |
+
draw.text((1294,666),f'X: {waterlo[0]:.2f} to {waterhi[0]:.2f} m',font=small,fill='white');draw.text((1294,694),f'Y: {waterlo[1]:.2f} to {waterhi[1]:.2f} m',font=small,fill='white')
|
| 81 |
+
draw.text((1294,735),'232,518 retained water particles',font=small,fill=(170,211,243))
|
| 82 |
+
draw.text((1294,771),'Final tube inventory: 1.008072 mL',font=small,fill=(170,211,243))
|
| 83 |
+
draw.text((24,839),'Audited checkpoint continuations include numerical repairs and external restarts. Failed branches preserved separately.',font=small,fill=(235,213,163))
|
| 84 |
+
draw.text((24,871),'Physics unqualified. Display: transparent glass + water point glyphs. 12 fps recorded-state sampling; no interpolation.',font=small,fill=(205,216,228))
|
| 85 |
+
if a.preview or i in (0,len(sampletimes)//2,len(sampletimes)-1):im.save(out/f'preview_{i:04}.jpg',quality=90)
|
| 86 |
+
if process:process.stdin.write(np.asarray(im).tobytes())
|
| 87 |
+
entries.append(dict(output_frame=i,display_time_s=float(displaytime),recorded_time_s=fr['time'],source_path=fr['path'],source_sha256=fr['sha256']))
|
| 88 |
+
elapsed=time.monotonic()-started
|
| 89 |
+
(out/'progress.json').write_text(json.dumps(dict(status='rendering',frames_done=i+1,frames_total=len(sampletimes),wall_seconds=elapsed,eta_minutes=(len(sampletimes)-i-1)*elapsed/(i+1)/60)))
|
| 90 |
+
finally:
|
| 91 |
+
if process:process.stdin.close();code=process.wait()
|
| 92 |
+
renderer.close()
|
| 93 |
+
if process:
|
| 94 |
+
assert code==0
|
| 95 |
+
check=subprocess.run([ffmpeg,'-v','error','-i',str(out/'dropperlab_actual_trajectory.mp4'),'-f','null','-'],capture_output=True,text=True);assert check.returncode==0,check.stderr
|
| 96 |
+
manifest=dict(status='completed',preview_only=a.preview,physics_qualified=False,full_water_stability_qualified=False,fps=fps,output_frames=len(entries),actual_end_time_s=end,video_duration_s=len(entries)/fps,source_audit=a.audit,source_audit_sha256=hashlib.sha256((BASE/a.audit/'report.json').read_bytes()).hexdigest(),decode_ok=bool(process),water_particles_per_frame=232518,frames=entries,wall_seconds=time.monotonic()-started,limitations=audit['limitations'])
|
| 97 |
+
(out/'manifest.json').write_text(json.dumps(manifest,indent=2));print(json.dumps({k:v for k,v in manifest.items() if k!='frames'}))
|
reproduce/tree_manifest.py
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""Create or compare deterministic file-tree manifests for artifact delivery."""
|
| 3 |
+
|
| 4 |
+
from __future__ import annotations
|
| 5 |
+
|
| 6 |
+
import argparse
|
| 7 |
+
import hashlib
|
| 8 |
+
import json
|
| 9 |
+
from pathlib import Path
|
| 10 |
+
import sys
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
DEFAULT_EXCLUDES = (".cache/huggingface/", ".git/")
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
def sha256(path: Path, chunk_size: int = 16 * 1024 * 1024) -> str:
|
| 17 |
+
digest = hashlib.sha256()
|
| 18 |
+
with path.open("rb") as handle:
|
| 19 |
+
while chunk := handle.read(chunk_size):
|
| 20 |
+
digest.update(chunk)
|
| 21 |
+
return digest.hexdigest()
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
def create_manifest(root: Path, excludes: tuple[str, ...]) -> dict:
|
| 25 |
+
root = root.resolve(strict=True)
|
| 26 |
+
if not root.is_dir():
|
| 27 |
+
raise ValueError(f"not a directory: {root}")
|
| 28 |
+
|
| 29 |
+
files = []
|
| 30 |
+
for path in sorted(p for p in root.rglob("*") if p.is_file()):
|
| 31 |
+
rel = path.relative_to(root).as_posix()
|
| 32 |
+
if any(rel == prefix.rstrip("/") or rel.startswith(prefix) for prefix in excludes):
|
| 33 |
+
continue
|
| 34 |
+
stat = path.stat()
|
| 35 |
+
files.append({"path": rel, "size": stat.st_size, "sha256": sha256(path)})
|
| 36 |
+
|
| 37 |
+
return {
|
| 38 |
+
"root": str(root),
|
| 39 |
+
"file_count": len(files),
|
| 40 |
+
"total_bytes": sum(item["size"] for item in files),
|
| 41 |
+
"files": files,
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
def load_manifest(path: Path) -> dict:
|
| 46 |
+
return json.loads(path.read_text(encoding="utf-8"))
|
| 47 |
+
|
| 48 |
+
|
| 49 |
+
def compare(left: dict, right: dict) -> list[str]:
|
| 50 |
+
errors = []
|
| 51 |
+
left_files = {item["path"]: item for item in left["files"]}
|
| 52 |
+
right_files = {item["path"]: item for item in right["files"]}
|
| 53 |
+
for name in sorted(left_files.keys() - right_files.keys()):
|
| 54 |
+
errors.append(f"missing on right: {name}")
|
| 55 |
+
for name in sorted(right_files.keys() - left_files.keys()):
|
| 56 |
+
errors.append(f"extra on right: {name}")
|
| 57 |
+
for name in sorted(left_files.keys() & right_files.keys()):
|
| 58 |
+
a, b = left_files[name], right_files[name]
|
| 59 |
+
if a["size"] != b["size"]:
|
| 60 |
+
errors.append(f"size mismatch: {name}: {a['size']} != {b['size']}")
|
| 61 |
+
if a["sha256"] != b["sha256"]:
|
| 62 |
+
errors.append(f"sha256 mismatch: {name}: {a['sha256']} != {b['sha256']}")
|
| 63 |
+
return errors
|
| 64 |
+
|
| 65 |
+
|
| 66 |
+
def main() -> int:
|
| 67 |
+
parser = argparse.ArgumentParser()
|
| 68 |
+
sub = parser.add_subparsers(dest="command", required=True)
|
| 69 |
+
|
| 70 |
+
make = sub.add_parser("create", help="hash a directory tree")
|
| 71 |
+
make.add_argument("root", type=Path)
|
| 72 |
+
make.add_argument("output", type=Path)
|
| 73 |
+
make.add_argument("--exclude", action="append", default=[])
|
| 74 |
+
|
| 75 |
+
check = sub.add_parser("compare", help="compare two manifest JSON files")
|
| 76 |
+
check.add_argument("left", type=Path)
|
| 77 |
+
check.add_argument("right", type=Path)
|
| 78 |
+
|
| 79 |
+
args = parser.parse_args()
|
| 80 |
+
if args.command == "create":
|
| 81 |
+
excludes = tuple(DEFAULT_EXCLUDES) + tuple(args.exclude)
|
| 82 |
+
manifest = create_manifest(args.root, excludes)
|
| 83 |
+
args.output.parent.mkdir(parents=True, exist_ok=True)
|
| 84 |
+
args.output.write_text(json.dumps(manifest, indent=2) + "\n", encoding="utf-8")
|
| 85 |
+
print(json.dumps({k: manifest[k] for k in ("root", "file_count", "total_bytes")}))
|
| 86 |
+
return 0
|
| 87 |
+
|
| 88 |
+
errors = compare(load_manifest(args.left), load_manifest(args.right))
|
| 89 |
+
if errors:
|
| 90 |
+
print("MANIFEST_MISMATCH")
|
| 91 |
+
for error in errors:
|
| 92 |
+
print(error)
|
| 93 |
+
return 1
|
| 94 |
+
print("MANIFEST_OK")
|
| 95 |
+
return 0
|
| 96 |
+
|
| 97 |
+
|
| 98 |
+
if __name__ == "__main__":
|
| 99 |
+
sys.exit(main())
|
v1/config/demo_v1_spec.yml
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Design specification only. Not consumed by the current frozen v93 runner.
|
| 2 |
+
schema_version: 1
|
| 3 |
+
status: specified_not_implemented
|
| 4 |
+
version: rack_to_rack_single_reagent_v1
|
| 5 |
+
initial:
|
| 6 |
+
arms: home_open_empty
|
| 7 |
+
dropper: {location: rack_A, orientation: tip_down, liquid_ml: 0.0}
|
| 8 |
+
tube: {location: rack_B_drying_post, orientation: mouth_down, liquid_ml: 0.0}
|
| 9 |
+
beaker_count: 1
|
| 10 |
+
water_source: beaker_only
|
| 11 |
+
sequence:
|
| 12 |
+
parallel_preparation:
|
| 13 |
+
left: [pick_dropper_from_A, aspirate_from_beaker, lift_loaded_dropper]
|
| 14 |
+
right: [pick_inverted_tube_from_B, clear_post_axially, turn_tube_upright, seat_tube_in_A, release_tube]
|
| 15 |
+
synchronization: verified_contact_and_shared_workspace_clearance
|
| 16 |
+
transfer: [right_grasp_stem, verify_right_support, left_release_bulb, left_regrasp_bulb]
|
| 17 |
+
dispense: [paired_move_above_stationary_tube, align_nozzle, pressure_controlled_dispense]
|
| 18 |
+
finish: [withdraw_nozzle, return_dropper_to_A, release_dropper, arms_home, settle]
|
| 19 |
+
constraints:
|
| 20 |
+
move_tube_after_initial_seating: false
|
| 21 |
+
initial_pregrasped_objects: false
|
| 22 |
+
contact_only_object_motion: true
|
| 23 |
+
full_domain_3d_liquid: true
|
| 24 |
+
preserve_existing_failure_guards: true
|
| 25 |
+
success_requires_actual_release_and_rack_support: true
|
| 26 |
+
target_transfer_ml: 1.0
|
| 27 |
+
physics_qualified: false
|
v1/docs/demo_versions.md
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# 新版 demo 需求(2026-10-13)
|
| 2 |
+
|
| 3 |
+
状态:已记录用户的新流程;尚未修改冻结运行源码,也未启动新版仿真。已交付的 75.83 秒视频是旧流程基线,不能当作本规格的完成证据。
|
| 4 |
+
|
| 5 |
+
## 第一版:双架准备与单次移液
|
| 6 |
+
|
| 7 |
+
初始状态为双臂空手归位、空滴管自然放在当前架 A、空试管管口朝下倒扣在新增架 B。B 采用用户图片中的倒置晾管支柱/支承结构,支柱需真实进入空腔且留出夹爪抓取空间;图片仅提供形态参考,尺寸由现有试管几何和机械臂可达性确定。烧杯是唯一初始水源,滴管和试管初始不含液体。
|
| 8 |
+
|
| 9 |
+
1. 左臂从 A 架取滴管;右臂同时从 B 架提取倒扣试管。右臂先轴向脱离支柱,再翻正试管并放入 A 架的接收槽,实际松爪、确认架承重。空中翻正试管是该初态所需动作,不增加滴管的多余翻转。
|
| 10 |
+
2. 左臂将滴管移到烧杯,实际压缩/释放胶头吸取约 1 mL 后提起。右臂完成放管、清空共同工作区后才接近滴管;并行动作受碰撞和共享空间占用条件约束,不按固定时间强行交接。
|
| 11 |
+
3. 右臂夹住滴管玻璃中段。只有双侧真实接触及稳定支撑确认后,左臂才暂时松开。
|
| 12 |
+
4. 左臂重新夹住胶头的合适挤压位置;右臂始终承担滴管支撑。不能把“左臂松开”直接接到“左臂挤压排液”。重新夹持不得提前向空中排出目标液量。
|
| 13 |
+
5. 双臂协同将滴管移到 A 架的试管上方。右臂稳住玻璃管,左臂挤压胶头,液体真实进入试管。剂量、接触、气压、形变、残留和穿模守卫继续有效。
|
| 14 |
+
6. 排液结束后撤出喷嘴,将滴管放回 A 架原槽并松爪;两臂退让归位。试管从第 1 步落座后保持在 A 架接收槽,不再拾取、搬运或二次插架。
|
| 15 |
+
|
| 16 |
+
建议流程标识:`parallel_pick` → `tube_clear_B_and_upright` → `tube_seat_A_and_release` / `aspirate_and_lift` → `stem_support` → `bulb_release_and_regrasp` → `paired_dispense` → `dropper_return_A` → `arms_home` → `settle`。并行分支需分别验证完成条件,再进入支撑交接。
|
| 17 |
+
|
| 18 |
+
第一版验收需覆盖新初态的真实取物、倒扣试管翻正、A 架稳定承重、吸排液、滴管回架与双臂归位,不能从旧的已夹持/含水检查点启动来替代。放好的试管允许物理接触导致的小幅自然运动,但不得再发起搬管动作或锁死物体姿态。
|
| 19 |
+
|
| 20 |
+
## 与旧实现的对应
|
| 21 |
+
|
| 22 |
+
可以复用当前双侧茎接触、胶头换抓、双臂排液、滴管回架和原生座姿检查。需要新增双架几何、新空载初态、右臂倒扣取管及翻正、双臂并行准备与汇合条件。旧流程中排液后的 `left_tube_pick_*`、`left_tube_lift/wait`、`left_tube_final_*` 不应出现在新第一版成功路径中;不得直接删除旧基线控制器或修改其冻结源码。
|
| 23 |
+
|
| 24 |
+
所有新仿真与全量记录仍在本任务远端运行。新场景从明确记录的新初态开始,旧结果和新版结果分别保存;功能完成与广义物理资格分别标注。
|
| 25 |
+
|
| 26 |
+
## 第二版:双试剂颜色反馈
|
| 27 |
+
|
| 28 |
+
两个烧杯分别提供试剂 A、B,显示颜色 a、b。试管先接收 A,再接收 B;加入 B 期间持续观测试管内颜色,接近目标 c 时降低滴速并停止,随后等待混合及管口在途液体进入,再判断稳定终态颜色。
|
| 29 |
+
|
| 30 |
+
“实时性”先解释为同一运行中的在线观测—控制闭环,不据此承诺仿真墙钟速度达到 1× 实时。不能按预定时长或事先已知粒子计数替代颜色反馈停滴,也不能只在渲染时把试管改成目标色。
|
| 31 |
+
|
| 32 |
+
颜色需要由实际 A/B 组分分布和混合状态产生;颜色容差、稳定时间、观测区域、光照和混合模型应明确。在线策略使用被允许的相机观测;评分端可用独立组分/体积真值验证,避免读隐藏真值代替视觉反馈。
|
| 33 |
+
|
| 34 |
+
若颜色只约束 A:B 比例,则同比例增加 A、B 也可能得到相同颜色。因此用户要求的“A 少或多都不符合”还需总量约束,例如固定最终总体积并同时限制稳定颜色误差;仅增加颜色阈值不足以唯一约束 A 的绝对剂量。首次 A 剂量也应有独立上限与判据。
|
| 35 |
+
|
| 36 |
+
切换试剂时需明确采用两支专用滴管还是可验证的清洗流程,避免上一种试剂残液改变第二烧杯成分。该选择及具体颜色、目标配比和总体积尚未指定,第一版不依赖这些参数。
|
v1/dropperlab/experimental_sph/static_world_contact.py
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Unilateral water contact with the actual fixed scene geometry.
|
| 2 |
+
|
| 3 |
+
The fixed rack/table receive the opposite impulse in a reaction ledger. Contact
|
| 4 |
+
changes velocities only; particle positions are accepted by the same independent
|
| 5 |
+
CAD test as the moving vessels. This does not qualify wall viscosity or wetting.
|
| 6 |
+
"""
|
| 7 |
+
import numpy as np,warp as wp,mujoco,trimesh
|
| 8 |
+
from .warp_dfsph import normal_contact,audit_actual_geometry
|
| 9 |
+
from .deterministic_reduction import FixedReduction
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
@wp.kernel
|
| 13 |
+
def plane_contact(dt:float,mass:float,x:wp.array(dtype=wp.vec3),v:wp.array(dtype=wp.vec3),
|
| 14 |
+
points:wp.array(dtype=wp.vec3),normals:wp.array(dtype=wp.vec3),
|
| 15 |
+
force:wp.array2d(dtype=wp.vec3d),torque:wp.array2d(dtype=wp.vec3d)):
|
| 16 |
+
i=wp.tid();xi=x[i];vi=v[i]
|
| 17 |
+
for p in range(points.shape[0]):
|
| 18 |
+
before=vi;normal=normals[p]
|
| 19 |
+
for k in range(6):
|
| 20 |
+
endpoint=xi+dt*vi
|
| 21 |
+
gap=wp.dot(wp.vec3d(endpoint)-wp.vec3d(points[p]),wp.vec3d(normal))
|
| 22 |
+
if gap>=wp.float64(2.e-7):break
|
| 23 |
+
correction=float((wp.float64(2.e-7)-gap)/wp.float64(dt))
|
| 24 |
+
vi+=correction*normal
|
| 25 |
+
reaction=-wp.float64(mass/dt)*wp.vec3d(vi-before)
|
| 26 |
+
force[i,0]+=reaction;torque[i,0]+=wp.cross(wp.vec3d(xi+dt*vi),reaction)
|
| 27 |
+
v[i]=vi
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
@wp.kernel
|
| 31 |
+
def plane_audit(x:wp.array(dtype=wp.vec3),points:wp.array(dtype=wp.vec3),
|
| 32 |
+
normals:wp.array(dtype=wp.vec3),failures:wp.array(dtype=int)):
|
| 33 |
+
i=wp.tid()
|
| 34 |
+
for p in range(points.shape[0]):
|
| 35 |
+
gap=wp.dot(wp.vec3d(x[i])-wp.vec3d(points[p]),wp.vec3d(normals[p]))
|
| 36 |
+
if gap<wp.float64(-1.e-7):wp.atomic_add(failures,0,1)
|
| 37 |
+
|
| 38 |
+
def scene_mesh(model,data,origin):
|
| 39 |
+
parts=[];names=[]
|
| 40 |
+
fixed={'world','Rack','Sleeve','DryingRackB'}
|
| 41 |
+
for i in range(model.ngeom):
|
| 42 |
+
if not model.geom_contype[i] or model.body(int(model.geom_bodyid[i])).name not in fixed:continue
|
| 43 |
+
kind=model.geom_type[i]
|
| 44 |
+
if kind==mujoco.mjtGeom.mjGEOM_MESH:
|
| 45 |
+
mid=int(model.geom_dataid[i]);nv=int(model.mesh_vertnum[mid]);nf=int(model.mesh_facenum[mid])
|
| 46 |
+
vertices=model.mesh_vert[int(model.mesh_vertadr[mid]):int(model.mesh_vertadr[mid])+nv]
|
| 47 |
+
faces=model.mesh_face[int(model.mesh_faceadr[mid]):int(model.mesh_faceadr[mid])+nf]
|
| 48 |
+
part=trimesh.Trimesh(vertices=vertices.copy(),faces=faces.copy(),process=False)
|
| 49 |
+
elif kind==mujoco.mjtGeom.mjGEOM_BOX:part=trimesh.creation.box(extents=2*model.geom_size[i])
|
| 50 |
+
elif kind==mujoco.mjtGeom.mjGEOM_CYLINDER:part=trimesh.creation.cylinder(radius=model.geom_size[i,0],height=2*model.geom_size[i,1],sections=64)
|
| 51 |
+
elif kind==mujoco.mjtGeom.mjGEOM_CAPSULE:
|
| 52 |
+
radius,half=model.geom_size[i,:2]
|
| 53 |
+
bottom=np.linspace(-np.pi/2,0.,17);top=np.linspace(0.,np.pi/2,17)
|
| 54 |
+
profile=np.vstack([np.c_[radius*np.cos(bottom),-half+radius*np.sin(bottom)],np.c_[radius*np.cos(top),half+radius*np.sin(top)]])
|
| 55 |
+
# Explicit centered profile avoids differing capsule-origin
|
| 56 |
+
# conventions across installed trimesh versions.
|
| 57 |
+
from ..assets import solid
|
| 58 |
+
part=solid(profile,n=64)
|
| 59 |
+
expected=np.array([model.geom_size[i,0],model.geom_size[i,0],model.geom_size[i,1]+model.geom_size[i,0]])
|
| 60 |
+
if not np.allclose(part.bounds,np.stack([-expected,expected]),atol=1e-9):raise RuntimeError('Capsule mesh frame differs from native collider')
|
| 61 |
+
else:raise RuntimeError('Unsupported fixed scene collider: '+model.geom(i).name)
|
| 62 |
+
part.vertices=part.vertices@data.geom_xmat[i].reshape(3,3).T+data.geom_xpos[i]-origin
|
| 63 |
+
if not part.is_watertight:raise RuntimeError('Fixed collision component is not closed: '+model.geom(i).name)
|
| 64 |
+
if part.volume<0:part.invert()
|
| 65 |
+
parts.append(part);names.append(model.geom(i).name)
|
| 66 |
+
if not parts:raise RuntimeError('No fixed scene colliders found')
|
| 67 |
+
mesh=trimesh.util.concatenate(parts)
|
| 68 |
+
return mesh.vertices.astype(np.float32),mesh.faces.astype(np.int32),names
|
| 69 |
+
|
| 70 |
+
class StaticWorldContact:
|
| 71 |
+
def __init__(self,solver,vertices,faces,planes=None):
|
| 72 |
+
self.solver=solver;self.device=solver.device;nf=solver.nf
|
| 73 |
+
self.mesh=wp.Mesh(points=wp.array(vertices,dtype=wp.vec3,device=self.device),indices=wp.array(faces.ravel(),dtype=int,device=self.device),support_winding_number=True)
|
| 74 |
+
self.ids=wp.array([self.mesh.id],dtype=wp.uint64,device=self.device)
|
| 75 |
+
self.position=wp.zeros(1,dtype=wp.vec3,device=self.device)
|
| 76 |
+
self.rotation=wp.array(np.eye(3,dtype=np.float32)[None],dtype=wp.mat33,device=self.device)
|
| 77 |
+
self.linear=wp.zeros(1,dtype=wp.vec3,device=self.device);self.angular=wp.zeros_like(self.linear)
|
| 78 |
+
self.force=wp.zeros((nf,1),dtype=wp.vec3d,device=self.device);self.torque=wp.zeros_like(self.force)
|
| 79 |
+
self.reaction_force=wp.zeros(1,dtype=wp.vec3d,device=self.device);self.reaction_torque=wp.zeros_like(self.reaction_force)
|
| 80 |
+
self.reference=wp.zeros((nf,1),dtype=wp.vec3,device=self.device)
|
| 81 |
+
self.distance=wp.full((nf,1),-1.,dtype=float,device=self.device)
|
| 82 |
+
self.queries=wp.zeros(1,dtype=int,device=self.device);self.failures=wp.zeros(1,dtype=int,device=self.device)
|
| 83 |
+
self.reduction=FixedReduction(nf,1,self.device)
|
| 84 |
+
plane_data=np.asarray([] if planes is None else planes,dtype=float).reshape(-1,2,3)
|
| 85 |
+
if len(plane_data) and (not np.isfinite(plane_data).all() or np.any(abs(np.linalg.norm(plane_data[:,1],axis=1)-1)>1e-10)):
|
| 86 |
+
raise ValueError('Static planes require finite points and unit normals')
|
| 87 |
+
self.plane_points=wp.array(plane_data[:,0].astype(np.float32),dtype=wp.vec3,device=self.device)
|
| 88 |
+
self.plane_normals=wp.array(plane_data[:,1].astype(np.float32),dtype=wp.vec3,device=self.device)
|
| 89 |
+
wp.launch(audit_actual_geometry,dim=nf,inputs=[solver.x,self.ids,self.position,self.rotation,self.failures,0,self.reference,self.distance,self.queries],device=self.device)
|
| 90 |
+
if len(plane_data):wp.launch(plane_audit,nf,[solver.x,self.plane_points,self.plane_normals,self.failures],device=self.device)
|
| 91 |
+
failures=int(self.failures.numpy()[0])
|
| 92 |
+
if failures:raise RuntimeError(f'Initial water overlaps fixed scene CAD: {failures}; no recovery is allowed')
|
| 93 |
+
def constrain(self,dt):
|
| 94 |
+
s=self.solver;self.force.zero_();self.torque.zero_();self.queries.zero_();self.failures.zero_()
|
| 95 |
+
wp.launch(normal_contact,dim=s.nf,inputs=[s.nf,dt,s.mass,s.x,s.v,self.ids,self.position,self.rotation,self.position,self.linear,self.angular,
|
| 96 |
+
self.force,self.torque,self.failures,self.position,self.rotation,1,self.reference,self.distance,self.queries],device=self.device)
|
| 97 |
+
if getattr(self,'plane_viscosity',None) is not None:self.plane_viscosity.apply(dt)
|
| 98 |
+
if len(self.plane_points):
|
| 99 |
+
wp.launch(plane_contact,s.nf,[dt,s.mass,s.x,s.v,self.plane_points,self.plane_normals,self.force,self.torque],device=self.device)
|
| 100 |
+
self.reduction.wrench(self.force,self.torque,self.reaction_force,self.reaction_torque)
|
| 101 |
+
def audit_candidate(self):
|
| 102 |
+
s=self.solver
|
| 103 |
+
wp.launch(audit_actual_geometry,dim=s.nf,inputs=[s.trial_position,self.ids,self.position,self.rotation,self.failures,1,self.reference,self.distance,self.queries],device=self.device)
|
| 104 |
+
if len(self.plane_points):wp.launch(plane_audit,s.nf,[s.trial_position,self.plane_points,self.plane_normals,self.failures],device=self.device)
|
| 105 |
+
return int(self.failures.numpy()[0])
|
v1/dropperlab/rack_to_rack_policy.py
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""New V1: empty tools on two racks, parallel pickup, stationary receiver.
|
| 2 |
+
Only bounded motor commands are issued; object poses are never assigned here.
|
| 3 |
+
"""
|
| 4 |
+
import numpy as np
|
| 5 |
+
from scipy.spatial.transform import Rotation
|
| 6 |
+
from .bimanual_policy import BimanualPolicy
|
| 7 |
+
from .dual_policy import DOWN,DOWN_FLIPPED
|
| 8 |
+
|
| 9 |
+
class RackToRackPolicy(BimanualPolicy):
|
| 10 |
+
def __init__(self,model,data,robots,tube_height):
|
| 11 |
+
super().__init__(model,data,robots,tube_height)
|
| 12 |
+
self.policy_kind='rack_to_rack_v1';self.stage='rack_v1_prepare';self.entered=float(data.time);self.events=[]
|
| 13 |
+
self.prep_phase=['approach','approach'];self.prep_entered=[float(data.time)]*2;self.prep_planned=[False,False];self.prep_last_plan=[-1.,-1.]
|
| 14 |
+
self.pick_rotations=[None,None];self.pick_approach_offsets=[None,None];self.prep_goals=[None,None];self.left_released=True;self.right_released=True
|
| 15 |
+
self.hold_grip=.006;self.hold_limit=.8;self.maintain_bulb_grasp=False;self.tube_placed=False
|
| 16 |
+
self.receiver_target=np.array([.072,-.018,.771]).tolist();self.bulb_empty_volume_m3=None
|
| 17 |
+
self.right_object='Tube';self.left_object='Dropper';self.support_transport_done=False
|
| 18 |
+
for robot in robots:robot.held=None;robot.grip=.044
|
| 19 |
+
|
| 20 |
+
def enter(self,stage):
|
| 21 |
+
if stage=='park_above':
|
| 22 |
+
stage='stem_approach' if self.support_transport_done else 'transfer_for_stem_support'
|
| 23 |
+
if stage=='stem_approach':self.right_object='Dropper';self.right_released=True
|
| 24 |
+
if stage=='left_tube_pick_approach':
|
| 25 |
+
self.left_object='Dropper';self.maintain_bulb_grasp=False;self.rack_turn_deg=-45.;stage='stem_rack_lift_for_turn'
|
| 26 |
+
if stage=='tube_pick_approach':
|
| 27 |
+
for robot in self.robots:robot.target=np.zeros(6);robot.held=None
|
| 28 |
+
stage='home'
|
| 29 |
+
super().enter(stage)
|
| 30 |
+
|
| 31 |
+
def tube_final_target(self):return np.asarray(self.receiver_target)
|
| 32 |
+
|
| 33 |
+
def prep_next(self,index,phase):
|
| 34 |
+
self.prep_phase[index]=phase;self.prep_entered[index]=float(self.data.time);self.prep_planned[index]=False;self.prep_last_plan[index]=-1.
|
| 35 |
+
self.events.append(dict(time=float(self.data.time),stage=f'prepare_{self.robots[index].arm}_{phase}'))
|
| 36 |
+
|
| 37 |
+
def grasp_point(self,index,rotation):
|
| 38 |
+
body=self.data.body('Dropper' if index==0 else 'Tube');height=.128 if index==0 else .100
|
| 39 |
+
return body.xpos+body.xmat.reshape(3,3)[:,2]*height-rotation@np.array([.007,0.,-.008])
|
| 40 |
+
|
| 41 |
+
def choose_pick(self,index):
|
| 42 |
+
robot=self.robots[index];robot.planning_grasp_name='Dropper' if index==0 else 'Tube';saved=robot.target.copy();options=[]
|
| 43 |
+
rotations=[np.eye(3),np.diag([-1.,-1.,1.]),DOWN,DOWN_FLIPPED]
|
| 44 |
+
if index==1:rotations.insert(0,Rotation.from_euler('z',45.,degrees=True).as_matrix())
|
| 45 |
+
for rot in rotations:
|
| 46 |
+
point=self.grasp_point(index,rot);robot.target=saved.copy()
|
| 47 |
+
try:
|
| 48 |
+
grasp_q=robot.solve(point,rot)
|
| 49 |
+
except RuntimeError:continue
|
| 50 |
+
for offset in (-rot[:,0]*.050,np.array([0.,0.,.060])):
|
| 51 |
+
robot.target=grasp_q.copy()
|
| 52 |
+
try:q=robot.solve(point+offset,rot)
|
| 53 |
+
except RuntimeError:continue
|
| 54 |
+
options.append((np.linalg.norm(q-self.data.qpos[robot.qids]),q.copy(),rot.copy(),offset.copy()))
|
| 55 |
+
if not options:raise RuntimeError('No collision-free rack pickup approach: '+robot.arm)
|
| 56 |
+
_,q,rot,offset=min(options,key=lambda x:x[0]);robot.target=q;self.pick_rotations[index]=rot.tolist();self.pick_approach_offsets[index]=offset.tolist()
|
| 57 |
+
|
| 58 |
+
def move_held(self,index,point,rotation=None):
|
| 59 |
+
robot=self.robots[index];name='Dropper' if index==0 else 'Tube';body=self.data.body(name)
|
| 60 |
+
if min(self.contact_support[robot.arm])<(.12 if index==0 else .4):raise RuntimeError('Actual pickup support lost: '+robot.arm)
|
| 61 |
+
self.capture_grasp(index,name);relp,relr=robot.held[1:];actual=body.xmat.reshape(3,3)
|
| 62 |
+
goal=actual if rotation is None else rotation
|
| 63 |
+
delta=np.asarray(point)-body.xpos;position=body.xpos+delta*min(1.,.001/max(np.linalg.norm(delta),1e-15))
|
| 64 |
+
increment=Rotation.from_matrix(goal@actual.T).as_rotvec();rot=Rotation.from_rotvec(increment*min(1.,.01/max(np.linalg.norm(increment),1e-15))).as_matrix()@actual
|
| 65 |
+
tcp=rot@relr.T;robot.solve(position-tcp@relp,tcp)
|
| 66 |
+
|
| 67 |
+
def update_prepare(self):
|
| 68 |
+
t=float(self.data.time)
|
| 69 |
+
if self.bulb_empty_volume_m3 is None:self.bulb_empty_volume_m3=self.measured_bulb_volume_m3
|
| 70 |
+
for index,robot in enumerate(self.robots):
|
| 71 |
+
phase=self.prep_phase[index];elapsed=t-self.prep_entered[index];name='Dropper' if index==0 else 'Tube';body=self.data.body(name)
|
| 72 |
+
if elapsed>25:raise RuntimeError('Rack preparation timed out: '+robot.arm+'/'+phase)
|
| 73 |
+
limit=.8 if index==0 else 4.
|
| 74 |
+
robot.grip=.044 if phase in ('approach','align','release','retreat','done') else (self.hold_grip if index==0 else 0.)
|
| 75 |
+
if phase=='approach':
|
| 76 |
+
if not self.prep_planned[index]:self.choose_pick(index);self.prep_planned[index]=True
|
| 77 |
+
if elapsed>.2 and self.joint_settled(index):self.prep_next(index,'align')
|
| 78 |
+
elif phase=='align':
|
| 79 |
+
rot=np.asarray(self.pick_rotations[index]);point=self.grasp_point(index,rot);delta=point-robot.position()
|
| 80 |
+
if t-self.prep_last_plan[index]>=.02:robot.solve(robot.position()+delta*min(1.,.001/max(np.linalg.norm(delta),1e-15)),rot);self.prep_last_plan[index]=t
|
| 81 |
+
if np.linalg.norm(delta)<.0005 and self.joint_settled(index):self.prep_next(index,'close')
|
| 82 |
+
elif phase=='close':
|
| 83 |
+
robot.grip=.006 if index==0 else 0.
|
| 84 |
+
if elapsed>.25 and min(self.contact_support[robot.arm])>(.25 if index==0 else .5):
|
| 85 |
+
self.capture_grasp(index,name)
|
| 86 |
+
if index==0:self.left_released=False;self.maintain_bulb_grasp=True
|
| 87 |
+
else:self.right_released=False
|
| 88 |
+
self.prep_goals[index]=(body.xpos+[0,0,.13]).tolist();self.prep_next(index,'lift')
|
| 89 |
+
elif phase in ('lift','beaker_above','receiver_above','receiver_seat'):
|
| 90 |
+
target=np.asarray(self.prep_goals[index]);rotation=np.eye(3) if index==1 and phase!='lift' else None
|
| 91 |
+
if t-self.prep_last_plan[index]>=.02:self.move_held(index,target,rotation);self.prep_last_plan[index]=t
|
| 92 |
+
distance=np.linalg.norm(body.xpos-target)
|
| 93 |
+
if elapsed>.2 and distance<(.0006 if phase=='receiver_seat' else .0015):
|
| 94 |
+
if phase=='lift' and index==0:self.prep_goals[index]=[-.24,.12,.85];self.prep_next(index,'beaker_above')
|
| 95 |
+
elif phase=='lift':self.flip_anchor=robot.position().tolist();self.flip_tcp_initial=self.data.site('right_tcp').xmat.reshape(3,3).tolist();self.prep_next(index,'turn_upright')
|
| 96 |
+
elif phase=='beaker_above':self.prep_next(index,'compress')
|
| 97 |
+
elif phase=='receiver_above':self.prep_goals[index]=self.receiver_target;self.prep_next(index,'receiver_seat')
|
| 98 |
+
else:self.prep_next(index,'release')
|
| 99 |
+
elif phase=='turn_upright':
|
| 100 |
+
if min(self.contact_support['right'])<.4:raise RuntimeError('Inverted tube grip lost during turn')
|
| 101 |
+
if t-self.prep_last_plan[index]>=.02:
|
| 102 |
+
axis=body.xmat.reshape(3,3)[:,2];angle=np.arccos(np.clip(axis[2],-1.,1.));direction=np.cross(axis,[0.,0.,1.])
|
| 103 |
+
if np.linalg.norm(direction)<1e-6:direction=np.array([1.,0.,0.])
|
| 104 |
+
direction/=np.linalg.norm(direction);step=Rotation.from_rotvec(direction*min(.01,angle)).as_matrix()
|
| 105 |
+
tcp=step@self.data.site('right_tcp').xmat.reshape(3,3);robot.solve(np.asarray(self.flip_anchor),tcp);self.prep_last_plan[index]=t
|
| 106 |
+
if elapsed>.3 and body.xmat.reshape(3,3)[2,2]>.99999 and self.joint_settled(index):self.capture_grasp(index,name);self.prep_goals[index]=(np.asarray(self.receiver_target)+[0,0,.129]).tolist();self.prep_next(index,'receiver_above')
|
| 107 |
+
elif phase=='release':
|
| 108 |
+
robot.grip=.024
|
| 109 |
+
if elapsed>.7 and max(self.contact_support['right'])<.03:
|
| 110 |
+
self.right_released=True;robot.held=None;self.tube_placed=True
|
| 111 |
+
rot=self.data.site('right_tcp').xmat.reshape(3,3);robot.solve(robot.position()-rot[:,0]*.060,rot);self.prep_next(index,'retreat')
|
| 112 |
+
elif phase=='retreat':
|
| 113 |
+
robot.grip=.044
|
| 114 |
+
if elapsed>.4 and self.joint_settled(index):self.prep_next(index,'done')
|
| 115 |
+
elif phase=='compress':
|
| 116 |
+
robot.grip=0.;limit=3.
|
| 117 |
+
if self.minimum_shape<.65:robot.grip=min(.008,float(np.min(robot.grip_reference))+.00005);limit=1.2
|
| 118 |
+
if elapsed>.6 and self.measured_bulb_volume_m3<=.70*self.bulb_empty_volume_m3 and min(self.contact_support['left'])>.12:self.hold_grip=float(np.min(robot.grip_reference));self.prep_next(index,'compressed_wait')
|
| 119 |
+
elif phase=='compressed_wait':robot.grip=self.hold_grip;limit=3.
|
| 120 |
+
for actuator in robot.gids:self.model.actuator_forcerange[actuator]=[-limit,limit]
|
| 121 |
+
if self.prep_phase==['compressed_wait','done']:
|
| 122 |
+
self.safe_grip_ceiling=.008;self.aspiration_goal_set=False;self.enter('await_dose')
|
| 123 |
+
return True
|
| 124 |
+
|
| 125 |
+
def update(self,bore_ml,tube_ml,grip_support_ready=True):
|
| 126 |
+
if self.tube_placed:
|
| 127 |
+
body=self.data.body('Tube')
|
| 128 |
+
if np.linalg.norm(body.xpos-np.asarray(self.receiver_target))>.003 or body.xmat.reshape(3,3)[2,2]<.995:raise RuntimeError('Stationary receiver lost rack seating')
|
| 129 |
+
if self.stage=='rack_v1_prepare':return self.update_prepare()
|
| 130 |
+
return super().update(bore_ml,tube_ml,grip_support_ready)
|
v1/scripts/prepare_rack_to_rack_v1.py
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Create a NEW time-zero empty-tool scene. Never migrates an accepted trajectory."""
|
| 2 |
+
import argparse,json,hashlib,shutil,sys
|
| 3 |
+
from pathlib import Path
|
| 4 |
+
import numpy as np,mujoco
|
| 5 |
+
from scipy.spatial.transform import Rotation
|
| 6 |
+
p=argparse.ArgumentParser();p.add_argument('--prior',type=Path,required=True);p.add_argument('--out',type=Path,required=True);a=p.parse_args()
|
| 7 |
+
assert not a.out.exists();a.out.mkdir();shutil.copytree(a.prior/'input/assets',a.out/'assets');(a.out/'solid').mkdir();(a.out/'fluid').mkdir()
|
| 8 |
+
old=mujoco.MjModel.from_binary_path(str(a.prior/'input/solid/model.mjb'));spec=mujoco.MjSpec.from_file(str(a.prior/'input/solid/model.xml'))
|
| 9 |
+
b=spec.worldbody.add_body(name='DryingRackB',pos=[.225,.10,.835])
|
| 10 |
+
b.add_geom(name='rack_B_base',type=mujoco.mjtGeom.mjGEOM_BOX,size=[.065,.060,.006],pos=[0,0,.006],rgba=[.80,.31,.07,1])
|
| 11 |
+
for i,(x,y) in enumerate([(-.057,-.052),(.057,-.052),(-.057,.052),(.057,.052)]):
|
| 12 |
+
b.add_geom(name=f'rack_B_leg_{i}',type=mujoco.mjtGeom.mjGEOM_BOX,size=[.004,.004,.035],pos=[x,y,-.035],rgba=[.72,.28,.05,1])
|
| 13 |
+
for i,(x,y) in enumerate([(-.025,-.025),(.025,-.025),(-.025,.025),(.025,.025)]):
|
| 14 |
+
b.add_geom(name=f'rack_B_post_{i}',type=mujoco.mjtGeom.mjGEOM_CAPSULE,size=[.003,.060,0],pos=[x,y,.073],rgba=[.80,.35,.10,1])
|
| 15 |
+
model=spec.compile();assert model.nq==old.nq and model.nv==old.nv
|
| 16 |
+
for i in range(old.nbody):
|
| 17 |
+
name=mujoco.mj_id2name(old,mujoco.mjtObj.mjOBJ_BODY,i);j=mujoco.mj_name2id(model,mujoco.mjtObj.mjOBJ_BODY,name)
|
| 18 |
+
assert j>=0;model.body_mass[j]=old.body_mass[i];model.body_inertia[j]=old.body_inertia[i]
|
| 19 |
+
model.actuator_forcerange[:]=old.actuator_forcerange;model.opt.timestep=7.5e-5;model.opt.ccd_tolerance=1e-10;model.opt.ccd_iterations=200
|
| 20 |
+
d=mujoco.MjData(model);mujoco.mj_setConst(model,d);d.qpos[:]=model.qpos0;d.qvel[:]=0;d.time=0.
|
| 21 |
+
def free_pose(name,position,quat):
|
| 22 |
+
adr=int(model.joint(name+'_free').qposadr[0]);d.qpos[adr:adr+7]=np.r_[position,quat]
|
| 23 |
+
free_pose('Dropper',[-.072,.018,.78000003],[1,0,0,0]);free_pose('Tube',[.200,.075,.91],[0,1,0,0])
|
| 24 |
+
with np.load(a.prior/'input/fluid/gpu_seed.npz') as original_seed:
|
| 25 |
+
beaker_position=original_seed['body_position'][0]+original_seed['origin_world']
|
| 26 |
+
quaternion=Rotation.from_matrix(original_seed['body_rotation'][0]).as_quat()
|
| 27 |
+
free_pose('Beaker',beaker_position,quaternion[[3,0,1,2]])
|
| 28 |
+
for arm in ('left','right'):
|
| 29 |
+
for i in range(1,9):
|
| 30 |
+
q=int(model.joint(f'{arm}_joint{i}').qposadr[0]);act=model.actuator(f'{arm}_joint{i}').id;d.qpos[q]=0 if i<=6 else .044;d.ctrl[act]=d.qpos[q]
|
| 31 |
+
# Locate time-zero inverted support without dynamics or a pose change in a run.
|
| 32 |
+
# The target position is an authored initial condition, not a recovered state.
|
| 33 |
+
post=model.geom('rack_B_post_0').id;tubeid=model.body('Tube').id;addr=int(model.joint('Tube_free').qposadr[0]);lo=.968;hi=1.000
|
| 34 |
+
for _ in range(32):
|
| 35 |
+
z=(lo+hi)/2;d.qpos[addr+2]=z;mujoco.mj_forward(model,d)
|
| 36 |
+
penetrating=any(post in c.geom and any(g>=0 and model.geom_bodyid[g]==tubeid for g in c.geom) and c.dist<0 for c in d.contact)
|
| 37 |
+
if penetrating:lo=z
|
| 38 |
+
else:hi=z
|
| 39 |
+
d.qpos[addr+2]=hi+2e-7;mujoco.mj_forward(model,d)
|
| 40 |
+
sys.path.insert(0,str(Path(__file__).resolve().parents[1]));from dropperlab.experimental_sph.bulb_fem import Cavity
|
| 41 |
+
from dropperlab.experimental_sph.bulb_integrity import BulbIntegrity
|
| 42 |
+
cavity=Cavity(model,d);integrity=BulbIntegrity(cavity);geometry=integrity.check()
|
| 43 |
+
bad=[]
|
| 44 |
+
for c in d.contact:
|
| 45 |
+
if c.dist<-.0000001:bad.append(dict(geoms=[int(x) for x in c.geom],distance=float(c.dist)))
|
| 46 |
+
assert not bad, bad
|
| 47 |
+
mujoco.mj_saveModel(model,str(a.out/'solid/model.mjb'),None);spec.to_file(str(a.out/'solid/model.xml'))
|
| 48 |
+
np.savez_compressed(a.out/'solid/initial_state.npz',qpos=d.qpos,qvel=d.qvel)
|
| 49 |
+
with np.load(a.prior/'input/fluid/gpu_seed.npz') as z:seed={k:z[k].copy() for k in z.files}
|
| 50 |
+
origin=seed['origin_world'];names=['Beaker','Dropper','Tube'];seed['body_position']=np.array([d.body(n).xpos-origin for n in names]);seed['body_rotation']=np.array([d.body(n).xmat.reshape(3,3) for n in names]);np.savez_compressed(a.out/'fluid/gpu_seed.npz',**seed)
|
| 51 |
+
beaker_local=(seed['water']-seed['body_position'][0])@seed['body_rotation'][0]
|
| 52 |
+
assert np.all(np.linalg.norm(beaker_local[:,:2],axis=1)<=.032+1e-7) and np.all(beaker_local[:,2]>=.002-1e-7) and np.all(beaker_local[:,2]<=.065+1e-7), 'New time-zero beaker must align to unchanged water seed'
|
| 53 |
+
report=dict(scope=__doc__,time=0.,new_trajectory=True,old_checkpoint_resumed=False,initial_hands_empty=True,water_particles=len(seed['water']),beaker_only_seed=True,dropper_position=d.body('Dropper').xpos.tolist(),tube_position=d.body('Tube').xpos.tolist(),tube_axis=d.body('Tube').xmat.reshape(3,3)[:,2].tolist(),rack_B_post_radius_m=.003,rack_B_post_top_m=.971,initial_penetrations=bad,geometry=geometry,model_sha256=hashlib.sha256((a.out/'solid/model.mjb').read_bytes()).hexdigest(),physics_qualified=False)
|
| 54 |
+
from dropperlab.dual_policy import MotorController
|
| 55 |
+
from dropperlab.rack_to_rack_policy import RackToRackPolicy
|
| 56 |
+
robots=[MotorController(model,d,arm) for arm in ('left','right')]
|
| 57 |
+
with np.load(a.out/'assets/generated/tube_inventory_cavity.npz') as tube_mesh:height=float(tube_mesh['vertices'][:,2].max())
|
| 58 |
+
q_before=d.qpos.copy();policy=RackToRackPolicy(model,d,robots,height)
|
| 59 |
+
for index in range(2):policy.choose_pick(index)
|
| 60 |
+
assert np.array_equal(d.qpos,q_before) and d.time==0., 'Preflight must not move the initial state'
|
| 61 |
+
report['pickup_endpoint_ik']={'rotations':policy.pick_rotations,'approach_offsets':policy.pick_approach_offsets,'targets':[r.target.tolist() for r in robots],'scope':'Independent IK endpoints only, not proof of executed motion or grasp'}
|
| 62 |
+
from dropperlab.experimental_sph.static_world_contact import scene_mesh
|
| 63 |
+
_,_,fixed_names=scene_mesh(model,d,origin)
|
| 64 |
+
assert all(f'rack_B_post_{i}' in fixed_names for i in range(4))
|
| 65 |
+
report['static_water_components']=len(fixed_names);report['rack_B_in_water_collision_geometry']=True
|
| 66 |
+
(a.out/'scene_initialization.json').write_text(json.dumps(report,indent=2));print(json.dumps(report))
|
v1/scripts/probe_gpu_full_transfer.py
ADDED
|
@@ -0,0 +1,505 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Unqualified same-run 3D-water aspiration/dispense/rack motor candidate.
|
| 2 |
+
|
| 3 |
+
Advancement requires actual liquid inventory. No phase-based water creation,
|
| 4 |
+
object pose substitution, or automatic physics qualification is performed.
|
| 5 |
+
"""
|
| 6 |
+
from pathlib import Path
|
| 7 |
+
import sys,argparse,json,time,math
|
| 8 |
+
import numpy as np,mujoco,warp as wp
|
| 9 |
+
from scipy.spatial.transform import Rotation
|
| 10 |
+
sys.path.insert(0,str(Path(__file__).resolve().parents[1]))
|
| 11 |
+
from dropperlab.experimental_sph.warp_dfsph import WarpDFSPH
|
| 12 |
+
from dropperlab.experimental_sph.bulb_fem import Cavity
|
| 13 |
+
from dropperlab.experimental_sph.bulb_integrity import BulbIntegrity
|
| 14 |
+
from dropperlab.dual_policy import MotorController
|
| 15 |
+
from dropperlab.assets import ROOT
|
| 16 |
+
from dropperlab.experiment_recording import ExperimentRecorder
|
| 17 |
+
from dropperlab.particle_inventory import CavityInventory
|
| 18 |
+
from dropperlab.transfer_policy import TransferPolicy
|
| 19 |
+
from dropperlab.interval_state import IntervalState
|
| 20 |
+
from dropperlab.accepted_checkpoint import save_checkpoint,load_checkpoint
|
| 21 |
+
from dropperlab.grasp_support import GraspSupport
|
| 22 |
+
from dropperlab.grasp_geometry import GraspGeometry
|
| 23 |
+
p=argparse.ArgumentParser();p.add_argument('--source',type=Path,default=ROOT/'results/coupled_gpu_seed_smoke')
|
| 24 |
+
p.add_argument('--out',type=Path,required=True);p.add_argument('--duration',type=float,default=60.)
|
| 25 |
+
p.add_argument('--release-duration',type=float,default=.3);p.add_argument('--sigma',type=float,default=.072)
|
| 26 |
+
p.add_argument('--release-gap',type=float,default=.008)
|
| 27 |
+
p.add_argument('--fluid-dt',type=float,default=.0001)
|
| 28 |
+
p.add_argument('--adaptive-contact',action='store_true')
|
| 29 |
+
p.add_argument('--contact-predictor-recovery',action='store_true')
|
| 30 |
+
p.add_argument('--paired-world-contact',action='store_true')
|
| 31 |
+
p.add_argument('--record-water-interval',type=float,default=.02)
|
| 32 |
+
p.add_argument('--maximum-coupling-iterations',type=int,default=24)
|
| 33 |
+
p.add_argument('--resume',type=Path)
|
| 34 |
+
p.add_argument('--minimum-solid-dt',type=float,default=.0000125)
|
| 35 |
+
p.add_argument('--neighbor-cache',action='store_true')
|
| 36 |
+
p.add_argument('--kinematics-only-prediction',action='store_true')
|
| 37 |
+
p.add_argument('--adopt-native-result',action='store_true')
|
| 38 |
+
p.add_argument('--gas-volume-tolerance',type=float,default=1e-11)
|
| 39 |
+
p.add_argument('--grasp-feedback',action='store_true')
|
| 40 |
+
p.add_argument('--transport-grasp-minimum',type=float,default=.12)
|
| 41 |
+
p.add_argument('--bulb-center-z',type=float)
|
| 42 |
+
p.add_argument('--stem-preclose-gap',type=float,default=.014)
|
| 43 |
+
p.add_argument('--synchronized-motion',action='store_true')
|
| 44 |
+
p.add_argument('--recover-solid-dt',type=float,default=0.)
|
| 45 |
+
p.add_argument('--coupling-relaxation',type=float,default=1.)
|
| 46 |
+
p.add_argument('--coupling-tolerance',type=float,default=5e-9)
|
| 47 |
+
p.add_argument('--ccd-tolerance',type=float)
|
| 48 |
+
p.add_argument('--ccd-iterations',type=int)
|
| 49 |
+
p.add_argument('--independent-grasp-geometry',action='store_true')
|
| 50 |
+
p.add_argument('--immersion-depth',type=float,default=.005)
|
| 51 |
+
p.add_argument('--aspiration-timeout',type=float,default=12.)
|
| 52 |
+
p.add_argument('--stop-request',type=Path)
|
| 53 |
+
p.add_argument('--bimanual-stem-support',action='store_true')
|
| 54 |
+
p.add_argument('--rack-to-rack-v1',action='store_true',help='New empty-tools dual-rack initial preparation; never reinterpret an old continuation')
|
| 55 |
+
p.add_argument('--static-world-contact',action='store_true')
|
| 56 |
+
p.add_argument('--world-floor-z',type=float)
|
| 57 |
+
p.add_argument('--record-port-flux',action='store_true')
|
| 58 |
+
p.add_argument('--substep-port-flux',action='store_true')
|
| 59 |
+
p.add_argument('--continuous-glass-wall-table',type=Path)
|
| 60 |
+
p.add_argument('--continuous-glass-pressure-table',type=Path)
|
| 61 |
+
p.add_argument('--dispense-force-max',type=float,default=3.)
|
| 62 |
+
p.add_argument('--swept-water-contact',action='store_true')
|
| 63 |
+
p.add_argument('--continuous-floor-viscosity',action='store_true')
|
| 64 |
+
p.add_argument('--surface-model',choices=['pair','number_density_energy','number_density_implicit'],default='pair')
|
| 65 |
+
p.add_argument('--kernel-support',type=float,default=2.)
|
| 66 |
+
p.add_argument('--viscosity-kernel-support',type=float)
|
| 67 |
+
p.add_argument('--viscosity-regularization',type=float,default=.01)
|
| 68 |
+
p.add_argument('--mirror-no-slip',action='store_true')
|
| 69 |
+
p.add_argument('--wall-velocity-model',choices=['quadratic_mirror','adaptive_mirror'],default='quadratic_mirror')
|
| 70 |
+
p.add_argument('--pressure-complementarity',action='store_true')
|
| 71 |
+
p.add_argument('--pressure-tolerance',type=float,default=5e-5)
|
| 72 |
+
p.add_argument('--maximum-pressure-iterations',type=int,default=200)
|
| 73 |
+
p.add_argument('--number-density-area-scale',type=float,default=1.)
|
| 74 |
+
p.add_argument('--interface-kernel-support',type=float,default=3.)
|
| 75 |
+
p.add_argument('--discrete-interface-normalization',action='store_true')
|
| 76 |
+
p.add_argument('--interface-epsilon',type=float,default=.05)
|
| 77 |
+
a=p.parse_args();out=a.out.resolve();out.mkdir(parents=True,exist_ok=False);started=time.perf_counter()
|
| 78 |
+
if a.rack_to_rack_v1 and not a.bimanual_stem_support:raise ValueError('Dual-rack V1 requires bimanual support')
|
| 79 |
+
if not .007<=a.stem_preclose_gap<=.014:raise ValueError('Stem preclose outside reviewed clearance range')
|
| 80 |
+
if a.world_floor_z is not None and (not a.static_world_contact or not np.isfinite(a.world_floor_z)):raise ValueError('A finite world floor requires fixed-world fluid contact')
|
| 81 |
+
if a.continuous_floor_viscosity and a.world_floor_z is None:raise ValueError('Continuous floor viscosity requires the explicit physical floor')
|
| 82 |
+
if a.substep_port_flux and not a.record_port_flux:raise ValueError('Substep flux requires the accepted port-flux ledger')
|
| 83 |
+
model=mujoco.MjModel.from_binary_path(str(a.source/'solid/model.mjb'));data=mujoco.MjData(model)
|
| 84 |
+
if not 3.<=a.dispense_force_max<=4.:raise ValueError('Dispense effort must remain within the original 4N gripper rating')
|
| 85 |
+
if any(model.actuator('left_joint'+str(i)).forcerange[1]<a.dispense_force_max for i in (7,8)):raise ValueError('Requested effort exceeds source model rating')
|
| 86 |
+
if a.ccd_tolerance is not None:
|
| 87 |
+
if not 0<a.ccd_tolerance<=1e-6:raise ValueError('Invalid high-precision CCD tolerance')
|
| 88 |
+
model.opt.ccd_tolerance=a.ccd_tolerance
|
| 89 |
+
if a.ccd_iterations is not None:
|
| 90 |
+
if a.ccd_iterations<35:raise ValueError('CCD iteration limit may not be reduced')
|
| 91 |
+
model.opt.ccd_iterations=a.ccd_iterations
|
| 92 |
+
initial=np.load(a.source/'solid/initial_state.npz');data.qpos[:]=initial['qpos'];data.qvel[:]=initial['qvel']
|
| 93 |
+
robots=[MotorController(model,data,arm) for arm in ['left','right']]
|
| 94 |
+
for r in robots:r.reference=data.qpos[r.qids].copy();r.target=r.reference.copy();data.ctrl[r.uids]=r.reference;data.ctrl[r.gids]=0.;r.grip_reference[:]=0.;r.grip_speed_limit=.03
|
| 95 |
+
if a.rack_to_rack_v1 and not a.resume:
|
| 96 |
+
for r in robots:r.grip=.044;r.grip_reference[:]=.044;data.ctrl[r.gids]=.044
|
| 97 |
+
for actuator in robots[0].gids:model.actuator_forcerange[actuator]=[-3.,3.]
|
| 98 |
+
mujoco.mj_forward(model,data);cavity=Cavity(model,data);integrity=BulbIntegrity(cavity)
|
| 99 |
+
grasp_geometry=GraspGeometry(model,integrity) if a.independent_grasp_geometry else None
|
| 100 |
+
names=['Beaker','Dropper','Tube'];assets=['beaker','dropper_glass','open_original_tube'];meshes=[]
|
| 101 |
+
for asset in assets:
|
| 102 |
+
mesh=np.load(ROOT/f'assets/generated/{asset}.npz');meshes.append((mesh['vertices'].astype(np.float32),mesh['faces'].astype(np.int32)))
|
| 103 |
+
seed=np.load(a.source/'fluid/gpu_seed.npz');origin=seed['origin_world'];spacing=float(seed['spacing'])
|
| 104 |
+
if a.surface_model=='number_density_energy' and a.sigma>0 and a.fluid_dt>.25*np.sqrt(998.2*spacing**3/a.sigma):
|
| 105 |
+
raise ValueError('Explicit interface timestep exceeds the capillary stability bound')
|
| 106 |
+
water=WarpDFSPH(seed,meshes,sigma=a.sigma,cohesion_calibration=.2074,neighbor_cache=a.neighbor_cache,
|
| 107 |
+
surface_model=a.surface_model,kernel_support=a.kernel_support,viscosity_kernel_support=a.viscosity_kernel_support,
|
| 108 |
+
viscosity_regularization=a.viscosity_regularization,mirror_no_slip=a.mirror_no_slip,wall_velocity_model=a.wall_velocity_model,
|
| 109 |
+
pressure_complementarity=a.pressure_complementarity,pressure_tolerance=a.pressure_tolerance,
|
| 110 |
+
maximum_pressure_iterations=a.maximum_pressure_iterations,number_density_area_scale=a.number_density_area_scale,interface_kernel_support=a.interface_kernel_support,discrete_interface_normalization=a.discrete_interface_normalization,interface_epsilon=a.interface_epsilon)
|
| 111 |
+
if a.continuous_glass_wall_table:
|
| 112 |
+
from dropperlab.experimental_sph.continuous_wall_gpu import ContinuousGlassWall
|
| 113 |
+
water.continuous_glass_wall=ContinuousGlassWall(water,a.continuous_glass_wall_table)
|
| 114 |
+
if a.continuous_glass_pressure_table:
|
| 115 |
+
from dropperlab.experimental_sph.continuous_wall_pressure import ContinuousGlassPressure
|
| 116 |
+
water.continuous_glass_pressure=ContinuousGlassPressure(water,a.continuous_glass_pressure_table)
|
| 117 |
+
if a.swept_water_contact:
|
| 118 |
+
from dropperlab.experimental_sph.swept_water_contact import SweptWaterAudit
|
| 119 |
+
water.swept_water_audit=SweptWaterAudit(water)
|
| 120 |
+
water.port_flux=None
|
| 121 |
+
if a.record_port_flux:
|
| 122 |
+
from dropperlab.port_flux import PortFluxLedger
|
| 123 |
+
initial_water=np.asarray(seed['water']);beaker_local=(initial_water-seed['body_position'][0])@seed['body_rotation'][0]
|
| 124 |
+
initial_source=(np.linalg.norm(beaker_local[:,:2],axis=1)<=.032+1e-7)&(beaker_local[:,2]>=.002-1e-7)&(beaker_local[:,2]<=.065+1e-7)
|
| 125 |
+
if not initial_source.all():raise RuntimeError('Initial water source is not the physical beaker; source flux cannot be invented')
|
| 126 |
+
water.port_flux=PortFluxLedger(water.nf,water.mass,initial_source,water.device,complete_history=not bool(a.resume))
|
| 127 |
+
static_component_names=[]
|
| 128 |
+
if a.static_world_contact:
|
| 129 |
+
from dropperlab.experimental_sph.static_world_contact import StaticWorldContact,scene_mesh
|
| 130 |
+
world_vertices,world_faces,static_component_names=scene_mesh(model,data,origin)
|
| 131 |
+
planes=None if a.world_floor_z is None else [[np.array([0.,0.,a.world_floor_z])-origin,np.array([0.,0.,1.])]]
|
| 132 |
+
water.static_world=StaticWorldContact(water,world_vertices,world_faces,planes=planes)
|
| 133 |
+
if a.continuous_floor_viscosity:
|
| 134 |
+
from dropperlab.experimental_sph.plane_viscosity import PlaneViscosity
|
| 135 |
+
water.static_world.plane_viscosity=PlaneViscosity(water.static_world)
|
| 136 |
+
void=np.load(ROOT/'assets/generated/tube_inventory_cavity.npz')
|
| 137 |
+
tube_inventory=CavityInventory(water,void['vertices'].astype(np.float32),void['faces'].astype(np.int32))
|
| 138 |
+
policy=TransferPolicy(model,data,robots,float(void['vertices'][:,2].max()))
|
| 139 |
+
support=GraspSupport(model,data,robots) if a.grasp_feedback else None
|
| 140 |
+
if not .12<=a.transport_grasp_minimum<=.4:raise ValueError('Transport feedback threshold outside reviewed range')
|
| 141 |
+
if a.transport_grasp_minimum!=.12 and support is None:raise ValueError('Transport support target requires measured grasp feedback')
|
| 142 |
+
if support is not None:support.transport_minimum=a.transport_grasp_minimum
|
| 143 |
+
if a.bulb_center_z is not None:
|
| 144 |
+
if support is None or not -.01<=a.bulb_center_z<=-.003:raise ValueError('Bulb recentering requires feedback and reviewed pad target')
|
| 145 |
+
support.bulb_center_z=a.bulb_center_z
|
| 146 |
+
for r in robots:
|
| 147 |
+
r.synchronized_motion=a.synchronized_motion
|
| 148 |
+
if a.synchronized_motion:r.motion_speed=.5
|
| 149 |
+
recorder=ExperimentRecorder(out,spacing,a.record_water_interval,model=model)
|
| 150 |
+
for r,name in zip(robots,['Dropper','Tube']):
|
| 151 |
+
sr=data.site(r.arm+'_tcp').xmat.reshape(3,3);sp=data.site(r.arm+'_tcp').xpos
|
| 152 |
+
r.held=(name,sr.T@(data.body(name).xpos-sp),sr.T@data.body(name).xmat.reshape(3,3))
|
| 153 |
+
if a.rack_to_rack_v1 and not a.resume:
|
| 154 |
+
for r in robots:r.held=None
|
| 155 |
+
dry=data.body('Dropper').xpos.copy();beaker=data.body('Beaker').xpos.copy()
|
| 156 |
+
initial_depth=water.nf*water.volume/(np.pi*.032**2)
|
| 157 |
+
wet=np.r_[beaker[:2],beaker[2]+.002+max(3*spacing,initial_depth-a.immersion_depth)]
|
| 158 |
+
pred=mujoco.MjData(model);integration=np.empty(mujoco.mj_stateSize(model,mujoco.mjtState.mjSTATE_INTEGRATION));previous=np.zeros((3,6))
|
| 159 |
+
mujoco.mj_forward(model,pred)
|
| 160 |
+
corrected=mujoco.MjData(model);mujoco.mj_forward(model,corrected)
|
| 161 |
+
corrected_cavity=Cavity(model,corrected);predicted_cavity=Cavity(model,pred)
|
| 162 |
+
prediction_state=np.empty_like(integration)
|
| 163 |
+
sealed=False;sealed_at=None;last_plan=-1.;rows=[];states=[];report={'status':'running','task_success':False,'physics_qualified':False,
|
| 164 |
+
'scope':'unqualified same-run 3D-water aspiration/dispense/rack candidate; initially held objects','water_particles':water.nf,'spacing_m':spacing}
|
| 165 |
+
report['adaptive_contact_retries']=0
|
| 166 |
+
report['coupling_recomputations']=0
|
| 167 |
+
report['rejected_solid_intervals']=0
|
| 168 |
+
report['initial_water_ml']=water.nf*water.volume*1e6
|
| 169 |
+
report['immersion_depth_below_initial_surface_m']=a.immersion_depth
|
| 170 |
+
report['wet_tip_target_m']=wet.tolist()
|
| 171 |
+
report['neighbor_cache']=a.neighbor_cache
|
| 172 |
+
report['kinematics_only_prediction']=a.kinematics_only_prediction
|
| 173 |
+
report['gas_volume_tolerance_m3']=a.gas_volume_tolerance
|
| 174 |
+
report['grasp_feedback']=a.grasp_feedback;report['synchronized_motion']=a.synchronized_motion
|
| 175 |
+
report['recover_solid_dt_max_s']=a.recover_solid_dt
|
| 176 |
+
if not 0.<a.coupling_relaxation<=1.:raise ValueError('Coupling relaxation must be in (0,1]')
|
| 177 |
+
report['coupling_relaxation']=a.coupling_relaxation
|
| 178 |
+
if not 0.<a.coupling_tolerance<=5e-8:raise ValueError('Coupling tolerance must be positive and no more than 50 nm')
|
| 179 |
+
report['coupling_tolerance_m']=a.coupling_tolerance
|
| 180 |
+
report['native_ccd_tolerance']=model.opt.ccd_tolerance;report['native_ccd_iterations']=model.opt.ccd_iterations
|
| 181 |
+
report['independent_grasp_geometry']=a.independent_grasp_geometry
|
| 182 |
+
report['static_water_world_contact']=a.static_world_contact
|
| 183 |
+
report['static_world_collider_components']=len(static_component_names)
|
| 184 |
+
report['record_port_flux']=a.record_port_flux
|
| 185 |
+
report['substep_port_flux']=a.substep_port_flux
|
| 186 |
+
report['native_commit']='copy accepted native FSI endpoint' if a.adopt_native_result else 'independent repeat integration'
|
| 187 |
+
report['world_floor_z']=a.world_floor_z
|
| 188 |
+
report['floor_scope']='Fixed infinite liquid support plane; native solids must remain strictly above it' if a.world_floor_z is not None else 'No ground plane'
|
| 189 |
+
checkpoint_parameters={k:getattr(a,k) for k in ['sigma','release_duration','release_gap','fluid_dt','immersion_depth']}
|
| 190 |
+
if a.rack_to_rack_v1:checkpoint_parameters['rack_to_rack_v1']=True
|
| 191 |
+
if a.transport_grasp_minimum!=.12:checkpoint_parameters['transport_grasp_minimum']=a.transport_grasp_minimum
|
| 192 |
+
if a.bulb_center_z is not None:checkpoint_parameters['bulb_center_z']=a.bulb_center_z
|
| 193 |
+
if a.stem_preclose_gap!=.014:checkpoint_parameters['stem_preclose_gap']=a.stem_preclose_gap
|
| 194 |
+
if a.substep_port_flux:checkpoint_parameters['substep_port_flux']=True
|
| 195 |
+
if a.world_floor_z is not None:checkpoint_parameters['world_floor_z']=a.world_floor_z
|
| 196 |
+
if a.dispense_force_max!=3.:checkpoint_parameters['dispense_force_max']=a.dispense_force_max
|
| 197 |
+
if a.swept_water_contact:checkpoint_parameters['swept_water_contact']=True
|
| 198 |
+
if a.continuous_floor_viscosity:checkpoint_parameters['continuous_floor_viscosity']=True
|
| 199 |
+
if a.continuous_glass_wall_table:
|
| 200 |
+
checkpoint_parameters['continuous_glass_wall_table_sha256']=water.continuous_glass_wall.sha256
|
| 201 |
+
report['continuous_wall_scope']='Opt-in continuous annular glass adhesion potential; all native collision facets unchanged. Wall-force model migration is explicit; not inherited physical qualification.'
|
| 202 |
+
if a.continuous_glass_pressure_table:
|
| 203 |
+
checkpoint_parameters['continuous_glass_pressure_table_sha256']=water.continuous_glass_pressure.sha256
|
| 204 |
+
report['continuous_pressure_scope']='Consistent continuous annular glass density/divergence/pressure/reaction operator. Native collision facets unchanged. Explicit numerical model migration, not inherited qualification.'
|
| 205 |
+
advanced_defaults=dict(surface_model='pair',kernel_support=2.,viscosity_kernel_support=None,viscosity_regularization=.01,
|
| 206 |
+
mirror_no_slip=False,wall_velocity_model='quadratic_mirror',pressure_complementarity=False,
|
| 207 |
+
pressure_tolerance=5e-5,maximum_pressure_iterations=200,number_density_area_scale=1.,interface_kernel_support=3.,discrete_interface_normalization=False,interface_epsilon=.05)
|
| 208 |
+
if any(getattr(a,k)!=v for k,v in advanced_defaults.items()):
|
| 209 |
+
checkpoint_parameters.update({k:getattr(a,k) for k in advanced_defaults})
|
| 210 |
+
checkpoint_parameters.update(seed_spacing_m=spacing,initial_particle_count=water.nf)
|
| 211 |
+
report['solver_parameters']=checkpoint_parameters.copy()
|
| 212 |
+
if a.resume:
|
| 213 |
+
previous,logic,resume_meta=load_checkpoint(a.resume,a.source/'solid/model.mjb',model,data,water,robots,cavity,policy,checkpoint_parameters,
|
| 214 |
+
restore_numerical_options=a.ccd_tolerance is None and a.ccd_iterations is None)
|
| 215 |
+
sealed,sealed_at,last_plan=logic;report['resumed_accepted_state']=str(a.resume.resolve())
|
| 216 |
+
report['resumed_physical_time']=float(data.time)
|
| 217 |
+
if a.bimanual_stem_support:
|
| 218 |
+
from dropperlab.bimanual_policy import BimanualPolicy
|
| 219 |
+
if a.rack_to_rack_v1:
|
| 220 |
+
from dropperlab.rack_to_rack_policy import RackToRackPolicy
|
| 221 |
+
saved_policy={k:v for k,v in policy.__dict__.items() if k not in ['model','data','robots']}
|
| 222 |
+
saved_targets=[r.target.copy() for r in robots]
|
| 223 |
+
policy=(RackToRackPolicy if a.rack_to_rack_v1 else BimanualPolicy)(model,data,robots,float(void['vertices'][:,2].max()))
|
| 224 |
+
if saved_policy.get('policy_kind') in ('bimanual_stem_support_v1','rack_to_rack_v1'):
|
| 225 |
+
if a.rack_to_rack_v1 and saved_policy.get('policy_kind')!='rack_to_rack_v1':raise RuntimeError('Old held-object trajectory cannot become new cold-start V1')
|
| 226 |
+
policy.__dict__.update(saved_policy)
|
| 227 |
+
for r,target in zip(robots,saved_targets):r.target=target
|
| 228 |
+
if saved_policy.get('controller_revision',1)<2:
|
| 229 |
+
if policy.stem_secured or policy.stage not in ['await_dose','lift_after_aspiration','transfer_for_stem_support','park_above','park_seat','park_release','park_retreat']:
|
| 230 |
+
raise RuntimeError('The reviewed grasp revision requires a checkpoint before the rigid stem grasp')
|
| 231 |
+
# Replace an unexecuted motor approach plan only. Accepted rigid,
|
| 232 |
+
# elastic, controller reference and water arrays remain untouched.
|
| 233 |
+
policy.stem_rotation=np.diag([-1.,-1.,1.]).tolist();policy.stem_height=.080
|
| 234 |
+
policy.controller_revision=2
|
| 235 |
+
policy.events.append(dict(time=float(data.time),stage='reviewed_unexecuted_stem_approach_revision'))
|
| 236 |
+
else:policy.events=saved_policy['events']+[{'time':float(data.time),'stage':'bimanual_stem_support_adaptation'}]
|
| 237 |
+
policy.dispense_force_max=a.dispense_force_max
|
| 238 |
+
policy.stem_preclose_gap=a.stem_preclose_gap
|
| 239 |
+
if not a.resume and not a.rack_to_rack_v1:policy.stage='await_dose';policy.entered=float(data.time);policy.events=[]
|
| 240 |
+
report['scope']='unqualified coupled 3D-water transfer with contact-only second-hand rigid glass support'
|
| 241 |
+
report['bimanual_stem_support']=True
|
| 242 |
+
if a.rack_to_rack_v1:report.update(scope='New cold-start V1: empty dropper on A, inverted empty tube on B, initially empty home hands',rack_to_rack_v1=True)
|
| 243 |
+
recorder.capture(data,water.positions_numpy()+origin,water_velocity=water.velocities_numpy())
|
| 244 |
+
print(json.dumps({'stage':'gpu_coupled_initialized','particles':water.nf,'wall_seconds':time.perf_counter()-started}),flush=True)
|
| 245 |
+
def poses(offset,length):
|
| 246 |
+
positions=[];rotations=[];centers=[];linear=[];angular=[]
|
| 247 |
+
for name in names:
|
| 248 |
+
b=data.body(name);e=pred.body(name);c0=data.xipos[b.id];c1=pred.xipos[e.id]
|
| 249 |
+
r0=b.xmat.reshape(3,3);vector=Rotation.from_matrix(e.xmat.reshape(3,3)@r0.T).as_rotvec();fraction=np.clip(offset/length,0,1)
|
| 250 |
+
r=Rotation.from_rotvec(vector*fraction).as_matrix()@r0;c=(1-fraction)*c0+fraction*c1
|
| 251 |
+
positions.append(c+r@(r0.T@(b.xpos-c0))-origin);rotations.append(r);centers.append(c-origin)
|
| 252 |
+
linear.append((c1-c0)/length);angular.append(vector/length)
|
| 253 |
+
return np.array(positions),np.array(rotations),np.array(centers),np.array(linear),np.array(angular)
|
| 254 |
+
def sync_current():
|
| 255 |
+
position=[];rotation=[];com=[];linear=[];angular=[]
|
| 256 |
+
for name in names:
|
| 257 |
+
body=data.body(name);velocity=np.empty(6)
|
| 258 |
+
mujoco.mj_objectVelocity(model,data,mujoco.mjtObj.mjOBJ_BODY,body.id,velocity,0)
|
| 259 |
+
position.append(body.xpos-origin);rotation.append(body.xmat.reshape(3,3));com.append(data.xipos[body.id]-origin)
|
| 260 |
+
linear.append(velocity[3:]);angular.append(velocity[:3])
|
| 261 |
+
water.sync_bodies(position,rotation,com,linear,angular)
|
| 262 |
+
def prediction_geometry(state):
|
| 263 |
+
if a.kinematics_only_prediction:
|
| 264 |
+
mujoco.mj_kinematics(model,state);mujoco.mj_comPos(model,state);mujoco.mj_flex(model,state)
|
| 265 |
+
else:mujoco.mj_forward(model,state)
|
| 266 |
+
def endpoint_geometry(state):
|
| 267 |
+
if a.kinematics_only_prediction:prediction_geometry(state)
|
| 268 |
+
else:mujoco.mj_fwdPosition(model,state)
|
| 269 |
+
try:
|
| 270 |
+
frame=0;next_step_recovery=float(data.time)+.005;controlled_stop=False
|
| 271 |
+
while data.time<a.duration-1e-10:
|
| 272 |
+
if water.port_flux is not None and not a.substep_port_flux:
|
| 273 |
+
# Smaller numerical intervals keep every real port crossing inside
|
| 274 |
+
# one accepted water step; no physical coefficient is changed.
|
| 275 |
+
model.opt.timestep=min(model.opt.timestep,a.fluid_dt,a.recover_solid_dt if a.recover_solid_dt>0 else a.fluid_dt)
|
| 276 |
+
t=float(data.time);dt=float(model.opt.timestep)
|
| 277 |
+
previous_before=previous.copy()
|
| 278 |
+
start=IntervalState(model,data,robots,cavity,policy)
|
| 279 |
+
initial_logic=(sealed,sealed_at,last_plan)
|
| 280 |
+
checkpoint=water.candidate_checkpoint()
|
| 281 |
+
# The legacy endpoint ledger is written only after acceptance and never
|
| 282 |
+
# needs a candidate backup. Substep measurements do need rollback.
|
| 283 |
+
flux_snapshot=water.port_flux.snapshot() if water.port_flux is not None and a.substep_port_flux else None
|
| 284 |
+
tip_before=data.body('Dropper').xpos.copy()-origin
|
| 285 |
+
rotation_before=data.body('Dropper').xmat.reshape(3,3).copy()
|
| 286 |
+
if water.port_flux is not None and not a.substep_port_flux and dt>a.fluid_dt+1e-15:
|
| 287 |
+
raise RuntimeError('Port-flux measurement requires each accepted solid interval to contain at most one water step')
|
| 288 |
+
sync_current()
|
| 289 |
+
bore_ml=water.bore_volume()*1e6;tube_ml=tube_inventory.volume()*1e6
|
| 290 |
+
if support and a.bimanual_stem_support:
|
| 291 |
+
support.right_object=policy.right_object;support.left_object=getattr(policy,'left_object','Dropper')
|
| 292 |
+
grasp_ready=support.regulate(policy) if support else True
|
| 293 |
+
vertices=data.flexvert_xpos[cavity.start:cavity.start+integrity.total_vertices]
|
| 294 |
+
jac_start=np.linalg.det(vertices[integrity.tetrahedra[:,1:]]-vertices[integrity.tetrahedra[:,0,None]])/integrity.reference_det
|
| 295 |
+
if policy.stage in ['dispense','supported_dispense'] or a.bimanual_stem_support:
|
| 296 |
+
policy.regulate_dispense(float(jac_start.min()),cavity.pressure)
|
| 297 |
+
if a.rack_to_rack_v1:policy.measured_bulb_volume_m3=cavity.volume()
|
| 298 |
+
policy.port_colour=float(water.port_color())
|
| 299 |
+
active_transfer=policy.update(bore_ml,tube_ml,grasp_ready)
|
| 300 |
+
aspiration_elapsed=t-policy.entered if a.rack_to_rack_v1 else t
|
| 301 |
+
if not active_transfer and aspiration_elapsed>a.aspiration_timeout:raise RuntimeError('Actual 1 mL aspiration not established before timeout')
|
| 302 |
+
if not active_transfer and t-last_plan>.02:
|
| 303 |
+
last_plan=t;policy.command_aspiration(wet)
|
| 304 |
+
color=water.port_color();surface=data.body('Beaker').xpos[2]+.002+water.nf*water.volume/(np.pi*.032**2)
|
| 305 |
+
if not sealed and color>.25 and data.body('Dropper').xpos[2]<surface-spacing:sealed=True;sealed_at=t
|
| 306 |
+
alpha=np.clip((t-((sealed_at+.03) if sealed_at is not None else float('inf')))/a.release_duration,0,1)
|
| 307 |
+
limit=3.-2.2*alpha*alpha*(3-2*alpha)
|
| 308 |
+
if not active_transfer:
|
| 309 |
+
for actuator in robots[0].gids:model.actuator_forcerange[actuator]=[-limit,limit]
|
| 310 |
+
else:limit=float(model.actuator_forcerange[robots[0].gids[0],1])
|
| 311 |
+
joint_fraction=None
|
| 312 |
+
if a.bimanual_stem_support and policy.stem_secured:
|
| 313 |
+
maximum=max(float(np.max(np.abs(r.target-r.reference))) for r in robots)
|
| 314 |
+
joint_fraction=min(1.,.5*dt/max(maximum,1e-15))
|
| 315 |
+
for i,r in enumerate(robots):
|
| 316 |
+
if not active_transfer:r.grip=min(a.release_gap*alpha*alpha*(3-2*alpha),policy.safe_grip_ceiling) if i==0 else (.044 if a.rack_to_rack_v1 else 0.)
|
| 317 |
+
r.update(dt,joint_fraction=joint_fraction)
|
| 318 |
+
# Empty, dry glass reconnects gas to the atmosphere. Retention/sealing
|
| 319 |
+
# still needs a qualified multiphase interface; no success flag is granted.
|
| 320 |
+
vented=not sealed or (active_transfer and bore_ml<.001 and color<.1)
|
| 321 |
+
cavity.apply(dt,vented=vented,water_volume=water.bore_volume(),apply_forces=False)
|
| 322 |
+
data.xfrc_applied[:]=0.;cavity.apply_pressure(cavity.pressure)
|
| 323 |
+
for i,name in enumerate(names):data.xfrc_applied[model.body(name).id]+=previous[i]
|
| 324 |
+
mujoco.mj_getState(model,data,integration,mujoco.mjtState.mjSTATE_INTEGRATION);mujoco.mj_setState(model,pred,integration,mujoco.mjtState.mjSTATE_INTEGRATION)
|
| 325 |
+
if not a.kinematics_only_prediction:mujoco.mj_forward(model,pred)
|
| 326 |
+
mujoco.mj_step(model,pred);endpoint_geometry(pred)
|
| 327 |
+
volume_start=cavity.volume()
|
| 328 |
+
water.contact_predictor_recovery=a.contact_predictor_recovery
|
| 329 |
+
water.paired_world_contact=a.paired_world_contact
|
| 330 |
+
if a.paired_world_contact and not hasattr(water,'paired_contact_applied'):
|
| 331 |
+
water.paired_contact_applied=wp.zeros(1,dtype=int,device=water.device)
|
| 332 |
+
for coupling in range(a.maximum_coupling_iterations):
|
| 333 |
+
if coupling:
|
| 334 |
+
water.reject_candidate_interval(checkpoint);report['coupling_recomputations']+=1
|
| 335 |
+
if a.substep_port_flux:water.port_flux.reject(flux_snapshot)
|
| 336 |
+
substeps=max(1,math.ceil(dt/min(a.fluid_dt,.3*spacing/max(water.maximum_speed(),.1))));nominal_h=dt/substeps
|
| 337 |
+
impulse=np.zeros((3,6));pressure_sum=0.;volume_end=predicted_cavity.volume()
|
| 338 |
+
elapsed=0.;retry_limit=nominal_h;rejected_prediction=False
|
| 339 |
+
while elapsed<dt-1e-14:
|
| 340 |
+
h=min(retry_limit,dt-elapsed)
|
| 341 |
+
pos,rot,com,lin,ang=poses(elapsed,dt);end_pos,end_rot,_,_,_=poses(elapsed+h,dt)
|
| 342 |
+
water.sync_bodies(pos,rot,com,lin,ang,end_pos,end_rot)
|
| 343 |
+
volume=volume_start+(volume_end-volume_start)*(elapsed+.5*h)/dt
|
| 344 |
+
gas=volume+cavity.dead_volume-water.bore_volume();pressure=cavity.gas_pv/gas
|
| 345 |
+
if gas<=1e-7 or pressure<3000:raise RuntimeError('Invalid gas state')
|
| 346 |
+
flux_before=None
|
| 347 |
+
if a.substep_port_flux:
|
| 348 |
+
flux_before=wp.empty(water.nf,dtype=wp.vec3,device=water.device);wp.copy(flux_before,water.x,count=water.nf)
|
| 349 |
+
try:liquid=water.step(h,gas_pressure=pressure-cavity.patm)
|
| 350 |
+
except RuntimeError as e:
|
| 351 |
+
if a.contact_predictor_recovery and 'physical CAD contact rejected' in str(e) and h<1e-6 and water.rejected_candidate_wrench is not None:
|
| 352 |
+
# Correct only the independent solid predictor with the
|
| 353 |
+
# rejected contact reaction. The next coupling iteration
|
| 354 |
+
# recomputes all water/flux from the accepted checkpoint.
|
| 355 |
+
trial_force,trial_torque=water.rejected_candidate_wrench
|
| 356 |
+
seed_impulse=impulse.copy()
|
| 357 |
+
for i,name in enumerate(names):
|
| 358 |
+
actual_com=data.xipos[model.body(name).id]-origin
|
| 359 |
+
seed_impulse[i]+=(dt-elapsed)*np.r_[trial_force[i],trial_torque[i]+np.cross(com[i]-actual_com,trial_force[i])]
|
| 360 |
+
mujoco.mj_setState(model,corrected,integration,mujoco.mjtState.mjSTATE_INTEGRATION)
|
| 361 |
+
prediction_geometry(corrected);corrected.xfrc_applied[:]=0.
|
| 362 |
+
corrected_cavity.apply_pressure((pressure_sum+(dt-elapsed)*pressure)/dt)
|
| 363 |
+
for i,name in enumerate(names):corrected.xfrc_applied[model.body(name).id]+=seed_impulse[i]/dt
|
| 364 |
+
mujoco.mj_step(model,corrected);endpoint_geometry(corrected)
|
| 365 |
+
mujoco.mj_getState(model,corrected,prediction_state,mujoco.mjtState.mjSTATE_INTEGRATION)
|
| 366 |
+
mujoco.mj_setState(model,pred,prediction_state,mujoco.mjtState.mjSTATE_INTEGRATION);prediction_geometry(pred)
|
| 367 |
+
rejected_prediction=True
|
| 368 |
+
report['contact_predictor_retries']=report.get('contact_predictor_retries',0)+1
|
| 369 |
+
print(json.dumps({'stage':'rejected_contact_predictor_retry','time':t,'coupling_iteration':coupling,'rejected_water_step':h}),flush=True)
|
| 370 |
+
break
|
| 371 |
+
if not a.adaptive_contact or 'physical CAD contact rejected' not in str(e) or h<1e-6:raise
|
| 372 |
+
retry_limit=h/2;report['adaptive_contact_retries']+=1
|
| 373 |
+
continue
|
| 374 |
+
if a.substep_port_flux:
|
| 375 |
+
# Trial measurements follow each actual numerical water
|
| 376 |
+
# step and its moving CAD. They are published only after
|
| 377 |
+
# the outer native endpoint passes the existing FSI guard.
|
| 378 |
+
water.port_flux.advance(flux_before,water.x,pos[1],rot[1],end_pos[1],end_rot[1])
|
| 379 |
+
force=water.force.numpy();torque=water.torque.numpy()
|
| 380 |
+
for i,name in enumerate(names):
|
| 381 |
+
actual_com=data.xipos[model.body(name).id]-origin
|
| 382 |
+
impulse[i]+=h*np.r_[force[i],torque[i]+np.cross(com[i]-actual_com,force[i])]
|
| 383 |
+
pressure_sum+=h*pressure;elapsed+=h
|
| 384 |
+
if rejected_prediction:
|
| 385 |
+
endpoint_error=float('inf');volume_endpoint_error=float('inf');geometry_failures=1
|
| 386 |
+
continue
|
| 387 |
+
# Compute an independently integrated corrected endpoint. The live
|
| 388 |
+
# solid state stays at the interval start until the candidate passes.
|
| 389 |
+
mujoco.mj_setState(model,corrected,integration,mujoco.mjtState.mjSTATE_INTEGRATION)
|
| 390 |
+
prediction_geometry(corrected);corrected.xfrc_applied[:]=0.
|
| 391 |
+
corrected_cavity.apply_pressure(pressure_sum/dt)
|
| 392 |
+
for i,name in enumerate(names):corrected.xfrc_applied[model.body(name).id]+=impulse[i]/dt
|
| 393 |
+
mujoco.mj_step(model,corrected);endpoint_geometry(corrected)
|
| 394 |
+
endpoint_position=np.array([corrected.body(name).xpos-origin for name in names])
|
| 395 |
+
endpoint_rotation=np.array([corrected.body(name).xmat.reshape(3,3) for name in names])
|
| 396 |
+
geometry_failures=water.actual_geometry_failures(endpoint_position,endpoint_rotation)
|
| 397 |
+
endpoint_error=max(float(np.linalg.norm(corrected.body(name).xpos-pred.body(name).xpos))+
|
| 398 |
+
.15*float(np.linalg.norm(corrected.body(name).xmat-pred.body(name).xmat)) for name in names)
|
| 399 |
+
volume_endpoint_error=abs(corrected_cavity.volume()-predicted_cavity.volume())
|
| 400 |
+
if endpoint_error<a.coupling_tolerance and volume_endpoint_error<=a.gas_volume_tolerance and geometry_failures==0:break
|
| 401 |
+
mujoco.mj_getState(model,corrected,prediction_state,mujoco.mjtState.mjSTATE_INTEGRATION)
|
| 402 |
+
if a.coupling_relaxation<1.:
|
| 403 |
+
old_qpos=pred.qpos.copy();old_qvel=pred.qvel.copy()
|
| 404 |
+
difference=np.empty(model.nv)
|
| 405 |
+
mujoco.mj_differentiatePos(model,difference,1.,old_qpos,corrected.qpos)
|
| 406 |
+
mujoco.mj_setState(model,pred,prediction_state,mujoco.mjtState.mjSTATE_INTEGRATION)
|
| 407 |
+
# Damp only the independent candidate prediction on MuJoCo's
|
| 408 |
+
# configuration manifold. Live bodies continue native steps.
|
| 409 |
+
pred.qpos[:]=old_qpos;mujoco.mj_integratePos(model,pred.qpos,difference,a.coupling_relaxation)
|
| 410 |
+
pred.qvel[:]=(1-a.coupling_relaxation)*old_qvel+a.coupling_relaxation*corrected.qvel
|
| 411 |
+
else:mujoco.mj_setState(model,pred,prediction_state,mujoco.mjtState.mjSTATE_INTEGRATION)
|
| 412 |
+
prediction_geometry(pred)
|
| 413 |
+
else:
|
| 414 |
+
water.reject_candidate_interval(checkpoint)
|
| 415 |
+
if a.substep_port_flux:water.port_flux.reject(flux_snapshot)
|
| 416 |
+
if dt<=a.minimum_solid_dt:raise RuntimeError(f'FSI candidate did not converge at minimum solid step; error={endpoint_error:g}, gas volume error={volume_endpoint_error:g}, CAD failures={geometry_failures}')
|
| 417 |
+
start.reject(model,data,robots,cavity,policy);sealed,sealed_at,last_plan=initial_logic
|
| 418 |
+
model.opt.timestep=max(a.minimum_solid_dt,dt/2);report['rejected_solid_intervals']+=1
|
| 419 |
+
next_step_recovery=t+.020
|
| 420 |
+
print(json.dumps({'stage':'rejected_coupled_interval_retry','time':t,'new_solid_dt':model.opt.timestep,
|
| 421 |
+
'endpoint_error_m':endpoint_error,'gas_volume_error_m3':volume_endpoint_error,'actual_cad_failures':geometry_failures}),flush=True)
|
| 422 |
+
continue
|
| 423 |
+
data.xfrc_applied[:]=0.;cavity.apply_pressure(pressure_sum/dt)
|
| 424 |
+
previous=impulse/dt
|
| 425 |
+
for i,name in enumerate(names):data.xfrc_applied[model.body(name).id]+=previous[i]
|
| 426 |
+
if a.adopt_native_result:
|
| 427 |
+
# Commit the independently integrated, already accepted FSI result.
|
| 428 |
+
# This is the native solver endpoint, never a prescribed object pose.
|
| 429 |
+
mujoco.mj_copyData(data,model,corrected)
|
| 430 |
+
else:mujoco.mj_step(model,data)
|
| 431 |
+
mujoco.mj_fwdPosition(model,data)
|
| 432 |
+
if np.max(np.abs(data.qpos-corrected.qpos))>1e-10:raise RuntimeError('Live solid integration differs from corrected native endpoint')
|
| 433 |
+
if any(c.dist<-.0001 for c in data.contact):raise RuntimeError('Solid contact overlap exceeds 0.1 mm')
|
| 434 |
+
sync_current()
|
| 435 |
+
if water.tabletop_geometry_failures(origin):raise RuntimeError('Water/table geometry guard; stationary world-fluid contacts remain unqualified')
|
| 436 |
+
if any(w.number for w in data.warning):raise RuntimeError('Native solid warning')
|
| 437 |
+
if a.world_floor_z is not None:
|
| 438 |
+
moving=(model.body_weldid[model.geom_bodyid]!=0)&(model.geom_contype!=0)
|
| 439 |
+
if np.any(data.geom_xpos[moving,2]-model.geom_rbound[moving]<=a.world_floor_z):raise RuntimeError('Native solid approached the liquid-only ground plane; native ground collision must be modeled before continuing')
|
| 440 |
+
vertices=data.flexvert_xpos[cavity.start:cavity.start+integrity.total_vertices]
|
| 441 |
+
jac=np.linalg.det(vertices[integrity.tetrahedra[:,1:]]-vertices[integrity.tetrahedra[:,0,None]])/integrity.reference_det
|
| 442 |
+
if jac.min()<.5:raise RuntimeError('FEM material guard')
|
| 443 |
+
if water.port_flux is not None and not a.substep_port_flux:
|
| 444 |
+
water.port_flux.advance(checkpoint[0],water.x,tip_before,rotation_before,
|
| 445 |
+
data.body('Dropper').xpos-origin,data.body('Dropper').xmat.reshape(3,3))
|
| 446 |
+
if frame%33==0:
|
| 447 |
+
geometry=integrity.check();row={'time':float(data.time),'stage':policy.stage if active_transfer else 'aspirate' if alpha>0 else 'immerse',
|
| 448 |
+
'bore_water_ml':water.bore_volume()*1e6,'bulb_volume_ml':cavity.volume()*1e6,'gas_pressure_pa':pressure_sum/dt,
|
| 449 |
+
'tube_water_ml':tube_inventory.volume()*1e6,
|
| 450 |
+
'velocity_max':water.maximum_speed(),'left_force_limit_n':limit,'left_grip_target_m':robots[0].grip,'port_color':color,**geometry}
|
| 451 |
+
if grasp_geometry:row['independent_fem_jaw_overlap_m']=grasp_geometry.check(data)
|
| 452 |
+
row.update(coupling_iterations=coupling+1,solid_endpoint_error_m=endpoint_error,
|
| 453 |
+
gas_volume_endpoint_error_m3=volume_endpoint_error,actual_endpoint_cad_failures=geometry_failures)
|
| 454 |
+
row.update(liquid)
|
| 455 |
+
if water.port_flux is not None:row.update(water.port_flux.summary())
|
| 456 |
+
row.update(left_joint_target_rad=robots[0].target.tolist(),
|
| 457 |
+
left_tcp_world_m=data.site('left_tcp').xpos.tolist(),
|
| 458 |
+
dropper_world_m=data.body('Dropper').xpos.tolist(),
|
| 459 |
+
aspiration_arm_hold=policy.aspiration_goal_set,dispense_feedback=policy.dispense_feedback)
|
| 460 |
+
if support:row['native_grasp_normal_forces_n']=policy.contact_support
|
| 461 |
+
if support and policy.stage in ['home','settle']:
|
| 462 |
+
from dropperlab.seating_measurement import measured_seats
|
| 463 |
+
row.update(measured_seats(model,support.state_view(),robots))
|
| 464 |
+
rows.append(row);states.append(data.qpos.copy());report['last_state']=row;report['wall_seconds']=time.perf_counter()-started
|
| 465 |
+
if data.time-recorder.last>=a.record_water_interval-1e-10:
|
| 466 |
+
recorder.capture(data,water.positions_numpy()+origin,water_velocity=water.velocities_numpy())
|
| 467 |
+
save_checkpoint(out/'accepted_checkpoint.npz',a.source/'solid/model.mjb',model,data,water,robots,cavity,policy,previous,(sealed,sealed_at,last_plan),checkpoint_parameters)
|
| 468 |
+
(out/'progress.json').write_text(json.dumps(report,indent=2));print(json.dumps(row),flush=True)
|
| 469 |
+
if policy.done:break
|
| 470 |
+
if a.stop_request and a.stop_request.exists():controlled_stop=True;break
|
| 471 |
+
if a.recover_solid_dt>0 and data.time>=next_step_recovery and coupling<4:
|
| 472 |
+
model.opt.timestep=min(a.recover_solid_dt,2*model.opt.timestep)
|
| 473 |
+
next_step_recovery=float(data.time)+.020
|
| 474 |
+
frame+=1
|
| 475 |
+
report['status']='completed'
|
| 476 |
+
report['execution_complete']=policy.done
|
| 477 |
+
if not policy.done:report.update(status='incomplete',error='Controlled stop at an accepted coupled boundary' if controlled_stop else 'Physical time limit reached before the full sequence completed')
|
| 478 |
+
recorder.capture(data,water.positions_numpy()+origin,force=True,water_velocity=water.velocities_numpy())
|
| 479 |
+
save_checkpoint(out/'accepted_checkpoint.npz',a.source/'solid/model.mjb',model,data,water,robots,cavity,policy,previous,(sealed,sealed_at,last_plan),checkpoint_parameters)
|
| 480 |
+
except Exception as e:
|
| 481 |
+
report.update(status='failed',error=str(e));print(str(e),flush=True)
|
| 482 |
+
if 'swept water path' in str(e) and getattr(water,'swept_water_audit',None) is not None:
|
| 483 |
+
report['swept_failure_detail']=water.swept_water_audit.describe_failure()
|
| 484 |
+
# An exception may occur after several liquid substeps in an unaccepted
|
| 485 |
+
# solid interval. Persist final arrays only after rejecting that interval.
|
| 486 |
+
if 'checkpoint' in locals():
|
| 487 |
+
water.reject_candidate_interval(checkpoint)
|
| 488 |
+
if flux_snapshot is not None:water.port_flux.reject(flux_snapshot)
|
| 489 |
+
start.reject(model,data,robots,cavity,policy);sealed,sealed_at,last_plan=initial_logic
|
| 490 |
+
previous=previous_before
|
| 491 |
+
report['failed_interval_rolled_back']=True
|
| 492 |
+
sync_current()
|
| 493 |
+
positions=np.array([data.body(name).xpos-origin for name in names])
|
| 494 |
+
rotations=np.array([data.body(name).xmat.reshape(3,3) for name in names])
|
| 495 |
+
failures=water.actual_geometry_failures(positions,rotations)
|
| 496 |
+
report['rollback_state_cad_failures']=failures
|
| 497 |
+
if not failures:
|
| 498 |
+
save_checkpoint(out/'accepted_checkpoint.npz',a.source/'solid/model.mjb',model,data,water,robots,cavity,policy,previous,(sealed,sealed_at,last_plan),checkpoint_parameters)
|
| 499 |
+
report.update(physical_seconds=float(data.time),wall_seconds=time.perf_counter()-started)
|
| 500 |
+
report['phase_events']=policy.events
|
| 501 |
+
if water.port_flux is not None:report.update(water.port_flux.summary())
|
| 502 |
+
(out/'report.json').write_text(json.dumps(report,indent=2));(out/'trajectory.json').write_text(json.dumps(rows,indent=2))
|
| 503 |
+
np.savez_compressed(out/'solid_states.npz',qpos=np.array(states))
|
| 504 |
+
np.savez_compressed(out/'final_water.npz',position=water.positions_numpy()+origin,velocity=water.velocities_numpy(),mass=water.mass)
|
| 505 |
+
print(json.dumps({k:v for k,v in report.items() if k!='last_state'},indent=2))
|