Preserve installed operator workspace before consolidation
Local preservation snapshot, not a new deployment or simulation acceptance.
This commit is contained in:
@@ -0,0 +1,121 @@
|
||||
"""Worker-only check of forward/recovery permission transitions in real ROS nodes."""
|
||||
|
||||
import argparse
|
||||
import datetime as dt
|
||||
import http.client
|
||||
import json
|
||||
import subprocess
|
||||
import time
|
||||
from pathlib import Path
|
||||
from uuid import uuid4
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("--adapter", type=Path, required=True)
|
||||
parser.add_argument("--image", required=True)
|
||||
parser.add_argument("--output", type=Path, required=True)
|
||||
args = parser.parse_args()
|
||||
container = "ndc-mission-core-direction-check-" + uuid4().hex[:8]
|
||||
report = dict(
|
||||
utc=dt.datetime.now(dt.timezone.utc).isoformat(), # noqa: UP017
|
||||
monotonic=time.monotonic(),
|
||||
image=args.image,
|
||||
cases=[],
|
||||
)
|
||||
connection = http.client.HTTPConnection("127.0.0.1", 18193, timeout=3)
|
||||
|
||||
def request(path, body=None):
|
||||
connection.request(
|
||||
"GET" if body is None else "POST", path, body=None if body is None else json.dumps(body)
|
||||
)
|
||||
response = connection.getresponse()
|
||||
value = json.loads(response.read())
|
||||
if response.status != 200:
|
||||
raise RuntimeError(str(value))
|
||||
return value
|
||||
|
||||
try:
|
||||
subprocess.run(
|
||||
[
|
||||
"docker",
|
||||
"run",
|
||||
"-d",
|
||||
"--name",
|
||||
container,
|
||||
"--cpus",
|
||||
"3",
|
||||
"--memory",
|
||||
"2g",
|
||||
"--label",
|
||||
"com.nodedc.product=mission-core",
|
||||
"--label",
|
||||
"com.nodedc.stack=ai-polygon-qualification",
|
||||
"--label",
|
||||
"com.nodedc.role=qualification",
|
||||
"--label",
|
||||
"com.nodedc.managed-by=ai-polygon-qualification",
|
||||
"-p",
|
||||
"127.0.0.1:18193:8010",
|
||||
"--mount",
|
||||
f"type=bind,source={args.adapter},target=/adapter,readonly",
|
||||
args.image,
|
||||
],
|
||||
check=True,
|
||||
capture_output=True,
|
||||
)
|
||||
deadline = time.monotonic() + 20
|
||||
while True:
|
||||
try:
|
||||
request("/ready")
|
||||
break
|
||||
except (OSError, RuntimeError, http.client.HTTPException):
|
||||
if time.monotonic() > deadline:
|
||||
raise
|
||||
time.sleep(0.2)
|
||||
floor = [[x / 10, y / 10, 0] for x in range(-25, 41) for y in range(-25, 26)]
|
||||
# Do not reset between directions: revoking recovery must also clear
|
||||
# the follower's latched navFwd state and require a fresh path.
|
||||
for name, reverse, goal in (
|
||||
("forward", False, [3, 0, 0]),
|
||||
("recovery", True, [-0.65, 0, 0]),
|
||||
("forward-near-left", False, [0.15, 0.55, 0]),
|
||||
("recovery-again", True, [-0.65, 0, 0]),
|
||||
("forward-restored", False, [3, 0, 0]),
|
||||
):
|
||||
samples = []
|
||||
for _ in range(16):
|
||||
samples.append(
|
||||
request(
|
||||
"/plan",
|
||||
dict(
|
||||
points=floor,
|
||||
pose=[0, 0, 0.37, 0, 0, 0, 1],
|
||||
goal=goal,
|
||||
allow_reverse=reverse,
|
||||
max_speed_mps=0.15,
|
||||
),
|
||||
)
|
||||
)
|
||||
time.sleep(0.1)
|
||||
tail = samples[-5:]
|
||||
if reverse:
|
||||
passed = all(s["speed_mps"] < -0.05 for s in tail)
|
||||
elif name == "forward-near-left":
|
||||
passed = all(s["yaw_rate_rps"] > 0.1 and s["speed_mps"] >= 0 for s in tail)
|
||||
else:
|
||||
passed = all(s["speed_mps"] > 0.05 for s in tail)
|
||||
report["cases"].append(dict(name=name, passed=passed, samples=samples))
|
||||
report["passed"] = all(c["passed"] for c in report["cases"])
|
||||
finally:
|
||||
connection.close()
|
||||
# The local case name must never replace the owned container name.
|
||||
subprocess.run(["docker", "rm", "-f", container], capture_output=True)
|
||||
args.output.write_text(json.dumps(report, indent=2))
|
||||
print(json.dumps({"passed": report["passed"], "cases": len(report["cases"])}))
|
||||
if not report["passed"]:
|
||||
raise SystemExit(1)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user