def setUp(self): self.user = User.objects.create_user('testuser', '*****@*****.**', 'testpass') self.user.save() self.client.force_login(self.user) # Create an active mission. pos = GpsPosition() pos.latitude = 10 pos.longitude = 10 pos.save() config = MissionConfig() config.is_active = True config.home_pos = pos config.emergent_last_known_pos = pos config.off_axis_odlc_pos = pos config.air_drop_pos = pos config.save() # Add a couple of stationary obstacles obst = self.create_stationary_obstacle(lat=38.142233, lon=-76.434082, radius=300, height=500) config.stationary_obstacles.add(obst) obst = self.create_stationary_obstacle(lat=38.442233, lon=-76.834082, radius=100, height=750) config.stationary_obstacles.add(obst) config.save()
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.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 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_odlc_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 setUp(self): self.user = User.objects.create_user('testuser', '*****@*****.**', 'testpass') self.user.save() # Create an active mission. pos = GpsPosition() pos.latitude = 10 pos.longitude = 10 pos.save() config = MissionConfig() config.is_active = True config.home_pos = pos config.emergent_last_known_pos = pos config.off_axis_target_pos = pos config.air_drop_pos = pos config.save() # Add a couple of stationary obstacles obst = self.create_stationary_obstacle(lat=38.142233, lon=-76.434082, radius=300, height=500) config.stationary_obstacles.add(obst) obst = self.create_stationary_obstacle(lat=38.442233, lon=-76.834082, radius=100, height=750) config.stationary_obstacles.add(obst) # And a couple of moving obstacles obst = self.create_moving_obstacle([ # (lat, lon, alt) (38.142233, -76.434082, 300), (38.141878, -76.425198, 700), ]) config.moving_obstacles.add(obst) obst = self.create_moving_obstacle([ # (lat, lon, alt) (38.145405, -76.428310, 100), (38.146582, -76.424099, 200), (38.144662, -76.427634, 300), (38.147729, -76.419185, 200), (38.147573, -76.420832, 100), (38.148522, -76.419507, 750), ]) config.moving_obstacles.add(obst) config.save() # Login response = self.client.post(login_url, { 'username': '******', 'password': '******' }) self.assertEqual(200, response.status_code)
def create_config(self): """Creates a dummy config for testing.""" pos = GpsPosition() pos.latitude = 10 pos.longitude = 10 pos.save() config = MissionConfig() config.is_active = False config.home_pos = pos config.emergent_last_known_pos = pos config.off_axis_odlc_pos = pos config.air_drop_pos = pos return config
def create_config(self): """Creates a dummy config for testing.""" pos = GpsPosition() pos.latitude = 10 pos.longitude = 10 pos.save() config = MissionConfig() config.is_active = False config.home_pos = pos config.emergent_last_known_pos = pos config.off_axis_target_pos = pos config.air_drop_pos = pos return config
def setUp(self): """Setup a single mission to test live kml with.""" super(TestGenerateLiveKMLNoFixture, self).setUp() pos = GpsPosition() pos.latitude = 10 pos.longitude = 10 pos.save() config = MissionConfig() config.home_pos = pos config.emergent_last_known_pos = pos config.off_axis_odlc_pos = pos config.air_drop_pos = pos config.save() self.config = config
def setUp(self): """Setup a single active mission to test live kml with.""" super(TestGenerateLiveKMLNoFixture, self).setUp() pos = GpsPosition() pos.latitude = 10 pos.longitude = 10 pos.save() config = MissionConfig() config.is_active = True config.home_pos = pos config.emergent_last_known_pos = pos config.off_axis_target_pos = pos config.air_drop_pos = pos config.save() self.config = config
def setUp(self): pos = GpsPosition() pos.latitude = 10 pos.longitude = 100 pos.save() wpt = Waypoint() wpt.order = 10 wpt.latitude = 10 wpt.longitude = 100 wpt.altitude_msl = 1000 wpt.save() config = MissionConfig() config.home_pos = pos config.lost_comms_pos = pos config.emergent_last_known_pos = pos config.off_axis_odlc_pos = pos config.map_center_pos = pos config.map_height_ft = 1 config.air_drop_pos = pos config.ugv_drive_pos = pos config.save() config.mission_waypoints.add(wpt) config.search_grid_points.add(wpt) config.save() user = User.objects.create_user('user', '*****@*****.**', 'pass') self.feedback = MissionJudgeFeedback( mission=config, user=user, flight_time=datetime.timedelta(seconds=1), post_process_time=datetime.timedelta(seconds=2), used_timeout=True, min_auto_flight_time=True, safety_pilot_takeovers=3, out_of_bounds=6, unsafe_out_of_bounds=7, things_fell_off_uas=False, crashed=False, air_drop_accuracy=interop_admin_api_pb2.MissionJudgeFeedback. WITHIN_05_FT, ugv_drove_to_location=False, operational_excellence_percent=9) self.feedback.save()
def setUp(self): 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() config = MissionConfig() config.home_pos = pos config.emergent_last_known_pos = pos config.off_axis_odlc_pos = pos config.air_drop_pos = pos config.save() config.mission_waypoints.add(wpt) config.search_grid_points.add(wpt) config.save() user = User.objects.create_user('user', '*****@*****.**', 'pass') self.feedback = MissionJudgeFeedback( mission=config, user=user, flight_time=datetime.timedelta(seconds=1), post_process_time=datetime.timedelta(seconds=2), used_timeout=True, min_auto_flight_time=True, safety_pilot_takeovers=3, waypoints_captured=5, out_of_bounds=6, unsafe_out_of_bounds=7, things_fell_off_uas=False, crashed=False, air_delivery_accuracy_ft=8, operational_excellence_percent=9) self.feedback.save()
def test_unicode(self): """Tests the unicode method executes.""" 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() config = MissionConfig() config.home_pos = pos config.emergent_last_known_pos = pos config.off_axis_target_pos = pos config.air_drop_pos = pos config.save() config.mission_waypoints.add(wpt) config.search_grid_points.add(wpt) config.save() self.assertTrue(config.__unicode__())
def test_satisfied_waypoints(self): """Tests the evaluation of waypoints method.""" # Create mission config gpos = GpsPosition() gpos.latitude = 10 gpos.longitude = 10 gpos.save() config = MissionConfig() config.home_pos = gpos config.emergent_last_known_pos = gpos config.off_axis_target_pos = gpos config.air_drop_pos = gpos config.save() # Create waypoints for config waypoints = [(38, -76, 100), (39, -77, 200), (40, -78, 0)] for i, waypoint in enumerate(waypoints): (lat, lon, alt) = waypoint pos = GpsPosition() pos.latitude = lat pos.longitude = lon pos.save() apos = AerialPosition() apos.altitude_msl = alt apos.gps_position = pos apos.save() wpt = Waypoint() wpt.position = apos wpt.order = i wpt.save() config.mission_waypoints.add(wpt) config.save() # Create UAS telemetry logs user = User.objects.create_user('testuser', '*****@*****.**', 'testpass') def assertSatisfiedWaypoints(expect, got): """Assert two satisfied_waypoints return values are equal.""" self.assertEqual(expect[0], got[0]) self.assertEqual(expect[1], got[1]) for k in expect[2].keys(): self.assertIn(k, got[2]) self.assertAlmostEqual(expect[2][k], got[2][k], delta=0.1) for k in got[2].keys(): self.assertIn(k, expect[2]) # Only first is valid. entries = [(38, -76, 140), (40, -78, 600), (37, -75, 40)] expect = (1, 1, {0: 40, 1: 460785.17}) logs = self.create_uas_logs(user, entries) assertSatisfiedWaypoints(expect, config.satisfied_waypoints(logs)) # First and last are valid, but missed second, so third doesn't count. entries = [(38, -76, 140), (40, -78, 600), (40, -78, 40)] expect = (1, 1, {0: 40, 1: 460785.03}) logs = self.create_uas_logs(user, entries) assertSatisfiedWaypoints(expect, config.satisfied_waypoints(logs)) # Hit all. entries = [(38, -76, 140), (39, -77, 180), (40, -78, 40)] expect = (3, 3, {0: 40, 1: 20, 2: 40}) logs = self.create_uas_logs(user, entries) assertSatisfiedWaypoints(expect, config.satisfied_waypoints(logs)) # Hit all, but don't stay within waypoint track. entries = [(38, -76, 140), (39, -77, 180), (41, -78, 40), (40, -78, 40)] expect = (3, 2, {0: 40, 1: 20, 2: 40}) logs = self.create_uas_logs(user, entries) assertSatisfiedWaypoints(expect, config.satisfied_waypoints(logs)) # Only hit the first waypoint on run one, hit all on run two. entries = [(38, -76, 140), (40, -78, 600), (37, -75, 40), # Run two: (38, -76, 140), (39, -77, 180), (40, -78, 40)] expect = (3, 3, {0: 40, 1: 20, 2: 40}) logs = self.create_uas_logs(user, entries) assertSatisfiedWaypoints(expect, config.satisfied_waypoints(logs)) # Hit all on run one, only hit the first waypoint on run two. entries = [(38, -76, 140), (39, -77, 180), (40, -78, 40), # Run two: (38, -76, 140), (40, -78, 600), (37, -75, 40)] expect = (3, 3, {0: 40, 1: 20, 2: 40}) logs = self.create_uas_logs(user, entries) assertSatisfiedWaypoints(expect, config.satisfied_waypoints(logs)) # Remain on the waypoint track only on the second run. entries = [(38, -76, 140), (39, -77, 180), (41, -78, 40), (40, -78, 40), # Run two: (38, -76, 140), (39, -77, 180), (40, -78, 40)] expect = (3, 3, {0: 40, 1: 20, 2: 40}) logs = self.create_uas_logs(user, entries) assertSatisfiedWaypoints(expect, config.satisfied_waypoints(logs)) # Keep flying after hitting all waypoints. entries = [(38, -76, 140), (39, -77, 180), (40, -78, 40), (30.1, -78.1, 100)] expect = (3, 3, {0: 40, 1: 20, 2: 40}) logs = self.create_uas_logs(user, entries) assertSatisfiedWaypoints(expect, config.satisfied_waypoints(logs)) # Miss last target by a sane distance. entries = [(38, -76, 140), (39, -77, 180), (40, -78, 60)] expect = (2, 2, {0: 40, 1: 20, 2: 60}) logs = self.create_uas_logs(user, entries) assertSatisfiedWaypoints(expect, config.satisfied_waypoints(logs))
def test_satisfied_waypoints(self): """Tests the evaluation of waypoints method.""" # Create mission config gpos = GpsPosition() gpos.latitude = 10 gpos.longitude = 10 gpos.save() config = MissionConfig() config.home_pos = gpos config.emergent_last_known_pos = gpos config.off_axis_target_pos = gpos config.air_drop_pos = gpos config.save() # Create waypoints for config waypoints = [(38, -76, 100), (39, -77, 200), (40, -78, 0)] for i, waypoint in enumerate(waypoints): (lat, lon, alt) = waypoint pos = GpsPosition() pos.latitude = lat pos.longitude = lon pos.save() apos = AerialPosition() apos.altitude_msl = alt apos.gps_position = pos apos.save() wpt = Waypoint() wpt.position = apos wpt.order = i wpt.save() config.mission_waypoints.add(wpt) config.save() # Create UAS telemetry logs user = User.objects.create_user('testuser', '*****@*****.**', 'testpass') # Only first is valid. entries = [(38, -76, 140), (40, -78, 600), (37, -75, 40)] expect = ({0: 40}, {0: 0.6, 1: 0.0, 2: 0.0}, {0: 40, 1: 460785.17}) logs = self.create_uas_logs(user, entries) self.assertSatisfiedWaypoints(expect, config.satisfied_waypoints(logs)) # First and last are valid, but missed second, so third doesn't count. entries = [(38, -76, 140), (40, -78, 600), (40, -78, 40)] expect = ({0: 40}, {0: 0.6, 1: 0.0, 2: 0.0}, {0: 40, 1: 460785.03}) logs = self.create_uas_logs(user, entries) self.assertSatisfiedWaypoints(expect, config.satisfied_waypoints(logs)) # Hit all. entries = [(38, -76, 140), (39, -77, 180), (40, -78, 40)] expect = ({0: 40, 1: 20, 2: 40}, {0: 0.6, 1: 0.8, 2: 0.6}, {0: 40, 1: 20, 2: 40}) # yapf: disable logs = self.create_uas_logs(user, entries) self.assertSatisfiedWaypoints(expect, config.satisfied_waypoints(logs)) # Only hit the first waypoint on run one, hit all on run two. entries = [(38, -76, 140), (40, -78, 600), (37, -75, 40), # Run two: (38, -76, 140), (39, -77, 180), (40, -78, 40)] expect = ({0: 40, 1: 20, 2: 40}, {0: 0.6, 1: 0.8, 2: 0.6}, {0: 40, 1: 20, 2: 40}) # yapf: disable logs = self.create_uas_logs(user, entries) self.assertSatisfiedWaypoints(expect, config.satisfied_waypoints(logs)) # Hit all on run one, only hit the first waypoint on run two. entries = [(38, -76, 140), (39, -77, 180), (40, -78, 40), # Run two: (38, -76, 140), (40, -78, 600), (37, -75, 40)] expect = ({0: 40, 1: 20, 2: 40}, {0: 0.6, 1: 0.8, 2: 0.6}, {0: 40, 1: 20, 2: 40}) # yapf: disable logs = self.create_uas_logs(user, entries) self.assertSatisfiedWaypoints(expect, config.satisfied_waypoints(logs)) # Keep flying after hitting all waypoints. entries = [(38, -76, 140), (39, -77, 180), (40, -78, 40), (30.1, -78.1, 100)] expect = ({0: 40, 1: 20, 2: 40}, {0: 0.6, 1: 0.8, 2: 0.6}, {0: 40, 1: 20, 2: 40}) # yapf: disable logs = self.create_uas_logs(user, entries) self.assertSatisfiedWaypoints(expect, config.satisfied_waypoints(logs)) # Hit all in first run, but second is higher scoring. entries = [(38, -76, 140), (39, -77, 180), (40, -78, 60), # Run two: (38, -76, 100), (39, -77, 200), (40, -78, 110)] expect = ({0: 0, 1: 0}, {0: 1, 1: 1, 2: 0}, {0: 0, 1: 0, 2: 60}) logs = self.create_uas_logs(user, entries) self.assertSatisfiedWaypoints(expect, config.satisfied_waypoints(logs)) # Restart waypoint path in the middle. waypoints = [(38, -76, 100), (39, -77, 200), (40, -78, 0)] entries = [(38, -76, 140), (39, -77, 180), # Restart: (38, -76, 70), (39, -77, 150), (40, -78, 10)] expect = ({0: 30, 1: 50, 2: 10}, {0: 0.7, 1: 0.5, 2: 0.9}, {0: 30, 1: 20, 2: 10}) # yapf: disable logs = self.create_uas_logs(user, entries) self.assertSatisfiedWaypoints(expect, config.satisfied_waypoints(logs))
def test_satisfied_waypoints(self): """Tests the evaluation of waypoints method.""" # Create mission config gpos = GpsPosition() gpos.latitude = 10 gpos.longitude = 10 gpos.save() config = MissionConfig() config.home_pos = gpos config.emergent_last_known_pos = gpos config.off_axis_target_pos = gpos config.air_drop_pos = gpos config.save() # Create waypoints for config waypoints = [(38, -76, 100), (39, -77, 200), (40, -78, 0)] for i, waypoint in enumerate(waypoints): (lat, lon, alt) = waypoint pos = GpsPosition() pos.latitude = lat pos.longitude = lon pos.save() apos = AerialPosition() apos.altitude_msl = alt apos.gps_position = pos apos.save() wpt = Waypoint() wpt.position = apos wpt.order = i wpt.save() config.mission_waypoints.add(wpt) config.save() # Create UAS telemetry logs user = User.objects.create_user('testuser', '*****@*****.**', 'testpass') def assertSatisfiedWaypoints(expect, got): """Assert two satisfied_waypoints return values are equal.""" self.assertEqual(expect[0], got[0]) self.assertEqual(expect[1], got[1]) for k in expect[2].keys(): self.assertIn(k, got[2]) self.assertAlmostEqual(expect[2][k], got[2][k], delta=0.1) for k in got[2].keys(): self.assertIn(k, expect[2]) # Only first is valid. entries = [(38, -76, 140), (40, -78, 600), (37, -75, 40)] expect = (1, 1, {0: 40, 1: 460785.17}) logs = self.create_uas_logs(user, entries) assertSatisfiedWaypoints(expect, config.satisfied_waypoints(logs)) # First and last are valid, but missed second, so third doesn't count. entries = [(38, -76, 140), (40, -78, 600), (40, -78, 40)] expect = (1, 1, {0: 40, 1: 460785.03}) logs = self.create_uas_logs(user, entries) assertSatisfiedWaypoints(expect, config.satisfied_waypoints(logs)) # Hit all. entries = [(38, -76, 140), (39, -77, 180), (40, -78, 40)] expect = (3, 3, {0: 40, 1: 20, 2: 40}) logs = self.create_uas_logs(user, entries) assertSatisfiedWaypoints(expect, config.satisfied_waypoints(logs)) # Hit all, but don't stay within waypoint track. entries = [(38, -76, 140), (39, -77, 180), (41, -78, 40), (40, -78, 40)] expect = (3, 2, {0: 40, 1: 20, 2: 40}) logs = self.create_uas_logs(user, entries) assertSatisfiedWaypoints(expect, config.satisfied_waypoints(logs)) # Only hit the first waypoint on run one, hit all on run two. entries = [ (38, -76, 140), (40, -78, 600), (37, -75, 40), # Run two: (38, -76, 140), (39, -77, 180), (40, -78, 40) ] expect = (3, 3, {0: 40, 1: 20, 2: 40}) logs = self.create_uas_logs(user, entries) assertSatisfiedWaypoints(expect, config.satisfied_waypoints(logs)) # Hit all on run one, only hit the first waypoint on run two. entries = [ (38, -76, 140), (39, -77, 180), (40, -78, 40), # Run two: (38, -76, 140), (40, -78, 600), (37, -75, 40) ] expect = (3, 3, {0: 40, 1: 20, 2: 40}) logs = self.create_uas_logs(user, entries) assertSatisfiedWaypoints(expect, config.satisfied_waypoints(logs)) # Remain on the waypoint track only on the second run. entries = [ (38, -76, 140), (39, -77, 180), (41, -78, 40), (40, -78, 40), # Run two: (38, -76, 140), (39, -77, 180), (40, -78, 40) ] expect = (3, 3, {0: 40, 1: 20, 2: 40}) logs = self.create_uas_logs(user, entries) assertSatisfiedWaypoints(expect, config.satisfied_waypoints(logs)) # Keep flying after hitting all waypoints. entries = [(38, -76, 140), (39, -77, 180), (40, -78, 40), (30.1, -78.1, 100)] expect = (3, 3, {0: 40, 1: 20, 2: 40}) logs = self.create_uas_logs(user, entries) assertSatisfiedWaypoints(expect, config.satisfied_waypoints(logs)) # Miss last target by a sane distance. entries = [(38, -76, 140), (39, -77, 180), (40, -78, 60)] expect = (2, 2, {0: 40, 1: 20, 2: 60}) logs = self.create_uas_logs(user, entries) assertSatisfiedWaypoints(expect, config.satisfied_waypoints(logs))
def test_satisfied_waypoints(self): """Tests the evaluation of waypoints method.""" # Create mission config gpos = GpsPosition() gpos.latitude = 10 gpos.longitude = 10 gpos.save() config = MissionConfig() config.home_pos = gpos config.emergent_last_known_pos = gpos config.off_axis_target_pos = gpos config.air_drop_pos = gpos config.save() # Create waypoints for config waypoints = [(38, -76, 100), (39, -77, 200), (40, -78, 0)] for i, waypoint in enumerate(waypoints): (lat, lon, alt) = waypoint pos = GpsPosition() pos.latitude = lat pos.longitude = lon pos.save() apos = AerialPosition() apos.altitude_msl = alt apos.gps_position = pos apos.save() wpt = Waypoint() wpt.position = apos wpt.order = i wpt.save() config.mission_waypoints.add(wpt) config.save() # Create UAS telemetry logs user = User.objects.create_user('testuser', '*****@*****.**', 'testpass') # Only first is valid. entries = [(38, -76, 140), (40, -78, 600), (37, -75, 40)] expect = ({0: 40}, {0: 0.6, 1: 0.0, 2: 0.0}, {0: 40, 1: 460785.17}) logs = self.create_uas_logs(user, entries) self.assertSatisfiedWaypoints(expect, config.satisfied_waypoints(logs)) # First and last are valid, but missed second, so third doesn't count. entries = [(38, -76, 140), (40, -78, 600), (40, -78, 40)] expect = ({0: 40}, {0: 0.6, 1: 0.0, 2: 0.0}, {0: 40, 1: 460785.03}) logs = self.create_uas_logs(user, entries) self.assertSatisfiedWaypoints(expect, config.satisfied_waypoints(logs)) # Hit all. entries = [(38, -76, 140), (39, -77, 180), (40, -78, 40)] expect = ({0: 40, 1: 20, 2: 40}, {0: 0.6, 1: 0.8, 2: 0.6}, {0: 40, 1: 20, 2: 40}) # yapf: disable logs = self.create_uas_logs(user, entries) self.assertSatisfiedWaypoints(expect, config.satisfied_waypoints(logs)) # Only hit the first waypoint on run one, hit all on run two. entries = [ (38, -76, 140), (40, -78, 600), (37, -75, 40), # Run two: (38, -76, 140), (39, -77, 180), (40, -78, 40) ] expect = ({0: 40, 1: 20, 2: 40}, {0: 0.6, 1: 0.8, 2: 0.6}, {0: 40, 1: 20, 2: 40}) # yapf: disable logs = self.create_uas_logs(user, entries) self.assertSatisfiedWaypoints(expect, config.satisfied_waypoints(logs)) # Hit all on run one, only hit the first waypoint on run two. entries = [ (38, -76, 140), (39, -77, 180), (40, -78, 40), # Run two: (38, -76, 140), (40, -78, 600), (37, -75, 40) ] expect = ({0: 40, 1: 20, 2: 40}, {0: 0.6, 1: 0.8, 2: 0.6}, {0: 40, 1: 20, 2: 40}) # yapf: disable logs = self.create_uas_logs(user, entries) self.assertSatisfiedWaypoints(expect, config.satisfied_waypoints(logs)) # Keep flying after hitting all waypoints. entries = [(38, -76, 140), (39, -77, 180), (40, -78, 40), (30.1, -78.1, 100)] expect = ({0: 40, 1: 20, 2: 40}, {0: 0.6, 1: 0.8, 2: 0.6}, {0: 40, 1: 20, 2: 40}) # yapf: disable logs = self.create_uas_logs(user, entries) self.assertSatisfiedWaypoints(expect, config.satisfied_waypoints(logs)) # Hit all in first run, but second is higher scoring. entries = [ (38, -76, 140), (39, -77, 180), (40, -78, 60), # Run two: (38, -76, 100), (39, -77, 200), (40, -78, 110) ] expect = ({0: 0, 1: 0}, {0: 1, 1: 1, 2: 0}, {0: 0, 1: 0, 2: 60}) logs = self.create_uas_logs(user, entries) self.assertSatisfiedWaypoints(expect, config.satisfied_waypoints(logs)) # Restart waypoint path in the middle. waypoints = [(38, -76, 100), (39, -77, 200), (40, -78, 0)] entries = [ (38, -76, 140), (39, -77, 180), # Restart: (38, -76, 70), (39, -77, 150), (40, -78, 10) ] expect = ({0: 30, 1: 50, 2: 10}, {0: 0.7, 1: 0.5, 2: 0.9}, {0: 30, 1: 20, 2: 10}) # yapf: disable logs = self.create_uas_logs(user, entries) self.assertSatisfiedWaypoints(expect, config.satisfied_waypoints(logs))
def create_sample_mission(superuser): """Creates a sample mission. Args: superuser: A superuser account to create mission under. Returns: MissionConfig for the created mission. """ mission = MissionConfig() gpos = GpsPosition(latitude=38.145103, longitude=-76.427856) gpos.save() mission.home_pos = gpos gpos = GpsPosition(latitude=38.145111, longitude=-76.427861) gpos.save() mission.emergent_last_known_pos = gpos gpos = GpsPosition(latitude=38.145111, longitude=-76.427861) gpos.save() mission.off_axis_odlc_pos = gpos gpos = GpsPosition(latitude=38.1458416666667, longitude=-76.426375) gpos.save() mission.air_drop_pos = gpos # All foreign keys must be defined before the first save. # All many-to-many must be defined after the first save. mission.save() bounds = FlyZone(altitude_msl_min=100, altitude_msl_max=750) bounds.save() # yapf: disable pts = [(38.1462694444444, -76.4281638888889), (38.1516250000000, -76.4286833333333), (38.1518888888889, -76.4314666666667), (38.1505944444444, -76.4353611111111), (38.1475666666667, -76.4323416666667), (38.1446666666667, -76.4329472222222), (38.1432555555556, -76.4347666666667), (38.1404638888889, -76.4326361111111), (38.1407194444444, -76.4260138888889), (38.1437611111111, -76.4212055555556), (38.1473472222222, -76.4232111111111), (38.1461305555556, -76.4266527777778)] # yapf: enable for ix, (lat, lon) in enumerate(pts): wpt = Waypoint(latitude=lat, longitude=lon, altitude_msl=0, order=ix + 1) wpt.save() bounds.boundary_pts.add(wpt) bounds.save() mission.fly_zones.add(bounds) # yapf: disable pts = [(38.146689, -76.426475, 150, 750), (38.142914, -76.430297, 300, 300), (38.149504, -76.433110, 100, 750), (38.148711, -76.429061, 300, 750), (38.144203, -76.426155, 50, 400), (38.146003, -76.430733, 225, 500)] # yapf: enable for lat, lon, radius, height in pts: obst = StationaryObstacle(latitude=lat, longitude=lon, cylinder_radius=radius, cylinder_height=height) obst.save() mission.stationary_obstacles.add(obst) # yapf: disable pts = [(38.1446916666667, -76.4279944444445, 200), (38.1461944444444, -76.4237138888889, 300), (38.1438972222222, -76.4225500000000, 400), (38.1417722222222, -76.4251083333333, 400), (38.1453500000000, -76.4286750000000, 300), (38.1508972222222, -76.4292972222222, 300), (38.1514944444444, -76.4313833333333, 300), (38.1505333333333, -76.4341750000000, 300), (38.1479472222222, -76.4316055555556, 200), (38.1443333333333, -76.4322888888889, 200), (38.1433166666667, -76.4337111111111, 300), (38.1410944444444, -76.4321555555556, 400), (38.1415777777778, -76.4252472222222, 400), (38.1446083333333, -76.4282527777778, 200)] # yapf: enable for ix, (lat, lon, alt) in enumerate(pts): wpt = Waypoint(latitude=lat, longitude=lon, altitude_msl=alt, order=ix + 1) wpt.save() mission.mission_waypoints.add(wpt) # yapf: disable pts = [(38.1444444444444, -76.4280916666667), (38.1459444444444, -76.4237944444445), (38.1439305555556, -76.4227444444444), (38.1417138888889, -76.4253805555556), (38.1412111111111, -76.4322361111111), (38.1431055555556, -76.4335972222222), (38.1441805555556, -76.4320111111111), (38.1452611111111, -76.4289194444444), (38.1444444444444, -76.4280916666667)] # yapf: enable for ix, (lat, lon) in enumerate(pts): wpt = Waypoint(latitude=lat, longitude=lon, altitude_msl=0, order=ix + 1) wpt.save() mission.search_grid_points.add(wpt) gpos = GpsPosition(latitude=38.143844, longitude=-76.426469) gpos.save() odlc = Odlc(mission=mission, user=superuser, odlc_type=interop_api_pb2.Odlc.STANDARD, location=gpos, orientation=interop_api_pb2.Odlc.N, shape=interop_api_pb2.Odlc.STAR, shape_color=interop_api_pb2.Odlc.RED, alphanumeric='A', alphanumeric_color=interop_api_pb2.Odlc.WHITE) odlc.save() mission.odlcs.add(odlc) gpos = GpsPosition(latitude=38.141872, longitude=-76.426183) gpos.save() odlc = Odlc(mission=mission, user=superuser, odlc_type=interop_api_pb2.Odlc.STANDARD, location=gpos, orientation=interop_api_pb2.Odlc.NE, shape=interop_api_pb2.Odlc.CROSS, shape_color=interop_api_pb2.Odlc.BLUE, alphanumeric='I', alphanumeric_color=interop_api_pb2.Odlc.BLACK) odlc.save() mission.odlcs.add(odlc) gpos = GpsPosition(latitude=38.142828, longitude=-76.427644) gpos.save() odlc = Odlc(mission=mission, user=superuser, odlc_type=interop_api_pb2.Odlc.STANDARD, location=gpos, orientation=interop_api_pb2.Odlc.E, shape=interop_api_pb2.Odlc.QUARTER_CIRCLE, shape_color=interop_api_pb2.Odlc.YELLOW, alphanumeric='R', alphanumeric_color=interop_api_pb2.Odlc.ORANGE) odlc.save() mission.odlcs.add(odlc) gpos = GpsPosition(latitude=38.144925, longitude=-76.425100) gpos.save() odlc = Odlc(mission=mission, user=superuser, odlc_type=interop_api_pb2.Odlc.STANDARD, location=gpos, orientation=interop_api_pb2.Odlc.SE, shape=interop_api_pb2.Odlc.CIRCLE, shape_color=interop_api_pb2.Odlc.BROWN, alphanumeric='V', alphanumeric_color=interop_api_pb2.Odlc.RED) odlc.save() mission.odlcs.add(odlc) gpos = GpsPosition(latitude=38.146747, longitude=-76.422131) gpos.save() odlc = Odlc(mission=mission, user=superuser, odlc_type=interop_api_pb2.Odlc.STANDARD, location=gpos, orientation=interop_api_pb2.Odlc.S, shape=interop_api_pb2.Odlc.TRAPEZOID, shape_color=interop_api_pb2.Odlc.WHITE, alphanumeric='E', alphanumeric_color=interop_api_pb2.Odlc.GRAY) odlc.save() mission.odlcs.add(odlc) gpos = GpsPosition(latitude=38.144097, longitude=-76.431089) gpos.save() odlc = Odlc(mission=mission, user=superuser, odlc_type=interop_api_pb2.Odlc.STANDARD, location=gpos, orientation=interop_api_pb2.Odlc.SW, shape=interop_api_pb2.Odlc.SQUARE, shape_color=interop_api_pb2.Odlc.GREEN, alphanumeric='H', alphanumeric_color=interop_api_pb2.Odlc.BLUE) odlc.save() mission.odlcs.add(odlc) gpos = GpsPosition(latitude=38.144878, longitude=-76.423681) gpos.save() odlc = Odlc(mission=mission, user=superuser, odlc_type=interop_api_pb2.Odlc.STANDARD, location=gpos, orientation=interop_api_pb2.Odlc.W, shape=interop_api_pb2.Odlc.RECTANGLE, shape_color=interop_api_pb2.Odlc.PURPLE, alphanumeric='I', alphanumeric_color=interop_api_pb2.Odlc.GREEN) odlc.save() mission.odlcs.add(odlc) gpos = GpsPosition(latitude=38.142819, longitude=-76.432375) gpos.save() odlc = Odlc(mission=mission, user=superuser, odlc_type=interop_api_pb2.Odlc.STANDARD, location=gpos, orientation=interop_api_pb2.Odlc.NW, shape=interop_api_pb2.Odlc.SEMICIRCLE, shape_color=interop_api_pb2.Odlc.ORANGE, alphanumeric='C', alphanumeric_color=interop_api_pb2.Odlc.YELLOW) odlc.save() mission.odlcs.add(odlc) gpos = GpsPosition(latitude=38.141639, longitude=-76.429347) gpos.save() odlc = Odlc(mission=mission, user=superuser, odlc_type=interop_api_pb2.Odlc.STANDARD, location=gpos, orientation=interop_api_pb2.Odlc.N, shape=interop_api_pb2.Odlc.TRIANGLE, shape_color=interop_api_pb2.Odlc.BLACK, alphanumeric='L', alphanumeric_color=interop_api_pb2.Odlc.PURPLE) odlc.save() mission.odlcs.add(odlc) gpos = GpsPosition(latitude=38.142478, longitude=-76.424967) gpos.save() odlc = Odlc(mission=mission, user=superuser, odlc_type=interop_api_pb2.Odlc.STANDARD, location=gpos, orientation=interop_api_pb2.Odlc.NE, shape=interop_api_pb2.Odlc.PENTAGON, shape_color=interop_api_pb2.Odlc.GRAY, alphanumeric='E', alphanumeric_color=interop_api_pb2.Odlc.BROWN) odlc.save() mission.odlcs.add(odlc) gpos = GpsPosition(latitude=38.143411, longitude=-76.424489) gpos.save() odlc = Odlc(mission=mission, user=superuser, odlc_type=interop_api_pb2.Odlc.EMERGENT, location=gpos, description='Randy the backpacker.') odlc.save() mission.odlcs.add(odlc) mission.save() return mission