Loading...
Home
  • Tech Blogs
  • Videos
  • Conferences
    • Droidcon News
    • Upcoming Conferences
    • Become a Partner
    • Past Events
    • Keep Me Informed
    • Diversity Scholarships
  • Community
    • droidcon Team
    • How to Hold a Droidcon
  • Android Careers
Sign In

Global CSS

droidcon News
Lightning Talk: Where the Heck Am I? Understanding Location in your Application
By
Richard Sueselbeck
droidcon London 2019
Transcript
English
00:00
hi everyone I've been told to just kick
00:02
off so kick off I shall hi my name is
00:05
Richard I'm a developer evangelist for
00:08
here technologies and we are the world's
00:11
leading location technology company and
00:13
that means that location matters to me
00:17
here's a fun fact I submitted this as a
00:19
full hour talking because it got
00:21
accepted as a 15 minute lightning talk
00:23
so I have an interesting challenge ahead
00:24
of me I wanted to do a talk about
00:27
location where does location come from
00:30
when we use location in our app we
00:32
usually have something like this we have
00:33
a latitude and a longitude but we don't
00:36
necessarily understand really what that
00:38
means so where it comes from we use that
00:40
maybe to start a routing API or to
00:44
Center a map all these kind of things
00:46
what we don't necessarily understand
00:48
what that means so I had a wonderful
00:50
one-hour talk there were there nice
00:52
stories about the Cold War and Ronald
00:54
Reagan and fighter jets and space and
00:56
dinosaurs and all that kind of thing for
00:59
a 15 minute talk I had to cut that down
01:01
a little bit and I picked out kind of
01:03
one thing from that talk and that really
01:06
is the question where does that location
01:08
come from and the answer is usually GPS
01:12
again that's only partially true and if
01:14
we had the full talk we could talk about
01:16
that as well but really what I want you
01:18
to take away from the next 15 minutes is
01:21
the idea of a how does GPS actually work
01:25
because we use that every day as
01:27
developers often we use location in our
01:30
apps on on our Android phone that will
01:34
usually come from GPS but do we actually
01:36
know how that works we have an idea
01:38
there's satellites in space and they
01:40
sort of we talk to them and then they we
01:42
know where we are but how does that work
01:44
and so that's what I'm going to talk
01:46
about in 15 minutes kind of try to get
01:48
the idea across of how does that work
01:51
how do we actually get a location from
01:53
GPS and then also if we have a little
01:55
time left we can talk a little bit about
01:57
why is that location always awful why is
01:59
it always oh my you're uber driver is
02:01
gonna be here in four minutes no
02:03
actually 15 minutes no actually he's
02:04
already there so where do these problems
02:07
come from and maybe if we understand
02:09
that we can deal with that a little bit
02:10
better right up
02:11
our applications okay so GPS is a system
02:15
of 24 satellites that orbit the Earth at
02:19
20,000 kilometers and is a system
02:22
designed so that at least four of those
02:24
satellites are visible at any given time
02:28
okay that's nice so we shoot satellites
02:31
into space so how do we determine our
02:34
position using these satellites and
02:36
that's basically just four steps one is
02:39
we have to find satellites at least four
02:42
of them hence the system being designed
02:45
to show it at a minimum four satellites
02:47
at any given time second we need to find
02:51
out where they are third we need to find
02:55
out how far away we are from them and
02:57
then we use the magic of trilateration
03:00
to calculate where we are and I actually
03:03
want to start with step four with
03:04
trilateration because when we understand
03:07
trilateration we understand why these
03:08
other three steps are necessary so
03:11
simple example of trilateration I'm
03:13
gonna do this in 2d because 2 D is much
03:16
more much more easy to understand than
03:18
3d so let's say I want to know where I
03:20
am and I'm calling a friend of mine who
03:24
lives in Mach 2 book and I'm asking him
03:26
hey do you know where I am and you can
03:28
already see this a very practical
03:29
real-life example and he's telling me I
03:32
don't know where you are but I do for
03:34
some reason know that you are 128
03:36
kilometers away from me I mean we've all
03:39
had those phone calls right what that
03:41
means and at that point is I don't know
03:43
still don't know where I am but I know I
03:45
must be somewhere on that red circle
03:47
because those are the only places in the
03:49
world that are 128 kilometers away from
03:51
octa book okay so that helps me somewhat
03:54
but not enough so I call another friend
03:55
he leaves them sniffing and I ask him do
03:58
you know where I am and he says no but I
04:01
happen to know you're 127 kilometers
04:03
away from me and that actually helps a
04:06
lot because now we can only be in two
04:08
spots anymore the two spots were those
04:11
two circles intersect so I call another
04:14
friend he lives in Corpus and once again
04:16
I asked him the question do you know
04:17
where I am and he says no but I happen
04:19
to know you are 107 kilometers away from
04:21
me and so I draw another circle
04:24
and now very very conveniently there's
04:27
only one spot where those three circles
04:29
intersect and in that case I would be in
04:31
Berlin which is where I normally live
04:33
now if you imagine this with an added
04:37
dimension and you imagine our friends as
04:40
being satellites and you imagine those
04:43
circle those circles actually being
04:45
spheres around the satellites and then
04:48
you can also see one satellite another
04:50
satellite another satellite another
04:52
satellite with the added dimension we
04:54
obviously need another satellite then
04:56
those spheres would only intersect in
04:58
one point so here's the thing though
05:01
there's only three satellites on this
05:03
picture and you actually only need three
05:05
any idea why
05:09
coming in yes so there I don't know if I
05:14
understood it correctly but the answer
05:15
is of course you get two positions based
05:17
on this but one of them is out in space
05:19
so unless you're an astronaut like this
05:21
fellow up there it's probably the one
05:24
that's on earth or another way to look
05:26
at it the earth is conveniently round
05:28
you can just use the earth as the fourth
05:30
sphere we actually do need four
05:32
satellites but we need them later and
05:34
we'll see why okay so we understand
05:37
trilateration basically just circles and
05:39
spheres and intersections and everything
05:41
is fine so now we kind of understand
05:44
what we need for satellites so we can do
05:46
those spheres we need to figure out
05:48
where they are so we know where to draw
05:50
the spheres around we need to figure out
05:51
they're in Mach Tabuk or called puss or
05:53
whatever or wherever and we need to
05:55
figure out how far away they are from us
05:57
so we know what the diameter of the
05:59
sphere is so let's figure out how we can
06:01
do those three things first we have to
06:05
find the four satellites and very
06:06
conveniently those satellites
06:07
permanently send out a signal so they're
06:11
saying hello to us all the time all we
06:12
need is a receiver that can read and
06:14
understand that signal and in our
06:16
Android phones very conveniently that
06:17
receivers already provide it so easy
06:21
checkmark also very good when you only
06:23
have 15 minutes and need to go through
06:25
it quickly it's always nice when some of
06:26
those points are easy to explain
06:28
determine their position it's a little
06:32
bit more tricky but again fortunately
06:34
the satellites like my friends actually
06:36
know where they are the GPS signal
06:38
that they're sending out contains a
06:40
whole bunch of information like date and
06:41
time and if the how well the satellites
06:44
feeling if you should trust it or not
06:46
and it contains two other things one is
06:48
called ephemeris which is the Greek word
06:50
for diary and the other is called
06:52
Almanac which is basically a a yearbook
06:57
and the ephemeris data essentially is
06:60
contains the location of where the
07:02
satellite is they've got pretty stable
07:04
orbits so they generally know where they
07:05
are anyway and they're monitored by
07:07
ground stations and the ground stations
07:08
can - can give them information as well
07:11
so the satellite actually knows where it
07:14
is the Almanac also has information
07:17
course location on all of the other
07:19
satellites and a bunch of other
07:21
information including an ionospheric
07:23
model which will become useful later
07:25
here's a really interesting thing about
07:27
this though it takes forever to transmit
07:29
that data it's sent at a really slow
07:32
data rate to get this whole data takes
07:35
12 minutes and you if you have a GPS
07:38
receiver that's cold which is it has no
07:42
idea where it is
07:42
I had as no information about where
07:44
satellites are it literally would take
07:47
12 minutes to get a fix in the worst
07:50
case now the reason why our Android
07:52
device always gets a quick fix is you
07:57
can just download that information over
07:58
the Internet that's called a GPS or a
08:00
GNSS so you don't actually need that
08:03
information from the satellites you can
08:04
just download it off the internet if you
08:06
happen to have an internet connection
08:07
which again conveniently our Android
08:09
phones usually have okay very nice
08:12
another check mark we can determine
08:14
their position now comes the harder part
08:16
figuring out how far away they are from
08:19
us and we need to do this very very
08:21
precisely now
08:24
satellites GPS satellites are really
08:27
just atomic clocks we've shot into space
08:29
so they know what time it is very very
08:32
precisely and they send a signal to us
08:36
and so what we could do is we could
08:40
figure out what time it was when the
08:41
signal was sent what time it is when I
08:43
receive the signal and then just you
08:46
know single get send at the speed of
08:47
light distance is time to unbar we can
08:51
just figure
08:52
out how long that single was traveling
08:54
and then we know the distance because we
08:56
know how fast it is traveling very cool
08:59
right done anyone see the problem that
09:04
is correct
09:05
our Android phone unfortunately does not
09:07
happen to Tommy clock built in because
09:09
if it did it would be much bigger and
09:10
much more expensive so this
09:13
unfortunately doesn't work it's a good
09:16
idea though and there's one thing you
09:18
might notice one thing is that all of
09:22
the signals and getting all of the
09:23
distances I'm measuring this way to the
09:26
signals are all off by the same way like
09:29
my clock on my phone is off it's not
09:31
precise it's not synchronized with the
09:33
satellites but the satellites are all
09:35
very very precise and therefore
09:36
synchronized and that means it is all
09:39
off by the same amount that's what's
09:42
called a pseudo range I don't exactly
09:44
know what the range is but it's wrong in
09:47
the same way which is really convenient
09:49
because if I can determine what that
09:51
offset is that that the way in which it
09:54
is wrong is I would get the correct
09:56
distance to all satellites and this is
09:59
actually where the fourth satellite
10:00
comes in because as it happens when I
10:03
use four satellites those when I pick
10:06
the right offset only then do those four
10:09
spheres align in one spot now this ends
10:13
up being a huge mathematical equation
10:15
and in fact that mathematical equation
10:18
is so long that it's also not on my
10:20
one-hour talk slides so we'll just skip
10:23
over this conveniently not bother with
10:24
the math too much and just realize that
10:26
that actually works you can solve this
10:28
with math and that is why you need four
10:31
satellites because you can use the earth
10:32
for that cool so we actually have we
10:36
found four satellites we've determined
10:38
their position we know how far away they
10:40
are from us and now I just do
10:42
trilateration like we did earlier and
10:45
that calculation is actually fairly
10:46
simple and I can get a position now if
10:51
it is so easy why does my uber driver
10:53
still can constantly hop around the map
10:56
and I get a wrong wrong location why is
10:58
this also imprecise
10:59
well by its nature GPS is only accurate
11:02
to be about five meters in the
11:05
stiff conditions and that usually the
11:09
best of conditions you don't have so
11:12
let's look at what not non-ideal
11:15
conditions are what are some things that
11:17
affect GPS I need to hurry up because
11:19
I've got less than five minutes but this
11:21
is really cool I left this in because
11:23
GPS is effect actually affected by
11:25
relativity theory because as it turns
11:29
out both by special and by general
11:31
relativity because it turns out the
11:33
satellites move really really quickly
11:34
fourteen thousand kilometers an hour and
11:37
that means they actually move faster
11:39
than the clocks on the ground and that
11:41
means they actually run slower by seven
11:44
microseconds every day and gravity also
11:47
alters time and they're further away
11:49
from the planet so there's less gravity
11:51
so actually run faster by around 45
11:53
microseconds a day which means they're
11:55
off by I bunt do the math in my head
11:59
because I forgot what the numbers work
11:60
but those couple of microseconds that it
12:03
that it ends up running wrong adds up to
12:05
11 kilometers a day so the clocks act
12:09
are actually set to run slower than
12:12
they're supposed to be to compensate for
12:15
that that won't really affect you every
12:17
day because the clocks are set to
12:19
compensate there but it's so cool I just
12:20
have to talk about it because and and
12:22
your your physics teacher will probably
12:24
really enjoy the fact that you're using
12:26
relativity theory every day in your life
12:28
another thing that affects it is the
12:30
ionosphere there is a charged layer of
12:34
the atmosphere that actually bends the
12:36
the radio signal which is also why the
12:39
satellite has some ionosphere weather
12:41
reports so you can compensate for that a
12:43
little bit but it's kind of an imprecise
12:45
science and so depending on how the
12:47
weather is in the ionosphere the signal
12:49
will be worse or better not much you can
12:51
do about it except maybe to get a better
12:53
ionosphere weather report but the thing
12:56
that very often really affects you on an
12:58
everyday basis particularly when you're
13:00
calling a cab in Manhattan our multipath
13:03
and reflection errors turns out that
13:07
first satellites are easily blocked we
13:10
all know in a building we don't get GPS
13:12
so if there's a satellite I would see in
13:14
the sky but there's a building in front
13:15
of it I don't see it and so suddenly I
13:17
have fewer satellites and the fewer
13:18
satellites I have
13:19
the more difficult that equation gets to
13:21
solve and the the less precise it is and
13:23
sometimes I might not even see the four
13:25
satellites or more satellites because
13:27
there's so much obstruction but it gets
13:29
worse if I have a big glass building the
13:32
signal might actually bounce off the
13:33
building so I get a single but it
13:35
traveled a longer path than I thought it
13:37
did and that also means I get a wrong
13:40
position and there's a lot to talk about
13:43
for all of these kinds of things but my
13:45
time I think is about up so I just hope
13:48
this was kind of interesting for you you
13:49
learned one interesting thing today
13:51
which is how GPS which you use every day
13:53
which you probably all used to get here
13:55
today how that actually works in
13:57
principle and maybe a little bit about
13:59
the problem so when you use it in your
14:01
apps you or have a little bit better
14:02
understanding of what goes wrong even if
14:04
it's not necessarily a solution and
14:06
here's a picture of a dinosaur thank you
14:08
very much
14:09
[Applause]
droidcon News

Tech Showcases,

Developer Resources &

Partners

/portal/rest/jcr/repository/collaboration/Groups/spaces/droidcon_hq/Documents/public/home-details/EmployerBrandingHeader
EmployerBrandingHeader
https://jobs.droidcon.com/
/portal/rest/jcr/repository/collaboration/Groups/spaces/droidcon_hq/Documents/public/employerbranding/jobs-droidcon/jobs.droidcon.com
jobs.droidcon.com

Latest Android Jobs

http://www.kotlinweekly.net/
/portal/rest/jcr/repository/collaboration/Groups/spaces/droidcon_hq/Documents/public/employerbranding/kotlin-weekly/Kotlin Weekly
Kotlin Weekly

Your weekly dose of Kotlin

https://proandroiddev.com/
/portal/rest/jcr/repository/collaboration/Groups/spaces/droidcon_hq/Documents/public/employerbranding/pad/ProAndroidDev
ProAndroidDev

Android Tech Blogs, Case Studies and Step-by-Step Coding

/detail?content-id=/repository/collaboration/Groups/spaces/droidcon_hq/Documents/public/employerbranding/Zalando/Zalando
/portal/rest/jcr/repository/collaboration/Groups/spaces/droidcon_hq/Documents/public/employerbranding/Zalando/Zalando
Zalando

Meet one of Berlin's top employers

/detail?content-id=/repository/collaboration/Groups/spaces/droidcon_hq/Documents/public/employerbranding/Academy for App Success/Academy for App Success
/portal/rest/jcr/repository/collaboration/Groups/spaces/droidcon_hq/Documents/public/employerbranding/Academy for App Success/Academy for App Success
Academy for App Success

Google Play resources tailored for the global droidcon community

Follow us

Team droidcon

Get in touch with us

Write us an Email

 

 

Quicklinks

> Code of Conduct

> Terms and Conditions

> How to hold a conference

> FAQs

> Imprint

Droidcon is a registered trademark of Mobile Seasons GmbH Copyright © 2020. All rights reserved.

powered by Breakpoint One