本文整理汇总了Python中auvsi_suas.models.AerialPosition.gps_position方法的典型用法代码示例。如果您正苦于以下问题:Python AerialPosition.gps_position方法的具体用法?Python AerialPosition.gps_position怎么用?Python AerialPosition.gps_position使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类auvsi_suas.models.AerialPosition
的用法示例。
在下文中一共展示了AerialPosition.gps_position方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_waypoint_travel_time
# 需要导入模块: from auvsi_suas.models import AerialPosition [as 别名]
# 或者: from auvsi_suas.models.AerialPosition import gps_position [as 别名]
def test_get_waypoint_travel_time(self):
"""Tests travel time calc."""
test_spds = [1, 10, 100, 500]
for (lon2, lat2, lon1, lat1, dist_km) in TESTDATA_COMPETITION_DIST:
dist_ft = units.kilometers_to_feet(dist_km)
for speed in test_spds:
speed_fps = units.knots_to_feet_per_second(speed)
time = dist_ft / speed_fps
gpos1 = GpsPosition()
gpos1.latitude = lat1
gpos1.longitude = lon1
gpos1.save()
apos1 = AerialPosition()
apos1.gps_position = gpos1
apos1.altitude_msl = 0
apos1.save()
wpt1 = Waypoint()
wpt1.position = apos1
gpos2 = GpsPosition()
gpos2.latitude = lat2
gpos2.longitude = lon2
gpos2.save()
apos2 = AerialPosition()
apos2.gps_position = gpos2
apos2.altitude_msl = 0
apos2.save()
wpt2 = Waypoint()
wpt2.position = apos2
waypoints = [wpt1, wpt2]
obstacle = MovingObstacle()
obstacle.speed_avg = speed
self.assertTrue(self.eval_travel_time(
obstacle.get_waypoint_travel_time(waypoints, 0, 1), time))
示例2: test_satisfied_waypoints
# 需要导入模块: from auvsi_suas.models import AerialPosition [as 别名]
# 或者: from auvsi_suas.models.AerialPosition import gps_position [as 别名]
def test_satisfied_waypoints(self):
"""Tests the evaluation of waypoints method."""
data = TESTDATA_MISSIONCONFIG_EVALWAYPOINTS
(waypoint_details, uas_log_details, exp_satisfied) = data
# 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.sric_pos = gpos
config.air_drop_pos = gpos
config.server_info = self.info
config.save()
# Create waypoints for config
for wpt_id in xrange(len(waypoint_details)):
(lat, lon, alt) = waypoint_details[wpt_id]
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 = wpt_id
wpt.save()
config.mission_waypoints.add(wpt)
config.save()
# Create UAS telemetry logs
uas_logs = []
user = User.objects.create_user('testuser', '[email protected]',
'testpass')
for (lat, lon, alt) in uas_log_details:
pos = GpsPosition()
pos.latitude = lat
pos.longitude = lon
pos.save()
apos = AerialPosition()
apos.altitude_msl = alt
apos.gps_position = pos
apos.save()
log = UasTelemetry()
log.user = user
log.uas_position = apos
log.uas_heading = 0
log.save()
uas_logs.append(log)
# Assert correct satisfied waypoints
wpts_satisfied = config.satisfied_waypoints(uas_logs)
self.assertEqual(wpts_satisfied, exp_satisfied)
示例3: setUp
# 需要导入模块: from auvsi_suas.models import AerialPosition [as 别名]
# 或者: from auvsi_suas.models.AerialPosition import gps_position [as 别名]
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: setUp
# 需要导入模块: from auvsi_suas.models import AerialPosition [as 别名]
# 或者: from auvsi_suas.models.AerialPosition import gps_position [as 别名]
def setUp(self):
"""Creates test data."""
# Form test set for contains position
self.testdata_containspos = []
for test_data in TESTDATA_FLYZONE_CONTAINSPOS:
# Create the FlyZone
zone = FlyZone()
zone.altitude_msl_min = test_data['min_alt']
zone.altitude_msl_max = test_data['max_alt']
zone.save()
for waypoint_id in range(len(test_data['waypoints'])):
(lat, lon) = test_data['waypoints'][waypoint_id]
gpos = GpsPosition()
gpos.latitude = lat
gpos.longitude = lon
gpos.save()
apos = AerialPosition()
apos.gps_position = gpos
apos.altitude_msl = 0
apos.save()
wpt = Waypoint()
wpt.order = waypoint_id
wpt.position = apos
wpt.save()
zone.boundary_pts.add(wpt)
# Form test set
test_pos = []
for pos in test_data['inside_pos']:
test_pos.append((pos, True))
for pos in test_data['outside_pos']:
test_pos.append((pos, False))
# Store
self.testdata_containspos.append((zone, test_pos))
示例5: create_uas_logs
# 需要导入模块: from auvsi_suas.models import AerialPosition [as 别名]
# 或者: from auvsi_suas.models.AerialPosition import gps_position [as 别名]
def create_uas_logs(self, user, entries):
"""Create a list of uas telemetry logs.
Args:
user: User to create logs for.
entries: List of (lat, lon, alt) tuples for each entry.
Returns:
List of UasTelemetry objects
"""
ret = []
for (lat, lon, alt) in entries:
pos = GpsPosition()
pos.latitude = lat
pos.longitude = lon
pos.save()
apos = AerialPosition()
apos.altitude_msl = alt
apos.gps_position = pos
apos.save()
log = UasTelemetry()
log.user = user
log.uas_position = apos
log.uas_heading = 0
log.save()
ret.append(log)
return ret
示例6: test_unicode
# 需要导入模块: from auvsi_suas.models import AerialPosition [as 别名]
# 或者: from auvsi_suas.models.AerialPosition import gps_position [as 别名]
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.sric_pos = pos
config.air_drop_pos = pos
config.server_info = self.info
config.save()
config.mission_waypoints.add(wpt)
config.search_grid_points.add(wpt)
config.save()
self.assertTrue(config.__unicode__())
示例7: postUasPosition
# 需要导入模块: from auvsi_suas.models import AerialPosition [as 别名]
# 或者: from auvsi_suas.models.AerialPosition import gps_position [as 别名]
def postUasPosition(request):
"""Posts the UAS position with a POST request.
User must send a POST request with the following paramters:
latitude: A latitude in decimal degrees.
longitude: A logitude in decimal degrees.
altitude_msl: An MSL altitude in decimal feet.
uas_heading: The UAS heading in decimal degrees. (0=north, 90=east)
"""
# Validate user is logged in to make request
if not request.user.is_authenticated():
return HttpResponseBadRequest('User not logged in. Login required.')
# Validate user made a POST request
if request.method != 'POST':
return HttpResponseBadRequest('Request must be POST request.')
try:
# Get the parameters
latitude = float(request.POST['latitude'])
longitude = float(request.POST['longitude'])
altitude_msl = float(request.POST['altitude_msl'])
uas_heading = float(request.POST['uas_heading'])
except KeyError:
# Failed to get POST parameters
return HttpResponseBadRequest(
'Posting UAS position must contain POST parameters "latitude", '
'"longitude", "altitude_msl", and "uas_heading".')
except ValueError:
# Failed to convert parameters
return HttpResponseBadRequest(
'Failed to convert provided POST parameters to correct form.')
else:
# Check the values make sense
if latitude < -90 or latitude > 90:
return HttpResponseBadRequest(
'Must provide latitude between -90 and 90 degrees.')
if longitude < -180 or longitude > 180:
return HttpResponseBadRequest(
'Must provide longitude between -180 and 180 degrees.')
if uas_heading < 0 or uas_heading > 360:
return HttpResponseBadRequest(
'Must provide heading between 0 and 360 degrees.')
# Store telemetry
gps_position = GpsPosition()
gps_position.latitude = latitude
gps_position.longitude = longitude
gps_position.save()
aerial_position = AerialPosition()
aerial_position.gps_position = gps_position
aerial_position.altitude_msl = altitude_msl
aerial_position.save()
uas_telemetry = UasTelemetry()
uas_telemetry.user = request.user
uas_telemetry.uas_position = aerial_position
uas_telemetry.uas_heading = uas_heading
uas_telemetry.save()
return HttpResponse('UAS Telemetry Successfully Posted.')
示例8: eval_distanceTo_input
# 需要导入模块: from auvsi_suas.models import AerialPosition [as 别名]
# 或者: from auvsi_suas.models.AerialPosition import gps_position [as 别名]
def eval_distanceTo_input(self, lon1, lat1, alt1, lon2, lat2, alt2,
dist_actual):
"""Evaluates the distanceTo calc with the given inputs."""
pos1 = AerialPosition()
pos1.gps_position = GpsPosition()
pos1.gps_position.latitude = lat1
pos1.gps_position.longitude = lon1
pos1.altitude_msl = alt1
pos2 = AerialPosition()
pos2.gps_position = GpsPosition()
pos2.gps_position.latitude = lat2
pos2.gps_position.longitude = lon2
pos2.altitude_msl = alt2
dist12 = pos1.distanceTo(pos2)
dist21 = pos2.distanceTo(pos1)
dist_actual_ft = kilometersToFeet(dist_actual)
diffdist12 = abs(dist12 - dist_actual_ft)
diffdist21 = abs(dist21 - dist_actual_ft)
dist_thresh = 10.0
return diffdist12 <= dist_thresh and diffdist21 <= dist_thresh
示例9: test_contains_pos
# 需要导入模块: from auvsi_suas.models import AerialPosition [as 别名]
# 或者: from auvsi_suas.models.AerialPosition import gps_position [as 别名]
def test_contains_pos(self):
"""Tests the contains_pos method."""
for (zone, test_pos) in self.testdata_containspos:
for ((lat, lon, alt), inside) in test_pos:
gpos = GpsPosition()
gpos.latitude = lat
gpos.longitude = lon
gpos.save()
apos = AerialPosition()
apos.altitude_msl = alt
apos.gps_position = gpos
self.assertEqual(zone.contains_pos(apos), inside)
示例10: test_contains_many_pos
# 需要导入模块: from auvsi_suas.models import AerialPosition [as 别名]
# 或者: from auvsi_suas.models.AerialPosition import gps_position [as 别名]
def test_contains_many_pos(self):
"""Tests the contains_many_pos method."""
for (zone, test_pos) in self.testdata_containspos:
aerial_pos_list = []
expected_results = []
for ((lat, lon, alt), inside) in test_pos:
gpos = GpsPosition()
gpos.latitude = lat
gpos.longitude = lon
gpos.save()
apos = AerialPosition()
apos.altitude_msl = alt
apos.gps_position = gpos
aerial_pos_list.append(apos)
expected_results.append(inside)
self.assertEqual(
zone.contains_many_pos(aerial_pos_list), expected_results)
示例11: test_unicode
# 需要导入模块: from auvsi_suas.models import AerialPosition [as 别名]
# 或者: from auvsi_suas.models.AerialPosition import gps_position [as 别名]
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__())
示例12: test_unicode
# 需要导入模块: from auvsi_suas.models import AerialPosition [as 别名]
# 或者: from auvsi_suas.models.AerialPosition import gps_position [as 别名]
def test_unicode(self):
"""Tests the unicode method executes."""
zone = FlyZone()
zone.altitude_msl_min = 1
zone.altitude_msl_max = 2
zone.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()
zone.boundary_pts.add(wpt)
self.assertTrue(zone.__unicode__())
示例13: test_contains_pos
# 需要导入模块: from auvsi_suas.models import AerialPosition [as 别名]
# 或者: from auvsi_suas.models.AerialPosition import gps_position [as 别名]
def test_contains_pos(self):
"""Tests the inside obstacle method."""
# Form the test obstacle
obst = MovingObstacle()
obst.sphere_radius = TESTDATA_MOVOBST_CONTAINSPOS_OBJ[2]
# Run test points against obstacle
test_data = [
(TESTDATA_MOVOBST_CONTAINSPOS_INSIDE, True),
(TESTDATA_MOVOBST_CONTAINSPOS_OUTSIDE, False)
]
for (cur_data, cur_contains) in test_data:
for (lat, lon, alt) in cur_data:
gpos = GpsPosition()
gpos.latitude = lat
gpos.longitude = lon
gpos.save()
apos = AerialPosition()
apos.gps_position = gpos
apos.altitude_msl = alt
self.assertEqual(obst.contains_pos(
TESTDATA_MOVOBST_CONTAINSPOS_OBJ[0],
TESTDATA_MOVOBST_CONTAINSPOS_OBJ[1],
TESTDATA_MOVOBST_CONTAINSPOS_OBJ[3], apos), cur_contains)
示例14: test_evaluate_collision_with_uas
# 需要导入模块: from auvsi_suas.models import AerialPosition [as 别名]
# 或者: from auvsi_suas.models.AerialPosition import gps_position [as 别名]
def test_evaluate_collision_with_uas(self):
"""Tests the collision with UAS method."""
# Get test data
user = User.objects.create_user('testuser', '[email protected]',
'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)
示例15: test_satisfied_waypoints
# 需要导入模块: from auvsi_suas.models import AerialPosition [as 别名]
# 或者: from auvsi_suas.models.AerialPosition import gps_position [as 别名]
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.sric_pos = gpos
config.air_drop_pos = gpos
config.server_info = self.info
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', '[email protected]',
'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),
#.........这里部分代码省略.........