openphysgraspgen 1.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- openphysgraspgen/__init__.py +64 -0
- openphysgraspgen/__main__.py +5 -0
- openphysgraspgen/benchmark/__init__.py +25 -0
- openphysgraspgen/benchmark/cli.py +85 -0
- openphysgraspgen/benchmark/pg_t1.py +1448 -0
- openphysgraspgen/benchmark/pg_t1_report.py +571 -0
- openphysgraspgen/confidence.py +42 -0
- openphysgraspgen/constitutive.py +292 -0
- openphysgraspgen/dataset/__init__.py +45 -0
- openphysgraspgen/dataset/check_criteria.yaml +53 -0
- openphysgraspgen/dataset/check_dataset.py +4790 -0
- openphysgraspgen/dataset/finalize.py +394 -0
- openphysgraspgen/dataset/reader.py +118 -0
- openphysgraspgen/dataset/video.py +306 -0
- openphysgraspgen/dataset/writer.py +936 -0
- openphysgraspgen/estimation.py +58 -0
- openphysgraspgen/formulations.py +89 -0
- openphysgraspgen/generation.py +115 -0
- openphysgraspgen/pipeline.py +130 -0
- openphysgraspgen/py.typed +0 -0
- openphysgraspgen/records.py +132 -0
- openphysgraspgen/sensors/__init__.py +13 -0
- openphysgraspgen/sensors/deformable_contact_sensor.py +21 -0
- openphysgraspgen/sensors/force_label.py +126 -0
- openphysgraspgen/sensors/frame.py +21 -0
- openphysgraspgen/sensors/layers/__init__.py +6 -0
- openphysgraspgen/sensors/layers/base.py +14 -0
- openphysgraspgen/sensors/layers/force.py +20 -0
- openphysgraspgen/sensors/recorder.py +20 -0
- openphysgraspgen-1.0.0.dist-info/METADATA +224 -0
- openphysgraspgen-1.0.0.dist-info/RECORD +36 -0
- openphysgraspgen-1.0.0.dist-info/WHEEL +5 -0
- openphysgraspgen-1.0.0.dist-info/entry_points.txt +2 -0
- openphysgraspgen-1.0.0.dist-info/licenses/LICENSE +201 -0
- openphysgraspgen-1.0.0.dist-info/licenses/NOTICE +9 -0
- openphysgraspgen-1.0.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: Copyright (c) 2026 SpaceAI
|
|
2
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import importlib.metadata
|
|
4
|
+
|
|
5
|
+
__version__ = importlib.metadata.version("openphysgraspgen")
|
|
6
|
+
|
|
7
|
+
from .constitutive import (
|
|
8
|
+
LABEL_LAWS,
|
|
9
|
+
MooneyRivlinParams,
|
|
10
|
+
OgdenParams,
|
|
11
|
+
YeohParams,
|
|
12
|
+
cauchy_stress,
|
|
13
|
+
strain_energy_density,
|
|
14
|
+
von_mises_stress,
|
|
15
|
+
)
|
|
16
|
+
from .estimation import LinearJointEstimator
|
|
17
|
+
from .generation import build_training_data, calibrate_material, transfer_parameter
|
|
18
|
+
from .records import (
|
|
19
|
+
MaterialPair,
|
|
20
|
+
MeasuredObjectData,
|
|
21
|
+
ProbeScene,
|
|
22
|
+
RobotObservation,
|
|
23
|
+
SafetyDecision,
|
|
24
|
+
StateEstimate,
|
|
25
|
+
TrainingSample,
|
|
26
|
+
)
|
|
27
|
+
from .sensors import DeformableContactSensor, ForceLabel, SensorRecorder, SimFrame
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def run_pipeline(
|
|
31
|
+
fracture_threshold: float = 0.25,
|
|
32
|
+
confidence_threshold: float = 0.5,
|
|
33
|
+
) -> dict[str, object]:
|
|
34
|
+
from .pipeline import run_pipeline as execute
|
|
35
|
+
|
|
36
|
+
return execute(fracture_threshold, confidence_threshold)
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
__all__ = [
|
|
40
|
+
"LABEL_LAWS",
|
|
41
|
+
"DeformableContactSensor",
|
|
42
|
+
"ForceLabel",
|
|
43
|
+
"LinearJointEstimator",
|
|
44
|
+
"MaterialPair",
|
|
45
|
+
"MeasuredObjectData",
|
|
46
|
+
"MooneyRivlinParams",
|
|
47
|
+
"OgdenParams",
|
|
48
|
+
"ProbeScene",
|
|
49
|
+
"RobotObservation",
|
|
50
|
+
"SafetyDecision",
|
|
51
|
+
"SensorRecorder",
|
|
52
|
+
"SimFrame",
|
|
53
|
+
"StateEstimate",
|
|
54
|
+
"TrainingSample",
|
|
55
|
+
"YeohParams",
|
|
56
|
+
"__version__",
|
|
57
|
+
"build_training_data",
|
|
58
|
+
"calibrate_material",
|
|
59
|
+
"cauchy_stress",
|
|
60
|
+
"run_pipeline",
|
|
61
|
+
"strain_energy_density",
|
|
62
|
+
"transfer_parameter",
|
|
63
|
+
"von_mises_stress",
|
|
64
|
+
]
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: Copyright (c) 2026 SpaceAI
|
|
2
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
"""Benchmarks scored from the public dataset alone, on a CPU.
|
|
4
|
+
|
|
5
|
+
Scoring a dataset needs ``pip install "openphysgraspgen[dataset]"``. PG-T1 is documented
|
|
6
|
+
in ``docs/benchmark/pg-t1.md``.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from .pg_t1 import Refused, score_episode, task_block_problems
|
|
10
|
+
from .pg_t1_report import (
|
|
11
|
+
DatasetUnreadable,
|
|
12
|
+
report_text,
|
|
13
|
+
score_dataset,
|
|
14
|
+
wilson_interval,
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
__all__ = [
|
|
18
|
+
"DatasetUnreadable",
|
|
19
|
+
"Refused",
|
|
20
|
+
"report_text",
|
|
21
|
+
"score_dataset",
|
|
22
|
+
"score_episode",
|
|
23
|
+
"task_block_problems",
|
|
24
|
+
"wilson_interval",
|
|
25
|
+
]
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: Copyright (c) 2026 SpaceAI
|
|
2
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
"""``openphysgraspgen benchmark``: score a benchmark from a dataset."""
|
|
4
|
+
|
|
5
|
+
from __future__ import annotations
|
|
6
|
+
|
|
7
|
+
import argparse
|
|
8
|
+
import json
|
|
9
|
+
import sys
|
|
10
|
+
from collections.abc import Sequence
|
|
11
|
+
from pathlib import Path
|
|
12
|
+
|
|
13
|
+
EXIT_OK, EXIT_NOT_OK, EXIT_FAILED = 0, 1, 2
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def episodes_path(report: Path) -> Path:
|
|
17
|
+
"""Where the per-episode records go: beside the report, as JSON lines."""
|
|
18
|
+
return report.with_name(f"{report.stem}.episodes.jsonl")
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def main(argv: Sequence[str] | None = None) -> int:
|
|
22
|
+
parser = argparse.ArgumentParser(
|
|
23
|
+
prog="openphysgraspgen benchmark",
|
|
24
|
+
description="Score a benchmark from a dataset in the public format.",
|
|
25
|
+
)
|
|
26
|
+
benchmarks = parser.add_subparsers(
|
|
27
|
+
dest="benchmark", required=True, metavar="BENCHMARK"
|
|
28
|
+
)
|
|
29
|
+
t1 = benchmarks.add_parser(
|
|
30
|
+
"pg-t1",
|
|
31
|
+
help="lifted, held and placed under criteria C and B",
|
|
32
|
+
description="Score PG-T1: lifted, held and placed per episode under criteria C "
|
|
33
|
+
"(5 cm for 2 s) and B (12 cm for 4 s). Prints one table per task and writes "
|
|
34
|
+
"the report as JSON, with one record per episode beside it as JSON lines. "
|
|
35
|
+
"Exits 0 when every listed episode was scored and no check failed, 1 when an "
|
|
36
|
+
"episode was refused or unlisted or a check failed, 2 when the dataset cannot "
|
|
37
|
+
"be read or the report cannot be written.",
|
|
38
|
+
)
|
|
39
|
+
t1.add_argument(
|
|
40
|
+
"dataset", type=Path, help="the dataset's root, which holds metadata.yaml"
|
|
41
|
+
)
|
|
42
|
+
t1.add_argument(
|
|
43
|
+
"--json",
|
|
44
|
+
type=Path,
|
|
45
|
+
default=Path("pg-t1.json"),
|
|
46
|
+
metavar="PATH",
|
|
47
|
+
help="where to write the report (default: pg-t1.json), creating its directory; "
|
|
48
|
+
"the episodes go to PATH with .episodes.jsonl in place of its suffix",
|
|
49
|
+
)
|
|
50
|
+
args = parser.parse_args(argv)
|
|
51
|
+
try:
|
|
52
|
+
from .pg_t1_report import DatasetUnreadable, report_text, score_dataset
|
|
53
|
+
|
|
54
|
+
report, episodes = score_dataset(args.dataset)
|
|
55
|
+
except ModuleNotFoundError as exc:
|
|
56
|
+
if exc.name not in ("pyarrow", "yaml"):
|
|
57
|
+
raise
|
|
58
|
+
print(
|
|
59
|
+
f"openphysgraspgen benchmark needs {exc.name}: "
|
|
60
|
+
'pip install "openphysgraspgen[dataset]"',
|
|
61
|
+
file=sys.stderr,
|
|
62
|
+
)
|
|
63
|
+
return EXIT_FAILED
|
|
64
|
+
except DatasetUnreadable as exc:
|
|
65
|
+
print(f"openphysgraspgen benchmark: {exc}", file=sys.stderr)
|
|
66
|
+
return EXIT_FAILED
|
|
67
|
+
sys.stdout.write(report_text(report))
|
|
68
|
+
lines = episodes_path(args.json)
|
|
69
|
+
try:
|
|
70
|
+
args.json.parent.mkdir(parents=True, exist_ok=True)
|
|
71
|
+
args.json.write_text(
|
|
72
|
+
json.dumps(report, indent=2, allow_nan=False) + "\n", encoding="utf-8"
|
|
73
|
+
)
|
|
74
|
+
lines.write_text(
|
|
75
|
+
"".join(json.dumps(e, allow_nan=False) + "\n" for e in episodes),
|
|
76
|
+
encoding="utf-8",
|
|
77
|
+
)
|
|
78
|
+
except OSError as exc:
|
|
79
|
+
print(
|
|
80
|
+
f"openphysgraspgen benchmark: cannot write the report: {exc}",
|
|
81
|
+
file=sys.stderr,
|
|
82
|
+
)
|
|
83
|
+
return EXIT_FAILED
|
|
84
|
+
print(f"report {args.json}\nepisodes {lines}")
|
|
85
|
+
return EXIT_OK if report["status"] == "ok" else EXIT_NOT_OK
|