41
www.buildwindows.com Using location & sensors in your app Gavin Gear Program Manager Microsoft Corporation PLAT-781T

Windows 8 empowers you to build apps that can seamlessly adapt to your customer’s environment using sensors and location

Embed Size (px)

Citation preview

Page 1: Windows 8 empowers you to build apps that can seamlessly adapt to your customer’s environment using sensors and location

www.buildwindows.com

Using location & sensors in your app

Gavin GearProgram ManagerMicrosoft Corporation

PLAT-781T

Page 2: Windows 8 empowers you to build apps that can seamlessly adapt to your customer’s environment using sensors and location

www.buildwindows.com

Agenda• Location and sensor experiences• Building location-aware apps• Everyday sensor apps• Sensor fusion in Windows 8

You’ll leave with examples of how to• Effectively use location and sensors in your

apps• Innovate with the latest sensor technology

Page 3: Windows 8 empowers you to build apps that can seamlessly adapt to your customer’s environment using sensors and location

www.buildwindows.com

Windows 8 empowers you to build apps that can seamlessly adapt to your

customer’s environment using sensors and location.

Page 4: Windows 8 empowers you to build apps that can seamlessly adapt to your customer’s environment using sensors and location

www.buildwindows.com

With sensors & location platform

• Simple interfaces enable Metro style apps to adapt to the surrounding environment

• Sensor fusion opens up new possibilities for creating cutting edge experiences in Metro style apps

• Windows 8 provides a consistent sensors and location hardware foundation

• Windows 8 ensures consistency between different systems to ensure that apps just work

Page 5: Windows 8 empowers you to build apps that can seamlessly adapt to your customer’s environment using sensors and location

www.buildwindows.com

Windows 8 supports the latest sensors

• Tablet and convertible standard equipment:• Ambient Light Sensor• Motion Sensor Fusion

(Accelerometer, Magnetometer, Gyroscope)• Windows Location Provider• GPS (If mobile broadband hardware is present)

Page 6: Windows 8 empowers you to build apps that can seamlessly adapt to your customer’s environment using sensors and location

Building location-aware apps

Page 7: Windows 8 empowers you to build apps that can seamlessly adapt to your customer’s environment using sensors and location

www.buildwindows.com

NearMe Location-Aware App

demo

Page 8: Windows 8 empowers you to build apps that can seamlessly adapt to your customer’s environment using sensors and location

www.buildwindows.com

The world is a big place.Your app can help make it smaller.

Page 9: Windows 8 empowers you to build apps that can seamlessly adapt to your customer’s environment using sensors and location

www.buildwindows.com

Single-shot location scenarios

• Search points of interest (POI)• Geo-tag photos and other content• Basic mapping application• Local info apps (weather, news, sports, …)• Social networking check-in

Page 10: Windows 8 empowers you to build apps that can seamlessly adapt to your customer’s environment using sensors and location

www.buildwindows.com

Event-based location scenarios

• Navigation• Real-time location-aware notifications• Location-aware tasks• Virtual tour guide• Local ads/coupons

• Auto checkout (social networking)

Page 11: Windows 8 empowers you to build apps that can seamlessly adapt to your customer’s environment using sensors and location

Declare the need for Geolocation

// Application manifest capabilities required // to access Geolocation & Camera in your app

<Capabilities>    <DeviceCapability Name="webcam" /> <DeviceCapability Name=“location" /></Capabilities>

Page 12: Windows 8 empowers you to build apps that can seamlessly adapt to your customer’s environment using sensors and location

www.buildwindows.com

Location-based user experience

Page 13: Windows 8 empowers you to build apps that can seamlessly adapt to your customer’s environment using sensors and location

GeoLocation – Single-Shot

var loc;loc = new Windows.Devices.Geolocation.Geolocator();loc.getGeopositionAsync().then(getPositionHandler);

function getPositionHandler(pos) { var lat = pos.coordinate.latitude; var long = pos.coordinate.longitude; var acc = pos.coordinate.accuracy;}

Page 14: Windows 8 empowers you to build apps that can seamlessly adapt to your customer’s environment using sensors and location

GeoLocation – Event-Basedvar loc;loc = new Windows.Devices.Geolocation.Geolocator();loc.addEventListener("positionchanged", onPositionChanged);

function onPositionChanged(args) { var pos = args.position; var lat = pos.coordinate.latitude; var long = pos.coordinate.longitude; var acc = pos.coordinate.accuracy;}

Page 15: Windows 8 empowers you to build apps that can seamlessly adapt to your customer’s environment using sensors and location

www.buildwindows.com

W3C API and Windows API comparison

• Metro style apps can use W3C or Windows Runtime• Differences:• W3C: maximum age• Windows: movement threshold, status• Windows supports multiple languages• JavaScript, C++, C#• W3C – JavaScript only

Page 16: Windows 8 empowers you to build apps that can seamlessly adapt to your customer’s environment using sensors and location

Everyday sensor apps

Page 17: Windows 8 empowers you to build apps that can seamlessly adapt to your customer’s environment using sensors and location

www.buildwindows.com

Labyrinth game demo

demo

Page 18: Windows 8 empowers you to build apps that can seamlessly adapt to your customer’s environment using sensors and location

www.buildwindows.com

Most apps can benefit from sensors.

Page 19: Windows 8 empowers you to build apps that can seamlessly adapt to your customer’s environment using sensors and location

www.buildwindows.com

Basic app scenarios for sensors

RotateShake Flip

Page 20: Windows 8 empowers you to build apps that can seamlessly adapt to your customer’s environment using sensors and location

www.buildwindows.com

Light-aware apps – render for lighting

Dark

Indoors

Outdoors

Page 21: Windows 8 empowers you to build apps that can seamlessly adapt to your customer’s environment using sensors and location

www.buildwindows.com

Intermediate motion sensor scenarios

• Casual games• Labyrinth: Accelerometer• Gyro for twisting response

Page 22: Windows 8 empowers you to build apps that can seamlessly adapt to your customer’s environment using sensors and location

www.buildwindows.com

Windows.Devices.Sensors Namespace

Simple Device Orientation

Simple Data

Accelerometer

Gyro

Light Sensor

Raw Sensor Data

Inclinometer

Device Orientation

Compass

Sensor Fusion Data

Page 23: Windows 8 empowers you to build apps that can seamlessly adapt to your customer’s environment using sensors and location

Accelerometer Sample Code

var accelerometer;accelerometer = Windows.Devices.Sensors.Accelerometer.getDefault();accelerometer.addEventListener("readingchanged",onAccReadingChanged);

function onAccReadingChanged(e) { var accelX = e.reading.accelerationX; var accelY = e.reading.accelerationY; var accelZ = e.reading.accelerationZ;}

Page 24: Windows 8 empowers you to build apps that can seamlessly adapt to your customer’s environment using sensors and location

www.buildwindows.com

Microsoft interns using sensors in their apps

video

Page 25: Windows 8 empowers you to build apps that can seamlessly adapt to your customer’s environment using sensors and location

Sensor Fusion

Page 26: Windows 8 empowers you to build apps that can seamlessly adapt to your customer’s environment using sensors and location

www.buildwindows.com

Metro steering wheelSimple3DApp

demo

Page 27: Windows 8 empowers you to build apps that can seamlessly adapt to your customer’s environment using sensors and location

www.buildwindows.com

The whole is greater than the sum of the parts.

Page 28: Windows 8 empowers you to build apps that can seamlessly adapt to your customer’s environment using sensors and location

www.buildwindows.com

What is Sensor Fusion?The process of using multiple sensor

inputs to enhance or synthesize sensor outputs.

Page 29: Windows 8 empowers you to build apps that can seamlessly adapt to your customer’s environment using sensors and location

www.buildwindows.com

Sensor Fusion inputs and outputs (9-Axis)

Pass-Through

Accelerometer3D Accelerometer

3D Gyro

3D Magnetometer

Sensor Fusion

Gyro

Compass

Inclinometer

Device Orientation

Page 30: Windows 8 empowers you to build apps that can seamlessly adapt to your customer’s environment using sensors and location

www.buildwindows.com

Sensor Fusion app scenarios

• Inclinometer: • Steering wheel input for game

• Device Orientation:• Augmented reality

control• First person style games

Page 31: Windows 8 empowers you to build apps that can seamlessly adapt to your customer’s environment using sensors and location

www.buildwindows.com

Device orientation - quaternion

X+

Y+Z+

�⃗�α

Vector Rotation

=𝑤+ (𝑥 , 𝑦 ,𝑧 )=¿cos (𝛼2 )+�⃗�sin(𝛼2 )

αx, y, z

Page 32: Windows 8 empowers you to build apps that can seamlessly adapt to your customer’s environment using sensors and location

www.buildwindows.com

Device orientation – using quaternion

DirectX ObjectDirectX MathQuaternion

Sensor Data Transform Data Apply to Environment

Page 33: Windows 8 empowers you to build apps that can seamlessly adapt to your customer’s environment using sensors and location

Inclinometer Code – Rotating an Elementinclinometer = Windows.Devices.Sensors.Inclinometer.getDefault();inclinometer.reportInterval = 50;reading = inclinometer.getCurrentReading();initialYaw = reading.yawDegrees;

inclinometer.addEventListener("readingchanged",onInclReadingChanged);

function onInclReadingChanged(e) { var deltaAngle = initialYaw – e.reading.yawDegrees; var el = document.getElementById("el");

el.style.msTransform = "rotate(" + deltaAngle.toFixed(4) + "deg)";}

Page 34: Windows 8 empowers you to build apps that can seamlessly adapt to your customer’s environment using sensors and location

Recap

Page 35: Windows 8 empowers you to build apps that can seamlessly adapt to your customer’s environment using sensors and location

www.buildwindows.com

Windows 8 empowers you to build apps that can seamlessly adapt to your

customers environment using sensors and location.

Page 36: Windows 8 empowers you to build apps that can seamlessly adapt to your customer’s environment using sensors and location

www.buildwindows.com

With sensors & location platform

• Simple interfaces enable Metro style apps to adapt to the surrounding environment

• Sensor fusion opens up new possibilities for creating cutting edge experiences in Metro style apps

• Windows 8 provides a consistent sensors and location hardware foundation

• Windows 8 ensures consistency between different systems to ensure that apps just work

Page 37: Windows 8 empowers you to build apps that can seamlessly adapt to your customer’s environment using sensors and location

www.buildwindows.com

Related sessions

• [HW-774T] Building great Windows 8 systems

• [HW-249T] Architecting and integrating sensor drivers

• [PLAT-754T] From touch to gamepads: master player input in your Metro style game

Page 39: Windows 8 empowers you to build apps that can seamlessly adapt to your customer’s environment using sensors and location

www.buildwindows.com

• Feedback and questions http://forums.dev.windows.com

• Session feedbackhttp://bldw.in/SessionFeedback

thank you

Page 40: Windows 8 empowers you to build apps that can seamlessly adapt to your customer’s environment using sensors and location

© 2011 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries.The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to

be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

Page 41: Windows 8 empowers you to build apps that can seamlessly adapt to your customer’s environment using sensors and location