1 / 29

Android as a Platform for Sensor Fusion Education and Evaluation

Android as a Platform for Sensor Fusion Education and Evaluation . 2013 Sensors Expo & Conference. Michael Stanley. Manager, Systems/Algorithms Sensors & Actuators Solutions Division Freescale Semiconductor Mike.Stanley@freescale.com http://www.freescale.com/blogs/mikestanley. June 2013.

helene
Download Presentation

Android as a Platform for Sensor Fusion Education and Evaluation

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Android as a Platform for Sensor Fusion Education and Evaluation 2013 Sensors Expo & Conference Michael Stanley Manager, Systems/Algorithms Sensors & Actuators Solutions Division Freescale Semiconductor Mike.Stanley@freescale.com http://www.freescale.com/blogs/mikestanley June 2013

  2. Introduction – Who am I • Michael Stanley • Formal training is in electrical engineering • B.S.E. from Michigan State, 1980 • MS from Arizona State 1986 • Employed at Motorola / Freescale Semiconductor from June 1980 to the present, where I’ve had multiple careers: • Bipolar circuit design • CAD development • SoC Integration / MCU Architecture • Sensors Architecture / Algorithms / Product Definition • http://www.freescale.com/blogs/mikestanley

  3. Project Goals Development of sensor fusion algorithms has been underway at Freescale for quite some time. We needed: • An intuitive way of evaluating if our algorithms work as expected. i.e. a visualization tool • Quantitative ways of measuring sensor and algorithm performance • A way to teach our customers about the pros & cons of various fusion options • A way to teach our customers how to apply the results of sensor fusion to implement useful features • A fun way for our field team to demonstrate these features

  4. Sensor Fusion Block Diagram gyro reading Bluetooth Communications X, Y & Z 9-axis Indirect Kalman Filter Convert to quaternion Frame of Reference Mapping Gyro Accelerometer 9-axis quaternion Magnetometer hard/soft iron compensation compute hard/soft iron compensation coefficients accelerometer reading compensated mag reading 6-axis quaternion 6-axis solution • Code is structured into 3 separate tasks running on the RTOS: • collect & integrate gyro samples • compute hard/soft iron compensation coefficients • everything else

  5. output selection Program Operation sensor selection algorithm selection Panorama View Best Sensors Native to your Android Device Device View Better OK Remote Sensor Interface Bad Log Window Worst Statistics View

  6. 1st Development Board Kinetis K20 (ARM Cortex-M4) Processor 3rd party Bluetooth Module • Subsequent app versions will be targeted to: • Freescale KL25Z Freedom Board • Freescale K20D50M Freedom Board • Avnet WiGo Board FXOS8700CQ Accel/Mag FXAS21000 Gyro Our 9-Axis Board

  7. +Y +X +Z is out of page ENU Frame of Reference X = East Y = North Z = up

  8. If you would like to try it… http://play.google.com/store/apps/details?id=com.freescale.sensors.sfusion

  9. Sensor Fusion App Structure BlueToothInputThread Communication between classes is always via “demo” pointer to the main activity, which in turn has pointers to other subsystems. A_FSL_Sensor_Demo (main activity) IMU public MyWebView (used for documentation) public DataSelector MyUtils public public inheritance all functions are static DataLogger in turn uses a separate “runnable” to schedule periodic updates. DataLogger (screen and file output) LocalSensors public public SharedPreferences Settings (secondary activity) Sensors Wrapper (base class) public Statistics public public HTML Generator public TextureCube TextureCube Renderer (X2) public public TimedTriad Timed Quaternion Graphic Screen Dump Sensor Stats Calculator Triad Demo Quaternion yellow = separate thread gray = separate activity light blue = classes that are stats-related all functions are static

  10. IMU Packet Structure • Acc, mag & gyro 16 bit quantities are treated as signed integers and multiplied by: • 122.07 g/LSB • 0.1 Teslas/LSB • 872.66 radians/LSB • Timestamps are 32 bit signed integers which are then multiplied by: • 1.33 s / LSB • Quaternion values are signed integers which are divided by 30,000 to get actual values.

  11. Using the sensors on your Android device private final SensorEventListener localSensorListener = new SensorEventListener() { @Override synchronized public void onSensorChanged(SensorEvent event) { intsensorType = event.sensor.getType(); switch (sensorType) { case Sensor.TYPE_ACCELEROMETER: acc.update( event.timestamp, event.values[0], event.values[1], event.values[2]); dump_acc(); break; case Sensor.TYPE_GYROSCOPE: gyro.update( event.timestamp, degreesPerRadian*event.values[0], degreesPerRadian*event.values[1], degreesPerRadian*event.values[2]); dump_gyro(); break; case Sensor.TYPE_MAGNETIC_FIELD: mag.update( event.timestamp, event.values[0], event.values[1], event.values[2]); dump_mag(); break; case Sensor.TYPE_ROTATION_VECTOR: updateRotation(event.timestamp, event.values); dump_quaternion(); break; } } Define a function to “listen” for new sensor values acc, gyro and mag are local class instances used to cache sensor data prior to use.

  12. Using the sensors on your Android device Get handles for your local sensors… localAcc = localSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER); localGyro = localSensorManager.getDefaultSensor(Sensor.TYPE_GYROSCOPE); localMag = localSensorManager.getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD); localRotationVectorSensor = localSensorManager.getDefaultSensor(Sensor.TYPE_ROTATION_VECTOR); localSensorManager.registerListener(localSensorListener, localAcc, accSampleRate); localSensorManager.registerListener(localSensorListener, localGyro, magSampleRate); localSensorManager.registerListener(localSensorListener, localMag, gyroSampleRate); localSensorManager.registerListener(localSensorListener, localRotationVectorSensor, rotationVectorSampleRate); Register your listener function for those sensors… EASY!

  13. Application Controls Navigation Control The Options Menu is a button on some devices Android Action Bar Fusion Settings Bar If present, click to enable low pass filter Sensor & Algorithm Selection Here

  14. Visualization: Accelerometer Only • Choose: • Source/Algorithm = Local Accel • Nav = Device view The device does not respond to rotation about the Z-axis It does respond to rotation about X and Y axes

  15. Visualization: Mag + Accel • Choose: • Source/Algorithm = Local Mag/Accel • Nav = Device view • The device now responds to rotation about the Z-axis as well as X and Y axes. Notice: Fairly high noise (jitter) Rotten immunity to magnetic interference Try experimenting with the low pass filter option

  16. Bringing it to life…

  17. Stats Page • For mag / accel / gyro and rotation, the “Statistics” Views displays: • sensor description • current sensor value • min / mean / max values • standard deviation • noise / √Hz • When used with the “local” sensor • sources, this is a great way to gain insight into devices from the competition!

  18. Observations • From a developer perspective, the graphical interface was great for evaluating: • frame of reference errors • static and dynamic response • noise / jitter • The tool makes a great interactive teaching aide • but we suspect that most users do not bother reading the included tutorial information • Deficiencies: • We also need a way to control inertial stimulus. Android isn’t ideal here • Android devices do not provide an easy environment for scripting.

  19. So we added an additional interface… Freescale 9-axis sensor board running on Kinetis MK20DX256ZVLK10 Sensor communications is via Bluetooth Non-ferrous stand designed to act as “spacer” between table and sensors USB-to-serial adapter cable PC running Matlab Excitron MRT7-57-25 7” motorized rotary table

  20. With the PC-based setup • Embedded code is exactly the same. • Matlab scripts control rotary table movement and read fusion packets • Able to get quick, quantitative, “sanity results” • Easy to package regression tests: • static orientation • dynamic response (subject to table limitations) • quality of magnetic calibration • magnetic interference

  21. Heading: Actual vs Expected

  22. Heading Error Heading accuracy appears limited by 6-axis (mag + accel) accuracy. As expected, 9-axis results less noisy.

  23. Magnetic X vs Y Plot This plot shows very good magCal results. Other runs were not as stellar.

  24. Heading vs Time 160 dps 120 dps 80 dps 40 dps

  25. Magnetic Disturbance Device is rotating here and here Device is stationary here Magnetic Interference

  26. Rotary table limitations • But the rotary table has limitations, including: • Stepper / Gear Noise • Noticeable lag between command and response • Cannot control linear acceleration – need lab robot and reference IMU for that Unfortunately, this baby does generate a lot of magnetic interference.

  27. In Summary • Android is a great environment for visualization and basic noise measurements. • Not so great for • environmental control of “off the shelf” equipment • ease of adapting scripts on-the-fly • PC-based environment: • great for scripting • but single-threaded nature poses limitations • Precise measurements require precise machining and a lot of attention paid to managing magnetic interference

  28. Thank you!

More Related