Skip to content

Commit

Permalink
Implemented new Findings by BlueAndi
Browse files Browse the repository at this point in the history
  • Loading branch information
jkerpe committed Nov 13, 2023
1 parent af74107 commit 92dd216
Show file tree
Hide file tree
Showing 5 changed files with 163 additions and 72 deletions.
25 changes: 16 additions & 9 deletions lib/HALInterfaces/IIMU.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@
* Types and Classes
*****************************************************************************/

/** Struct of the IMU data in x, y and z direction. */
/** Struct of the raw, unitless and not yet converted IMU (=accelerometer, gyro or magnetometer) data in x, y and z
* direction. */
typedef struct _IMUData
{
int16_t valueX; /* Raw sensor value in x direction (unitless) */
Expand Down Expand Up @@ -113,37 +114,43 @@ class IIMU
virtual bool accelerometerDataReady() = 0;

/**
* Indicates whether the gyro has new measurement data ready.
* Indicates whether the gyro has new measurement data ready.
*
* @return True if there is new gyro data available; false otherwise.
*/
virtual bool gyroDataReady() = 0;

/**
* Indicates whether the magnetometer has new measurement data ready.
* Indicates whether the magnetometer has new measurement data ready.
*
* @return True if there is new magnetometer data available; false otherwise.
*/
virtual bool magnetometerDataReady() = 0;

/**
* Get last raw Accelerometer values as a IMUData struct containing values in x, y and z.
* Get last raw Accelerometer values as an IMUData struct containing values in x, y and z.
*
* @param[in] accelerationValues Pointer to IMUData struct.
* @param[in] accelerationValues Pointer to IMUData struct where the raw, unitless acceleration values in
* x, y and z direction will be written into. The values can be converted into physical values in mm/s^2 via the
* multiplication with a sensitivity factor in mm/s^2/bit.
*/
virtual const void getAccelerationValues(IMUData* accelerationValues) = 0;

/**
* Get last raw Gyroscope values as a IMUData struct containing values in x, y and z.
* Get last raw Gyroscope values as an IMUData struct containing values in x, y and z.
*
* @param[in] turnRates Pointer to IMUData struct.
* @param[in] turnRates Pointer to IMUData struct where the raw, unitless turn Rates in x, y and z
* direction will be written into. The values can be converted into physical values in mrad/s via the multiplication
* with a sensitivity factor in mrad/s/bit.
*/
virtual const void getTurnRates(IMUData* turnRates) = 0;

/**
* Get last raw Magnetometer values as a IMUData struct containing values in x, y and z.
* Get last raw Magnetometer values as an IMUData struct containing values in x, y and z.
*
* @param[in] magnetometerValues Pointer to IMUData struct.
* @param[in] magnetometerValues Pointer to IMUData struct where the raw, unitless magnetometer values in
* x, y and z direction will be written into. The values can be converted into physical values in mgauss via the
* multiplication with a sensitivity factor in mgauss/bit.
*/
virtual const void getMagnetometerValues(IMUData* magnetometerValues) = 0;

Expand Down
24 changes: 16 additions & 8 deletions lib/HALSim/IMU.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
DESCRIPTION
*******************************************************************************/
/**
* @brief IMU implementation of the simulation
* @brief IMU (Inertial Measurement Unit) implementation of the simulation
* @author Juliane Kerpe <[email protected]>
*
* @addtogroup HALSim
Expand Down Expand Up @@ -58,7 +58,9 @@
* Types and Classes
*****************************************************************************/

/** The IMU adapter. */
/** The IMU adapter.
* IMU stands for Inertial Measurement Unit.
*/
class IMU : public IIMU
{
public:
Expand Down Expand Up @@ -156,23 +158,29 @@ class IMU : public IIMU
}

/**
* Get last raw Accelerometer values as a IMUData struct containing values in x, y and z.
* Get last raw Accelerometer values as an IMUData struct containing values in x, y and z.
*
* @param[in] accelerationValues Pointer to IMUData struct.
* @param[in] accelerationValues Pointer to IMUData struct where the raw, unitless acceleration values in
* x, y and z direction will be written into. The values can be converted into physical values in mm/s^2 via the
* multiplication with a sensitivity factor in mm/s^2/bit.
*/
void const getAccelerationValues(IMUData* accelerationValues);

/**
* Get last raw Gyroscope values as a IMUData struct containing values in x, y and z.
* Get last raw Gyroscope values as an IMUData struct containing values in x, y and z.
*
* @param[in] turnRates Pointer to IMUData struct.
* @param[in] turnRates Pointer to IMUData struct where the raw, unitless turn Rates in x, y and z
* direction will be written into. The values can be converted into physical values in mrad/s via the multiplication
* with a sensitivity factor in mrad/s/bit.
*/
void const getTurnRates(IMUData* turnRates);

/**
* Get last raw Magnetometer values as a IMUData struct containing values in x, y and z.
* Get last raw Magnetometer values as an IMUData struct containing values in x, y and z.
*
* @param[in] magnetometerValues Pointer to IMUData struct.
* @param[in] magnetometerValues Pointer to IMUData struct where the raw, unitless magnetometer values in
* x, y and z direction will be written into. The values can be converted into physical values in mgauss via the
* multiplication with a sensitivity factor in mgauss/bit.
*/
void const getMagnetometerValues(IMUData* magnetometerValues);

Expand Down
33 changes: 22 additions & 11 deletions lib/HALTarget/IMU.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
DESCRIPTION
*******************************************************************************/
/**
* @brief IMU implementation
* @brief IMU (Inertial Measurement Unit) implementation
* @author Juliane Kerpe <[email protected]>
*
* @addtogroup HALSim
Expand Down Expand Up @@ -53,7 +53,9 @@
* Types and Classes
*****************************************************************************/

/** The IMU adapter. */
/** The IMU adapter.
* IMU stands for Inertial Measurement Unit.
*/
class IMU : public IIMU
{
public:
Expand All @@ -63,6 +65,9 @@ class IMU : public IIMU
*/
IMU() :
IIMU(),
m_accelerometerValues{0, 0, 0},
m_gyroValues{0, 0, 0},
m_magnetometerValues{0, 0, 0},
m_rawAccelerometerOffsetX(0),
m_rawAccelerometerOffsetY(0),
m_rawAccelerometerOffsetZ(0),
Expand Down Expand Up @@ -133,23 +138,29 @@ class IMU : public IIMU
bool magnetometerDataReady();

/**
* Get last raw Accelerometer values as a IMUData struct containing values in x, y and z.
* Get last raw Accelerometer values as an IMUData struct containing values in x, y and z.
*
* @param[in] accelerationValues Pointer to IMUData struct.
* @param[in] accelerationValues Pointer to IMUData struct where the raw, unitless acceleration values in
* x, y and z direction will be written into. The values can be converted into physical values in mm/s^2 via the
* multiplication with a sensitivity factor in mm/s^2/bit.
*/
const void getAccelerationValues(IMUData* accelerationValues);

/**
* Get last raw Gyroscope values as a IMUData struct containing values in x, y and z.
* Get last raw Gyroscope values as an IMUData struct containing values in x, y and z.
*
* @param[in] turnRates Pointer to IMUData struct.
* @param[in] turnRates Pointer to IMUData struct where the raw, unitless turn Rates in x, y and z
* direction will be written into. The values can be converted into physical values in mrad/s via the multiplication
* with a sensitivity factor in mrad/s/bit.
*/
const void getTurnRates(IMUData* turnRates);

/**
* Get last raw Magnetometer values as a IMUData struct containing values in x, y and z.
* Get last raw Magnetometer values as an IMUData struct containing values in x, y and z.
*
* @param[in] magnetometerValues Pointer to IMUData struct.
* @param[in] magnetometerValues Pointer to IMUData struct where the raw, unitless magnetometer values in
* x, y and z direction will be written into. The values can be converted into physical values in mgauss via the
* multiplication with a sensitivity factor in mgauss/bit.
*/
const void getMagnetometerValues(IMUData* magnetometerValues);

Expand All @@ -159,9 +170,9 @@ class IMU : public IIMU
void calibrate();

private:
IMUData m_accelerometerValues = {0, 0, 0}; /* Raw accelerometer readings. */
IMUData m_gyroValues = {0, 0, 0}; /* Raw gyro readings. */
IMUData m_magnetometerValues = {0, 0, 0}; /* Raw magnetometer readings. */
IMUData m_accelerometerValues; /* Raw accelerometer readings. */
IMUData m_gyroValues; /* Raw gyro readings. */
IMUData m_magnetometerValues; /* Raw magnetometer readings. */

protected:
private:
Expand Down
107 changes: 71 additions & 36 deletions lib/HALTest/IMU.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
DESCRIPTION
*******************************************************************************/
/**
* @brief IMU realization
* @brief IMU (Inertial Measurement Unit) realization
* @author Juliane Kerpe <[email protected]>
*
* @addtogroup HALSim
Expand All @@ -36,7 +36,6 @@
#ifndef IMU_H
#define IMU_H


/******************************************************************************
* Compile Switches
*****************************************************************************/
Expand All @@ -45,7 +44,9 @@
* Includes
*****************************************************************************/
#include "IIMU.h"

/** The IMU adapter.
* IMU stands for Inertial Measurement Unit.
*/
class IMU : public IIMU
{
public:
Expand All @@ -61,80 +62,114 @@ class IMU : public IIMU
*
* @return True if the sensor type was detected succesfully; false otherwise.
*/
bool init(){return true;}

bool init()
{
return true;
}

/**
* Enables all of the inertial sensors with a default configuration.
*/
void enableDefault() {};
void enableDefault(){};

/**
* Configures the sensors with settings optimized for turn sensing.
*/
void configureForTurnSensing() {}
void configureForTurnSensing()
{
}

/**
* Takes a reading from the accelerometer and makes the measurements available in a.
*/
void readAccelerometer() {}

*/
void readAccelerometer()
{
}

/**
* Takes a reading from the gyro and makes the measurements available in g.
*/
void readGyro() {}

void readGyro()
{
}

/**
* Takes a reading from the magnetometer and makes the measurements available in m.
*/
void readMagnetometer() {}

void readMagnetometer()
{
}

/**
* Indicates whether the accelerometer has new measurement data ready.
*
* @return True if there is new accelerometer data available; false otherwise.
*
* @return True if there is new accelerometer data available; false otherwise.
*/
bool accelerometerDataReady() {return true;}

bool accelerometerDataReady()
{
return true;
}

/**
* Indicates whether the gyro has new measurement data ready.
*
*
* @return True if there is new gyro data available; false otherwise.
*/
bool gyroDataReady() {return true;}

bool gyroDataReady()
{
return true;
}

/**
* Indicates whether the magnetometer has new measurement data ready.
*
*
* @return True if there is new magnetometer data available; false otherwise.
*/
bool magnetometerDataReady() {return true;}

bool magnetometerDataReady()
{
return true;
}

/**
* Get last raw Accelerometer values as a IMUData struct containing values in x, y and z.
* Get last raw Accelerometer values as an IMUData struct containing values in x, y and z.
*
* @param[in] accelerationValues Pointer to IMUData struct.
* @param[in] accelerationValues Pointer to IMUData struct where the raw, unitless acceleration values in
* x, y and z direction will be written into. The values can be converted into physical values in mm/s^2 via the
* multiplication with a sensitivity factor in mm/s^2/bit.
*/
const void getAccelerationValues(IMUData* accelerationValues) {}
const void getAccelerationValues(IMUData* accelerationValues)
{
}

/**
* Get last raw Gyroscope values as a IMUData struct containing values in x, y and z.
* Get last raw Gyroscope values as an IMUData struct containing values in x, y and z.
*
* @param[in] turnRates Pointer to IMUData struct.
* @param[in] turnRates Pointer to IMUData struct where the raw, unitless turn Rates in x, y and z
* direction will be written into. The values can be converted into physical values in mrad/s via the multiplication
* with a sensitivity factor in mrad/s/bit.
*/
const void getTurnRates(IMUData* turnRates) {}
const void getTurnRates(IMUData* turnRates)
{
}

/**
* Get last raw Magnetometer values as a IMUData struct containing values in x, y and z.
* Get last raw Magnetometer values as an IMUData struct containing values in x, y and z.
*
* @param[in] magnetometerValues Pointer to IMUData struct.
* @param[in] magnetometerValues Pointer to IMUData struct where the raw, unitless magnetometer values in
* x, y and z direction will be written into. The values can be converted into physical values in mgauss via the
* multiplication with a sensitivity factor in mgauss/bit.
*/
const void getMagnetometerValues(IMUData* magnetometerValues) {}

const void getMagnetometerValues(IMUData* magnetometerValues)
{
}

/**
* Calibrate the IMU.
*/
virtual void calibrate() {}

virtual void calibrate()
{
}

private:
};

Expand Down
Loading

0 comments on commit 92dd216

Please sign in to comment.