410 likes | 596 Views
PLAT-781T. Using location & sensors in your app. Gavin Gear Program Manager Microsoft Corporation. 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
E N D
PLAT-781T Using location & sensors in your app Gavin Gear Program Manager Microsoft Corporation
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
Windows 8 empowers you to build apps that can seamlessly adapt to your customer’s environment using sensors and location.
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
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)
demo NearMe Location-Aware App
The world is a big place. Your app can help make it smaller.
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
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" /> • <DeviceCapabilityName=“location" /> • </Capabilities>
GeoLocation – Single-Shot • varloc; • loc = new Windows.Devices.Geolocation.Geolocator(); • loc.getGeopositionAsync().then(getPositionHandler); • function getPositionHandler(pos) { • varlat = pos.coordinate.latitude; • var long = pos.coordinate.longitude; • varacc = pos.coordinate.accuracy; • }
GeoLocation – Event-Based • varloc; • loc = new Windows.Devices.Geolocation.Geolocator(); • loc.addEventListener("positionchanged", onPositionChanged); • function onPositionChanged(args) { • varpos = args.position; • varlat = pos.coordinate.latitude; • var long = pos.coordinate.longitude; • varacc = pos.coordinate.accuracy; • }
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
demo Labyrinth game demo
Basic app scenarios for sensors Shake Rotate Flip
Light-aware apps – render for lighting Dark Indoors Outdoors
Intermediate motion sensor scenarios • Casual games • Labyrinth: Accelerometer • Gyro for twisting response
Windows.Devices.Sensors Namespace Simple Data Simple Device Orientation Raw Sensor Data Light Sensor Accelerometer Gyro Sensor Fusion Data Compass Inclinometer Device Orientation
Accelerometer Sample Code • var accelerometer; • accelerometer = Windows.Devices.Sensors.Accelerometer.getDefault(); • accelerometer.addEventListener("readingchanged",onAccReadingChanged); • function onAccReadingChanged(e) { • varaccelX = e.reading.accelerationX; • varaccelY = e.reading.accelerationY; • varaccelZ = e.reading.accelerationZ; • }
video Microsoft interns using sensors in their apps
demo Metro steering wheelSimple3DApp
The whole is greater than the sum of the parts.
What is Sensor Fusion? The process of using multiple sensor inputs to enhance or synthesize sensor outputs.
Sensor Fusion inputs and outputs (9-Axis) Accelerometer 3D Accelerometer Pass-Through 3D Gyro Gyro 3D Magnetometer Sensor Fusion Compass Inclinometer Device Orientation
Sensor Fusion app scenarios • Inclinometer: • Steering wheel input for game • Device Orientation: • Augmented reality control • First person style games
Device orientation - quaternion α x, y, z α Y+ Z+ Vector Rotation = X+
Device orientation – using quaternion Quaternion DirectX Math DirectX Object Apply to Environment Transform Data Sensor Data
Inclinometer Code – Rotating an Element • inclinometer = Windows.Devices.Sensors.Inclinometer.getDefault(); • inclinometer.reportInterval = 50; • reading = inclinometer.getCurrentReading(); • initialYaw = reading.yawDegrees; • inclinometer.addEventListener("readingchanged",onInclReadingChanged); • function onInclReadingChanged(e) { • vardeltaAngle = initialYaw– e.reading.yawDegrees; • varel = document.getElementById("el"); • el.style.msTransform= "rotate(" + deltaAngle.toFixed(4) + "deg)"; • }
Windows 8 empowers you to build apps that can seamlessly adapt to your customers environment using sensors and location.
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
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
Further reading and documentation • Whitepapers: • Detecting geolocation • Responding to motion & orientationsensors • Responding to light • Guidelines and checklist for sensors • Introduction to Background Tasks (Location) • Contact info: Location – locext@microsoft.com • Contact info: Sensors – sensext@microsoft.com
thank you Feedback and questions http://forums.dev.windows.com Session feedbackhttp://bldw.in/SessionFeedback
© 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.