From 59f5be75a09e3f3e275bf9358049875b424f90b3 Mon Sep 17 00:00:00 2001 From: Erynn Scholtes Date: Fri, 26 Apr 2024 20:24:08 +0200 Subject: [PATCH 01/12] compass branch creation + matching files uwuwu --- hhs-system-engineer-project.ino | 3 +++ work/sensor/compass/accelerometer/accel.cpp | 15 +++++++++++ work/sensor/compass/accelerometer/accel.h | 11 ++++++++ work/sensor/compass/compassbase.cpp | 11 ++++++++ work/sensor/compass/compassbase.h | 30 +++++++++++++++++++++ work/sensor/compass/gyroscope/gyro.cpp | 15 +++++++++++ work/sensor/compass/gyroscope/gyro.h | 11 ++++++++ work/sensor/compass/magnetometer/magnet.cpp | 15 +++++++++++ work/sensor/compass/magnetometer/magnet.h | 11 ++++++++ 9 files changed, 122 insertions(+) create mode 100644 work/sensor/compass/accelerometer/accel.cpp create mode 100644 work/sensor/compass/accelerometer/accel.h create mode 100644 work/sensor/compass/compassbase.cpp create mode 100644 work/sensor/compass/compassbase.h create mode 100644 work/sensor/compass/gyroscope/gyro.cpp create mode 100644 work/sensor/compass/gyroscope/gyro.h create mode 100644 work/sensor/compass/magnetometer/magnet.cpp create mode 100644 work/sensor/compass/magnetometer/magnet.h diff --git a/hhs-system-engineer-project.ino b/hhs-system-engineer-project.ino index caf8a1d..8ad52a7 100644 --- a/hhs-system-engineer-project.ino +++ b/hhs-system-engineer-project.ino @@ -1,6 +1,9 @@ #include #include "work/ran-func.cpp" #include "work/serial/serial.cpp" +#include "work/sensor/compass/accelerometer/accel.cpp" +#include "work/sensor/compass/gyroscope/gyro.cpp" +#include "work/sensor/compass/magnetometer/magnet.cpp" int test = 0; int speed = 0; diff --git a/work/sensor/compass/accelerometer/accel.cpp b/work/sensor/compass/accelerometer/accel.cpp new file mode 100644 index 0000000..52c2263 --- /dev/null +++ b/work/sensor/compass/accelerometer/accel.cpp @@ -0,0 +1,15 @@ +#include "../../../headers.hpp" +#include "accel.h" + + +void Accelerometer::_retrieveData() { + if (_interface.accDataReady()) + { + _interface.readAcc(); + _vector.x = _interface.a.x; + _vector.y = _interface.a.y; + _vector.z = _interface.a.z; + } +} + +// written by: Erynn 'foorpyxof' Scholtes | 2024 NSE Zumo project diff --git a/work/sensor/compass/accelerometer/accel.h b/work/sensor/compass/accelerometer/accel.h new file mode 100644 index 0000000..3d8c264 --- /dev/null +++ b/work/sensor/compass/accelerometer/accel.h @@ -0,0 +1,11 @@ +#include "../../../headers.hpp" +#include "../compassbase.h" + +class Accelerometer : public CompassBase { + using CompassBase::CompassBase; + + protected: + void _retrieveData() override; +}; + +// written by: Erynn 'foorpyxof' Scholtes | 2024 NSE Zumo project diff --git a/work/sensor/compass/compassbase.cpp b/work/sensor/compass/compassbase.cpp new file mode 100644 index 0000000..85d653c --- /dev/null +++ b/work/sensor/compass/compassbase.cpp @@ -0,0 +1,11 @@ +#include "../../headers.hpp" +#include "compassbase.h" + + +CompassBase::CompassBase(): _vector.x(0), _vector.y(0), _vector.z(0) { _interface.init(); } + +Vector3 CompassBase::Values() { + return _vector; +} + +// written by: Erynn 'foorpyxof' Scholtes | 2024 NSE Zumo project diff --git a/work/sensor/compass/compassbase.h b/work/sensor/compass/compassbase.h new file mode 100644 index 0000000..ca2d44f --- /dev/null +++ b/work/sensor/compass/compassbase.h @@ -0,0 +1,30 @@ +#include "../../headers.hpp" +#include + +#ifndef COMPASSBASE_H +#define COMPASSBASE_H + +struct Vector3 { int16_t x,y,z; }; + +// this is a class meant as a template only!!! is abstract class :3c +class CompassBase { + // the object that allows us to interface with the IMU-sensors + protected: + Vector3 _vector; // the Vector3 struct (x,y,z) that holds the data that has been read + Zumo32U4IMU _interface; // contains methods to read raw values, as well as three containers to temporarily store them in; + // container names: 'a' for accel readings, 'g' for gyro readings, 'm' for magnet readings + // these containers will only be used by their respective derived-classes + + private: + virtual void _retrieveData() = 0; // template method that will make the derived class read from its respective sensor + + public: + CompassBase(); // constructor that's gonna be copied to all derived classes (accel, gyro, magnet) + Vector3 Values(); // public method that allows the Zumo to read whatever is currently stored in '_vector' + + // methods are defined in attached file, 'compassbase.cpp' +}; + +#endif + +// written by: Erynn 'foorpyxof' Scholtes | 2024 NSE Zumo project diff --git a/work/sensor/compass/gyroscope/gyro.cpp b/work/sensor/compass/gyroscope/gyro.cpp new file mode 100644 index 0000000..ae7bc27 --- /dev/null +++ b/work/sensor/compass/gyroscope/gyro.cpp @@ -0,0 +1,15 @@ +#include "../../../headers.hpp" +#include "gyro.h" + + +void Gyroscope::_retrieveData() { + if (_interface.gyroDataReady()) + { + _interface.readGyro(); + _vector.x = _interface.g.x; + _vector.y = _interface.g.y; + _vector.z = _interface.g.z; + } +} + +// written by: Erynn 'foorpyxof' Scholtes | 2024 NSE Zumo project diff --git a/work/sensor/compass/gyroscope/gyro.h b/work/sensor/compass/gyroscope/gyro.h new file mode 100644 index 0000000..890073d --- /dev/null +++ b/work/sensor/compass/gyroscope/gyro.h @@ -0,0 +1,11 @@ +#include "../../../headers.hpp" +#include "../compassbase.h" + +class Gyroscope : public CompassBase { + using CompassBase::CompassBase; + + protected: + void _retrieveData() override; +}; + +// written by: Erynn 'foorpyxof' Scholtes | 2024 NSE Zumo project diff --git a/work/sensor/compass/magnetometer/magnet.cpp b/work/sensor/compass/magnetometer/magnet.cpp new file mode 100644 index 0000000..39ab124 --- /dev/null +++ b/work/sensor/compass/magnetometer/magnet.cpp @@ -0,0 +1,15 @@ +#include "../../../headers.hpp" +#include "magnet.h" + + +void Magnetometer::_retrieveData() { + if (_interface.magDataReady()) + { + _interface.readMag(); + _vector.x = _interface.m.x; + _vector.y = _interface.m.y; + _vector.z = _interface.m.z; + } +} + +// written by: Erynn 'foorpyxof' Scholtes | 2024 NSE Zumo project diff --git a/work/sensor/compass/magnetometer/magnet.h b/work/sensor/compass/magnetometer/magnet.h new file mode 100644 index 0000000..2a780e6 --- /dev/null +++ b/work/sensor/compass/magnetometer/magnet.h @@ -0,0 +1,11 @@ +#include "../../../headers.hpp" +#include "../compassbase.h" + +class Magnetometer : public CompassBase { + using CompassBase::CompassBase; + + protected: + void _retrieveData() override; +}; + +// written by: Erynn 'foorpyxof' Scholtes | 2024 NSE Zumo project From 50cdb9a81eb5f09b21573e712370392d8cff3712 Mon Sep 17 00:00:00 2001 From: Erynn Scholtes Date: Fri, 26 Apr 2024 20:24:08 +0200 Subject: [PATCH 02/12] compass branch creation + matching files uwuwu --- work/sensor/compass/accelerometer/accel.h | 2 +- work/sensor/compass/compassbase.cpp | 3 ++ work/sensor/compass/compassbase.h | 35 +++++++++++++++++------ work/sensor/compass/gyroscope/gyro.h | 2 +- work/sensor/compass/magnetometer/magnet.h | 2 +- 5 files changed, 32 insertions(+), 12 deletions(-) diff --git a/work/sensor/compass/accelerometer/accel.h b/work/sensor/compass/accelerometer/accel.h index 3d8c264..4344971 100644 --- a/work/sensor/compass/accelerometer/accel.h +++ b/work/sensor/compass/accelerometer/accel.h @@ -4,7 +4,7 @@ class Accelerometer : public CompassBase { using CompassBase::CompassBase; - protected: + private: void _retrieveData() override; }; diff --git a/work/sensor/compass/compassbase.cpp b/work/sensor/compass/compassbase.cpp index 85d653c..5bdb3cb 100644 --- a/work/sensor/compass/compassbase.cpp +++ b/work/sensor/compass/compassbase.cpp @@ -5,6 +5,9 @@ CompassBase::CompassBase(): _vector.x(0), _vector.y(0), _vector.z(0) { _interface.init(); } Vector3 CompassBase::Values() { + + this._retrieveData(); + return _vector; } diff --git a/work/sensor/compass/compassbase.h b/work/sensor/compass/compassbase.h index ca2d44f..59fde5a 100644 --- a/work/sensor/compass/compassbase.h +++ b/work/sensor/compass/compassbase.h @@ -6,21 +6,38 @@ struct Vector3 { int16_t x,y,z; }; -// this is a class meant as a template only!!! is abstract class :3c +// this is a class meant as a template only!!! +// is abstract class :3c class CompassBase { - // the object that allows us to interface with the IMU-sensors protected: - Vector3 _vector; // the Vector3 struct (x,y,z) that holds the data that has been read - Zumo32U4IMU _interface; // contains methods to read raw values, as well as three containers to temporarily store them in; - // container names: 'a' for accel readings, 'g' for gyro readings, 'm' for magnet readings - // these containers will only be used by their respective derived-classes + Vector3 _vector; // the Vector3 struct (x,y,z) that holds + // the data that has been read + + // the object that allows us to interface with the IMU-sensors + Zumo32U4IMU _interface; // it contains methods to read raw values + // as well as three containers to + // temporarily store them in; + // + // container names: + // 'a' for accel readings + // 'g' for gyro readings + // 'm' for magnet readings + // + // these containers will only be used by + // their respective derived-classes private: - virtual void _retrieveData() = 0; // template method that will make the derived class read from its respective sensor + virtual void _retrieveData() = 0; // template method that will make + // the derived class read from + // its respective sensor public: - CompassBase(); // constructor that's gonna be copied to all derived classes (accel, gyro, magnet) - Vector3 Values(); // public method that allows the Zumo to read whatever is currently stored in '_vector' + CompassBase(); // constructor that's gonna be inherited + // by all derived classes + // (accel, gyro, magnet) + + Vector3 Values(); // public method that allows the Zumo to read + // whatever is currently stored in '_vector' // methods are defined in attached file, 'compassbase.cpp' }; diff --git a/work/sensor/compass/gyroscope/gyro.h b/work/sensor/compass/gyroscope/gyro.h index 890073d..a1f8e2e 100644 --- a/work/sensor/compass/gyroscope/gyro.h +++ b/work/sensor/compass/gyroscope/gyro.h @@ -4,7 +4,7 @@ class Gyroscope : public CompassBase { using CompassBase::CompassBase; - protected: + private: void _retrieveData() override; }; diff --git a/work/sensor/compass/magnetometer/magnet.h b/work/sensor/compass/magnetometer/magnet.h index 2a780e6..d929a50 100644 --- a/work/sensor/compass/magnetometer/magnet.h +++ b/work/sensor/compass/magnetometer/magnet.h @@ -4,7 +4,7 @@ class Magnetometer : public CompassBase { using CompassBase::CompassBase; - protected: + private: void _retrieveData() override; }; From 814b4a8aacc78a370787c54e6f53003544fd1cb4 Mon Sep 17 00:00:00 2001 From: Erynn Scholtes Date: Fri, 26 Apr 2024 20:24:08 +0200 Subject: [PATCH 03/12] compass branch creation + matching files uwuwu --- hhs-system-engineer-project.ino | 3 ++ work/sensor/compass/accelerometer/accel.cpp | 15 ++++++ work/sensor/compass/accelerometer/accel.h | 11 +++++ work/sensor/compass/compassbase.cpp | 14 ++++++ work/sensor/compass/compassbase.h | 52 +++++++++++++++++++++ work/sensor/compass/gyroscope/gyro.cpp | 15 ++++++ work/sensor/compass/gyroscope/gyro.h | 11 +++++ work/sensor/compass/magnetometer/magnet.cpp | 15 ++++++ work/sensor/compass/magnetometer/magnet.h | 11 +++++ 9 files changed, 147 insertions(+) create mode 100644 work/sensor/compass/accelerometer/accel.cpp create mode 100644 work/sensor/compass/accelerometer/accel.h create mode 100644 work/sensor/compass/compassbase.cpp create mode 100644 work/sensor/compass/compassbase.h create mode 100644 work/sensor/compass/gyroscope/gyro.cpp create mode 100644 work/sensor/compass/gyroscope/gyro.h create mode 100644 work/sensor/compass/magnetometer/magnet.cpp create mode 100644 work/sensor/compass/magnetometer/magnet.h diff --git a/hhs-system-engineer-project.ino b/hhs-system-engineer-project.ino index caf8a1d..8ad52a7 100644 --- a/hhs-system-engineer-project.ino +++ b/hhs-system-engineer-project.ino @@ -1,6 +1,9 @@ #include #include "work/ran-func.cpp" #include "work/serial/serial.cpp" +#include "work/sensor/compass/accelerometer/accel.cpp" +#include "work/sensor/compass/gyroscope/gyro.cpp" +#include "work/sensor/compass/magnetometer/magnet.cpp" int test = 0; int speed = 0; diff --git a/work/sensor/compass/accelerometer/accel.cpp b/work/sensor/compass/accelerometer/accel.cpp new file mode 100644 index 0000000..52c2263 --- /dev/null +++ b/work/sensor/compass/accelerometer/accel.cpp @@ -0,0 +1,15 @@ +#include "../../../headers.hpp" +#include "accel.h" + + +void Accelerometer::_retrieveData() { + if (_interface.accDataReady()) + { + _interface.readAcc(); + _vector.x = _interface.a.x; + _vector.y = _interface.a.y; + _vector.z = _interface.a.z; + } +} + +// written by: Erynn 'foorpyxof' Scholtes | 2024 NSE Zumo project diff --git a/work/sensor/compass/accelerometer/accel.h b/work/sensor/compass/accelerometer/accel.h new file mode 100644 index 0000000..4344971 --- /dev/null +++ b/work/sensor/compass/accelerometer/accel.h @@ -0,0 +1,11 @@ +#include "../../../headers.hpp" +#include "../compassbase.h" + +class Accelerometer : public CompassBase { + using CompassBase::CompassBase; + + private: + void _retrieveData() override; +}; + +// written by: Erynn 'foorpyxof' Scholtes | 2024 NSE Zumo project diff --git a/work/sensor/compass/compassbase.cpp b/work/sensor/compass/compassbase.cpp new file mode 100644 index 0000000..5bdb3cb --- /dev/null +++ b/work/sensor/compass/compassbase.cpp @@ -0,0 +1,14 @@ +#include "../../headers.hpp" +#include "compassbase.h" + + +CompassBase::CompassBase(): _vector.x(0), _vector.y(0), _vector.z(0) { _interface.init(); } + +Vector3 CompassBase::Values() { + + this._retrieveData(); + + return _vector; +} + +// written by: Erynn 'foorpyxof' Scholtes | 2024 NSE Zumo project diff --git a/work/sensor/compass/compassbase.h b/work/sensor/compass/compassbase.h new file mode 100644 index 0000000..788a61e --- /dev/null +++ b/work/sensor/compass/compassbase.h @@ -0,0 +1,52 @@ +#include "../../headers.hpp" +#include + +#ifndef COMPASSBASE_H +#define COMPASSBASE_H + + +// this is a class meant as a template only!!! +// is abstract class :3c +class CompassBase { + protected: + struct Vector3 { int16_t x,y,z; }; // the struct containing three + // 16bit integers that will hold + // the values read by the sensor + // attached to the child-class + // of CompassBase + + Vector3 _vector; // the Vector3 struct (x,y,z) that holds + // the data that has been read + + // the object that allows us to interface with the IMU-sensors + Zumo32U4IMU _interface; // it contains methods to read raw values + // as well as three containers to + // temporarily store them in; + // + // container names: + // 'a' for accel readings + // 'g' for gyro readings + // 'm' for magnet readings + // + // these containers will only be used by + // their respective derived-classes + + private: + virtual void _retrieveData() = 0; // template method that will make + // the derived class read from + // its respective sensor + + public: + CompassBase(); // constructor that's gonna be inherited + // by all derived classes + // (accel, gyro, magnet) + + Vector3 Values(); // public method that allows the Zumo to read + // whatever is currently stored in '_vector' + + // methods are defined in attached file, 'compassbase.cpp' +}; + +#endif + +// written by: Erynn 'foorpyxof' Scholtes | 2024 NSE Zumo project diff --git a/work/sensor/compass/gyroscope/gyro.cpp b/work/sensor/compass/gyroscope/gyro.cpp new file mode 100644 index 0000000..ae7bc27 --- /dev/null +++ b/work/sensor/compass/gyroscope/gyro.cpp @@ -0,0 +1,15 @@ +#include "../../../headers.hpp" +#include "gyro.h" + + +void Gyroscope::_retrieveData() { + if (_interface.gyroDataReady()) + { + _interface.readGyro(); + _vector.x = _interface.g.x; + _vector.y = _interface.g.y; + _vector.z = _interface.g.z; + } +} + +// written by: Erynn 'foorpyxof' Scholtes | 2024 NSE Zumo project diff --git a/work/sensor/compass/gyroscope/gyro.h b/work/sensor/compass/gyroscope/gyro.h new file mode 100644 index 0000000..a1f8e2e --- /dev/null +++ b/work/sensor/compass/gyroscope/gyro.h @@ -0,0 +1,11 @@ +#include "../../../headers.hpp" +#include "../compassbase.h" + +class Gyroscope : public CompassBase { + using CompassBase::CompassBase; + + private: + void _retrieveData() override; +}; + +// written by: Erynn 'foorpyxof' Scholtes | 2024 NSE Zumo project diff --git a/work/sensor/compass/magnetometer/magnet.cpp b/work/sensor/compass/magnetometer/magnet.cpp new file mode 100644 index 0000000..39ab124 --- /dev/null +++ b/work/sensor/compass/magnetometer/magnet.cpp @@ -0,0 +1,15 @@ +#include "../../../headers.hpp" +#include "magnet.h" + + +void Magnetometer::_retrieveData() { + if (_interface.magDataReady()) + { + _interface.readMag(); + _vector.x = _interface.m.x; + _vector.y = _interface.m.y; + _vector.z = _interface.m.z; + } +} + +// written by: Erynn 'foorpyxof' Scholtes | 2024 NSE Zumo project diff --git a/work/sensor/compass/magnetometer/magnet.h b/work/sensor/compass/magnetometer/magnet.h new file mode 100644 index 0000000..d929a50 --- /dev/null +++ b/work/sensor/compass/magnetometer/magnet.h @@ -0,0 +1,11 @@ +#include "../../../headers.hpp" +#include "../compassbase.h" + +class Magnetometer : public CompassBase { + using CompassBase::CompassBase; + + private: + void _retrieveData() override; +}; + +// written by: Erynn 'foorpyxof' Scholtes | 2024 NSE Zumo project From 1cedc7bd6fdedf126302a26c34e846815d86e303 Mon Sep 17 00:00:00 2001 From: Erynn Scholtes Date: Sat, 27 Apr 2024 13:24:54 +0200 Subject: [PATCH 04/12] tiny fix in .ino file --- hhs-system-engineer-project.ino | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hhs-system-engineer-project.ino b/hhs-system-engineer-project.ino index 8ad52a7..3e88d2b 100644 --- a/hhs-system-engineer-project.ino +++ b/hhs-system-engineer-project.ino @@ -1,9 +1,9 @@ #include #include "work/ran-func.cpp" #include "work/serial/serial.cpp" -#include "work/sensor/compass/accelerometer/accel.cpp" -#include "work/sensor/compass/gyroscope/gyro.cpp" -#include "work/sensor/compass/magnetometer/magnet.cpp" +#include "work/sensor/compass/accelerometer/accel.h" +#include "work/sensor/compass/gyroscope/gyro.h" +#include "work/sensor/compass/magnetometer/magnet.h" int test = 0; int speed = 0; From 7ce25df042eb3a17dc69f8aad75ccb7ba5703a47 Mon Sep 17 00:00:00 2001 From: Erynn Scholtes Date: Sun, 28 Apr 2024 09:27:42 +0200 Subject: [PATCH 05/12] Update .gitignore --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index b730a30..6ef0ddc 100644 --- a/.gitignore +++ b/.gitignore @@ -36,3 +36,6 @@ build/* # Ignore vscode .vscode/* + +# .vim session files +*.vim From 2a794de388acd4651516cf8b7792e6c50358bea8 Mon Sep 17 00:00:00 2001 From: Erynn Scholtes Date: Mon, 29 Apr 2024 22:38:46 +0200 Subject: [PATCH 06/12] Wrote testcode in .ino file --- hhs-system-engineer-project.ino | 54 ++++++++++++++++++--- work/sensor/compass/accelerometer/accel.cpp | 4 -- work/sensor/compass/accelerometer/accel.h | 12 ++++- work/sensor/compass/compassbase.cpp | 19 +++++--- work/sensor/compass/compassbase.h | 21 ++++---- work/sensor/compass/gyroscope/gyro.cpp | 4 -- work/sensor/compass/gyroscope/gyro.h | 12 ++++- work/sensor/compass/magnetometer/magnet.cpp | 4 -- work/sensor/compass/magnetometer/magnet.h | 12 ++++- 9 files changed, 103 insertions(+), 39 deletions(-) diff --git a/hhs-system-engineer-project.ino b/hhs-system-engineer-project.ino index 3e88d2b..95034de 100644 --- a/hhs-system-engineer-project.ino +++ b/hhs-system-engineer-project.ino @@ -1,4 +1,4 @@ -#include +#include "work/headers.hpp" #include "work/ran-func.cpp" #include "work/serial/serial.cpp" #include "work/sensor/compass/accelerometer/accel.h" @@ -8,16 +8,24 @@ int test = 0; int speed = 0; +Accelerometer accel; +Gyroscope gyro; +Magnetometer magnet; + +Vector3 accelData; +Vector3 gyroData; +Vector3 magnetData; + #define RECHTS OCR1A #define LINKS OCR1B -auto& xbee = Serial; +//auto& xbee = Serial; void setup() { Serial1.begin(4800); Serial1.println("Zumo Active, Serial1 Output"); - xbee.begin(4800); + // xbee.begin(4800); pinMode(A10, OUTPUT); pinMode(A9, OUTPUT); @@ -28,11 +36,45 @@ void setup() { SetupTimer1(); Serial.println(); + + CompassBase* cBase = new CompassBase(); + cBase->Initialize(); + delete cBase; + + accel = Accelerometer(); + gyro = Gyroscope(); + magnet = Magnetometer(); + + accelData = accel.Values(); + gyroData = gyro.Values(); + magnetData = magnet.Values(); } void loop() { - if(Serial1.available()){ - readserial(test,speed); - } + //if(Serial1.available()){ + //readserial(test,speed); + //} + accelData = accel.Values(); + gyroData = gyro.Values(); + magnetData = magnet.Values(); + + printCompassValues(); } +void printCompassValues() { + Serial1.print("Acceleration:"); + Serial1.print("\r\nX: "); Serial1.print(accelData.x); + Serial1.print("\r\nY: "); Serial1.print(accelData.y); + Serial1.print("\r\nZ: "); Serial1.print(accelData.z); + + Serial1.print("\r\nGyroscope:"); + Serial1.print("\r\nX: "); Serial1.print(gyroData.x); + Serial1.print("\r\nY: "); Serial1.print(gyroData.y); + Serial1.print("\r\nZ: "); Serial1.print(gyroData.z); + + Serial1.print("\r\nMagnetometer:"); + Serial1.print("\r\nX: "); Serial1.print(magnetData.x); + Serial1.print("\r\nY: "); Serial1.print(magnetData.y); + Serial1.print("\r\nZ: "); Serial1.print(magnetData.z); + Serial1.println("----------------"); +} diff --git a/work/sensor/compass/accelerometer/accel.cpp b/work/sensor/compass/accelerometer/accel.cpp index 52c2263..5343ee8 100644 --- a/work/sensor/compass/accelerometer/accel.cpp +++ b/work/sensor/compass/accelerometer/accel.cpp @@ -1,7 +1,3 @@ -#include "../../../headers.hpp" -#include "accel.h" - - void Accelerometer::_retrieveData() { if (_interface.accDataReady()) { diff --git a/work/sensor/compass/accelerometer/accel.h b/work/sensor/compass/accelerometer/accel.h index 4344971..9d09884 100644 --- a/work/sensor/compass/accelerometer/accel.h +++ b/work/sensor/compass/accelerometer/accel.h @@ -1,11 +1,19 @@ #include "../../../headers.hpp" #include "../compassbase.h" -class Accelerometer : public CompassBase { - using CompassBase::CompassBase; +#ifndef ACCEL_H +#define ACCEL_H +class Accelerometer : private CompassBase { private: void _retrieveData() override; + public: + using CompassBase::CompassBase; + using CompassBase::Values; }; +#include "accel.cpp" + +#endif + // written by: Erynn 'foorpyxof' Scholtes | 2024 NSE Zumo project diff --git a/work/sensor/compass/compassbase.cpp b/work/sensor/compass/compassbase.cpp index 5bdb3cb..d80813b 100644 --- a/work/sensor/compass/compassbase.cpp +++ b/work/sensor/compass/compassbase.cpp @@ -1,14 +1,21 @@ -#include "../../headers.hpp" -#include "compassbase.h" - - -CompassBase::CompassBase(): _vector.x(0), _vector.y(0), _vector.z(0) { _interface.init(); } +CompassBase::CompassBase(): _vector{0, 0, 0} { } +void CompassBase::_retrieveData() { + return; +} Vector3 CompassBase::Values() { - this._retrieveData(); + this->_retrieveData(); return _vector; } +void CompassBase::Initialize() { + if (_interface.init()) + { + Serial1.println("Compass interface initialized successfully!"); + } else { + Serial1.println("Compass interface initialized successfully?"); + } +} // written by: Erynn 'foorpyxof' Scholtes | 2024 NSE Zumo project diff --git a/work/sensor/compass/compassbase.h b/work/sensor/compass/compassbase.h index 788a61e..e55e19c 100644 --- a/work/sensor/compass/compassbase.h +++ b/work/sensor/compass/compassbase.h @@ -4,17 +4,16 @@ #ifndef COMPASSBASE_H #define COMPASSBASE_H +struct Vector3 { int16_t x,y,z; }; // the struct containing three + // 16bit integers that will hold + // the values read by the sensor + // attached to the child-class + // of CompassBase // this is a class meant as a template only!!! // is abstract class :3c class CompassBase { protected: - struct Vector3 { int16_t x,y,z; }; // the struct containing three - // 16bit integers that will hold - // the values read by the sensor - // attached to the child-class - // of CompassBase - Vector3 _vector; // the Vector3 struct (x,y,z) that holds // the data that has been read @@ -32,9 +31,9 @@ class CompassBase { // their respective derived-classes private: - virtual void _retrieveData() = 0; // template method that will make - // the derived class read from - // its respective sensor + virtual void _retrieveData(); // template method that will make + // the derived class read from + // its respective sensor public: CompassBase(); // constructor that's gonna be inherited @@ -43,10 +42,14 @@ class CompassBase { Vector3 Values(); // public method that allows the Zumo to read // whatever is currently stored in '_vector' + + void Initialize(); // methods are defined in attached file, 'compassbase.cpp' }; +#include "compassbase.cpp" + #endif // written by: Erynn 'foorpyxof' Scholtes | 2024 NSE Zumo project diff --git a/work/sensor/compass/gyroscope/gyro.cpp b/work/sensor/compass/gyroscope/gyro.cpp index ae7bc27..dcf6f4a 100644 --- a/work/sensor/compass/gyroscope/gyro.cpp +++ b/work/sensor/compass/gyroscope/gyro.cpp @@ -1,7 +1,3 @@ -#include "../../../headers.hpp" -#include "gyro.h" - - void Gyroscope::_retrieveData() { if (_interface.gyroDataReady()) { diff --git a/work/sensor/compass/gyroscope/gyro.h b/work/sensor/compass/gyroscope/gyro.h index a1f8e2e..72806a3 100644 --- a/work/sensor/compass/gyroscope/gyro.h +++ b/work/sensor/compass/gyroscope/gyro.h @@ -1,11 +1,19 @@ #include "../../../headers.hpp" #include "../compassbase.h" -class Gyroscope : public CompassBase { - using CompassBase::CompassBase; +#ifndef GYRO_H +#define GYRO_H +class Gyroscope : private CompassBase { private: void _retrieveData() override; + public: + using CompassBase::CompassBase; + using CompassBase::Values; }; +#include "gyro.cpp" + +#endif + // written by: Erynn 'foorpyxof' Scholtes | 2024 NSE Zumo project diff --git a/work/sensor/compass/magnetometer/magnet.cpp b/work/sensor/compass/magnetometer/magnet.cpp index 39ab124..64eae80 100644 --- a/work/sensor/compass/magnetometer/magnet.cpp +++ b/work/sensor/compass/magnetometer/magnet.cpp @@ -1,7 +1,3 @@ -#include "../../../headers.hpp" -#include "magnet.h" - - void Magnetometer::_retrieveData() { if (_interface.magDataReady()) { diff --git a/work/sensor/compass/magnetometer/magnet.h b/work/sensor/compass/magnetometer/magnet.h index d929a50..fb7f857 100644 --- a/work/sensor/compass/magnetometer/magnet.h +++ b/work/sensor/compass/magnetometer/magnet.h @@ -1,11 +1,19 @@ #include "../../../headers.hpp" #include "../compassbase.h" -class Magnetometer : public CompassBase { - using CompassBase::CompassBase; +#ifndef MAGNET_H +#define MAGNET_H +class Magnetometer : private CompassBase { private: void _retrieveData() override; + public: + using CompassBase::CompassBase; + using CompassBase::Values; }; +#include "magnet.cpp" + +#endif + // written by: Erynn 'foorpyxof' Scholtes | 2024 NSE Zumo project From fcb41b56c46f33755edad1acb4dfca094d974f6f Mon Sep 17 00:00:00 2001 From: Erynn Date: Thu, 2 May 2024 17:49:05 +0200 Subject: [PATCH 07/12] data gets read :thumbsup: it's bad data though......... either that or the Zumo is actually accelerating by 17000 units on the Z-axis lol --- hhs-system-engineer-project.ino | 61 +++++++++++++-------- work/sensor/compass/accelerometer/accel.cpp | 10 ++-- work/sensor/compass/accelerometer/accel.h | 1 + work/sensor/compass/compassbase.cpp | 13 +++-- work/sensor/compass/compassbase.h | 23 ++++---- work/sensor/compass/gyroscope/gyro.cpp | 10 ++-- work/sensor/compass/gyroscope/gyro.h | 1 + work/sensor/compass/magnetometer/magnet.cpp | 10 ++-- work/sensor/compass/magnetometer/magnet.h | 1 + 9 files changed, 77 insertions(+), 53 deletions(-) diff --git a/hhs-system-engineer-project.ino b/hhs-system-engineer-project.ino index 95034de..3874bd4 100644 --- a/hhs-system-engineer-project.ino +++ b/hhs-system-engineer-project.ino @@ -1,3 +1,4 @@ +#define __AVR_ATmega32U4__ #include "work/headers.hpp" #include "work/ran-func.cpp" #include "work/serial/serial.cpp" @@ -16,12 +17,16 @@ Vector3 accelData; Vector3 gyroData; Vector3 magnetData; +char imuOutBuffer[139]; + #define RECHTS OCR1A #define LINKS OCR1B //auto& xbee = Serial; void setup() { + Wire.begin(); + Serial1.begin(4800); Serial1.println("Zumo Active, Serial1 Output"); @@ -37,13 +42,24 @@ void setup() { Serial.println(); - CompassBase* cBase = new CompassBase(); - cBase->Initialize(); - delete cBase; - - accel = Accelerometer(); - gyro = Gyroscope(); - magnet = Magnetometer(); + // check if compass can be initialized properly + Zumo32U4IMU* compassInterfacePTR = new Zumo32U4IMU(); + if (compassInterfacePTR->init()) + { + Serial1.println("Compass interface initialized successfully!"); + compassInterfacePTR->enableDefault(); + accel = Accelerometer(compassInterfacePTR); + gyro = Gyroscope(compassInterfacePTR); + magnet = Magnetometer(compassInterfacePTR); + + // these three are not implemented yet + // accel.PrintDebugInfo(); + // gyro.PrintDebugInfo(); + // magnet.PrintDebugInfo(); + } else { + Serial1.println("Compass interface probably not initialized successfully?"); + } + // end of compass initialization test accelData = accel.Values(); gyroData = gyro.Values(); @@ -62,19 +78,18 @@ void loop() { } void printCompassValues() { - Serial1.print("Acceleration:"); - Serial1.print("\r\nX: "); Serial1.print(accelData.x); - Serial1.print("\r\nY: "); Serial1.print(accelData.y); - Serial1.print("\r\nZ: "); Serial1.print(accelData.z); - - Serial1.print("\r\nGyroscope:"); - Serial1.print("\r\nX: "); Serial1.print(gyroData.x); - Serial1.print("\r\nY: "); Serial1.print(gyroData.y); - Serial1.print("\r\nZ: "); Serial1.print(gyroData.z); - - Serial1.print("\r\nMagnetometer:"); - Serial1.print("\r\nX: "); Serial1.print(magnetData.x); - Serial1.print("\r\nY: "); Serial1.print(magnetData.y); - Serial1.print("\r\nZ: "); Serial1.print(magnetData.z); - Serial1.println("----------------"); -} + Serial1.println(sprintf(imuOutBuffer, "%s\r\n%s%d\r\n%s%d\r\n%s%d\r\n%s%d\r\n%s%d\r\n%s%d\r\n%s%d\r\n%s%d\r\n%s%d\r\n%s", + "--------------------", + "aX: ", accelData.x, + "aY: ", accelData.y, + "aZ: ", accelData.z, + "gX: ", gyroData.x, + "gY: ", gyroData.y, + "gZ: ", gyroData.z, + "mX: ", magnetData.x, + "mY: ", magnetData.y, + "mZ: ", magnetData.z, + "--------------------")); + + Serial1.println(imuOutBuffer); +} \ No newline at end of file diff --git a/work/sensor/compass/accelerometer/accel.cpp b/work/sensor/compass/accelerometer/accel.cpp index 5343ee8..c754968 100644 --- a/work/sensor/compass/accelerometer/accel.cpp +++ b/work/sensor/compass/accelerometer/accel.cpp @@ -1,10 +1,10 @@ void Accelerometer::_retrieveData() { - if (_interface.accDataReady()) + if (_interfacePTR->accDataReady()) { - _interface.readAcc(); - _vector.x = _interface.a.x; - _vector.y = _interface.a.y; - _vector.z = _interface.a.z; + _interfacePTR->readAcc(); + _vector.x = _interfacePTR->a.x; + _vector.y = _interfacePTR->a.y; + _vector.z = _interfacePTR->a.z; } } diff --git a/work/sensor/compass/accelerometer/accel.h b/work/sensor/compass/accelerometer/accel.h index 9d09884..e9e66c3 100644 --- a/work/sensor/compass/accelerometer/accel.h +++ b/work/sensor/compass/accelerometer/accel.h @@ -10,6 +10,7 @@ class Accelerometer : private CompassBase { public: using CompassBase::CompassBase; using CompassBase::Values; + using CompassBase::PrintDebugInfo; }; #include "accel.cpp" diff --git a/work/sensor/compass/compassbase.cpp b/work/sensor/compass/compassbase.cpp index d80813b..766de5e 100644 --- a/work/sensor/compass/compassbase.cpp +++ b/work/sensor/compass/compassbase.cpp @@ -1,8 +1,6 @@ CompassBase::CompassBase(): _vector{0, 0, 0} { } +CompassBase::CompassBase(Zumo32U4IMU* ifacePTR): _vector{0, 0, 0}, _interfacePTR(ifacePTR) { } -void CompassBase::_retrieveData() { - return; -} Vector3 CompassBase::Values() { this->_retrieveData(); @@ -11,11 +9,16 @@ Vector3 CompassBase::Values() { } void CompassBase::Initialize() { - if (_interface.init()) + if (_interfacePTR->init()) { Serial1.println("Compass interface initialized successfully!"); } else { Serial1.println("Compass interface initialized successfully?"); } } -// written by: Erynn 'foorpyxof' Scholtes | 2024 NSE Zumo project + +// void CompassBase::PrintDebugInfo() { +// Serial1.println(_interfacePTR->getType()); +// } + +// written by: Erynn 'foorpyxof' Scholtes | 2024 NSE Zumo project \ No newline at end of file diff --git a/work/sensor/compass/compassbase.h b/work/sensor/compass/compassbase.h index e55e19c..9beec6b 100644 --- a/work/sensor/compass/compassbase.h +++ b/work/sensor/compass/compassbase.h @@ -4,11 +4,11 @@ #ifndef COMPASSBASE_H #define COMPASSBASE_H -struct Vector3 { int16_t x,y,z; }; // the struct containing three - // 16bit integers that will hold - // the values read by the sensor - // attached to the child-class - // of CompassBase +struct Vector3 { int16_t x,y,z; }; /* the struct containing three + 16bit integers that will hold + the values read by the sensor + attached to the child-class + of CompassBase */ // this is a class meant as a template only!!! // is abstract class :3c @@ -18,7 +18,7 @@ class CompassBase { // the data that has been read // the object that allows us to interface with the IMU-sensors - Zumo32U4IMU _interface; // it contains methods to read raw values + Zumo32U4IMU* _interfacePTR; // it contains methods to read raw values // as well as three containers to // temporarily store them in; // @@ -31,19 +31,22 @@ class CompassBase { // their respective derived-classes private: - virtual void _retrieveData(); // template method that will make + virtual void _retrieveData() = 0; // template method that will make // the derived class read from // its respective sensor public: - CompassBase(); // constructor that's gonna be inherited - // by all derived classes - // (accel, gyro, magnet) + CompassBase(); // empty constructor. shouldn't use. no worky. + CompassBase(Zumo32U4IMU*); // constructor that's gonna be inherited + // by all derived classes + // (accel, gyro, magnet) Vector3 Values(); // public method that allows the Zumo to read // whatever is currently stored in '_vector' void Initialize(); + + void PrintDebugInfo(); // methods are defined in attached file, 'compassbase.cpp' }; diff --git a/work/sensor/compass/gyroscope/gyro.cpp b/work/sensor/compass/gyroscope/gyro.cpp index dcf6f4a..19309f5 100644 --- a/work/sensor/compass/gyroscope/gyro.cpp +++ b/work/sensor/compass/gyroscope/gyro.cpp @@ -1,10 +1,10 @@ void Gyroscope::_retrieveData() { - if (_interface.gyroDataReady()) + if (_interfacePTR->gyroDataReady()) { - _interface.readGyro(); - _vector.x = _interface.g.x; - _vector.y = _interface.g.y; - _vector.z = _interface.g.z; + _interfacePTR->readGyro(); + _vector.x = _interfacePTR->g.x; + _vector.y = _interfacePTR->g.y; + _vector.z = _interfacePTR->g.z; } } diff --git a/work/sensor/compass/gyroscope/gyro.h b/work/sensor/compass/gyroscope/gyro.h index 72806a3..ff35a85 100644 --- a/work/sensor/compass/gyroscope/gyro.h +++ b/work/sensor/compass/gyroscope/gyro.h @@ -10,6 +10,7 @@ class Gyroscope : private CompassBase { public: using CompassBase::CompassBase; using CompassBase::Values; + using CompassBase::PrintDebugInfo; }; #include "gyro.cpp" diff --git a/work/sensor/compass/magnetometer/magnet.cpp b/work/sensor/compass/magnetometer/magnet.cpp index 64eae80..08f5a84 100644 --- a/work/sensor/compass/magnetometer/magnet.cpp +++ b/work/sensor/compass/magnetometer/magnet.cpp @@ -1,10 +1,10 @@ void Magnetometer::_retrieveData() { - if (_interface.magDataReady()) + if (_interfacePTR->magDataReady()) { - _interface.readMag(); - _vector.x = _interface.m.x; - _vector.y = _interface.m.y; - _vector.z = _interface.m.z; + _interfacePTR->readMag(); + _vector.x = _interfacePTR->m.x; + _vector.y = _interfacePTR->m.y; + _vector.z = _interfacePTR->m.z; } } diff --git a/work/sensor/compass/magnetometer/magnet.h b/work/sensor/compass/magnetometer/magnet.h index fb7f857..c395578 100644 --- a/work/sensor/compass/magnetometer/magnet.h +++ b/work/sensor/compass/magnetometer/magnet.h @@ -10,6 +10,7 @@ class Magnetometer : private CompassBase { public: using CompassBase::CompassBase; using CompassBase::Values; + using CompassBase::PrintDebugInfo; }; #include "magnet.cpp" From 8c3a3a55d2ed815e88be7dfdd7ad9531597bdee1 Mon Sep 17 00:00:00 2001 From: Erynn Scholtes Date: Sat, 4 May 2024 13:14:32 +0200 Subject: [PATCH 08/12] Naming convention changes Private member vars: _camelCase -> m_PascalCase Private methods: _camelCase -> pvt_PascalCase also implemented small debug print on IMU sensors init :3 --- hhs-system-engineer-project.ino | 52 ++++++++++----------- work/sensor/compass/accelerometer/accel.cpp | 12 ++--- work/sensor/compass/accelerometer/accel.h | 2 +- work/sensor/compass/compassbase.cpp | 17 ++++--- work/sensor/compass/compassbase.h | 7 ++- work/sensor/compass/gyroscope/gyro.cpp | 12 ++--- work/sensor/compass/gyroscope/gyro.h | 2 +- work/sensor/compass/magnetometer/magnet.cpp | 12 ++--- work/sensor/compass/magnetometer/magnet.h | 2 +- 9 files changed, 56 insertions(+), 62 deletions(-) diff --git a/hhs-system-engineer-project.ino b/hhs-system-engineer-project.ino index 3874bd4..2be8bf0 100644 --- a/hhs-system-engineer-project.ino +++ b/hhs-system-engineer-project.ino @@ -1,4 +1,5 @@ -#define __AVR_ATmega32U4__ +bool debug = 1; + #include "work/headers.hpp" #include "work/ran-func.cpp" #include "work/serial/serial.cpp" @@ -9,9 +10,9 @@ int test = 0; int speed = 0; -Accelerometer accel; -Gyroscope gyro; -Magnetometer magnet; +Accelerometer* accel; +Gyroscope* gyro; +Magnetometer* magnet; Vector3 accelData; Vector3 gyroData; @@ -44,41 +45,36 @@ void setup() { // check if compass can be initialized properly Zumo32U4IMU* compassInterfacePTR = new Zumo32U4IMU(); - if (compassInterfacePTR->init()) - { - Serial1.println("Compass interface initialized successfully!"); + if (compassInterfacePTR->init()){ + Serial1.println("Compass interface initialized successfully!"); compassInterfacePTR->enableDefault(); - accel = Accelerometer(compassInterfacePTR); - gyro = Gyroscope(compassInterfacePTR); - magnet = Magnetometer(compassInterfacePTR); - - // these three are not implemented yet - // accel.PrintDebugInfo(); - // gyro.PrintDebugInfo(); - // magnet.PrintDebugInfo(); - } else { - Serial1.println("Compass interface probably not initialized successfully?"); - } + *accel = Accelerometer(compassInterfacePTR); + *gyro = Gyroscope(compassInterfacePTR); + *magnet = Magnetometer(compassInterfacePTR); + if (debug) { + accel->PrintDebugInfo(); + gyro->PrintDebugInfo(); + magnet->PrintDebugInfo(); + } + } else { + Serial1.println("Compass interface probably not initialized successfully?"); + } // end of compass initialization test - - accelData = accel.Values(); - gyroData = gyro.Values(); - magnetData = magnet.Values(); } void loop() { //if(Serial1.available()){ //readserial(test,speed); //} - accelData = accel.Values(); - gyroData = gyro.Values(); - magnetData = magnet.Values(); + accelData = accel->Values(); + gyroData = gyro->Values(); + magnetData = magnet->Values(); printCompassValues(); } void printCompassValues() { - Serial1.println(sprintf(imuOutBuffer, "%s\r\n%s%d\r\n%s%d\r\n%s%d\r\n%s%d\r\n%s%d\r\n%s%d\r\n%s%d\r\n%s%d\r\n%s%d\r\n%s", + sprintf(imuOutBuffer, "%s\r\n%s%d\r\n%s%d\r\n%s%d\r\n%s%d\r\n%s%d\r\n%s%d\r\n%s%d\r\n%s%d\r\n%s%d\r\n%s", "--------------------", "aX: ", accelData.x, "aY: ", accelData.y, @@ -89,7 +85,7 @@ void printCompassValues() { "mX: ", magnetData.x, "mY: ", magnetData.y, "mZ: ", magnetData.z, - "--------------------")); + "--------------------"); Serial1.println(imuOutBuffer); -} \ No newline at end of file +} diff --git a/work/sensor/compass/accelerometer/accel.cpp b/work/sensor/compass/accelerometer/accel.cpp index c754968..abc9795 100644 --- a/work/sensor/compass/accelerometer/accel.cpp +++ b/work/sensor/compass/accelerometer/accel.cpp @@ -1,10 +1,10 @@ -void Accelerometer::_retrieveData() { - if (_interfacePTR->accDataReady()) +void Accelerometer::pvt_RetrieveData() { + if (m_InterfacePTR->accDataReady()) { - _interfacePTR->readAcc(); - _vector.x = _interfacePTR->a.x; - _vector.y = _interfacePTR->a.y; - _vector.z = _interfacePTR->a.z; + m_InterfacePTR->readAcc(); + m_Vector.x = m_InterfacePTR->a.x; + m_Vector.y = m_InterfacePTR->a.y; + m_Vector.z = m_InterfacePTR->a.z; } } diff --git a/work/sensor/compass/accelerometer/accel.h b/work/sensor/compass/accelerometer/accel.h index e9e66c3..4333c94 100644 --- a/work/sensor/compass/accelerometer/accel.h +++ b/work/sensor/compass/accelerometer/accel.h @@ -6,7 +6,7 @@ class Accelerometer : private CompassBase { private: - void _retrieveData() override; + void pvt_RetrieveData() override; public: using CompassBase::CompassBase; using CompassBase::Values; diff --git a/work/sensor/compass/compassbase.cpp b/work/sensor/compass/compassbase.cpp index 766de5e..ff7eb07 100644 --- a/work/sensor/compass/compassbase.cpp +++ b/work/sensor/compass/compassbase.cpp @@ -1,15 +1,14 @@ -CompassBase::CompassBase(): _vector{0, 0, 0} { } -CompassBase::CompassBase(Zumo32U4IMU* ifacePTR): _vector{0, 0, 0}, _interfacePTR(ifacePTR) { } +CompassBase::CompassBase(Zumo32U4IMU* ifacePTR): m_Vector{0, 0, 0}, m_InterfacePTR(ifacePTR) { } Vector3 CompassBase::Values() { - this->_retrieveData(); + this->pvt_RetrieveData(); - return _vector; + return m_Vector; } void CompassBase::Initialize() { - if (_interfacePTR->init()) + if (m_InterfacePTR->init()) { Serial1.println("Compass interface initialized successfully!"); } else { @@ -17,8 +16,8 @@ void CompassBase::Initialize() { } } -// void CompassBase::PrintDebugInfo() { -// Serial1.println(_interfacePTR->getType()); -// } +void CompassBase::PrintDebugInfo() { + Serial1.println((uint8_t)m_InterfacePTR->getType()); +} -// written by: Erynn 'foorpyxof' Scholtes | 2024 NSE Zumo project \ No newline at end of file +// written by: Erynn 'foorpyxof' Scholtes | 2024 NSE Zumo project diff --git a/work/sensor/compass/compassbase.h b/work/sensor/compass/compassbase.h index 9beec6b..3537834 100644 --- a/work/sensor/compass/compassbase.h +++ b/work/sensor/compass/compassbase.h @@ -14,11 +14,11 @@ struct Vector3 { int16_t x,y,z; }; /* the struct containing three // is abstract class :3c class CompassBase { protected: - Vector3 _vector; // the Vector3 struct (x,y,z) that holds + Vector3 m_Vector; // the Vector3 struct (x,y,z) that holds // the data that has been read // the object that allows us to interface with the IMU-sensors - Zumo32U4IMU* _interfacePTR; // it contains methods to read raw values + Zumo32U4IMU* m_InterfacePTR; // it contains methods to read raw values // as well as three containers to // temporarily store them in; // @@ -31,12 +31,11 @@ class CompassBase { // their respective derived-classes private: - virtual void _retrieveData() = 0; // template method that will make + virtual void pvt_RetrieveData() = 0; // template method that will make // the derived class read from // its respective sensor public: - CompassBase(); // empty constructor. shouldn't use. no worky. CompassBase(Zumo32U4IMU*); // constructor that's gonna be inherited // by all derived classes // (accel, gyro, magnet) diff --git a/work/sensor/compass/gyroscope/gyro.cpp b/work/sensor/compass/gyroscope/gyro.cpp index 19309f5..42757dc 100644 --- a/work/sensor/compass/gyroscope/gyro.cpp +++ b/work/sensor/compass/gyroscope/gyro.cpp @@ -1,10 +1,10 @@ -void Gyroscope::_retrieveData() { - if (_interfacePTR->gyroDataReady()) +void Gyroscope::pvt_RetrieveData() { + if (m_InterfacePTR->gyroDataReady()) { - _interfacePTR->readGyro(); - _vector.x = _interfacePTR->g.x; - _vector.y = _interfacePTR->g.y; - _vector.z = _interfacePTR->g.z; + m_InterfacePTR->readGyro(); + m_Vector.x = m_InterfacePTR->g.x; + m_Vector.y = m_InterfacePTR->g.y; + m_Vector.z = m_InterfacePTR->g.z; } } diff --git a/work/sensor/compass/gyroscope/gyro.h b/work/sensor/compass/gyroscope/gyro.h index ff35a85..58723e8 100644 --- a/work/sensor/compass/gyroscope/gyro.h +++ b/work/sensor/compass/gyroscope/gyro.h @@ -6,7 +6,7 @@ class Gyroscope : private CompassBase { private: - void _retrieveData() override; + void pvt_RetrieveData() override; public: using CompassBase::CompassBase; using CompassBase::Values; diff --git a/work/sensor/compass/magnetometer/magnet.cpp b/work/sensor/compass/magnetometer/magnet.cpp index 08f5a84..c5ecdea 100644 --- a/work/sensor/compass/magnetometer/magnet.cpp +++ b/work/sensor/compass/magnetometer/magnet.cpp @@ -1,10 +1,10 @@ -void Magnetometer::_retrieveData() { - if (_interfacePTR->magDataReady()) +void Magnetometer::pvt_RetrieveData() { + if (m_InterfacePTR->magDataReady()) { - _interfacePTR->readMag(); - _vector.x = _interfacePTR->m.x; - _vector.y = _interfacePTR->m.y; - _vector.z = _interfacePTR->m.z; + m_InterfacePTR->readMag(); + m_Vector.x = m_InterfacePTR->m.x; + m_Vector.y = m_InterfacePTR->m.y; + m_Vector.z = m_InterfacePTR->m.z; } } diff --git a/work/sensor/compass/magnetometer/magnet.h b/work/sensor/compass/magnetometer/magnet.h index c395578..0486f97 100644 --- a/work/sensor/compass/magnetometer/magnet.h +++ b/work/sensor/compass/magnetometer/magnet.h @@ -6,7 +6,7 @@ class Magnetometer : private CompassBase { private: - void _retrieveData() override; + void pvt_RetrieveData() override; public: using CompassBase::CompassBase; using CompassBase::Values; From 6d920c4462740cd34cf778f36510747e031dcf75 Mon Sep 17 00:00:00 2001 From: Erynn Date: Sun, 5 May 2024 01:21:22 +0200 Subject: [PATCH 09/12] documentation hell :thumbsup: made a makefile to generate docs pages based on configs in the Doxyfile file. --- .gitignore | 3 + work/sensor/compass/Doxyfile | 413 ++++++++++++++++++++ work/sensor/compass/Makefile | 2 + work/sensor/compass/accelerometer/accel.cpp | 4 + work/sensor/compass/accelerometer/accel.h | 8 + work/sensor/compass/compassbase.cpp | 12 +- work/sensor/compass/compassbase.h | 93 +++-- work/sensor/compass/gyroscope/gyro.cpp | 4 + work/sensor/compass/gyroscope/gyro.h | 8 + work/sensor/compass/magnetometer/magnet.cpp | 4 + work/sensor/compass/magnetometer/magnet.h | 8 + 11 files changed, 518 insertions(+), 41 deletions(-) create mode 100644 work/sensor/compass/Doxyfile create mode 100644 work/sensor/compass/Makefile diff --git a/.gitignore b/.gitignore index 6ef0ddc..cb4ce5c 100644 --- a/.gitignore +++ b/.gitignore @@ -39,3 +39,6 @@ build/* # .vim session files *.vim + +# doxygen output +_doxygen/* diff --git a/work/sensor/compass/Doxyfile b/work/sensor/compass/Doxyfile new file mode 100644 index 0000000..ef042a9 --- /dev/null +++ b/work/sensor/compass/Doxyfile @@ -0,0 +1,413 @@ +# Doxyfile 1.10.0 + +#--------------------------------------------------------------------------- +# Project related configuration options +#--------------------------------------------------------------------------- +DOXYFILE_ENCODING = UTF-8 +PROJECT_NAME = "HHS-NSE Zumo IMU Sensor docs" +PROJECT_NUMBER = +PROJECT_BRIEF = "Docs for the code that allows easy interfacing with the Zumo32U4's IMU sensors" +PROJECT_LOGO = _doxygen/files/miyano-happy.gif +PROJECT_ICON = +OUTPUT_DIRECTORY = _doxygen/output +CREATE_SUBDIRS = YES +CREATE_SUBDIRS_LEVEL = 8 +ALLOW_UNICODE_NAMES = NO +OUTPUT_LANGUAGE = English +BRIEF_MEMBER_DESC = YES +REPEAT_BRIEF = YES +ABBREVIATE_BRIEF = "The $name class" \ + "The $name widget" \ + "The $name file" \ + is \ + provides \ + specifies \ + contains \ + represents \ + a \ + an \ + the +ALWAYS_DETAILED_SEC = NO +INLINE_INHERITED_MEMB = NO +FULL_PATH_NAMES = NO +STRIP_FROM_PATH = +STRIP_FROM_INC_PATH = +SHORT_NAMES = NO +JAVADOC_AUTOBRIEF = NO +JAVADOC_BANNER = NO +QT_AUTOBRIEF = NO +MULTILINE_CPP_IS_BRIEF = NO +PYTHON_DOCSTRING = YES +INHERIT_DOCS = YES +SEPARATE_MEMBER_PAGES = NO +TAB_SIZE = 2 +ALIASES = +OPTIMIZE_OUTPUT_FOR_C = NO +OPTIMIZE_OUTPUT_JAVA = NO +OPTIMIZE_FOR_FORTRAN = NO +OPTIMIZE_OUTPUT_VHDL = NO +OPTIMIZE_OUTPUT_SLICE = NO +EXTENSION_MAPPING = +MARKDOWN_SUPPORT = YES +TOC_INCLUDE_HEADINGS = 5 +MARKDOWN_ID_STYLE = GITHUB +AUTOLINK_SUPPORT = YES +BUILTIN_STL_SUPPORT = NO +CPP_CLI_SUPPORT = NO +SIP_SUPPORT = NO +IDL_PROPERTY_SUPPORT = YES +DISTRIBUTE_GROUP_DOC = NO +GROUP_NESTED_COMPOUNDS = NO +SUBGROUPING = YES +INLINE_GROUPED_CLASSES = NO +INLINE_SIMPLE_STRUCTS = NO +TYPEDEF_HIDES_STRUCT = NO +LOOKUP_CACHE_SIZE = 0 +NUM_PROC_THREADS = 1 +TIMESTAMP = NO +#--------------------------------------------------------------------------- +# Build related configuration options +#--------------------------------------------------------------------------- +EXTRACT_ALL = YES +EXTRACT_PRIVATE = YES +EXTRACT_PRIV_VIRTUAL = NO +EXTRACT_PACKAGE = NO +EXTRACT_STATIC = YES +EXTRACT_LOCAL_CLASSES = YES +EXTRACT_LOCAL_METHODS = NO +EXTRACT_ANON_NSPACES = NO +RESOLVE_UNNAMED_PARAMS = YES +HIDE_UNDOC_MEMBERS = NO +HIDE_UNDOC_CLASSES = NO +HIDE_FRIEND_COMPOUNDS = NO +HIDE_IN_BODY_DOCS = NO +INTERNAL_DOCS = NO +CASE_SENSE_NAMES = SYSTEM +HIDE_SCOPE_NAMES = NO +HIDE_COMPOUND_REFERENCE= NO +SHOW_HEADERFILE = YES +SHOW_INCLUDE_FILES = YES +SHOW_GROUPED_MEMB_INC = NO +FORCE_LOCAL_INCLUDES = NO +INLINE_INFO = YES +SORT_MEMBER_DOCS = YES +SORT_BRIEF_DOCS = NO +SORT_MEMBERS_CTORS_1ST = NO +SORT_GROUP_NAMES = NO +SORT_BY_SCOPE_NAME = NO +STRICT_PROTO_MATCHING = NO +GENERATE_TODOLIST = YES +GENERATE_TESTLIST = YES +GENERATE_BUGLIST = YES +GENERATE_DEPRECATEDLIST= YES +ENABLED_SECTIONS = +MAX_INITIALIZER_LINES = 30 +SHOW_USED_FILES = YES +SHOW_FILES = YES +SHOW_NAMESPACES = YES +FILE_VERSION_FILTER = +LAYOUT_FILE = +CITE_BIB_FILES = +#--------------------------------------------------------------------------- +# Configuration options related to warning and progress messages +#--------------------------------------------------------------------------- +QUIET = NO +WARNINGS = YES +WARN_IF_UNDOCUMENTED = YES +WARN_IF_DOC_ERROR = YES +WARN_IF_INCOMPLETE_DOC = YES +WARN_NO_PARAMDOC = NO +WARN_IF_UNDOC_ENUM_VAL = NO +WARN_AS_ERROR = NO +WARN_FORMAT = "$file:$line: $text" +WARN_LINE_FORMAT = "at line $line of file $file" +WARN_LOGFILE = +#--------------------------------------------------------------------------- +# Configuration options related to the input files +#--------------------------------------------------------------------------- +INPUT = . +INPUT_ENCODING = UTF-8 +INPUT_FILE_ENCODING = +FILE_PATTERNS = *.c \ + *.cc \ + *.cxx \ + *.cxxm \ + *.cpp \ + *.cppm \ + *.ccm \ + *.c++ \ + *.c++m \ + *.java \ + *.ii \ + *.ixx \ + *.ipp \ + *.i++ \ + *.inl \ + *.idl \ + *.ddl \ + *.odl \ + *.h \ + *.hh \ + *.hxx \ + *.hpp \ + *.h++ \ + *.ixx \ + *.l \ + *.cs \ + *.d \ + *.php \ + *.php4 \ + *.php5 \ + *.phtml \ + *.inc \ + *.m \ + *.markdown \ + *.md \ + *.mm \ + *.dox \ + *.py \ + *.pyw \ + *.f90 \ + *.f95 \ + *.f03 \ + *.f08 \ + *.f18 \ + *.f \ + *.for \ + *.vhd \ + *.vhdl \ + *.ucf \ + *.qsf \ + *.ice +RECURSIVE = YES +EXCLUDE = +EXCLUDE_SYMLINKS = NO +EXCLUDE_PATTERNS = +EXCLUDE_SYMBOLS = +EXAMPLE_PATH = +EXAMPLE_PATTERNS = * +EXAMPLE_RECURSIVE = NO +IMAGE_PATH = +INPUT_FILTER = +FILTER_PATTERNS = +FILTER_SOURCE_FILES = NO +FILTER_SOURCE_PATTERNS = +USE_MDFILE_AS_MAINPAGE = _doxygen/files/imu.md +FORTRAN_COMMENT_AFTER = 72 +#--------------------------------------------------------------------------- +# Configuration options related to source browsing +#--------------------------------------------------------------------------- +SOURCE_BROWSER = YES +INLINE_SOURCES = NO +STRIP_CODE_COMMENTS = YES +REFERENCED_BY_RELATION = NO +REFERENCES_RELATION = NO +REFERENCES_LINK_SOURCE = YES +SOURCE_TOOLTIPS = YES +USE_HTAGS = NO +VERBATIM_HEADERS = YES +CLANG_ASSISTED_PARSING = NO +CLANG_ADD_INC_PATHS = YES +CLANG_OPTIONS = +CLANG_DATABASE_PATH = +#--------------------------------------------------------------------------- +# Configuration options related to the alphabetical class index +#--------------------------------------------------------------------------- +ALPHABETICAL_INDEX = YES +IGNORE_PREFIX = +#--------------------------------------------------------------------------- +# Configuration options related to the HTML output +#--------------------------------------------------------------------------- +GENERATE_HTML = YES +HTML_OUTPUT = html +HTML_FILE_EXTENSION = .html +HTML_HEADER = +HTML_FOOTER = +HTML_STYLESHEET = +HTML_EXTRA_STYLESHEET = +HTML_EXTRA_FILES = +HTML_COLORSTYLE = LIGHT +HTML_COLORSTYLE_HUE = 302 +HTML_COLORSTYLE_SAT = 48 +HTML_COLORSTYLE_GAMMA = 86 +HTML_DYNAMIC_MENUS = YES +HTML_DYNAMIC_SECTIONS = NO +HTML_CODE_FOLDING = YES +HTML_COPY_CLIPBOARD = YES +HTML_PROJECT_COOKIE = +HTML_INDEX_NUM_ENTRIES = 100 +GENERATE_DOCSET = NO +DOCSET_FEEDNAME = "Doxygen generated docs" +DOCSET_FEEDURL = +DOCSET_BUNDLE_ID = org.doxygen.Project +DOCSET_PUBLISHER_ID = org.doxygen.Publisher +DOCSET_PUBLISHER_NAME = Publisher +GENERATE_HTMLHELP = NO +CHM_FILE = +HHC_LOCATION = +GENERATE_CHI = NO +CHM_INDEX_ENCODING = +BINARY_TOC = NO +TOC_EXPAND = NO +SITEMAP_URL = +GENERATE_QHP = NO +QCH_FILE = +QHP_NAMESPACE = org.doxygen.Project +QHP_VIRTUAL_FOLDER = doc +QHP_CUST_FILTER_NAME = +QHP_CUST_FILTER_ATTRS = +QHP_SECT_FILTER_ATTRS = +QHG_LOCATION = +GENERATE_ECLIPSEHELP = NO +ECLIPSE_DOC_ID = org.doxygen.Project +DISABLE_INDEX = NO +GENERATE_TREEVIEW = YES +FULL_SIDEBAR = NO +ENUM_VALUES_PER_LINE = 4 +TREEVIEW_WIDTH = 250 +EXT_LINKS_IN_WINDOW = NO +OBFUSCATE_EMAILS = YES +HTML_FORMULA_FORMAT = png +FORMULA_FONTSIZE = 10 +FORMULA_MACROFILE = +USE_MATHJAX = NO +MATHJAX_VERSION = MathJax_2 +MATHJAX_FORMAT = HTML-CSS +MATHJAX_RELPATH = +MATHJAX_EXTENSIONS = +MATHJAX_CODEFILE = +SEARCHENGINE = YES +SERVER_BASED_SEARCH = NO +EXTERNAL_SEARCH = NO +SEARCHENGINE_URL = +SEARCHDATA_FILE = searchdata.xml +EXTERNAL_SEARCH_ID = +EXTRA_SEARCH_MAPPINGS = +#--------------------------------------------------------------------------- +# Configuration options related to the LaTeX output +#--------------------------------------------------------------------------- +GENERATE_LATEX = NO +LATEX_OUTPUT = latex +LATEX_CMD_NAME = +MAKEINDEX_CMD_NAME = makeindex +LATEX_MAKEINDEX_CMD = makeindex +COMPACT_LATEX = NO +PAPER_TYPE = a4 +EXTRA_PACKAGES = +LATEX_HEADER = +LATEX_FOOTER = +LATEX_EXTRA_STYLESHEET = +LATEX_EXTRA_FILES = +PDF_HYPERLINKS = YES +USE_PDFLATEX = YES +LATEX_BATCHMODE = NO +LATEX_HIDE_INDICES = NO +LATEX_BIB_STYLE = plain +LATEX_EMOJI_DIRECTORY = +#--------------------------------------------------------------------------- +# Configuration options related to the RTF output +#--------------------------------------------------------------------------- +GENERATE_RTF = NO +RTF_OUTPUT = rtf +COMPACT_RTF = NO +RTF_HYPERLINKS = NO +RTF_STYLESHEET_FILE = +RTF_EXTENSIONS_FILE = +#--------------------------------------------------------------------------- +# Configuration options related to the man page output +#--------------------------------------------------------------------------- +GENERATE_MAN = NO +MAN_OUTPUT = man +MAN_EXTENSION = .3 +MAN_SUBDIR = +MAN_LINKS = NO +#--------------------------------------------------------------------------- +# Configuration options related to the XML output +#--------------------------------------------------------------------------- +GENERATE_XML = NO +XML_OUTPUT = xml +XML_PROGRAMLISTING = YES +XML_NS_MEMB_FILE_SCOPE = NO +#--------------------------------------------------------------------------- +# Configuration options related to the DOCBOOK output +#--------------------------------------------------------------------------- +GENERATE_DOCBOOK = NO +DOCBOOK_OUTPUT = docbook +#--------------------------------------------------------------------------- +# Configuration options for the AutoGen Definitions output +#--------------------------------------------------------------------------- +GENERATE_AUTOGEN_DEF = NO +#--------------------------------------------------------------------------- +# Configuration options related to Sqlite3 output +#--------------------------------------------------------------------------- +GENERATE_SQLITE3 = NO +SQLITE3_OUTPUT = sqlite3 +SQLITE3_RECREATE_DB = YES +#--------------------------------------------------------------------------- +# Configuration options related to the Perl module output +#--------------------------------------------------------------------------- +GENERATE_PERLMOD = NO +PERLMOD_LATEX = NO +PERLMOD_PRETTY = YES +PERLMOD_MAKEVAR_PREFIX = +#--------------------------------------------------------------------------- +# Configuration options related to the preprocessor +#--------------------------------------------------------------------------- +ENABLE_PREPROCESSING = YES +MACRO_EXPANSION = NO +EXPAND_ONLY_PREDEF = NO +SEARCH_INCLUDES = YES +INCLUDE_PATH = +INCLUDE_FILE_PATTERNS = +PREDEFINED = +EXPAND_AS_DEFINED = +SKIP_FUNCTION_MACROS = YES +#--------------------------------------------------------------------------- +# Configuration options related to external references +#--------------------------------------------------------------------------- +TAGFILES = +GENERATE_TAGFILE = +ALLEXTERNALS = NO +EXTERNAL_GROUPS = YES +EXTERNAL_PAGES = YES +#--------------------------------------------------------------------------- +# Configuration options related to diagram generator tools +#--------------------------------------------------------------------------- +HIDE_UNDOC_RELATIONS = YES +HAVE_DOT = NO +DOT_NUM_THREADS = 0 +DOT_COMMON_ATTR = "fontname=Helvetica,fontsize=10" +DOT_EDGE_ATTR = "labelfontname=Helvetica,labelfontsize=10" +DOT_NODE_ATTR = "shape=box,height=0.2,width=0.4" +DOT_FONTPATH = +CLASS_GRAPH = NO +COLLABORATION_GRAPH = YES +GROUP_GRAPHS = YES +UML_LOOK = NO +UML_LIMIT_NUM_FIELDS = 10 +DOT_UML_DETAILS = NO +DOT_WRAP_THRESHOLD = 17 +TEMPLATE_RELATIONS = NO +INCLUDE_GRAPH = YES +INCLUDED_BY_GRAPH = YES +CALL_GRAPH = NO +CALLER_GRAPH = NO +GRAPHICAL_HIERARCHY = YES +DIRECTORY_GRAPH = YES +DIR_GRAPH_MAX_DEPTH = 1 +DOT_IMAGE_FORMAT = png +INTERACTIVE_SVG = NO +DOT_PATH = +DOTFILE_DIRS = +DIA_PATH = +DIAFILE_DIRS = +PLANTUML_JAR_PATH = +PLANTUML_CFG_FILE = +PLANTUML_INCLUDE_PATH = +DOT_GRAPH_MAX_NODES = 50 +MAX_DOT_GRAPH_DEPTH = 0 +DOT_MULTI_TARGETS = NO +GENERATE_LEGEND = YES +DOT_CLEANUP = YES +MSCGEN_TOOL = +MSCFILE_DIRS = \ No newline at end of file diff --git a/work/sensor/compass/Makefile b/work/sensor/compass/Makefile new file mode 100644 index 0000000..341db68 --- /dev/null +++ b/work/sensor/compass/Makefile @@ -0,0 +1,2 @@ +doxygen: + @doxygen Doxyfile \ No newline at end of file diff --git a/work/sensor/compass/accelerometer/accel.cpp b/work/sensor/compass/accelerometer/accel.cpp index abc9795..8c3b171 100644 --- a/work/sensor/compass/accelerometer/accel.cpp +++ b/work/sensor/compass/accelerometer/accel.cpp @@ -1,7 +1,11 @@ void Accelerometer::pvt_RetrieveData() { + // if new data ready if (m_InterfacePTR->accDataReady()) { + // get new reading m_InterfacePTR->readAcc(); + + // copy reading to m_Vector m_Vector.x = m_InterfacePTR->a.x; m_Vector.y = m_InterfacePTR->a.y; m_Vector.z = m_InterfacePTR->a.z; diff --git a/work/sensor/compass/accelerometer/accel.h b/work/sensor/compass/accelerometer/accel.h index 4333c94..6692e6c 100644 --- a/work/sensor/compass/accelerometer/accel.h +++ b/work/sensor/compass/accelerometer/accel.h @@ -4,8 +4,16 @@ #ifndef ACCEL_H #define ACCEL_H +/** Class that interfaces with + * the Accelerometer sensor in the IMU + * to read its data + */ class Accelerometer : private CompassBase { private: + /** + * Private method that checks if the Accelerometer + * has new data available, and if so, it copies it into m_Vector + */ void pvt_RetrieveData() override; public: using CompassBase::CompassBase; diff --git a/work/sensor/compass/compassbase.cpp b/work/sensor/compass/compassbase.cpp index ff7eb07..7549f45 100644 --- a/work/sensor/compass/compassbase.cpp +++ b/work/sensor/compass/compassbase.cpp @@ -1,21 +1,13 @@ -CompassBase::CompassBase(Zumo32U4IMU* ifacePTR): m_Vector{0, 0, 0}, m_InterfacePTR(ifacePTR) { } +CompassBase::CompassBase(Zumo32U4IMU* zumoInterfacePTR): m_Vector{0, 0, 0}, m_InterfacePTR(zumoInterfacePTR) { } Vector3 CompassBase::Values() { + // call pvt_RetrieveData to place sensor reading in m_Vector this->pvt_RetrieveData(); return m_Vector; } -void CompassBase::Initialize() { - if (m_InterfacePTR->init()) - { - Serial1.println("Compass interface initialized successfully!"); - } else { - Serial1.println("Compass interface initialized successfully?"); - } -} - void CompassBase::PrintDebugInfo() { Serial1.println((uint8_t)m_InterfacePTR->getType()); } diff --git a/work/sensor/compass/compassbase.h b/work/sensor/compass/compassbase.h index 3537834..81c6034 100644 --- a/work/sensor/compass/compassbase.h +++ b/work/sensor/compass/compassbase.h @@ -4,47 +4,78 @@ #ifndef COMPASSBASE_H #define COMPASSBASE_H -struct Vector3 { int16_t x,y,z; }; /* the struct containing three - 16bit integers that will hold - the values read by the sensor - attached to the child-class - of CompassBase */ +/** + * the struct containing three + * 16bit integers that will hold + * the values read by the sensor + * attached to the child-class + * of CompassBase + */ +struct Vector3 { int16_t x,y,z; }; -// this is a class meant as a template only!!! -// is abstract class :3c +/** + * This is a class meant as a template only!!! + * Is abstract class! :3c + * + * This is the base class for all Zumo IMU-interfacing classes. + * The Accelerometer, Gyroscope and Magnetometer classes + * are all derived from this class (CompassBase). + */ class CompassBase { protected: - Vector3 m_Vector; // the Vector3 struct (x,y,z) that holds - // the data that has been read + /** + * the Vector3 struct (x,y,z) that holds + * the data that gets read from the sensor + */ + Vector3 m_Vector; - // the object that allows us to interface with the IMU-sensors - Zumo32U4IMU* m_InterfacePTR; // it contains methods to read raw values - // as well as three containers to - // temporarily store them in; - // - // container names: - // 'a' for accel readings - // 'g' for gyro readings - // 'm' for magnet readings - // - // these containers will only be used by - // their respective derived-classes + /** + * The object that allows us to interface with the IMU-sensors. + * It contains methods to read raw values + * as well as three containers to + * temporarily store them in; + * + * + * Container names: + * 'a' for accel readings - + * 'g' for gyro readings - + * 'm' for magnet readings + * + * These containers will only be used by + * their respective derived-classes + */ + Zumo32U4IMU* m_InterfacePTR; + private: - virtual void pvt_RetrieveData() = 0; // template method that will make - // the derived class read from - // its respective sensor + /** + * Template method that will make + * the derived class read from + * its respective sensor + */ + virtual void pvt_RetrieveData() = 0; public: - CompassBase(Zumo32U4IMU*); // constructor that's gonna be inherited - // by all derived classes - // (accel, gyro, magnet) + /** + * Constructor that places a pointer to + * the pre-initialized Zumo32U4IMU sensor class + * in the m_InterfacePTR member variable + */ + CompassBase(Zumo32U4IMU*); - Vector3 Values(); // public method that allows the Zumo to read - // whatever is currently stored in '_vector' - - void Initialize(); + /** + * Public method that allows the Zumo to read + * whatever is currently stored in 'm_Vector' + * + * Basically: This method returns the current x,y,z (Vector3) + * for the sensor you call this method on. + */ + Vector3 Values(); + /** + * Prints debug info. + * Currently only the type of sensor that is detected. + */ void PrintDebugInfo(); // methods are defined in attached file, 'compassbase.cpp' diff --git a/work/sensor/compass/gyroscope/gyro.cpp b/work/sensor/compass/gyroscope/gyro.cpp index 42757dc..c843d8d 100644 --- a/work/sensor/compass/gyroscope/gyro.cpp +++ b/work/sensor/compass/gyroscope/gyro.cpp @@ -1,7 +1,11 @@ void Gyroscope::pvt_RetrieveData() { + // if new data ready if (m_InterfacePTR->gyroDataReady()) { + // get new reading m_InterfacePTR->readGyro(); + + // copy reading to m_Vector m_Vector.x = m_InterfacePTR->g.x; m_Vector.y = m_InterfacePTR->g.y; m_Vector.z = m_InterfacePTR->g.z; diff --git a/work/sensor/compass/gyroscope/gyro.h b/work/sensor/compass/gyroscope/gyro.h index 58723e8..ead045b 100644 --- a/work/sensor/compass/gyroscope/gyro.h +++ b/work/sensor/compass/gyroscope/gyro.h @@ -4,8 +4,16 @@ #ifndef GYRO_H #define GYRO_H +/** Class that interfaces with + * the Gyroscope sensor in the IMU + * to read its data + */ class Gyroscope : private CompassBase { private: + /** + * Private method that checks if the Gyroscope + * has new data available, and if so, it copies it into m_Vector + */ void pvt_RetrieveData() override; public: using CompassBase::CompassBase; diff --git a/work/sensor/compass/magnetometer/magnet.cpp b/work/sensor/compass/magnetometer/magnet.cpp index c5ecdea..ea801b8 100644 --- a/work/sensor/compass/magnetometer/magnet.cpp +++ b/work/sensor/compass/magnetometer/magnet.cpp @@ -1,7 +1,11 @@ void Magnetometer::pvt_RetrieveData() { + // if new data ready if (m_InterfacePTR->magDataReady()) { + // get new reading m_InterfacePTR->readMag(); + + // copy reading to m_Vector m_Vector.x = m_InterfacePTR->m.x; m_Vector.y = m_InterfacePTR->m.y; m_Vector.z = m_InterfacePTR->m.z; diff --git a/work/sensor/compass/magnetometer/magnet.h b/work/sensor/compass/magnetometer/magnet.h index 0486f97..54efc7a 100644 --- a/work/sensor/compass/magnetometer/magnet.h +++ b/work/sensor/compass/magnetometer/magnet.h @@ -4,8 +4,16 @@ #ifndef MAGNET_H #define MAGNET_H +/** Class that interfaces with + * the Magnetometer sensor in the IMU + * to read its data + */ class Magnetometer : private CompassBase { private: + /** + * Private method that checks if the Magnetometer + * has new data available, and if so, it copies it into m_Vector + */ void pvt_RetrieveData() override; public: using CompassBase::CompassBase; From 6d6ab16485bb8eb92dce17eb59a88dc003456e4a Mon Sep 17 00:00:00 2001 From: Stetsed <33891782+Stetsed@users.noreply.github.com> Date: Mon, 6 May 2024 09:54:10 +0200 Subject: [PATCH 10/12] Delete work/sensor/compass/Makefile --- work/sensor/compass/Makefile | 2 -- 1 file changed, 2 deletions(-) delete mode 100644 work/sensor/compass/Makefile diff --git a/work/sensor/compass/Makefile b/work/sensor/compass/Makefile deleted file mode 100644 index 341db68..0000000 --- a/work/sensor/compass/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -doxygen: - @doxygen Doxyfile \ No newline at end of file From 33df0a09fae28abd88c0a71da74ff6e5a9b2ae87 Mon Sep 17 00:00:00 2001 From: Stetsed <33891782+Stetsed@users.noreply.github.com> Date: Mon, 6 May 2024 09:55:06 +0200 Subject: [PATCH 11/12] Delete work/sensor/compass/Doxyfile --- work/sensor/compass/Doxyfile | 413 ----------------------------------- 1 file changed, 413 deletions(-) delete mode 100644 work/sensor/compass/Doxyfile diff --git a/work/sensor/compass/Doxyfile b/work/sensor/compass/Doxyfile deleted file mode 100644 index ef042a9..0000000 --- a/work/sensor/compass/Doxyfile +++ /dev/null @@ -1,413 +0,0 @@ -# Doxyfile 1.10.0 - -#--------------------------------------------------------------------------- -# Project related configuration options -#--------------------------------------------------------------------------- -DOXYFILE_ENCODING = UTF-8 -PROJECT_NAME = "HHS-NSE Zumo IMU Sensor docs" -PROJECT_NUMBER = -PROJECT_BRIEF = "Docs for the code that allows easy interfacing with the Zumo32U4's IMU sensors" -PROJECT_LOGO = _doxygen/files/miyano-happy.gif -PROJECT_ICON = -OUTPUT_DIRECTORY = _doxygen/output -CREATE_SUBDIRS = YES -CREATE_SUBDIRS_LEVEL = 8 -ALLOW_UNICODE_NAMES = NO -OUTPUT_LANGUAGE = English -BRIEF_MEMBER_DESC = YES -REPEAT_BRIEF = YES -ABBREVIATE_BRIEF = "The $name class" \ - "The $name widget" \ - "The $name file" \ - is \ - provides \ - specifies \ - contains \ - represents \ - a \ - an \ - the -ALWAYS_DETAILED_SEC = NO -INLINE_INHERITED_MEMB = NO -FULL_PATH_NAMES = NO -STRIP_FROM_PATH = -STRIP_FROM_INC_PATH = -SHORT_NAMES = NO -JAVADOC_AUTOBRIEF = NO -JAVADOC_BANNER = NO -QT_AUTOBRIEF = NO -MULTILINE_CPP_IS_BRIEF = NO -PYTHON_DOCSTRING = YES -INHERIT_DOCS = YES -SEPARATE_MEMBER_PAGES = NO -TAB_SIZE = 2 -ALIASES = -OPTIMIZE_OUTPUT_FOR_C = NO -OPTIMIZE_OUTPUT_JAVA = NO -OPTIMIZE_FOR_FORTRAN = NO -OPTIMIZE_OUTPUT_VHDL = NO -OPTIMIZE_OUTPUT_SLICE = NO -EXTENSION_MAPPING = -MARKDOWN_SUPPORT = YES -TOC_INCLUDE_HEADINGS = 5 -MARKDOWN_ID_STYLE = GITHUB -AUTOLINK_SUPPORT = YES -BUILTIN_STL_SUPPORT = NO -CPP_CLI_SUPPORT = NO -SIP_SUPPORT = NO -IDL_PROPERTY_SUPPORT = YES -DISTRIBUTE_GROUP_DOC = NO -GROUP_NESTED_COMPOUNDS = NO -SUBGROUPING = YES -INLINE_GROUPED_CLASSES = NO -INLINE_SIMPLE_STRUCTS = NO -TYPEDEF_HIDES_STRUCT = NO -LOOKUP_CACHE_SIZE = 0 -NUM_PROC_THREADS = 1 -TIMESTAMP = NO -#--------------------------------------------------------------------------- -# Build related configuration options -#--------------------------------------------------------------------------- -EXTRACT_ALL = YES -EXTRACT_PRIVATE = YES -EXTRACT_PRIV_VIRTUAL = NO -EXTRACT_PACKAGE = NO -EXTRACT_STATIC = YES -EXTRACT_LOCAL_CLASSES = YES -EXTRACT_LOCAL_METHODS = NO -EXTRACT_ANON_NSPACES = NO -RESOLVE_UNNAMED_PARAMS = YES -HIDE_UNDOC_MEMBERS = NO -HIDE_UNDOC_CLASSES = NO -HIDE_FRIEND_COMPOUNDS = NO -HIDE_IN_BODY_DOCS = NO -INTERNAL_DOCS = NO -CASE_SENSE_NAMES = SYSTEM -HIDE_SCOPE_NAMES = NO -HIDE_COMPOUND_REFERENCE= NO -SHOW_HEADERFILE = YES -SHOW_INCLUDE_FILES = YES -SHOW_GROUPED_MEMB_INC = NO -FORCE_LOCAL_INCLUDES = NO -INLINE_INFO = YES -SORT_MEMBER_DOCS = YES -SORT_BRIEF_DOCS = NO -SORT_MEMBERS_CTORS_1ST = NO -SORT_GROUP_NAMES = NO -SORT_BY_SCOPE_NAME = NO -STRICT_PROTO_MATCHING = NO -GENERATE_TODOLIST = YES -GENERATE_TESTLIST = YES -GENERATE_BUGLIST = YES -GENERATE_DEPRECATEDLIST= YES -ENABLED_SECTIONS = -MAX_INITIALIZER_LINES = 30 -SHOW_USED_FILES = YES -SHOW_FILES = YES -SHOW_NAMESPACES = YES -FILE_VERSION_FILTER = -LAYOUT_FILE = -CITE_BIB_FILES = -#--------------------------------------------------------------------------- -# Configuration options related to warning and progress messages -#--------------------------------------------------------------------------- -QUIET = NO -WARNINGS = YES -WARN_IF_UNDOCUMENTED = YES -WARN_IF_DOC_ERROR = YES -WARN_IF_INCOMPLETE_DOC = YES -WARN_NO_PARAMDOC = NO -WARN_IF_UNDOC_ENUM_VAL = NO -WARN_AS_ERROR = NO -WARN_FORMAT = "$file:$line: $text" -WARN_LINE_FORMAT = "at line $line of file $file" -WARN_LOGFILE = -#--------------------------------------------------------------------------- -# Configuration options related to the input files -#--------------------------------------------------------------------------- -INPUT = . -INPUT_ENCODING = UTF-8 -INPUT_FILE_ENCODING = -FILE_PATTERNS = *.c \ - *.cc \ - *.cxx \ - *.cxxm \ - *.cpp \ - *.cppm \ - *.ccm \ - *.c++ \ - *.c++m \ - *.java \ - *.ii \ - *.ixx \ - *.ipp \ - *.i++ \ - *.inl \ - *.idl \ - *.ddl \ - *.odl \ - *.h \ - *.hh \ - *.hxx \ - *.hpp \ - *.h++ \ - *.ixx \ - *.l \ - *.cs \ - *.d \ - *.php \ - *.php4 \ - *.php5 \ - *.phtml \ - *.inc \ - *.m \ - *.markdown \ - *.md \ - *.mm \ - *.dox \ - *.py \ - *.pyw \ - *.f90 \ - *.f95 \ - *.f03 \ - *.f08 \ - *.f18 \ - *.f \ - *.for \ - *.vhd \ - *.vhdl \ - *.ucf \ - *.qsf \ - *.ice -RECURSIVE = YES -EXCLUDE = -EXCLUDE_SYMLINKS = NO -EXCLUDE_PATTERNS = -EXCLUDE_SYMBOLS = -EXAMPLE_PATH = -EXAMPLE_PATTERNS = * -EXAMPLE_RECURSIVE = NO -IMAGE_PATH = -INPUT_FILTER = -FILTER_PATTERNS = -FILTER_SOURCE_FILES = NO -FILTER_SOURCE_PATTERNS = -USE_MDFILE_AS_MAINPAGE = _doxygen/files/imu.md -FORTRAN_COMMENT_AFTER = 72 -#--------------------------------------------------------------------------- -# Configuration options related to source browsing -#--------------------------------------------------------------------------- -SOURCE_BROWSER = YES -INLINE_SOURCES = NO -STRIP_CODE_COMMENTS = YES -REFERENCED_BY_RELATION = NO -REFERENCES_RELATION = NO -REFERENCES_LINK_SOURCE = YES -SOURCE_TOOLTIPS = YES -USE_HTAGS = NO -VERBATIM_HEADERS = YES -CLANG_ASSISTED_PARSING = NO -CLANG_ADD_INC_PATHS = YES -CLANG_OPTIONS = -CLANG_DATABASE_PATH = -#--------------------------------------------------------------------------- -# Configuration options related to the alphabetical class index -#--------------------------------------------------------------------------- -ALPHABETICAL_INDEX = YES -IGNORE_PREFIX = -#--------------------------------------------------------------------------- -# Configuration options related to the HTML output -#--------------------------------------------------------------------------- -GENERATE_HTML = YES -HTML_OUTPUT = html -HTML_FILE_EXTENSION = .html -HTML_HEADER = -HTML_FOOTER = -HTML_STYLESHEET = -HTML_EXTRA_STYLESHEET = -HTML_EXTRA_FILES = -HTML_COLORSTYLE = LIGHT -HTML_COLORSTYLE_HUE = 302 -HTML_COLORSTYLE_SAT = 48 -HTML_COLORSTYLE_GAMMA = 86 -HTML_DYNAMIC_MENUS = YES -HTML_DYNAMIC_SECTIONS = NO -HTML_CODE_FOLDING = YES -HTML_COPY_CLIPBOARD = YES -HTML_PROJECT_COOKIE = -HTML_INDEX_NUM_ENTRIES = 100 -GENERATE_DOCSET = NO -DOCSET_FEEDNAME = "Doxygen generated docs" -DOCSET_FEEDURL = -DOCSET_BUNDLE_ID = org.doxygen.Project -DOCSET_PUBLISHER_ID = org.doxygen.Publisher -DOCSET_PUBLISHER_NAME = Publisher -GENERATE_HTMLHELP = NO -CHM_FILE = -HHC_LOCATION = -GENERATE_CHI = NO -CHM_INDEX_ENCODING = -BINARY_TOC = NO -TOC_EXPAND = NO -SITEMAP_URL = -GENERATE_QHP = NO -QCH_FILE = -QHP_NAMESPACE = org.doxygen.Project -QHP_VIRTUAL_FOLDER = doc -QHP_CUST_FILTER_NAME = -QHP_CUST_FILTER_ATTRS = -QHP_SECT_FILTER_ATTRS = -QHG_LOCATION = -GENERATE_ECLIPSEHELP = NO -ECLIPSE_DOC_ID = org.doxygen.Project -DISABLE_INDEX = NO -GENERATE_TREEVIEW = YES -FULL_SIDEBAR = NO -ENUM_VALUES_PER_LINE = 4 -TREEVIEW_WIDTH = 250 -EXT_LINKS_IN_WINDOW = NO -OBFUSCATE_EMAILS = YES -HTML_FORMULA_FORMAT = png -FORMULA_FONTSIZE = 10 -FORMULA_MACROFILE = -USE_MATHJAX = NO -MATHJAX_VERSION = MathJax_2 -MATHJAX_FORMAT = HTML-CSS -MATHJAX_RELPATH = -MATHJAX_EXTENSIONS = -MATHJAX_CODEFILE = -SEARCHENGINE = YES -SERVER_BASED_SEARCH = NO -EXTERNAL_SEARCH = NO -SEARCHENGINE_URL = -SEARCHDATA_FILE = searchdata.xml -EXTERNAL_SEARCH_ID = -EXTRA_SEARCH_MAPPINGS = -#--------------------------------------------------------------------------- -# Configuration options related to the LaTeX output -#--------------------------------------------------------------------------- -GENERATE_LATEX = NO -LATEX_OUTPUT = latex -LATEX_CMD_NAME = -MAKEINDEX_CMD_NAME = makeindex -LATEX_MAKEINDEX_CMD = makeindex -COMPACT_LATEX = NO -PAPER_TYPE = a4 -EXTRA_PACKAGES = -LATEX_HEADER = -LATEX_FOOTER = -LATEX_EXTRA_STYLESHEET = -LATEX_EXTRA_FILES = -PDF_HYPERLINKS = YES -USE_PDFLATEX = YES -LATEX_BATCHMODE = NO -LATEX_HIDE_INDICES = NO -LATEX_BIB_STYLE = plain -LATEX_EMOJI_DIRECTORY = -#--------------------------------------------------------------------------- -# Configuration options related to the RTF output -#--------------------------------------------------------------------------- -GENERATE_RTF = NO -RTF_OUTPUT = rtf -COMPACT_RTF = NO -RTF_HYPERLINKS = NO -RTF_STYLESHEET_FILE = -RTF_EXTENSIONS_FILE = -#--------------------------------------------------------------------------- -# Configuration options related to the man page output -#--------------------------------------------------------------------------- -GENERATE_MAN = NO -MAN_OUTPUT = man -MAN_EXTENSION = .3 -MAN_SUBDIR = -MAN_LINKS = NO -#--------------------------------------------------------------------------- -# Configuration options related to the XML output -#--------------------------------------------------------------------------- -GENERATE_XML = NO -XML_OUTPUT = xml -XML_PROGRAMLISTING = YES -XML_NS_MEMB_FILE_SCOPE = NO -#--------------------------------------------------------------------------- -# Configuration options related to the DOCBOOK output -#--------------------------------------------------------------------------- -GENERATE_DOCBOOK = NO -DOCBOOK_OUTPUT = docbook -#--------------------------------------------------------------------------- -# Configuration options for the AutoGen Definitions output -#--------------------------------------------------------------------------- -GENERATE_AUTOGEN_DEF = NO -#--------------------------------------------------------------------------- -# Configuration options related to Sqlite3 output -#--------------------------------------------------------------------------- -GENERATE_SQLITE3 = NO -SQLITE3_OUTPUT = sqlite3 -SQLITE3_RECREATE_DB = YES -#--------------------------------------------------------------------------- -# Configuration options related to the Perl module output -#--------------------------------------------------------------------------- -GENERATE_PERLMOD = NO -PERLMOD_LATEX = NO -PERLMOD_PRETTY = YES -PERLMOD_MAKEVAR_PREFIX = -#--------------------------------------------------------------------------- -# Configuration options related to the preprocessor -#--------------------------------------------------------------------------- -ENABLE_PREPROCESSING = YES -MACRO_EXPANSION = NO -EXPAND_ONLY_PREDEF = NO -SEARCH_INCLUDES = YES -INCLUDE_PATH = -INCLUDE_FILE_PATTERNS = -PREDEFINED = -EXPAND_AS_DEFINED = -SKIP_FUNCTION_MACROS = YES -#--------------------------------------------------------------------------- -# Configuration options related to external references -#--------------------------------------------------------------------------- -TAGFILES = -GENERATE_TAGFILE = -ALLEXTERNALS = NO -EXTERNAL_GROUPS = YES -EXTERNAL_PAGES = YES -#--------------------------------------------------------------------------- -# Configuration options related to diagram generator tools -#--------------------------------------------------------------------------- -HIDE_UNDOC_RELATIONS = YES -HAVE_DOT = NO -DOT_NUM_THREADS = 0 -DOT_COMMON_ATTR = "fontname=Helvetica,fontsize=10" -DOT_EDGE_ATTR = "labelfontname=Helvetica,labelfontsize=10" -DOT_NODE_ATTR = "shape=box,height=0.2,width=0.4" -DOT_FONTPATH = -CLASS_GRAPH = NO -COLLABORATION_GRAPH = YES -GROUP_GRAPHS = YES -UML_LOOK = NO -UML_LIMIT_NUM_FIELDS = 10 -DOT_UML_DETAILS = NO -DOT_WRAP_THRESHOLD = 17 -TEMPLATE_RELATIONS = NO -INCLUDE_GRAPH = YES -INCLUDED_BY_GRAPH = YES -CALL_GRAPH = NO -CALLER_GRAPH = NO -GRAPHICAL_HIERARCHY = YES -DIRECTORY_GRAPH = YES -DIR_GRAPH_MAX_DEPTH = 1 -DOT_IMAGE_FORMAT = png -INTERACTIVE_SVG = NO -DOT_PATH = -DOTFILE_DIRS = -DIA_PATH = -DIAFILE_DIRS = -PLANTUML_JAR_PATH = -PLANTUML_CFG_FILE = -PLANTUML_INCLUDE_PATH = -DOT_GRAPH_MAX_NODES = 50 -MAX_DOT_GRAPH_DEPTH = 0 -DOT_MULTI_TARGETS = NO -GENERATE_LEGEND = YES -DOT_CLEANUP = YES -MSCGEN_TOOL = -MSCFILE_DIRS = \ No newline at end of file From 60d05b36a81044cb47267ba5bd6ff01a01f721e8 Mon Sep 17 00:00:00 2001 From: Stetsed <33891782+Stetsed@users.noreply.github.com> Date: Mon, 6 May 2024 09:55:24 +0200 Subject: [PATCH 12/12] Update .gitignore --- .gitignore | 3 --- 1 file changed, 3 deletions(-) diff --git a/.gitignore b/.gitignore index cb4ce5c..6ef0ddc 100644 --- a/.gitignore +++ b/.gitignore @@ -39,6 +39,3 @@ build/* # .vim session files *.vim - -# doxygen output -_doxygen/*