VEHwang's picture
Upload CoCogni4D-Bench (questions, media, scripts, render records, code) (part 7)
7ff74f6 verified
Raw History Blame Contribute Delete
677 Bytes
"""Swept collision checks retain a crossing failure and a clear-path control."""
import unittest
import numpy as np
from embodied_pipeline.gen import avoid
class Walls(unittest.TestCase):
CELL = .025
def test_sweep_catches_crossing_between_safe_ends(self):
ok = np.ones((120, 240), bool)
ok[:80, 118:122] = False
self.assertTrue(ok[int(1/self.CELL), int(2.8/self.CELL)] and ok[int(1/self.CELL), int(3.2/self.CELL)])
self.assertFalse(avoid.sweep_ok(ok, (0., 0.), self.CELL, (2.8, 1.), (3.2, 1.)))
self.assertTrue(avoid.sweep_ok(ok, (0., 0.), self.CELL, (2.8, 2.5), (3.2, 2.5)))
if __name__ == "__main__":
unittest.main()