예제 #1
0
    def create_moving_obstacle(self, waypoints):
        """Create a new MovingObstacle model.

        Args:
            waypoints: List of (lat, lon, alt) tuples

        Returns:
            Saved MovingObstacle
        """
        obstacle = MovingObstacle(speed_avg=40, sphere_radius=100)
        obstacle.save()

        for num, waypoint in enumerate(waypoints):
            (lat, lon, alt) = waypoint

            gps = GpsPosition(latitude=lat, longitude=lon)
            gps.save()

            pos = AerialPosition(gps_position=gps, altitude_msl=alt)
            pos.save()

            waypoint = Waypoint(order=num, position=pos)
            waypoint.save()

            obstacle.waypoints.add(waypoint)

        obstacle.save()
        return obstacle
예제 #2
0
    def create_moving_obstacle(self, waypoints):
        """Create a new MovingObstacle model.

        Args:
            waypoints: List of (lat, lon, alt) tuples

        Returns:
            Saved MovingObstacle
        """
        obstacle = MovingObstacle(speed_avg=40, sphere_radius=100)
        obstacle.save()

        for num, waypoint in enumerate(waypoints):
            (lat, lon, alt) = waypoint

            gps = GpsPosition(latitude=lat, longitude=lon)
            gps.save()

            pos = AerialPosition(gps_position=gps, altitude_msl=alt)
            pos.save()

            waypoint = Waypoint(order=num, position=pos)
            waypoint.save()

            obstacle.waypoints.add(waypoint)

        obstacle.save()
        return obstacle
예제 #3
0
    def setUp(self):
        """Create the obstacles for testing."""
        # Obstacle with no waypoints
        obst_no_wpt = MovingObstacle()
        obst_no_wpt.speed_avg = 1
        obst_no_wpt.sphere_radius = 1
        obst_no_wpt.save()
        self.obst_no_wpt = obst_no_wpt

        # Obstacle with single waypoint
        self.single_wpt_lat = 40
        self.single_wpt_lon = 76
        self.single_wpt_alt = 100
        obst_single_wpt = MovingObstacle()
        obst_single_wpt.speed_avg = 1
        obst_single_wpt.sphere_radius = 1
        obst_single_wpt.save()
        single_gpos = GpsPosition()
        single_gpos.latitude = self.single_wpt_lat
        single_gpos.longitude = self.single_wpt_lon
        single_gpos.save()
        single_apos = AerialPosition()
        single_apos.gps_position = single_gpos
        single_apos.altitude_msl = self.single_wpt_alt
        single_apos.save()
        single_wpt = Waypoint()
        single_wpt.position = single_apos
        single_wpt.name = 'Waypoint'
        single_wpt.order = 1
        single_wpt.save()
        obst_single_wpt.waypoints.add(single_wpt)
        self.obst_single_wpt = obst_single_wpt

        # Obstacles with predefined path
        self.obstacles = list()
        for path in TESTDATA_MOVOBST_PATHS:
            cur_obst = MovingObstacle()
            cur_obst.name = 'MovingObstacle'
            cur_obst.speed_avg = 68
            cur_obst.sphere_radius = 10
            cur_obst.save()
            for pt_id in range(len(path)):
                (lat, lon, alt) = path[pt_id]
                cur_gpos = GpsPosition()
                cur_gpos.latitude = lat
                cur_gpos.longitude = lon
                cur_gpos.save()
                cur_apos = AerialPosition()
                cur_apos.gps_position = cur_gpos
                cur_apos.altitude_msl = alt
                cur_apos.save()
                cur_wpt = Waypoint()
                cur_wpt.position = cur_apos
                cur_wpt.name = 'Waypoint'
                cur_wpt.order = pt_id
                cur_wpt.save()
                cur_obst.waypoints.add(cur_wpt)
            cur_obst.save()
            self.obstacles.append(cur_obst)
예제 #4
0
    def setUp(self):
        """Create the obstacles for testing."""
        # Obstacle with no waypoints
        obst_no_wpt = MovingObstacle()
        obst_no_wpt.speed_avg = 1
        obst_no_wpt.sphere_radius = 1
        obst_no_wpt.save()
        self.obst_no_wpt = obst_no_wpt

        # Obstacle with single waypoint
        self.single_wpt_lat = 40
        self.single_wpt_lon = 76
        self.single_wpt_alt = 100
        obst_single_wpt = MovingObstacle()
        obst_single_wpt.speed_avg = 1
        obst_single_wpt.sphere_radius = 1
        obst_single_wpt.save()
        single_gpos = GpsPosition()
        single_gpos.latitude = self.single_wpt_lat
        single_gpos.longitude = self.single_wpt_lon
        single_gpos.save()
        single_apos = AerialPosition()
        single_apos.gps_position = single_gpos
        single_apos.altitude_msl = self.single_wpt_alt
        single_apos.save()
        single_wpt = Waypoint()
        single_wpt.position = single_apos
        single_wpt.name = 'Waypoint'
        single_wpt.order = 1
        single_wpt.save()
        obst_single_wpt.waypoints.add(single_wpt)
        self.obst_single_wpt = obst_single_wpt

        # Obstacles with predefined path
        self.obstacles = list()
        for path in TESTDATA_MOVOBST_PATHS:
            cur_obst = MovingObstacle()
            cur_obst.name = 'MovingObstacle'
            cur_obst.speed_avg = 68
            cur_obst.sphere_radius = 10
            cur_obst.save()
            for pt_id in range(len(path)):
                (lat, lon, alt) = path[pt_id]
                cur_gpos = GpsPosition()
                cur_gpos.latitude = lat
                cur_gpos.longitude = lon
                cur_gpos.save()
                cur_apos = AerialPosition()
                cur_apos.gps_position = cur_gpos
                cur_apos.altitude_msl = alt
                cur_apos.save()
                cur_wpt = Waypoint()
                cur_wpt.position = cur_apos
                cur_wpt.name = 'Waypoint'
                cur_wpt.order = pt_id
                cur_wpt.save()
                cur_obst.waypoints.add(cur_wpt)
            cur_obst.save()
            self.obstacles.append(cur_obst)
예제 #5
0
 def setUp(self):
     """Sets up the client, obstacle URL, obstacles, and user."""
     # Setup user
     self.user = User.objects.create_user('testuser', '*****@*****.**',
                                          'testpass')
     self.user.save()
     # Setup the obstacles
     for path in TESTDATA_MOVOBST_PATHS:
         # Stationary obstacle
         (stat_lat, stat_lon, _) = path[0]
         stat_gps = GpsPosition()
         stat_gps.latitude = stat_lat
         stat_gps.longitude = stat_lon
         stat_gps.save()
         stat_obst = StationaryObstacle()
         stat_obst.gps_position = stat_gps
         stat_obst.cylinder_radius = 100
         stat_obst.cylinder_height = 200
         stat_obst.save()
         # Moving obstacle
         mov_obst = MovingObstacle()
         mov_obst.speed_avg = 40
         mov_obst.sphere_radius = 100
         mov_obst.save()
         for pt_id in range(len(path)):
             # Obstacle waypoints
             (wpt_lat, wpt_lon, wpt_alt) = path[pt_id]
             gpos = GpsPosition()
             gpos.latitude = wpt_lat
             gpos.longitude = wpt_lon
             gpos.save()
             apos = AerialPosition()
             apos.altitude_msl = wpt_alt
             apos.gps_position = gpos
             apos.save()
             wpt = Waypoint()
             wpt.name = 'test waypoint'
             wpt.order = pt_id
             wpt.position = apos
             wpt.save()
             mov_obst.waypoints.add(wpt)
         mov_obst.save()
     # Setup test objs
     self.client = Client()
     self.loginUrl = reverse('auvsi_suas:login')
     self.obstUrl = reverse('auvsi_suas:obstacles')
예제 #6
0
 def setUp(self):
     """Sets up the client, obstacle URL, obstacles, and user."""
     # Setup user
     self.user = User.objects.create_user(
             'testuser', '*****@*****.**', 'testpass')
     self.user.save()
     # Setup the obstacles
     for path in TESTDATA_MOVOBST_PATHS:
         # Stationary obstacle
         (stat_lat, stat_lon, _) = path[0]
         stat_gps = GpsPosition()
         stat_gps.latitude = stat_lat
         stat_gps.longitude = stat_lon
         stat_gps.save()
         stat_obst = StationaryObstacle()
         stat_obst.gps_position = stat_gps
         stat_obst.cylinder_radius = 100
         stat_obst.cylinder_height = 200
         stat_obst.save()
         # Moving obstacle
         mov_obst = MovingObstacle()
         mov_obst.speed_avg = 40
         mov_obst.sphere_radius = 100
         mov_obst.save()
         for pt_id  in range(len(path)):
             # Obstacle waypoints
             (wpt_lat, wpt_lon, wpt_alt) = path[pt_id]
             gpos = GpsPosition()
             gpos.latitude = wpt_lat
             gpos.longitude = wpt_lon
             gpos.save()
             apos = AerialPosition()
             apos.altitude_msl = wpt_alt
             apos.gps_position = gpos
             apos.save()
             wpt = Waypoint()
             wpt.name = 'test waypoint'
             wpt.order = pt_id
             wpt.position = apos
             wpt.save()
             mov_obst.waypoints.add(wpt)
         mov_obst.save()
     # Setup test objs
     self.client = Client()
     self.loginUrl = reverse('auvsi_suas:login')
     self.obstUrl = reverse('auvsi_suas:obstacles')
예제 #7
0
 def test_unicode(self):
     """Tests the unicode method executes."""
     obst = MovingObstacle()
     obst.speed_avg = 10
     obst.sphere_radius = 100
     obst.save()
     for _ in range(3):
         pos = GpsPosition()
         pos.latitude = 10
         pos.longitude = 100
         pos.save()
         apos = AerialPosition()
         apos.altitude_msl = 1000
         apos.gps_position = pos
         apos.save()
         wpt = Waypoint()
         wpt.position = apos
         wpt.order = 10
         wpt.save()
         obst.waypoints.add(wpt)
     self.assertTrue(obst.__unicode__())
예제 #8
0
 def test_unicode(self):
     """Tests the unicode method executes."""
     obst = MovingObstacle()
     obst.speed_avg = 10
     obst.sphere_radius = 100
     obst.save()
     for _ in range(3):
         pos = GpsPosition()
         pos.latitude = 10
         pos.longitude = 100
         pos.save()
         apos = AerialPosition()
         apos.altitude_msl = 1000
         apos.gps_position = pos
         apos.save()
         wpt = Waypoint()
         wpt.position = apos
         wpt.order = 10
         wpt.save()
         obst.waypoints.add(wpt)
     self.assertTrue(obst.__unicode__())
예제 #9
0
    def test_evaluate_collision_with_uas(self):
        """Tests the collision with UAS method."""
        # Get test data
        user = User.objects.create_user('testuser', '*****@*****.**',
                                        'testpass')
        user.save()
        testdata = TESTDATA_MOVOBST_EVALCOLLISION
        (obst_rad, obst_speed, obst_pos, log_details) = testdata
        # Create the obstacle
        obst = MovingObstacle()
        obst.speed_avg = obst_speed
        obst.sphere_radius = obst_rad
        obst.save()
        for pos_id in xrange(len(obst_pos)):
            (lat, lon, alt) = obst_pos[pos_id]
            gpos = GpsPosition()
            gpos.latitude = lat
            gpos.longitude = lon
            gpos.save()
            apos = AerialPosition()
            apos.gps_position = gpos
            apos.altitude_msl = alt
            apos.save()
            wpt = Waypoint()
            wpt.order = pos_id
            wpt.position = apos
            wpt.save()
            obst.waypoints.add(wpt)
        obst.save()
        # Create sets of logs
        epoch = timezone.now().replace(year=1970,
                                       month=1,
                                       day=1,
                                       hour=0,
                                       minute=0,
                                       second=0,
                                       microsecond=0)
        inside_logs = []
        outside_logs = []
        for (time_sec, inside_pos, outside_pos) in log_details:
            log_time = epoch + datetime.timedelta(seconds=time_sec)
            logs_pos = [(inside_pos, inside_logs), (outside_pos, outside_logs)]
            for (positions, log_list) in logs_pos:
                for (lat, lon, alt) in positions:
                    gpos = GpsPosition()
                    gpos.latitude = lat
                    gpos.longitude = lon
                    gpos.save()
                    apos = AerialPosition()
                    apos.gps_position = gpos
                    apos.altitude_msl = alt
                    apos.save()
                    log = UasTelemetry()
                    log.user = user
                    log.uas_position = apos
                    log.uas_heading = 0
                    log.save()
                    log.timestamp = log_time
                    log.save()
                    log_list.append(log)

        # Assert the obstacle correctly computes collisions
        log_collisions = [(True, inside_logs), (False, outside_logs)]
        for (inside, logs) in log_collisions:
            self.assertEqual(obst.evaluate_collision_with_uas(logs), inside)
            for log in logs:
                self.assertEqual(obst.evaluate_collision_with_uas([log]),
                                 inside)
예제 #10
0
    def test_evaluate_collision_with_uas(self):
        """Tests the collision with UAS method."""
        # Get test data
        user = User.objects.create_user('testuser', '*****@*****.**',
                                        'testpass')
        user.save()
        testdata = TESTDATA_MOVOBST_EVALCOLLISION
        (obst_rad, obst_speed, obst_pos, log_details) = testdata
        # Create the obstacle
        obst = MovingObstacle()
        obst.speed_avg = obst_speed
        obst.sphere_radius = obst_rad
        obst.save()
        for pos_id in xrange(len(obst_pos)):
            (lat, lon, alt) = obst_pos[pos_id]
            gpos = GpsPosition()
            gpos.latitude = lat
            gpos.longitude = lon
            gpos.save()
            apos = AerialPosition()
            apos.gps_position = gpos
            apos.altitude_msl = alt
            apos.save()
            wpt = Waypoint()
            wpt.order = pos_id
            wpt.position = apos
            wpt.save()
            obst.waypoints.add(wpt)
        obst.save()
        # Create sets of logs
        epoch = timezone.now().replace(year=1970,
                                       month=1,
                                       day=1,
                                       hour=0,
                                       minute=0,
                                       second=0,
                                       microsecond=0)
        inside_logs = []
        outside_logs = []
        for (time_sec, inside_pos, outside_pos) in log_details:
            log_time = epoch + datetime.timedelta(seconds=time_sec)
            logs_pos = [(inside_pos, inside_logs), (outside_pos, outside_logs)]
            for (positions, log_list) in logs_pos:
                for (lat, lon, alt) in positions:
                    gpos = GpsPosition()
                    gpos.latitude = lat
                    gpos.longitude = lon
                    gpos.save()
                    apos = AerialPosition()
                    apos.gps_position = gpos
                    apos.altitude_msl = alt
                    apos.save()
                    log = UasTelemetry()
                    log.user = user
                    log.uas_position = apos
                    log.uas_heading = 0
                    log.save()
                    log.timestamp = log_time
                    log.save()
                    log_list.append(log)

        # Assert the obstacle correctly computes collisions
        log_collisions = [(True, inside_logs), (False, outside_logs)]
        for (inside, logs) in log_collisions:
            self.assertEqual(obst.evaluate_collision_with_uas(logs), inside)
            for log in logs:
                self.assertEqual(obst.evaluate_collision_with_uas([log]),
                                 inside)