Upload
ferdinand-goodwin
View
213
Download
0
Tags:
Embed Size (px)
Citation preview
www.buildwindows.com
Using location & sensors in your app
Gavin GearProgram ManagerMicrosoft Corporation
PLAT-781T
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
www.buildwindows.com
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
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)
Building location-aware apps
www.buildwindows.com
NearMe Location-Aware App
demo
www.buildwindows.com
The world is a big place.Your app can help make it smaller.
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
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)
Declare the need for Geolocation
// Application manifest capabilities required // to access Geolocation & Camera in your app
<Capabilities> <DeviceCapability Name="webcam" /> <DeviceCapability Name=“location" /></Capabilities>
www.buildwindows.com
Location-based user experience
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;}
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;}
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
Everyday sensor apps
www.buildwindows.com
Labyrinth game demo
demo
www.buildwindows.com
Most apps can benefit from sensors.
www.buildwindows.com
Basic app scenarios for sensors
RotateShake Flip
www.buildwindows.com
Light-aware apps – render for lighting
Dark
Indoors
Outdoors
www.buildwindows.com
Intermediate motion sensor scenarios
• Casual games• Labyrinth: Accelerometer• Gyro for twisting response
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
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;}
www.buildwindows.com
Microsoft interns using sensors in their apps
video
Sensor Fusion
www.buildwindows.com
Metro steering wheelSimple3DApp
demo
www.buildwindows.com
The whole is greater than the sum of the parts.
www.buildwindows.com
What is Sensor Fusion?The process of using multiple sensor
inputs to enhance or synthesize sensor outputs.
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
www.buildwindows.com
Sensor Fusion app scenarios
• Inclinometer: • Steering wheel input for game
• Device Orientation:• Augmented reality
control• First person style games
www.buildwindows.com
Device orientation - quaternion
X+
Y+Z+
�⃗�α
Vector Rotation
=𝑤+ (𝑥 , 𝑦 ,𝑧 )=¿cos (𝛼2 )+�⃗�sin(𝛼2 )
αx, y, z
www.buildwindows.com
Device orientation – using quaternion
DirectX ObjectDirectX MathQuaternion
Sensor Data Transform Data Apply to Environment
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)";}
Recap
www.buildwindows.com
Windows 8 empowers you to build apps that can seamlessly adapt to your
customers 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
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
www.buildwindows.com
Further reading and documentation• Whitepapers:• Detecting geolocation• Responding to motion & orientation sensors• Responding to light• Guidelines and checklist for sensors• Introduction to Background Tasks (Location)
• Contact info: Location – [email protected]• Contact info: Sensors – [email protected]
www.buildwindows.com
• Feedback and questions http://forums.dev.windows.com
• Session feedbackhttp://bldw.in/SessionFeedback
thank you
© 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.