pronenewbits / Arduino_AHRS_System

A compact realtime embedded Attitude and Heading Reference System (AHRS) using Recursive Least Squares (RLS) for magnetometer calibration and EKF/UKF for sensor fusion on Arduino platform
Creative Commons Zero v1.0 Universal
166 stars 52 forks source link

Changing sensors in code #6

Open brightproject opened 1 year ago

brightproject commented 1 year ago

Hello @pronenewbits I want to use gyroscope and accelerometer sensors like lsm303dlh and l3gd20. How to find the “entry point” to insert your own acceleration and angular velocity values into the code? I get the raw data something like this:

#include <Wire.h>
#include <L3G.h>
#include <LSM303.h>

LSM303 mag_accel;
L3G gyro;

void setup() {
  Serial.begin(115200);
  Wire.begin();
  if (!gyro.init())
  {
    Serial.println("Failed to autodetect gyro type!");
    while (1);
  }
  if (!mag_accel.init())
  {
    Serial.println("Failed to initialize mag_accel!");
    while (1);
  }
  gyro.enableDefault();
  mag_accel.enableDefault(); 
}

void loop() {

  gyro.read();
  mag_accel.read();

Serial.print(gyro.g.x);
Serial.print(",");
Serial.print(gyro.g.y);
Serial.print(",");
Serial.print(gyro.g.z);
Serial.print(",");
Serial.print(mag_accel.a.x);
Serial.print(",");
Serial.print(mag_accel.a.y);
Serial.print(",");
Serial.println(mag_accel.a.z);

}