only add virtual to superclass function
This commit is contained in:
parent
87459557b2
commit
2e20d45a26
3 changed files with 21 additions and 36 deletions
|
|
@ -41,53 +41,45 @@ private:
|
||||||
// Function declarations
|
// Function declarations
|
||||||
public:
|
public:
|
||||||
Adafruit_Madgwick(void);
|
Adafruit_Madgwick(void);
|
||||||
virtual void begin(float sampleFrequency) {
|
void begin(float sampleFrequency) { invSampleFreq = 1.0f / sampleFrequency; }
|
||||||
invSampleFreq = 1.0f / sampleFrequency;
|
void update(float gx, float gy, float gz, float ax, float ay, float az,
|
||||||
}
|
float mx, float my, float mz);
|
||||||
virtual void update(float gx, float gy, float gz, float ax, float ay,
|
|
||||||
float az, float mx, float my, float mz);
|
|
||||||
void updateIMU(float gx, float gy, float gz, float ax, float ay, float az);
|
void updateIMU(float gx, float gy, float gz, float ax, float ay, float az);
|
||||||
// float getPitch(){return atan2f(2.0f * q2 * q3 - 2.0f * q0 * q1, 2.0f * q0 *
|
// float getPitch(){return atan2f(2.0f * q2 * q3 - 2.0f * q0 * q1, 2.0f * q0 *
|
||||||
// q0 + 2.0f * q3 * q3 - 1.0f);}; float getRoll(){return -1.0f * asinf(2.0f *
|
// q0 + 2.0f * q3 * q3 - 1.0f);}; float getRoll(){return -1.0f * asinf(2.0f *
|
||||||
// q1 * q3 + 2.0f * q0 * q2);}; float getYaw(){return atan2f(2.0f * q1 * q2
|
// q1 * q3 + 2.0f * q0 * q2);}; float getYaw(){return atan2f(2.0f * q1 * q2
|
||||||
// - 2.0f * q0 * q3, 2.0f * q0 * q0 + 2.0f * q1 * q1 - 1.0f);};
|
// - 2.0f * q0 * q3, 2.0f * q0 * q0 + 2.0f * q1 * q1 - 1.0f);};
|
||||||
virtual float getRoll() {
|
float getRoll() {
|
||||||
if (!anglesComputed)
|
if (!anglesComputed)
|
||||||
computeAngles();
|
computeAngles();
|
||||||
return roll * 57.29578f;
|
return roll * 57.29578f;
|
||||||
}
|
}
|
||||||
|
float getPitch() {
|
||||||
virtual float getPitch() {
|
|
||||||
if (!anglesComputed)
|
if (!anglesComputed)
|
||||||
computeAngles();
|
computeAngles();
|
||||||
return pitch * 57.29578f;
|
return pitch * 57.29578f;
|
||||||
}
|
}
|
||||||
|
float getYaw() {
|
||||||
virtual float getYaw() {
|
|
||||||
if (!anglesComputed)
|
if (!anglesComputed)
|
||||||
computeAngles();
|
computeAngles();
|
||||||
return yaw * 57.29578f + 180.0f;
|
return yaw * 57.29578f + 180.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
float getRollRadians() {
|
float getRollRadians() {
|
||||||
if (!anglesComputed)
|
if (!anglesComputed)
|
||||||
computeAngles();
|
computeAngles();
|
||||||
return roll;
|
return roll;
|
||||||
}
|
}
|
||||||
|
|
||||||
float getPitchRadians() {
|
float getPitchRadians() {
|
||||||
if (!anglesComputed)
|
if (!anglesComputed)
|
||||||
computeAngles();
|
computeAngles();
|
||||||
return pitch;
|
return pitch;
|
||||||
}
|
}
|
||||||
|
|
||||||
float getYawRadians() {
|
float getYawRadians() {
|
||||||
if (!anglesComputed)
|
if (!anglesComputed)
|
||||||
computeAngles();
|
computeAngles();
|
||||||
return yaw;
|
return yaw;
|
||||||
}
|
}
|
||||||
|
void getQuaternion(float *w, float *x, float *y, float *z) {
|
||||||
virtual void getQuaternion(float *w, float *x, float *y, float *z) {
|
|
||||||
*w = q0;
|
*w = q0;
|
||||||
*x = q1;
|
*x = q1;
|
||||||
*y = q2;
|
*y = q2;
|
||||||
|
|
|
||||||
|
|
@ -38,31 +38,25 @@ private:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Adafruit_Mahony();
|
Adafruit_Mahony();
|
||||||
virtual void begin(float sampleFrequency) {
|
void begin(float sampleFrequency) { invSampleFreq = 1.0f / sampleFrequency; }
|
||||||
invSampleFreq = 1.0f / sampleFrequency;
|
void update(float gx, float gy, float gz, float ax, float ay, float az,
|
||||||
}
|
float mx, float my, float mz);
|
||||||
virtual void update(float gx, float gy, float gz, float ax, float ay,
|
|
||||||
float az, float mx, float my, float mz);
|
|
||||||
void updateIMU(float gx, float gy, float gz, float ax, float ay, float az);
|
void updateIMU(float gx, float gy, float gz, float ax, float ay, float az);
|
||||||
|
float getRoll() {
|
||||||
virtual float getRoll() {
|
|
||||||
if (!anglesComputed)
|
if (!anglesComputed)
|
||||||
computeAngles();
|
computeAngles();
|
||||||
return roll * 57.29578f;
|
return roll * 57.29578f;
|
||||||
}
|
}
|
||||||
|
float getPitch() {
|
||||||
virtual float getPitch() {
|
|
||||||
if (!anglesComputed)
|
if (!anglesComputed)
|
||||||
computeAngles();
|
computeAngles();
|
||||||
return pitch * 57.29578f;
|
return pitch * 57.29578f;
|
||||||
}
|
}
|
||||||
|
float getYaw() {
|
||||||
virtual float getYaw() {
|
|
||||||
if (!anglesComputed)
|
if (!anglesComputed)
|
||||||
computeAngles();
|
computeAngles();
|
||||||
return yaw * 57.29578f + 180.0f;
|
return yaw * 57.29578f + 180.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
float getRollRadians() {
|
float getRollRadians() {
|
||||||
if (!anglesComputed)
|
if (!anglesComputed)
|
||||||
computeAngles();
|
computeAngles();
|
||||||
|
|
@ -78,8 +72,7 @@ public:
|
||||||
computeAngles();
|
computeAngles();
|
||||||
return yaw;
|
return yaw;
|
||||||
}
|
}
|
||||||
|
void getQuaternion(float *w, float *x, float *y, float *z) {
|
||||||
virtual void getQuaternion(float *w, float *x, float *y, float *z) {
|
|
||||||
*w = q0;
|
*w = q0;
|
||||||
*x = q1;
|
*x = q1;
|
||||||
*y = q2;
|
*y = q2;
|
||||||
|
|
|
||||||
|
|
@ -34,15 +34,15 @@
|
||||||
// changed class name to avoid collision
|
// changed class name to avoid collision
|
||||||
class Adafruit_NXPSensorFusion : public Adafruit_AHRS_FusionInterface {
|
class Adafruit_NXPSensorFusion : public Adafruit_AHRS_FusionInterface {
|
||||||
public:
|
public:
|
||||||
virtual void begin(float sampleRate = 100.0f);
|
void begin(float sampleRate = 100.0f);
|
||||||
virtual void update(float gx, float gy, float gz, float ax, float ay,
|
void update(float gx, float gy, float gz, float ax, float ay, float az,
|
||||||
float az, float mx, float my, float mz);
|
float mx, float my, float mz);
|
||||||
|
|
||||||
virtual float getRoll() { return PhiPl; }
|
float getRoll() { return PhiPl; }
|
||||||
virtual float getPitch() { return ThePl; }
|
float getPitch() { return ThePl; }
|
||||||
virtual float getYaw() { return PsiPl; }
|
float getYaw() { return PsiPl; }
|
||||||
|
|
||||||
virtual void getQuaternion(float *w, float *x, float *y, float *z) {
|
void getQuaternion(float *w, float *x, float *y, float *z) {
|
||||||
*w = qPl.q0;
|
*w = qPl.q0;
|
||||||
*x = qPl.q1;
|
*x = qPl.q1;
|
||||||
*y = qPl.q2;
|
*y = qPl.q2;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue