only add virtual to superclass function

This commit is contained in:
hathach 2020-02-21 10:20:58 +07:00
parent 87459557b2
commit 2e20d45a26
No known key found for this signature in database
GPG key ID: 2FA891220FBFD581
3 changed files with 21 additions and 36 deletions

View file

@ -41,53 +41,45 @@ private:
// Function declarations
public:
Adafruit_Madgwick(void);
virtual void begin(float sampleFrequency) {
invSampleFreq = 1.0f / sampleFrequency;
}
virtual void update(float gx, float gy, float gz, float ax, float ay,
float az, float mx, float my, float mz);
void begin(float 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);
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 *
// 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
// - 2.0f * q0 * q3, 2.0f * q0 * q0 + 2.0f * q1 * q1 - 1.0f);};
virtual float getRoll() {
float getRoll() {
if (!anglesComputed)
computeAngles();
return roll * 57.29578f;
}
virtual float getPitch() {
float getPitch() {
if (!anglesComputed)
computeAngles();
return pitch * 57.29578f;
}
virtual float getYaw() {
float getYaw() {
if (!anglesComputed)
computeAngles();
return yaw * 57.29578f + 180.0f;
}
float getRollRadians() {
if (!anglesComputed)
computeAngles();
return roll;
}
float getPitchRadians() {
if (!anglesComputed)
computeAngles();
return pitch;
}
float getYawRadians() {
if (!anglesComputed)
computeAngles();
return yaw;
}
virtual void getQuaternion(float *w, float *x, float *y, float *z) {
void getQuaternion(float *w, float *x, float *y, float *z) {
*w = q0;
*x = q1;
*y = q2;

View file

@ -38,31 +38,25 @@ private:
public:
Adafruit_Mahony();
virtual void begin(float sampleFrequency) {
invSampleFreq = 1.0f / sampleFrequency;
}
virtual void update(float gx, float gy, float gz, float ax, float ay,
float az, float mx, float my, float mz);
void begin(float 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);
void updateIMU(float gx, float gy, float gz, float ax, float ay, float az);
virtual float getRoll() {
float getRoll() {
if (!anglesComputed)
computeAngles();
return roll * 57.29578f;
}
virtual float getPitch() {
float getPitch() {
if (!anglesComputed)
computeAngles();
return pitch * 57.29578f;
}
virtual float getYaw() {
float getYaw() {
if (!anglesComputed)
computeAngles();
return yaw * 57.29578f + 180.0f;
}
float getRollRadians() {
if (!anglesComputed)
computeAngles();
@ -78,8 +72,7 @@ public:
computeAngles();
return yaw;
}
virtual void getQuaternion(float *w, float *x, float *y, float *z) {
void getQuaternion(float *w, float *x, float *y, float *z) {
*w = q0;
*x = q1;
*y = q2;

View file

@ -34,15 +34,15 @@
// changed class name to avoid collision
class Adafruit_NXPSensorFusion : public Adafruit_AHRS_FusionInterface {
public:
virtual void begin(float sampleRate = 100.0f);
virtual void update(float gx, float gy, float gz, float ax, float ay,
float az, float mx, float my, float mz);
void begin(float sampleRate = 100.0f);
void update(float gx, float gy, float gz, float ax, float ay, float az,
float mx, float my, float mz);
virtual float getRoll() { return PhiPl; }
virtual float getPitch() { return ThePl; }
virtual float getYaw() { return PsiPl; }
float getRoll() { return PhiPl; }
float getPitch() { return ThePl; }
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;
*x = qPl.q1;
*y = qPl.q2;