Main Menu and Understanding our Sensors
Weekly Update
With the app now working for recording, we understand the direction we need to take to complete this project. We have 3 different functions that can be split into 3 separate apps or can be combined into one. The 3 functions are recording data, training data, and predicting the state. Our goal is to take the 3 functions and combine them into a single app. To do this successfully we will have to get classifier and state predictor code working. Then we can rearrange our app with a main menu that lists the functions: Recording, Training, and Predicting.
Functionality
The first menu item is recording, this part of the app has already been written and all we have to do is shift all the functionality down the navigation hierarchy so it is no longer on the main screen. The purpose of this function is to record data from the two chosen sensors at very similar intervals, then output the recorded values to the ARFF file followed by the state. Clicking the button will take us through to a new page/activity where we can process all the recording.
Next is the train button, this button requires little to no code from us, using the code snippets provided by Jacob we are able to simply pass an ARFF file, and a Weka training method. The function will then return our data after having been trained and output in a file format that Weka can interpret. Clicking this button will not navigate the user anywhere but will instead just take the ARFF file from device storage and output the trained Weka file to another folder in storage.
Lastly is the predict button, this button navigates the user to a different page containing a start/stop button and a simple text label. This button is intended to begin recording from both the sensors when pressed, and will use the StatePredict code snippet to read the trained Weka file when the state is predicted, we will then update the label to whatever state the device is in. You can hit the button again to turn off the sensors and end the prediction.
Further understanding: The sensors inside a cell phone
Accelerometer
As mentioned in our previous blog, an accelerometer measures the amount of acceleration an object has in relation to gravity and other objects and is measured in meter/per second^2. In other words, the amount of force being exerted on the object. An accelerometer in a cell phone can measure the velocity on 3 axes (x, y and z) but cannot determine the angular rotational velocity.
In order to fit an accelerometer inside a phone, a Micro-Electro-Mechanical System is used. Essentially the MEMS measures the flow current over a differential capacitor. The accelerometer has plates in the middle that move with acceleration and the plates on the outside that are fixed. When acceleration is applied to the phone, the mass moves, producing an electric charge between these 2 plates. This voltage signal is 0 when there is no acceleration, positive with acceleration and negative with deceleration.
With the app now working for recording, we understand the direction we need to take to complete this project. We have 3 different functions that can be split into 3 separate apps or can be combined into one. The 3 functions are recording data, training data, and predicting the state. Our goal is to take the 3 functions and combine them into a single app. To do this successfully we will have to get classifier and state predictor code working. Then we can rearrange our app with a main menu that lists the functions: Recording, Training, and Predicting.
Functionality
The first menu item is recording, this part of the app has already been written and all we have to do is shift all the functionality down the navigation hierarchy so it is no longer on the main screen. The purpose of this function is to record data from the two chosen sensors at very similar intervals, then output the recorded values to the ARFF file followed by the state. Clicking the button will take us through to a new page/activity where we can process all the recording.
Lastly is the predict button, this button navigates the user to a different page containing a start/stop button and a simple text label. This button is intended to begin recording from both the sensors when pressed, and will use the StatePredict code snippet to read the trained Weka file when the state is predicted, we will then update the label to whatever state the device is in. You can hit the button again to turn off the sensors and end the prediction.
| Figure 1. 7 Values: Accelerometer X,Y,Z - Gyroscope X,Y,Z - State being recorded |
Further understanding: The sensors inside a cell phone
Accelerometer
As mentioned in our previous blog, an accelerometer measures the amount of acceleration an object has in relation to gravity and other objects and is measured in meter/per second^2. In other words, the amount of force being exerted on the object. An accelerometer in a cell phone can measure the velocity on 3 axes (x, y and z) but cannot determine the angular rotational velocity.
In order to fit an accelerometer inside a phone, a Micro-Electro-Mechanical System is used. Essentially the MEMS measures the flow current over a differential capacitor. The accelerometer has plates in the middle that move with acceleration and the plates on the outside that are fixed. When acceleration is applied to the phone, the mass moves, producing an electric charge between these 2 plates. This voltage signal is 0 when there is no acceleration, positive with acceleration and negative with deceleration.
Gyroscope
The Gyroscope detects the current orientation of an object and the angular rotational velocity (measured in radians per second in Android). In this case, the gyroscope aids the accelerometer by adding which way your phone is oriented. If a phone rotates, the accelerometer would pick this up as noise. Therefore a gyroscope is needed in order to determine this rotation and measures values on 3 axes; x, y and z.
A cell phone also uses a MEMS for the gyroscope which allows the gyroscope to fit inside a small device and is becoming smaller (around 1-100 micrometers), cheaper and more popular. The Gyroscope is calibrated to give a result of 0 when the phone is held flat on a surface. Once the phone is rotated or tilted on its axis, the vibrating mass inside the gyroscope is shifted as the angular velocity changes. A similar force wants to keep the mass that is changing in its original orientation, which therefore helps to keep the phones orientation.
The Gyroscope detects the current orientation of an object and the angular rotational velocity (measured in radians per second in Android). In this case, the gyroscope aids the accelerometer by adding which way your phone is oriented. If a phone rotates, the accelerometer would pick this up as noise. Therefore a gyroscope is needed in order to determine this rotation and measures values on 3 axes; x, y and z.
A cell phone also uses a MEMS for the gyroscope which allows the gyroscope to fit inside a small device and is becoming smaller (around 1-100 micrometers), cheaper and more popular. The Gyroscope is calibrated to give a result of 0 when the phone is held flat on a surface. Once the phone is rotated or tilted on its axis, the vibrating mass inside the gyroscope is shifted as the angular velocity changes. A similar force wants to keep the mass that is changing in its original orientation, which therefore helps to keep the phones orientation.
One of the main issues of a gyroscope is that the gyroscope is subject to ‘drift’. Drift occurs when the gyroscope is off by a tiny amount due to missing constants. For example, an individual can hold up their phone and change its orientation quickly. However, the gyroscope will not be able to keep up with the changes and will not be able to detect them. The approximation therefore, will be off by a tiny amount. In an ideal situation, you would hope the gyroscope has a normal distribution of errors around 0. But this value depends on frequency and due to the tiny errors, this distribution will be slightly off.
Written by Sam and Celine
Proofread by James
Written by Sam and Celine
Proofread by James
Comments
Post a Comment