programming mobile devices - sti-innsbruck.at...lecture programming mobile devices, thomas strang,...

31
Programming Mobile Devices Location and Location-Awareness University of Innsbruck WS 2009/2010 [email protected]

Upload: others

Post on 19-Aug-2020

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Programming Mobile Devices - sti-innsbruck.at...Lecture Programming Mobile Devices, Thomas Strang, WS 2009/2010 4. Geometric Coordinates Earth. e.g. Innsbruck Airport at. N 47° 15.6

Programming Mobile DevicesLocation and Location-Awareness

University of InnsbruckWS 2009/2010

[email protected]

Page 2: Programming Mobile Devices - sti-innsbruck.at...Lecture Programming Mobile Devices, Thomas Strang, WS 2009/2010 4. Geometric Coordinates Earth. e.g. Innsbruck Airport at. N 47° 15.6

Lect

ure

Prog

ram

min

gM

obile

Dev

ices

, Th

omas

Str

ang,

WS

2009

/201

0

2

Device Mobility

MIDP: Mobile Information Device Profile

Degree of mobility of a device is determined by

its size, its weight and its battery endurance

Portable devices are most of the time stationary, but can be moved

Notebooks, Point-of-Sales (POS) terminals etc.

Mobile devices are moved around all the day

PDAs, mobile phones, pagers, whatches etc.

Objective: Opportunity rather than challenge.

Page 3: Programming Mobile Devices - sti-innsbruck.at...Lecture Programming Mobile Devices, Thomas Strang, WS 2009/2010 4. Geometric Coordinates Earth. e.g. Innsbruck Airport at. N 47° 15.6

Lect

ure

Prog

ram

min

gM

obile

Dev

ices

, Th

omas

Str

ang,

WS

2009

/201

0

3

Device Position

Position of a device is a projection to a position reference system (geometric or symbolic)

Mobility is driving force for the dynamics of this kind of projection

Typical reference systemsGeometric

WGS84Gauß-Krüger

Germany, Austria

SymbolicFloorplans etc."Virtual Numbers" such as CellIDs

Page 4: Programming Mobile Devices - sti-innsbruck.at...Lecture Programming Mobile Devices, Thomas Strang, WS 2009/2010 4. Geometric Coordinates Earth. e.g. Innsbruck Airport at. N 47° 15.6

Lect

ure

Prog

ram

min

gM

obile

Dev

ices

, Th

omas

Str

ang,

WS

2009

/201

0

4

Geometric Coordinates

Earth

e.g. Innsbruck Airport atN 47° 15.6' E 11° 20.6' 579m(latitude) (longitude) (altitude)

Page 5: Programming Mobile Devices - sti-innsbruck.at...Lecture Programming Mobile Devices, Thomas Strang, WS 2009/2010 4. Geometric Coordinates Earth. e.g. Innsbruck Airport at. N 47° 15.6

Lect

ure

Prog

ram

min

gM

obile

Dev

ices

, Th

omas

Str

ang,

WS

2009

/201

0

5

Geoid vs. Ellipsoid

[in parts from Kuhn, 2003]

Geoid

WGS84 uses Geoid instead of Ellipsoid

Page 6: Programming Mobile Devices - sti-innsbruck.at...Lecture Programming Mobile Devices, Thomas Strang, WS 2009/2010 4. Geometric Coordinates Earth. e.g. Innsbruck Airport at. N 47° 15.6

Lect

ure

Prog

ram

min

gM

obile

Dev

ices

, Th

omas

Str

ang,

WS

2009

/201

0

6

Positioning Technologies

Global Navigation Satellite Systems (GNSS, outdoor)

Wide-Range Comm (outdoor, indoor)

Inertial (outdoor, indoor)

Short-Range Comm (indoor)

Light (indoor)

etc.

Page 7: Programming Mobile Devices - sti-innsbruck.at...Lecture Programming Mobile Devices, Thomas Strang, WS 2009/2010 4. Geometric Coordinates Earth. e.g. Innsbruck Airport at. N 47° 15.6

Lect

ure

Prog

ram

min

gM

obile

Dev

ices

, Th

omas

Str

ang,

WS

2009

/201

0

The determination of the 3 unknowns

XR, YR, ZR

requires the reception of the signalsof 3 navigation satellites

SatNav is based on the measurement of the propagation delay of the navigation signals from the satellite to the receiver δt1, δt2, δt3

Based on the measured delays, so-called „pseudo ranges“ between satellite and receiver are determined ρ1, ρ2, ρ3

ρ1

ρ2

ρ3

ρi = c δti

XR, YR, ZR

Principle of GNSS: Ranging

Page 8: Programming Mobile Devices - sti-innsbruck.at...Lecture Programming Mobile Devices, Thomas Strang, WS 2009/2010 4. Geometric Coordinates Earth. e.g. Innsbruck Airport at. N 47° 15.6

Lect

ure

Prog

ram

min

gM

obile

Dev

ices

, Th

omas

Str

ang,

WS

2009

/201

0

Determination of the 3 unknowns

XR, YR, ZR

by solving the navigation equation

ρ1ρ2

ρ3

Problem:

Receiver has to be synchronised to the satellites clocks` – this is impossible

Hence, the receiver‘s clock is offset with respect to the clocks of the satellites

A time uncertainty of 1 ns means 30 cm in distance (in 1 μs the signal travels 300 m) !

Navigation equation

[ ] [ ] [ ]

[ ] [ ] [ ]

[ ] [ ] [ ]

2 2 21 1 1 1

2 2 22 2 2 2

2 2 23 3 3

1

3

2

3

SAT SAT SAT

SAT SAT SAT

SAT SAT SA

R R R

R R R

R R RT

c X Y Z

c X Y Z

c X Y Z

X Y Z

X Y Z

X

t

t Z

t

Y

δ

δ

δ

ρ

ρ

ρ

− − −

− − −

− − −

⋅ = = − + − + −

⋅ = = − + − + −

⋅ = = − + − + −

XR, YR, ZR

Principle of GNSS: Ranging

Page 9: Programming Mobile Devices - sti-innsbruck.at...Lecture Programming Mobile Devices, Thomas Strang, WS 2009/2010 4. Geometric Coordinates Earth. e.g. Innsbruck Airport at. N 47° 15.6

Lect

ure

Prog

ram

min

gM

obile

Dev

ices

, Th

omas

Str

ang,

WS

2009

/201

0

Receiver measures δti . However, not ρi = c δti but ρi = c δti - δTR is obtainedReception of signals from 4 satellites to determine δTR δt1, δt2, δt3, δt4

4 „pseudo ranges“ are determined ρ1, ρ2, ρ3, ρ4

Determination of the 3 unknowns of the location and the receiver's clock

offset

XR, YR, ZR, δTRρ1

ρ2 ρ4ρ3

Navigation equation

[ ] [ ] [ ]

[ ] [ ] [ ]

[ ] [ ] [ ]

[ ] [ ] [ ]

1

2

3

4

2 2 21 1 1 1

2 2 22 2 2 2

2 2 23 3 3 3

2 2 24 4 4 4

SAT SAT SAT

SAT SA

R R

T SAT

SAT SAT SAT

SAT S

R R

R R R R

R R R R

R RAT S RAT R

c X Y Z c

c X Y Z c

c X Y Z c

X Y Z T

X Y Z T

X Y Z T

c X Y Z c

t

t

t X Y Z T

t

ρ δ

ρ δ

ρ δ

ρ

δ

δ

δ

δ δ

− − −

− − −

− − −

− − −

⋅ = = − + − + − +

⋅ = = − + − + − +

= = − + − + − +

⋅ = = − + − + − +

Principle of GNSS: Ranging

Page 10: Programming Mobile Devices - sti-innsbruck.at...Lecture Programming Mobile Devices, Thomas Strang, WS 2009/2010 4. Geometric Coordinates Earth. e.g. Innsbruck Airport at. N 47° 15.6

Lect

ure

Prog

ram

min

gM

obile

Dev

ices

, Th

omas

Str

ang,

WS

2009

/201

0

GNSS Error Sources

Page 11: Programming Mobile Devices - sti-innsbruck.at...Lecture Programming Mobile Devices, Thomas Strang, WS 2009/2010 4. Geometric Coordinates Earth. e.g. Innsbruck Airport at. N 47° 15.6

Lect

ure

Prog

ram

min

gM

obile

Dev

ices

, Th

omas

Str

ang,

WS

2009

/201

0

Dilution of Precision (DOP)

Good DOP value

Uncertainty

Bad DOP value

Indicator for Quality of Position Information

Page 12: Programming Mobile Devices - sti-innsbruck.at...Lecture Programming Mobile Devices, Thomas Strang, WS 2009/2010 4. Geometric Coordinates Earth. e.g. Innsbruck Airport at. N 47° 15.6

Lect

ure

Prog

ram

min

gM

obile

Dev

ices

, Th

omas

Str

ang,

WS

2009

/201

0

12

Global Navigation Satellite Systems (GNSS)

GPS

USA; military

GLONASS

Russia; military

GALILEO (in the Future)

Europe; civilian and public regulated

COMPASS (in the Future)

China

Page 13: Programming Mobile Devices - sti-innsbruck.at...Lecture Programming Mobile Devices, Thomas Strang, WS 2009/2010 4. Geometric Coordinates Earth. e.g. Innsbruck Airport at. N 47° 15.6

Lect

ure

Prog

ram

min

gM

obile

Dev

ices

, Th

omas

Str

ang,

WS

2009

/201

0

13

Assisted GPS (A-GPS)

[Wunderlich, 2002]

Page 14: Programming Mobile Devices - sti-innsbruck.at...Lecture Programming Mobile Devices, Thomas Strang, WS 2009/2010 4. Geometric Coordinates Earth. e.g. Innsbruck Airport at. N 47° 15.6

Lect

ure

Prog

ram

min

gM

obile

Dev

ices

, Th

omas

Str

ang,

WS

2009

/201

0

Higher availabilityin critical environments

Ele ?!

None Availability (NSAT<4)(24 h statistics for Lat = 47.5°, Lon=10°)

0

20

40

60

80

100

25° 30° 35° 40° 45° 50° 55°

Elevation (°)

Prob

abili

ty (%

)

GPSGALGNSS2

Twice the number of satellites compared to one system

GALILEO's Interoperability to GPS

Page 15: Programming Mobile Devices - sti-innsbruck.at...Lecture Programming Mobile Devices, Thomas Strang, WS 2009/2010 4. Geometric Coordinates Earth. e.g. Innsbruck Airport at. N 47° 15.6

Lect

ure

Prog

ram

min

gM

obile

Dev

ices

, Th

omas

Str

ang,

WS

2009

/201

0

15

Positioning Technologies

Global Navigation Satellite Systems (GNSS, outdoor)

Wide-Range Comm (outdoor, indoor)

Inertial (outdoor, indoor)

Short-Range Comm (indoor)

Light (indoor)

etc.

Page 16: Programming Mobile Devices - sti-innsbruck.at...Lecture Programming Mobile Devices, Thomas Strang, WS 2009/2010 4. Geometric Coordinates Earth. e.g. Innsbruck Airport at. N 47° 15.6

Lect

ure

Prog

ram

min

gM

obile

Dev

ices

, Th

omas

Str

ang,

WS

2009

/201

0

16

Gauß-Krüger

Gauß-Krüger-Grid is a metric, plane and rectangular coordinate system

consists of 3° wide stripes

every stripe is 1°30' left and 1°30' right of a "main meridian"

main meridians used in Germany are 3°E, 6°E, 9°E, 12°E, 15°E, 18°E and 21°E, numbered from 1 to 7

coordinates are expressed as "rechtswert" and "hochwert"

to avoid negative values in the x-axis, a value of 500 is added

Molodenski-Transformation used to transform GK into WGS84

Page 17: Programming Mobile Devices - sti-innsbruck.at...Lecture Programming Mobile Devices, Thomas Strang, WS 2009/2010 4. Geometric Coordinates Earth. e.g. Innsbruck Airport at. N 47° 15.6

Lect

ure

Prog

ram

min

gM

obile

Dev

ices

, Th

omas

Str

ang,

WS

2009

/201

0

17

Gauß-Krüger

How it is used:

The reference point of one of the sectors is 68,522 km (568,522 km – 500 km) in the east of the 2nd main meridian (6°E) and 5593,796 km north of the Equator.

120°

= 2568522 5593796

(Remark: O2 in Germany omits the last digit, i.e. would send 256852 559379)

"Rechtswert"

"Hochwert"

Page 18: Programming Mobile Devices - sti-innsbruck.at...Lecture Programming Mobile Devices, Thomas Strang, WS 2009/2010 4. Geometric Coordinates Earth. e.g. Innsbruck Airport at. N 47° 15.6

Lect

ure

Prog

ram

min

gM

obile

Dev

ices

, Th

omas

Str

ang,

WS

2009

/201

0

18

Positioning in Wide Area Networks (e.g. GSM)

The most simple approach – Cell-IDs:

Operator'sDatabase

Cell-ID receivedat the mobile

Area Estimation

Page 19: Programming Mobile Devices - sti-innsbruck.at...Lecture Programming Mobile Devices, Thomas Strang, WS 2009/2010 4. Geometric Coordinates Earth. e.g. Innsbruck Airport at. N 47° 15.6

Lect

ure

Prog

ram

min

gM

obile

Dev

ices

, Th

omas

Str

ang,

WS

2009

/201

0

19

Positioning in Wide Area Networks (e.g. GSM)

Page 20: Programming Mobile Devices - sti-innsbruck.at...Lecture Programming Mobile Devices, Thomas Strang, WS 2009/2010 4. Geometric Coordinates Earth. e.g. Innsbruck Airport at. N 47° 15.6

Lect

ure

Prog

ram

min

gM

obile

Dev

ices

, Th

omas

Str

ang,

WS

2009

/201

0

20Source: Supporting Location-Awareness in Open Distributed Systems, Ulf Leonhardt, May 1998

hard mapping

From Position to Location

Terminal A

Corridor 2Corridor 1

HelpDesk

Leonhardt's Semi-Symbolic Hierarchical Location Model

Page 21: Programming Mobile Devices - sti-innsbruck.at...Lecture Programming Mobile Devices, Thomas Strang, WS 2009/2010 4. Geometric Coordinates Earth. e.g. Innsbruck Airport at. N 47° 15.6

Lect

ure

Prog

ram

min

gM

obile

Dev

ices

, Th

omas

Str

ang,

WS

2009

/201

0

21

Making MIDlets location aware

Two common options (may be preceeded by additional steps to connect to positioning device):

a. evaluate NMEA sentences ("low level")

b. use the Location API for J2ME ("high level")

Page 22: Programming Mobile Devices - sti-innsbruck.at...Lecture Programming Mobile Devices, Thomas Strang, WS 2009/2010 4. Geometric Coordinates Earth. e.g. Innsbruck Airport at. N 47° 15.6

Lect

ure

Prog

ram

min

gM

obile

Dev

ices

, Th

omas

Str

ang,

WS

2009

/201

0

22

Option a: NMEA 0183

Want (almost) full access to raw data?talk NMEA to your device!

NMEA 0183 is a standard to transmit ASCII encoded data in "sentence"-like messages from a sender (i.e. a GPS receiver) to one or more receivers (e.g. your application)

used for position data, time/date, sat-info, direction etc. – even proprietary dataExample:

$GPGGA,060003,3348.784,N,11754.064,W,1,07,1.0,66.2,M,-31.9,M,,*45

Page 23: Programming Mobile Devices - sti-innsbruck.at...Lecture Programming Mobile Devices, Thomas Strang, WS 2009/2010 4. Geometric Coordinates Earth. e.g. Innsbruck Airport at. N 47° 15.6

Lect

ure

Prog

ram

min

gM

obile

Dev

ices

, Th

omas

Str

ang,

WS

2009

/201

0

23

NMEA 0183 (cont'd)

Example: GPRMC (GPS recommended minimum sentence C)$GPRMC,191410,A,4735.5634,N,00739.3538,E,0.0,0.0,181107,0.4,E,A*19^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^| | | | | | | | | | |GPS | | | | | | | | | Checksum

| | | | | | | | || | | | | | | | Mode (A,D,E,N,S)| | | | | | | || | | | | | | magnetic| | | | | | | Declination 0.4° E| | | | | | || | | | | | Date: 18.11.2007| | | | | | | | | | | true course (w/o move 0)| | | | | | | | | speed above ground (in Kt)| | | || | | 007° 39.3538' longitude (east)| | | | | 47° 35.5634' latitude (north)| || integrity, A = data OK, V = warning|timestamp of data: 19:14:10 UTC

Page 24: Programming Mobile Devices - sti-innsbruck.at...Lecture Programming Mobile Devices, Thomas Strang, WS 2009/2010 4. Geometric Coordinates Earth. e.g. Innsbruck Airport at. N 47° 15.6

Lect

ure

Prog

ram

min

gM

obile

Dev

ices

, Th

omas

Str

ang,

WS

2009

/201

0

24

Option b: Making MIDlets location aware

JSR-179 defined the Location API for J2ME to have a standard (high level) interface to location information for CLDC 1.1 based applications

all classes in javax.microedition.location

The hardware platform determines which location methods are supported

Page 25: Programming Mobile Devices - sti-innsbruck.at...Lecture Programming Mobile Devices, Thomas Strang, WS 2009/2010 4. Geometric Coordinates Earth. e.g. Innsbruck Airport at. N 47° 15.6

Lect

ure

Prog

ram

min

gM

obile

Dev

ices

, Th

omas

Str

ang,

WS

2009

/201

0

25

Location Provider

Applications can request a source of positioning information ("location provider") with particular characteristics (Criteria), such as

a minimum degree of accuracyresponse timeneed for altitudespeed

Once the application obtains a LocationProvider instance that meets the criteria, it can use that object to obtain the location, in either of two ways:

Invoke a method synchronously to get a single locationRegister a listener and get periodic updates at application-defined intervals

Page 26: Programming Mobile Devices - sti-innsbruck.at...Lecture Programming Mobile Devices, Thomas Strang, WS 2009/2010 4. Geometric Coordinates Earth. e.g. Innsbruck Airport at. N 47° 15.6

Lect

ure

Prog

ram

min

gM

obile

Dev

ices

, Th

omas

Str

ang,

WS

2009

/201

0

26

How the Location API integrates with MIDlets

[based on Image from Nokia]

sync

e.g.

Page 27: Programming Mobile Devices - sti-innsbruck.at...Lecture Programming Mobile Devices, Thomas Strang, WS 2009/2010 4. Geometric Coordinates Earth. e.g. Innsbruck Airport at. N 47° 15.6

Lect

ure

Prog

ram

min

gM

obile

Dev

ices

, Th

omas

Str

ang,

WS

2009

/201

0

27

Example of Location API – sync access

import javax.microedition.location.*;

try {

// Set criteria for selecting a location provider:Criteria cr = new Criteria(); cr.setHorizontalAccuracy(500); // min 500 m

// Get an instance of the provider lp = LocationProvider.getInstance(cr);

// Request the location, setting a one-minute timeout Location l = lp.getLocation(60); // sync (blocking)Coordinates c = l.getQualifiedCoordinates();

if (c != null ) { // Use coordinate information double lat = c.getLatitude(); double lon = c.getLongitude();

} //... }

catch (LocationException e) { System.err.println(e); }

Page 28: Programming Mobile Devices - sti-innsbruck.at...Lecture Programming Mobile Devices, Thomas Strang, WS 2009/2010 4. Geometric Coordinates Earth. e.g. Innsbruck Airport at. N 47° 15.6

Lect

ure

Prog

ram

min

gM

obile

Dev

ices

, Th

omas

Str

ang,

WS

2009

/201

0

28

Async Location Updatestime

setLocationListener(obj, interval, timeout, maxAge)obj.locationUpdate(lp, location)

LocationProvider().getInstance()

obj.locationUpdate(lp, location)

obj.locationUpdate(lp, location)

obj.locationUpdate(lp, location)

obj.locationUpdate(lp, location)

interval

interval

interval

interval

asap, but async

"time tofirst fix"

!location.isValid()

!location.isValid()

!location.isValid()

location.isValid()

location.isValid()

up to timeout late

up to timeout late

Page 29: Programming Mobile Devices - sti-innsbruck.at...Lecture Programming Mobile Devices, Thomas Strang, WS 2009/2010 4. Geometric Coordinates Earth. e.g. Innsbruck Airport at. N 47° 15.6

Lect

ure

Prog

ram

min

gM

obile

Dev

ices

, Th

omas

Str

ang,

WS

2009

/201

0

29

Proximity Notification

convenient method to get notified when 'near' a point of interest

LocationProvider.addProximityListener(obj, coordinates, radius_m)

obj.proximityEvent(coordinates, location)

"you are less than 50 m from an ATM"

Page 30: Programming Mobile Devices - sti-innsbruck.at...Lecture Programming Mobile Devices, Thomas Strang, WS 2009/2010 4. Geometric Coordinates Earth. e.g. Innsbruck Airport at. N 47° 15.6

Lect

ure

Prog

ram

min

gM

obile

Dev

ices

, Th

omas

Str

ang,

WS

2009

/201

0

30

Exercise 13 – determine position

Implement a MIDlet which synchronously checks the position of your device (using option b: Location API).

Print position to LCDUI

Helpful is the WTK External Event Generator (EEG)

activated at "MIDlet" menu in emulated phone

Page 31: Programming Mobile Devices - sti-innsbruck.at...Lecture Programming Mobile Devices, Thomas Strang, WS 2009/2010 4. Geometric Coordinates Earth. e.g. Innsbruck Airport at. N 47° 15.6

Lect

ure

Prog

ram

min

gM

obile

Dev

ices

, Th

omas

Str

ang,

WS

2009

/201

0

31

Exercise 14 – determine timezone for position

Implement a MIDlet which asynchronously monitors the position of your device (using option b: Location API).

Use a connection to the Internet to determine the timezone for the current position, e.g. utilize

http://www.earthtools.org/webservices.htm#timezone

Update the output of the timezone whenever the position has changed (make „jumps“ in position)