LowpassFilter(仮)?を使って加速度の値をフィルタリングして角度をもとめてます。ローカルファイルシステムを使って値をグラフ化できるようにしてます。 ローパスフィルタについてアドバイスがあればお願いします。
Dependencies: LIS3DH_Hello mbed
Fork of LocalFileSystem_HelloWorld by
Revision 3:edc2c71d87b1, committed 2015-03-30
- Comitter:
- tknara
- Date:
- Mon Mar 30 16:05:06 2015 +0000
- Parent:
- 2:69e9bf864751
- Commit message:
- LowPassFilter_test;
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Mon Mar 30 15:33:24 2015 +0000
+++ b/main.cpp Mon Mar 30 16:05:06 2015 +0000
@@ -8,12 +8,16 @@
DigitalOut myled(LED4);
//角度を算出する関数(ローパスフィルタを使用)
float angle (float nowx,float nowy) {
- static float x = 0,y = 0;
+ static float x = 0,y = 0;//前回の値を入れておく変数
float theta,deg,getx,gety;
+ //filter
getx = filter*x + (1-filter)*nowx;
gety = filter*y + (1-filter)*nowy;
+ //角度を求める[theta]
theta = atan(getx/gety);
+ //変換[deg]
deg = theta * 180 / pi;
+ //今回の値を保存
x = nowx;
y = nowy;
return deg;
