-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathgps.py
45 lines (37 loc) · 1.21 KB
/
gps.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
###############################################################################
#
# Copyright (c) 2017-2024 Master AI, Inc.
# ALL RIGHTS RESERVED
#
# Use of this library, in source or binary form, is prohibited without written
# approval from Master AI, Inc.
#
###############################################################################
"""
This module provides a simplified interface to the GPS sensor.
"""
from auto.asyncio_tools import thread_safe
from auto.capabilities import list_caps, acquire
def query():
"""
Query the GPS sensor. The return value depends on the type of device
you are using:
For *physical* devices, the return value is a point using the
*Geographic coordinate system*, thus it is a three-tuple:
(`latitude`, `longitude`, `altitude`)
For *virtual* devices, the return value is a point using the
*Cartesian coordinate system*, thus it is a three-tuple:
(`x`, `y`, `z`)
"""
return _get_gps().query()
@thread_safe
def _get_gps():
global _GPS
try:
_GPS
except NameError:
caps = list_caps()
if 'GPS' not in caps:
raise AttributeError('This device has no GPS!')
_GPS = acquire('GPS')
return _GPS