本文整理汇总了Python中auvsi_suas.models.UasTelemetry类的典型用法代码示例。如果您正苦于以下问题:Python UasTelemetry类的具体用法?Python UasTelemetry怎么用?Python UasTelemetry使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了UasTelemetry类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_kml_simple
def test_kml_simple(self):
coordinates = [
(-76.0, 38.0, 0.0),
(-76.0, 38.0, 10.0),
(-76.0, 38.0, 20.0),
(-76.0, 38.0, 30.0),
(-76.0, 38.0, 100.0),
(-76.0, 38.0, 30.0),
(-76.0, 38.0, 60.0),
]
# Create Coordinates
start = TakeoffOrLandingEvent(user=self.user, uas_in_air=True)
start.save()
for coord in coordinates:
self.create_log_element(*coord)
end = TakeoffOrLandingEvent(user=self.user, uas_in_air=False)
end.save()
kml = Kml()
UasTelemetry.kml(user=self.user,
logs=UasTelemetry.by_user(self.user),
kml=kml,
kml_doc=kml)
for coord in coordinates:
tag = self.coord_format.format(coord[1], coord[0],
units.feet_to_meters(coord[2]))
self.assertTrue(tag in kml.kml())
示例2: test_kml_filter
def test_kml_filter(self):
coordinates = [
(-76.0, 38.0, 0.0),
(-76.0, 38.0, 10.0),
(-76.0, 38.0, 20.0),
(-76.0, 38.0, 30.0),
(-76.0, 38.0, 100.0),
(-76.0, 38.0, 30.0),
(-76.0, 38.0, 60.0),
]
filtered_out = [(0.1, 0.001, 100), (0.0, 0.0, 0)]
# Create Coordinates
start = TakeoffOrLandingEvent(user=self.user, uas_in_air=True)
start.save()
for coord in coordinates:
self.create_log_element(*coord)
for coord in filtered_out:
self.create_log_element(*coord)
end = TakeoffOrLandingEvent(user=self.user, uas_in_air=False)
end.save()
kml = Kml()
UasTelemetry.kml(user=self.user,
logs=UasTelemetry.by_user(self.user),
kml=kml,
kml_doc=kml)
for filtered in filtered_out:
tag = self.coord_format.format(filtered[1], filtered[0],
filtered[2])
self.assertTrue(tag not in kml.kml())
for coord in coordinates:
tag = self.coord_format.format(coord[1], coord[0], coord[2])
self.assertTrue(tag in kml.kml())
示例3: test_kml_empty
def test_kml_empty(self):
kml = Kml()
UasTelemetry.kml(
user=self.user,
logs=UasTelemetry.by_user(self.user),
kml=kml,
kml_doc=kml, )
示例4: get
def get(self, request):
kml = Kml(name='LIVE Data')
MovingObstacle.live_kml(kml, timedelta(seconds=5))
UasTelemetry.live_kml(kml, timedelta(seconds=5))
response = HttpResponse(kml.kml())
response['Content-Type'] = 'application/vnd.google-earth.kml+xml'
response['Content-Disposition'] = 'attachment; filename=update.kml'
response['Content-Length'] = str(len(response.content))
return response
示例5: create_log_element
def create_log_element(self, timestamp, user, lat, lon, alt, heading):
pos = GpsPosition(latitude=lat, longitude=lon)
pos.save()
apos = AerialPosition(gps_position=pos, altitude_msl=alt)
apos.save()
log = UasTelemetry(timestamp=timezone.now(),
user=user,
uas_position=apos,
uas_heading=heading)
log.save()
return log
示例6: user_json
def user_json(user):
"""Generate JSON-style dict for user."""
return {
'name': user.username,
'id': user.pk,
'in_air': TakeoffOrLandingEvent.user_in_air(user),
'active': UasTelemetry.user_active(user),
}
示例7: user_json
def user_json(user):
"""Generate JSON-style dict for user."""
return {
'name': user.username,
'id': user.pk,
'on_clock': MissionClockEvent.user_on_clock(user),
'on_timeout': MissionClockEvent.user_on_timeout(user),
'in_air': TakeoffOrLandingEvent.user_in_air(user),
'active': UasTelemetry.user_active(user),
}
示例8: test_evaluate_collision_with_uas
def test_evaluate_collision_with_uas(self):
"""Tests the collision with UAS method."""
# Create testing data
user = User.objects.create_user('testuser', '[email protected]',
'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)
示例9: create_data
def create_data(self):
"""Create a basic sample dataset."""
self.user1 = User.objects.create_user('user1', '[email protected]',
'testpass')
self.user1.save()
self.user2 = User.objects.create_user('user2', '[email protected]',
'testpass')
self.user2.save()
# user1 is flying
event = TakeoffOrLandingEvent(user=self.user1, uas_in_air=True)
event.save()
# user2 has landed
event = TakeoffOrLandingEvent(user=self.user2, uas_in_air=True)
event.save()
event = TakeoffOrLandingEvent(user=self.user2, uas_in_air=False)
event.save()
# user2 is active
self.timestamp = timezone.now()
gps = GpsPosition(latitude=38.6462, longitude=-76.2452)
gps.save()
pos = AerialPosition(gps_position=gps, altitude_msl=0)
pos.save()
telem = UasTelemetry(user=self.user2, uas_position=pos, uas_heading=90)
telem.save()
telem.timestamp = self.timestamp
telem.save()
示例10: create_logs
def create_logs(self,
user,
num=10,
start=None,
delta=None,
altitude=100,
heading=90):
if start is None:
start = timezone.now()
if delta is None:
delta = datetime.timedelta(seconds=1)
logs = []
for i in xrange(num):
gps = GpsPosition(latitude=38 + 0.001 * i,
longitude=-78 + 0.001 * i)
gps.save()
pos = AerialPosition(gps_position=gps, altitude_msl=altitude)
pos.save()
log = UasTelemetry(user=user,
uas_position=pos,
uas_heading=heading)
log.save()
log.timestamp = start + i * delta
log.save()
logs.append(log)
return logs
示例11: test_satisfied_waypoints
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)
示例12: create_uas_logs
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
示例13: get
def get(self, request):
kml = Kml(name='AUVSI SUAS Flight Data')
kml_teams = kml.newfolder(name='Teams')
kml_mission = kml.newfolder(name='Missions')
users = User.objects.all()
for user in users:
# Ignore admins
if user.is_superuser:
continue
UasTelemetry.kml(user=user,
logs=UasTelemetry.by_user(user),
kml=kml_teams,
kml_doc=kml.document)
MissionConfig.kml_all(kml_mission)
kml_flyzone = kml.newfolder(name='Fly Zones')
FlyZone.kml_all(kml_flyzone)
response = HttpResponse(kml.kml())
response['Content-Type'] = 'application/vnd.google-earth.kml+xml'
response['Content-Disposition'] = 'attachment; filename=mission.kml'
response['Content-Length'] = str(len(response.content))
return response
示例14: postUasPosition
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.')
示例15: create_log_element
def create_log_element(self, lat, lon, alt, user, log_time):
pos = GpsPosition(latitude=lat, longitude=lon)
pos.save()
apos = AerialPosition(gps_position=pos, altitude_msl=alt)
apos.save()
log = UasTelemetry(user=user, uas_position=apos, uas_heading=100, )
log.save()
log.timestamp = log_time
log.save()
return log