Datasets:
Download code/exhibition_dataset/kernel_geometry.py from Heiheihaha17/MESH-Benchmark: direct link, hf CLI and curl.
- Browser
- Download file 1.85 kB
-
https://huggingface.co/datasets/Heiheihaha17/MESH-Benchmark/resolve/main/code/exhibition_dataset/kernel_geometry.py
- Command line
-
hf download hf://datasets/Heiheihaha17/MESH-Benchmark/code/exhibition_dataset/kernel_geometry.py
-
curl -L -o kernel_geometry.py https://huggingface.co/datasets/Heiheihaha17/MESH-Benchmark/resolve/main/code/exhibition_dataset/kernel_geometry.py
1.85 kB
| """Keep native two-time source/receiver combinations outside the near singularity. | |
| This is distinct from same-time body collision checking. The frozen RIR | |
| approximation evaluates emission and reception positions at different knots. | |
| Only combinations needed by the finite convolution horizon are inspected. | |
| """ | |
| from __future__ import annotations | |
| import numpy as np | |
| from .common import SR,position,rir_nodes | |
| def minimum_kernel_separation(episode,ir_time_s=2.5): | |
| minimum=float('inf') | |
| detail=None | |
| for source in episode['humans']+episode['playback_sources']: | |
| sn=rir_nodes(source) | |
| for i,te in enumerate(sn): | |
| support_lo=sn[i-1] if i else 0. | |
| support_hi=sn[i+1] if i+1<len(sn) else episode['duration_samples']/SR | |
| spans=[(max(support_lo,e['start_sample']/SR),min(support_hi,e['end_sample']/SR)) for e in source['events']] | |
| spans=[(a,b) for a,b in spans if b>a] | |
| if not spans: | |
| continue | |
| for receiver in episode['robots']: | |
| if source['entity_id']==receiver['entity_id']: | |
| continue | |
| rn=rir_nodes(receiver) | |
| for j,tr in enumerate(rn): | |
| left=rn[j-1] if j else 0. | |
| right=rn[j+1] if j+1<len(rn) else episode['duration_samples']/SR | |
| if not any(right>a and left<b+ir_time_s+.001 for a,b in spans): | |
| continue | |
| distance=float(np.linalg.norm(position(source,te)-position(receiver,tr))) | |
| if distance<minimum: | |
| minimum=distance | |
| detail=dict(source_id=source['entity_id'],receiver_id=receiver['entity_id'], | |
| emission_knot_s=te,reception_knot_s=tr,distance_m=distance) | |
| return minimum,detail | |