Added accelerometer & magnetometer framework

This commit is contained in:
Pascal Serrarens 2023-11-23 17:51:20 +01:00
parent 438d8ba941
commit afa459b120
3 changed files with 48 additions and 0 deletions

19
Accelerometer.h Normal file
View File

@ -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();
};

23
Magnetometer.h Normal file
View File

@ -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();
}

View File

@ -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;