Compare commits
3 commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2e20d45a26 | ||
|
|
87459557b2 | ||
|
|
0475fc7ad0 |
5 changed files with 54 additions and 3 deletions
|
|
@ -1,3 +1,8 @@
|
|||
#ifndef __ADAFRUIT_AHRS_H_
|
||||
#define __ADAFRUIT_AHRS_H_
|
||||
|
||||
#include <Adafruit_AHRS_Madgwick.h>
|
||||
#include <Adafruit_AHRS_Mahony.h>
|
||||
#include <Adafruit_AHRS_NXPFusion.h>
|
||||
|
||||
#endif // __ADAFRUIT_AHRS_H_
|
||||
|
|
|
|||
41
src/Adafruit_AHRS_FusionInterface.h
Normal file
41
src/Adafruit_AHRS_FusionInterface.h
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2020 Ha Thach (tinyusb.org) for Adafruit Industries
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef ADAFRUIT_AHRS_FUSIONINTERFACE_H_
|
||||
#define ADAFRUIT_AHRS_FUSIONINTERFACE_H_
|
||||
|
||||
// Interface for Fusion Algorithm
|
||||
class Adafruit_AHRS_FusionInterface {
|
||||
public:
|
||||
virtual void begin(float sampleFrequency) = 0;
|
||||
virtual void update(float gx, float gy, float gz, float ax, float ay,
|
||||
float az, float mx, float my, float mz) = 0;
|
||||
|
||||
virtual float getRoll() = 0;
|
||||
virtual float getPitch() = 0;
|
||||
virtual float getYaw() = 0;
|
||||
virtual void getQuaternion(float *w, float *x, float *y, float *z) = 0;
|
||||
};
|
||||
|
||||
#endif /* ADAFRUIT_AHRS_FUSIONINTERFACE_H_ */
|
||||
|
|
@ -16,11 +16,13 @@
|
|||
//=============================================================================================
|
||||
#ifndef __Adafruit_Madgwick_h__
|
||||
#define __Adafruit_Madgwick_h__
|
||||
|
||||
#include "Adafruit_AHRS_FusionInterface.h"
|
||||
#include <math.h>
|
||||
|
||||
//--------------------------------------------------------------------------------------------
|
||||
// Variable declaration
|
||||
class Adafruit_Madgwick {
|
||||
class Adafruit_Madgwick : public Adafruit_AHRS_FusionInterface {
|
||||
private:
|
||||
static float invSqrt(float x);
|
||||
float beta; // algorithm gain
|
||||
|
|
|
|||
|
|
@ -12,12 +12,14 @@
|
|||
//=============================================================================================
|
||||
#ifndef __Adafruit_Mahony_h__
|
||||
#define __Adafruit_Mahony_h__
|
||||
|
||||
#include "Adafruit_AHRS_FusionInterface.h"
|
||||
#include <math.h>
|
||||
|
||||
//--------------------------------------------------------------------------------------------
|
||||
// Variable declaration
|
||||
|
||||
class Adafruit_Mahony {
|
||||
class Adafruit_Mahony : public Adafruit_AHRS_FusionInterface {
|
||||
private:
|
||||
float twoKp; // 2 * proportional gain (Kp)
|
||||
float twoKi; // 2 * integral gain (Ki)
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
#include "Adafruit_AHRS_FusionInterface.h"
|
||||
#include <Arduino.h>
|
||||
|
||||
// This is a modification of
|
||||
|
|
@ -31,7 +32,7 @@
|
|||
//
|
||||
|
||||
// changed class name to avoid collision
|
||||
class Adafruit_NXPSensorFusion {
|
||||
class Adafruit_NXPSensorFusion : public Adafruit_AHRS_FusionInterface {
|
||||
public:
|
||||
void begin(float sampleRate = 100.0f);
|
||||
void update(float gx, float gy, float gz, float ax, float ay, float az,
|
||||
|
|
|
|||
Loading…
Reference in a new issue