Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/martinkersner/accgyr


https://github.com/martinkersner/accgyr

Last synced: 15 days ago
JSON representation

Awesome Lists containing this project

README

        

# accgyr

This project tries to identify different movements using accelerometer and/or gyroscope in mobile phone.

In all testing cases phone was in one fixed position; screen up, top of phone always in direction of movement.

Several different movements were recorded (so far):

* Walking forward
* Moving on chair forward
* Sit on a chair and stand up
* Walking up/down stairs

## Progress

### Noise reduction
Recorded data seems very noisy, therefore we tried to get rid of noise by using *rolling mean.*

Blue line represents movements in Z-axis from *moving on chair forward* experiment.
Because there was only simple move forward we would expect that there is not going to be any change. However, it is hard to say what is going on only from the plot below.

After *rolling mean* was applied we can see that there are no big changes between measurements. Also, value about 9 m/s^2 seems right.

### Visualization of movements
Red, green and blue colors in plots correspond to acceleration in X, Y and Z-axis.

Plots were created with [exploreData.R](https://github.com/martinkersner/accgyr/blob/master/exploreData.R).

#### Sit on a chair and stand up

#### Walking up stairs

#### Walking down stairs

#### Moving on chair forward

### Classify movements in 1D
Following table shows comparisons of different movements in Z-axis using *dynamic time warping*. For this experiment, full lengths of signals were used. In further experiments we should use shorter templates (mainly for case when walking up/down stairs) in order to be able to detect step on/from even single stair.

In table you can see that the same movements have smaller values (smaller number means more similar signals) than movements that differ. In all cases values of corresponding movements are at least more than 40 % smaller than values of non-corresponding ones. To distinguish between them we will have to set a threshold.

Setting a threshold at the right place will be also challenging, however with enough data decision should be easier.

Values displayed in this table were computed using [compare1DSignals.R](https://github.com/martinkersner/accgyr/blob/master/compare1DSignals.R).

sitandup1sitandup2stairsup1stairsup2stairsdown1stairsdown2chairforward1chairforward2sitandup18.0753118.2528120.270799.28724103.268489.2435874.56808sitandup2103.5235103.591990.5696897.7186673.2165460.06544stairsup122.326243.4036257.641794.8755292.64532stairsup241.7976850.1502492.7042692.04128stairsdown119.8481465.671666.04926stairsdown284.3855484.448chairforward116.95338chairforward2

### Classify movements in 1D with short time signals
The longer template signal we would use, the longer it would take to compute DTW.
Simple solution could be to create short-time templates.
However, it means we have to compute DTW more often.
It all boils down to how precise we want to be, eg. do we have to able detect even just one step on stairs?
[compare1DSignals_part2.R](https://github.com/martinkersner/accgyr/blob/master/compare1DSignals_part2.R) enables to experiment with short time signal templates in 1D (Z-axis).
The main focus was put on determining whether person is going up or down on stairs.
~~Currently we are not able to distinguish between them using short time 1D signal template.~~
Adding one more dimension (Y-axis) could help because it captures speed of forward movement (it should differ in our observations).

After examining data more thoroughly it turned out that we could be able to distinguish between movements only using 1D short time signal template.
However, additional dimension would be still beneficial for increasing classification confidence.
In following plot you can see comparison statistics of *stairs up 1* movement with others.
Again, the lower values mean higher similarity.
Two green lines denote the worst false positive and false negative medians.
The space between them contains almost one fifth (the more the better) on scale of all comparisons with *stairs up 1* movement.

### Exploring Y-axis
[Y-axis](https://developer.android.com/guide/topics/sensors/sensors_overview.html#sensors-coords) denotes forward movement.
Both graphs were generated by [exploreData_part2.R](https://github.com/martinkersner/accgyr/blob/master/exploreData_part2.R).

Following graph depicts movement patterns for walking stairs up or down.
In plots that are denoting walking stairs up you can see that after each step on stair acceleration diminishes.
When walking from stairs down there is no distinct regular pattern, but speed is slightly higher.
Red lines in plot express minimum and maximum values, while green line denotes median value.

Previous graph contains patterns that could be recognized, however, values on Y-axis could be also used for determination of an average speed (if we expect that walking up is slower than walking down from stairs)
Slope of red line in plot denotes average speed (walking down was faster).
If we would decide to use this computation of an average speed we would have to also incorporate sliding window to reduce error which accumulates along with time.

### Generating templates from recorded data
New data (10 for each case) were captured while walking stairs up and down.
This data should be used for generating templates and then employed with dynamic time warping.
Each template should look like a single wave, describing one step on stairs.
Each signal was divided to equidistant non-overlapping parts for which we then computed crosscorrelation with one manually selected wave.
After that we shifted signal in order to achieve the maximum correlation.
All (if they achieved at least minimum determined correlation) shifted signals were then averaged to create final template.
For wave expressing walking up we were able to obtain template that quite nicely summarize all signal waves, however we are not sure if this generalization is not too big.
In case of walking stairs down we came accros problem that is related to quite different dynamics between steps, therefore the way how we generate template now is not good enough.
Allowing overlap between parts of signal could help to obtain better results.

On the following graph you can see signal wave from walking stairs up. The higher plot expresses base signal which was used to compute correlation with all other waves.
The plot below is generated template.
Graphs was generated by [generateTemplate.R](https://github.com/martinkersner/accgyr/blob/master/generateTemplate.R).

### Classifying walking stairs up and down
Since the combining signals from the last step didn't work as we would expect we decided to try to classfiy signals without generating any template from all data.
We used one manually selected signal window as a template.
Matching signals with template window using DTW algorithm gave us responses which we then utilized for determining threshold that classify signals.
When [classifying](https://github.com/martinkersner/accgyr/blob/master/classify.R) collected data (10 times walking stairs up, 10 times walking stairs down) we obtained 90 % precision (2 false positives).
Even though this results looks promising, it is hard to say if this approach could be employed in real situations.
Quality of this approach could be determined by using much more data.