如何在环形缓冲区中存储加速度计值(x,y,z) [英] How to store accelerometer values(x, y, z) in ring buffer

查看:75
本文介绍了如何在环形缓冲区中存储加速度计值(x,y,z)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从谷歌那里得到了一些研究论文。有一些关于Humain活动识别的代码。

而我的最终项目也基于此。

所以有一些我面临的问题。

纸张包含:

加速度计的新数据存储在由游标变量指定的适当位置。这个游标变量在存储一个新值后递增,当它到达最高值时 - 它是BUFFER_SIZE-它变为零。



从这个值开始的平均值当前由游标定义的缓冲区索引和先前存储的值old作为缓冲区中WINDOW_SIZE的数量。

同时,它计算属于此窗口的值的标准偏差。





如果这段代码能清楚地告诉我我的重大问题将会解决,那就有某种代码:



I got some research paper from google.There is about some code of Humain Activity Recognition.
And my final project also base on this.
so there is some issue facing me.
the paper conatain:
The new data of the accelerometer is stored to the proper location which is assigned by cursor variable. This cursor variable is incremented after storing a new value, when it reaches to the top value –which is BUFFER_SIZE- it becomes zero.

average of the values starting from the current index of buffer defined by cursor and the previously stored values old as the number of WINDOW_SIZE in the buffer.
Concurrently, it calculates the standard deviation of the values belonging to this window.


And there is some sort of code if this code can clear to me my big big problem will solve:

       float avgACC=0,sumsquare=0;
int dataNo=cursor; //cursor is the current global index of buffer
String state="other";
for(int i=0;i<WINDOW_SIZE;i++){
avgACC+=buffer[dataNo]/WINDOW_SIZE;
sumsquare+=buffer[dataNo]*buffer[dataNo];
dataNo=(dataNo+BUFFER_SIZE-1)%BUFFER_SIZE;
//data no is decremented one after every iteration

float std=(float) Math.sqrt((Math.abs(sumsquare-WINDOW_SIZE*(avgACC*avgACC))/(WINDOW_SIZE-1)));
//standard deviation of the values in corresponding window is calculatig





这段代码给出了一些错误,我不知道来自哪里以及如何处理

1:无法恢复符号光标:

2:无法恢复符号WINDOW_SIZE:

3:无法恢复符号缓冲区:

3:无法恢复符号BUFFER_SIZE:

请帮助我新的开始者



我尝试了什么:



我已经尝试了很多次但是所有时间都得到同样的错误无法重新载入



this code give some error and i don't know where it come from and how to handle
1:cannot resove symbol cursor:
2:cannot resove symbol WINDOW_SIZE:
3:cannot resove symbol buffer:
3:cannot resove symbol BUFFER_SIZE:
please help i m new beginer

What I have tried:

I have tried many time but all the time get the same error cannot reslove

推荐答案

首先需要在代码中定义这些项目,然后才能使用它们。如果这是您的最终项目,那么我认为您需要花更多的时间来学习课程笔记。下面的示例显示了如何定义这些值 ,但它只是一个示例,实数将取决于您的应用程序的要求:

You first need to define those items in your code before you can use them. If this is your final project then I think you need to spend much more time studying your course notes. The example below shows how these values may be defined, but it is only an example, the real numbers will depend on your application's requirements:
#define BUFFER_SIZE    4096
#define WINDOW_SIZE    1024

    char buffer[BUFFER_SIZE];
    int cursor;


引用:

这段代码给出了一些错误,我不知道它来自何处以及如何处理

this code give some error and i don't know where it come from and how to handle

1:cannot resolve symbol cursor:
2:cannot resolve symbol WINDOW_SIZE:
3:cannot resolve symbol buffer:
3:cannot resolve symbol BUFFER_SIZE:


错误消息告诉您正在使用游标 WINDOW_SIZE 缓冲区 SIZE 但从未在代码中说出它们是什么以及它们的值。


The error messages tell you that you are using cursor, WINDOW_SIZE, buffer and SIZE but never said in code what they are and their values.


这篇关于如何在环形缓冲区中存储加速度计值(x,y,z)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆