Files
RC2027_BR_code/sim_ws/tools/repair_ramp_winding.py
T
Kevin 664eaa81e5 feat(sim): integrate Gazebo Classic with Point-LIO and SCAN navigation
Import the complete field and a simplified omnidirectional robot in sim_ws.
Reuse original Point-LIO, SCAN and controller implementations with isolated
simulation profiles, timed MID360/IMU data, readiness and command guards.
Support known-corridor terrain paths, optional sensor stress profiles and
separate physics/algorithm launch processes.

Remove retired Fortress resources and operating instructions; add build,
usage, scope and durable validation documentation.

Validation: full build script; 8 adapter tests and 4 SCAN CTest targets;
8 continuous mild-noise routes; red/blue terrain 4 cases each; noise 9/9;
visibility characterization 9/9; default sensors 16/16; loss-stop and
post-build straight navigation. Real wheels/network remain unverified.
2026-11-08 19:04:32 +08:00

57 lines
2.4 KiB
Python

#!/usr/bin/python3
"""Reproduce the pinned upstream ramp face-winding correction, without moving vertices."""
import argparse
import hashlib
import json
from pathlib import Path
UPSTREAM_SHA256 = '5344932eae23391872e371758bbe9a70a6b5b9979fa53d3862b3183bee331f13'
def corrected_bytes(source):
if hashlib.sha256(source).hexdigest() != UPSTREAM_SHA256:
raise ValueError('Unknown upstream ramp: review geometry before applying this repair')
lines=source.decode().splitlines(keepends=True)
return ''.join('f '+' '.join(reversed(l.split()[1:]))+'\n' if l.startswith('f ') else l
for l in lines).encode()
def geometry(data):
lines=data.decode().splitlines()
vertices=[tuple(map(float,l.split()[1:])) for l in lines if l.startswith('v ')]
faces=[tuple(int(v)-1 for v in l.split()[1:]) for l in lines if l.startswith('f ')]
volume=0.
for f in faces:
a,b,c=[vertices[i] for i in f]
volume+=(a[0]*(b[1]*c[2]-b[2]*c[1])+a[1]*(b[2]*c[0]-b[0]*c[2])+a[2]*(b[0]*c[1]-b[1]*c[0]))/6
edges={}
for f in faces:
for a,b in zip(f,f[1:]+f[:1]):edges[(a,b)]=edges.get((a,b),0)+1
closed=all(count==1 and edges.get((b,a))==1 for (a,b),count in edges.items())
return vertices,faces,volume,closed
def verify(source,target):
sv,sf,volume_in,closed_in=geometry(source)
tv,tf,volume_out,closed_out=geometry(target)
return dict(upstream_sha256=hashlib.sha256(source).hexdigest(),
repaired_sha256=hashlib.sha256(target).hexdigest(),
exact_pinned_repair=target==corrected_bytes(source),
vertices_unchanged=sv==tv,
all_faces_reversed=tf==[tuple(reversed(f)) for f in sf],
closed_before=closed_in,closed_after=closed_out,
signed_volume_before_m3=volume_in,signed_volume_after_m3=volume_out)
def main():
ap=argparse.ArgumentParser();ap.add_argument('source');ap.add_argument('--output',required=True)
args=ap.parse_args();source=Path(args.source).read_bytes();target=corrected_bytes(source)
evidence=verify(source,target)
assert all(evidence[k] for k in ('exact_pinned_repair','vertices_unchanged','all_faces_reversed','closed_before','closed_after'))
assert evidence['signed_volume_before_m3']<0<evidence['signed_volume_after_m3']
Path(args.output).write_bytes(target)
print(json.dumps(evidence,indent=2))
if __name__=='__main__':main()