From afa459b120a02aa6fb72b64ad2e79f1e535ca147 Mon Sep 17 00:00:00 2001 From: Pascal Serrarens Date: Thu, 23 Nov 2023 17:51:20 +0100 Subject: [PATCH] Added accelerometer & magnetometer framework --- Accelerometer.h | 19 +++++++++++++++++++ Magnetometer.h | 23 +++++++++++++++++++++++ Roboid.h | 6 ++++++ 3 files changed, 48 insertions(+) create mode 100644 Accelerometer.h create mode 100644 Magnetometer.h diff --git a/Accelerometer.h b/Accelerometer.h new file mode 100644 index 0000000..b7bf662 --- /dev/null +++ b/Accelerometer.h @@ -0,0 +1,19 @@ +#pragma once + +#include "Sensor.h" + +/// @brief A Sensor which can measure the magnetic field +class Accelerometer : public Sensor { + public: + Accelerometer(){}; + + /// @brief This gives the gravity direciton relative to the down direction. + /// @param forward the forward direction, negative is backward, positive is forward + /// @param sideward the sideward direction, negative is left, positive is to the right + /// @note the units (degrees, radians, -1..1, ...) depend on the sensor + void GetAccelerationDirection(float* forward, float* sideward); + /// @brief The magnitude of the gravity field. + /// @return The magnitude. This value is never negative. + /// @note the unity (m/s^2, 0..1) depends on the sensor. + float GetAccelerationMagnitude(); +}; \ No newline at end of file diff --git a/Magnetometer.h b/Magnetometer.h new file mode 100644 index 0000000..ee9cf88 --- /dev/null +++ b/Magnetometer.h @@ -0,0 +1,23 @@ +#pragma once + +#include "Sensor.h" + +/// @brief A Sensor which can measure the magnetic field +class Magnetometer : public Sensor { + public: + Magnetometer(); + + /// @brief Returns the direction of the magnetic field relative to the forward direction + /// @return The direction, negative is to the left, positive is to the right + /// @note The actual unit (degrees, radians, -1..1, ...) depends on the sensor. + virtual float GetDirection(); + /// @brief Returns the inclination of the magnetic field relative to the horizontal plane + /// @return The direction, negative is downward, positive is upward + /// @note The actual unit (degrees, radias, -1..1, ...) depends on the sensor. + virtual float GetInclination(); + + /// @brief Returns the strength of the magnetic field + /// @return The strength. This values should always be positive + /// @note The actual unit (tesla, 0..1, ...) depends on the sensor. + virtual unsigned float GetMagnitude(); +} \ No newline at end of file diff --git a/Roboid.h b/Roboid.h index 7aa1b23..6b16a6d 100644 --- a/Roboid.h +++ b/Roboid.h @@ -5,6 +5,11 @@ #include "Placement.h" #include "Propulsion.h" +class Acceleration { + public: + float GetMagnitude() { return 0;}; +}; + class Roboid { public: Roboid(); @@ -12,6 +17,7 @@ class Roboid { Perception perception; Propulsion propulsion; + Acceleration acceleration; Placement* configuration; unsigned int thingCount;