|
各位前輩好
小弟因剛接觸四軸飛行器有些問題想請教,目前所使用的感測器為adxl345 l3g4200d
目前已經可以從陀螺儀得到角速度 , 想請教的是接下來該怎麼去積分才能得我要的角度值呢??
因剛接觸,所以程式碼沒有什麼概念 ,望前輩多指教!!下面是我目前的程式碼
#include <Wire.h>
#include <L3G.h>
L3G gyro;
void setup() {
Serial.begin(9600);
Wire.begin();
if (!gyro.init())
{
Serial.println("Failed to autodetect gyro type!");
while (1);
}
gyro.enableDefault();
}
void loop() {
gyro.read();
float dpsgyrox;
float dpsgyroy;
float dpsgyroz;
dpsgyrox = ( gyro.g.x * 8.75 ) / 1000;
dpsgyroy = ( gyro.g.y * 8.75 ) / 1000;
dpsgyroz = ( gyro.g.z * 8.75 ) / 1000;
Serial.print("G ");
Serial.print("X: ");
Serial.print(dpsgyrox);
Serial.print(" Y: ");
Serial.print(dpsgyroy);
Serial.print(" Z: ");
Serial.println(dpsgyroz);
delay(100);
} |
|