Beispiel #1
0
    def test_evaluate_collision_with_uas(self):
        """Tests the collision with UAS method."""
        # Create testing data

        (cyl_details, inside_pos,
         outside_pos) = TESTDATA_STATOBST_EVALCOLLISION
        (cyl_lat, cyl_lon, cyl_height, cyl_rad) = cyl_details

        gpos = GpsPosition(latitude=cyl_lat, longitude=cyl_lon)
        gpos.save()

        obst = StationaryObstacle(gps_position=gpos,
                                  cylinder_radius=cyl_rad,
                                  cylinder_height=cyl_height)
        obst.save()

        inside_logs = []
        outside_logs = []
        logs_to_create = [(inside_pos, inside_logs),
                          (outside_pos, outside_logs)]

        for (positions, log_list) in logs_to_create:
            log_list += self.create_uas_logs(self.user, positions)

        # Assert collisions correctly evaluated
        collisions = [(inside_logs, True), (outside_logs, False)]
        for (log_list, inside) in collisions:
            self.assertEqual(obst.evaluate_collision_with_uas(log_list),
                             inside)
            for log in log_list:
                self.assertEqual(obst.evaluate_collision_with_uas([log]),
                                 inside)
Beispiel #2
0
    def test_evaluate_collision_with_uas(self):
        """Tests the collision with UAS method."""
        TESTDATA_STATOBST_EVALCOLLISION = (
            # Cylinder position
            (-76, 38, 100, 100),
            # Inside positions
            [(-76, 38, 50),
             (-76, 38, 0),
             (-76, 38, 100),
             (-76.0001, 38.0001, 0),
             (-76.0001, 38.0001, 100)],
            # Outside positions
            [(-76.001, 38, 50),
             (-76, 38.002, 150),
             (-76, 38, 150),
             (-76, 38, 101)]
        )  # yapf: disable

        (cyl_details, inside_pos,
         outside_pos) = TESTDATA_STATOBST_EVALCOLLISION
        (cyl_lat, cyl_lon, cyl_height, cyl_rad) = cyl_details

        gpos = GpsPosition(latitude=cyl_lat, longitude=cyl_lon)
        gpos.save()

        obst = StationaryObstacle(gps_position=gpos,
                                  cylinder_radius=cyl_rad,
                                  cylinder_height=cyl_height)
        obst.save()

        inside_logs = []
        outside_logs = []
        logs_to_create = [(inside_pos, inside_logs),
                          (outside_pos, outside_logs)]

        for (positions, log_list) in logs_to_create:
            log_list += self.create_uas_logs(self.user, positions)

        # Assert collisions correctly evaluated
        collisions = [(inside_logs, True), (outside_logs, False)]
        for (log_list, inside) in collisions:
            self.assertEqual(obst.evaluate_collision_with_uas(log_list),
                             inside)
            for log in log_list:
                self.assertEqual(obst.evaluate_collision_with_uas([log]),
                                 inside)

        # Regression test past failed case.
        pos = GpsPosition(latitude=45.4342114, longitude=-71.8538153)
        pos.save()
        obst = StationaryObstacle(gps_position=pos,
                                  cylinder_radius=10.0,
                                  cylinder_height=1300.0)
        logs = self.create_uas_logs(self.user, [
            (45.433839, -71.8523434, 770.013137988),
            (45.4338393, -71.8523446, 769.881926415),
        ])
        self.assertFalse(obst.evaluate_collision_with_uas(logs))
    def test_evaluate_collision_with_uas(self):
        """Tests the collision with UAS method."""
        # Create testing data
        user = User.objects.create_user('testuser', '*****@*****.**',
                                        'testpass')
        user.save()

        (cyl_details, inside_pos,
         outside_pos) = TESTDATA_STATOBST_EVALCOLLISION
        (cyl_lat, cyl_lon, cyl_height, cyl_rad) = cyl_details

        gpos = GpsPosition(latitude=cyl_lat, longitude=cyl_lon)
        gpos.save()

        obst = StationaryObstacle(gps_position=gpos,
                                  cylinder_radius=cyl_rad,
                                  cylinder_height=cyl_height)
        obst.save()

        inside_logs = []
        outside_logs = []
        logs_to_create = [
            (inside_pos, inside_logs), (outside_pos, outside_logs)
        ]

        for (positions, log_list) in logs_to_create:
            for (lat, lon, alt) in positions:
                gpos = GpsPosition(latitude=lat, longitude=lon)
                gpos.save()
                apos = AerialPosition(gps_position=gpos, altitude_msl=alt)
                apos.save()
                log = UasTelemetry(user=user, uas_position=apos, uas_heading=0)
                log.save()
                log_list.append(log)
        # Assert collisions correctly evaluated
        collisions = [(inside_logs, True), (outside_logs, False)]
        for (log_list, inside) in collisions:
            self.assertEqual(
                obst.evaluate_collision_with_uas(log_list), inside)
            for log in log_list:
                self.assertEqual(
                    obst.evaluate_collision_with_uas([log]), inside)