def setUp(self): """Populates an active mission to test a cached view.""" pos = GpsPosition() pos.latitude = 10 pos.longitude = 10 pos.save() self.pos = pos obst = StationaryObstacle() obst.gps_position = pos obst.cylinder_radius = 10 obst.cylinder_height = 10 obst.save() self.obst = obst config = MissionConfig() config.is_active = True config.home_pos = pos config.emergent_last_known_pos = pos config.off_axis_target_pos = pos config.sric_pos = pos config.air_drop_pos = pos config.save() self.config = config config.stationary_obstacles.add(obst) config.save() self.login_url = reverse('auvsi_suas:login') self.obst_url = reverse('auvsi_suas:obstacles') self.clear_cache_url = reverse('auvsi_suas:clear_cache')
def test_unicode(self): """Tests the unicode method executes.""" pos = GpsPosition(latitude=100, longitude=200) pos.save() obst = StationaryObstacle(gps_position=pos, cylinder_radius=10, cylinder_height=100) obst.save() self.assertTrue(obst.__unicode__())
def test_unicode(self): """Tests the unicode method executes.""" pos = GpsPosition(latitude=100, longitude=200) pos.save() obst = StationaryObstacle(gps_position=pos, cylinder_radius=10, cylinder_height=100) obst.save() self.assertTrue(obst.__unicode__())
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')
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')
def create_stationary_obstacle(self, lat, lon, radius, height): """Create a new StationaryObstacle model. Args: lat: Latitude of centroid lon: Longitude of centroid radius: Cylinder radius height: Cylinder height Returns: Saved StationaryObstacle """ gps = GpsPosition(latitude=lat, longitude=lon) gps.save() obstacle = StationaryObstacle(gps_position=gps, cylinder_radius=radius, cylinder_height=height) obstacle.save() return obstacle
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)
def create_stationary_obstacle(self, lat, lon, radius, height): """Create a new StationaryObstacle model. Args: lat: Latitude of centroid lon: Longitude of centroid radius: Cylinder radius height: Cylinder height Returns: Saved StationaryObstacle """ gps = GpsPosition(latitude=lat, longitude=lon) gps.save() obstacle = StationaryObstacle(gps_position=gps, cylinder_radius=radius, cylinder_height=height) obstacle.save() return obstacle
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)
def setUp(self): """Populates an active mission to test a cached view.""" pos = GpsPosition() pos.latitude = 10 pos.longitude = 10 pos.save() self.pos = pos info = ServerInfo() info.timestamp = datetime.datetime.now() info.message = "Hello World" info.save() obst = StationaryObstacle() obst.gps_position = pos obst.cylinder_radius = 10 obst.cylinder_height = 10 obst.save() self.obst = obst config = MissionConfig() config.is_active = True config.home_pos = pos config.emergent_last_known_pos = pos config.off_axis_target_pos = pos config.sric_pos = pos config.ir_primary_target_pos = pos config.ir_secondary_target_pos = pos config.air_drop_pos = pos config.server_info = info config.save() self.config = config config.stationary_obstacles.add(obst) config.save() self.login_url = reverse('auvsi_suas:login') self.obst_url = reverse('auvsi_suas:obstacles') self.clear_cache_url = reverse('auvsi_suas:clear_cache')