imunano33
0.1.1
|
A data processor for IMU and climate data from an Arduino Nano 33 BLE Sense. More...
#include <imunano33.hpp>
Public Member Functions | |
IMUNano33 ()=default | |
Default constructor. More... | |
IMUNano33 (const num_t gyroFavoring) | |
Constructor. More... | |
IMUNano33 (const num_t gyroFavoring, const Quaternion &initialQ) | |
Constructor. More... | |
IMUNano33 (const IMUNano33 &other)=default | |
Copy constructor. | |
IMUNano33 & | operator= (const IMUNano33 &other)=default |
Assignment operator. | |
~IMUNano33 ()=default | |
Destructor. | |
IMUNano33 (IMUNano33 &&)=default | |
Move constructor. | |
IMUNano33 & | operator= (IMUNano33 &&)=default |
Move assignment. | |
void | updateClimate (const num_t temperature, const num_t humidity, const num_t pressure) |
Updates climate data. More... | |
void | updateIMU (const Vector3D &accel, const Vector3D &gyro, const num_t deltaT) |
Updates IMU data. More... | |
void | updateIMUAccel (const Vector3D &accel) |
Updates IMU acceleration data. More... | |
void | updateIMUGyro (const Vector3D &gyro, const num_t deltaT) |
Updates IMU gyroscope data. More... | |
void | update (const Vector3D &accel, const Vector3D &gyro, const num_t deltaT, const num_t temperature, const num_t humidity, const num_t pressure) |
Updates both IMU and climate data. More... | |
void | resetIMU () |
Resets IMU orientation to the initialQ argument provided in the constructor. More... | |
void | zeroIMU () |
Sets current IMU orientation to be facing the positive X-axis.. More... | |
void | resetClimate () |
Resets climate data. More... | |
void | setRotQ (const Quaternion &q) |
Sets rotation quaternion for the filter. More... | |
void | setGyroFavoring (const num_t favoring) |
Sets gyro favoring. More... | |
Quaternion | getRotQ () const |
Gets rotation quaternion of the complementary filter. More... | |
num_t | getGyroFavoring () const |
Gets gyroscope favoring. More... | |
template<TempUnit U> | |
num_t | getTemperature () const |
Gets temperature. More... | |
template<PressureUnit U> | |
num_t | getPressure () const |
Gets pressure. More... | |
num_t | getHumidity () const |
Gets relative humidity. More... | |
bool | climateDataExists () const |
Determines if climate data exists. More... | |
A data processor for IMU and climate data from an Arduino Nano 33 BLE Sense.
This processor includes a 6-axis complementary filter which can determine the orientation of the Arduino from its built-in IMU, the LSM9DS1, and the 3-axis acceleration and 3-axis angular velocity measurements. The reason why the magnetometer is not used is due to unknown magnetic interference which could affect sensor measurements, which means that the yaw measurement will inevitably drift over time. Note that the filter assumes that the gyro and accelerometer are calibrated.
The xyz axes are defined as following for the Nano 33 BLE sense (or any Arduino Nano): With the Arduino flat on a table and the sensors facing up and the opening of the Micro USB port facing towards the front, the positive x direction points towards the front, the positive y direction points perpendicular and to the left, and the positive z direction points directly up. Note that the Arduino may not measure the angular velocities and accelerations with respect to these axes, so you may need to correct the measured values.
The processor also takes in climate (temperature, humidity, and pressure) from the HTS221 (for temperature and humidity) and the LPS22HB sensors (for the pressure). These values should be measured in celsius (for temperature), kilopascals (for pressure), and percent relative humidity. The temperature and pressure units can later be converted to other units (see imunano33::TempUnit and imunano33::PressureUnit for supported units).
This can also be used outside the context of a Nano 33 BLE Sense (such as with an external MPU-6050 IMU or a DHT22 temperature and humidity sensor). If certain values are unknown, you can substitute zerores for these values, or not call the corresponding update() method. For example, if you do not want to have an accelerometer ccorrect gyro measurements, pass a zero vector for the accelerometer measurement so that there will be no correction. If you do not know climate data, do not call updateClimate() and only call updateIMU().
|
default |
Default constructor.
Sets filter gyro favoring to 0.98 and initial orientation to be pointing in the positive x-direction.
|
inline |
Constructor.
Sets initial orientation to be pointing in the positive x-direction.
gyroFavoring | Determines how much gravity should correct, in the range [0, 1]. 0 means that gravity should fully correct the error (does not mean that orientation is solely determined by gravity), and 1 means that gravity does not correct error at all. |
|
inline |
Constructor.
gyroFavoring | Determines how much gravity should correct, in the range [0, 1]. 0 means that gravity should fully correct the error (does not mean that orientation is solely determined by gravity), and 1 means that gravity does not correct error at all. |
initialQ | The initial rotation quaternion. When resetIMU() is called, the orientation quaternion will be set to this value. |
|
inline |
Determines if climate data exists.
This only returns false if the object is initialized but none of update() or updateClimate() have not been called yet.
|
inline |
Gets gyroscope favoring.
|
inline |
Gets relative humidity.
Check that this humidity measurement is valid with climateDataExists() first.
Unit is percent humidity.
|
inline |
Gets pressure.
Check that this pressure measurement is valid with climateDataExists() first.
U | Pressure unit. |
|
inline |
Gets rotation quaternion of the complementary filter.
|
inline |
Gets temperature.
Check that this temperature measurement is valid with climateDataExists() first.
U | Temperature unit. |
|
inline |
Resets climate data.
climateDataExists() will be false after this is called.
|
inline |
Resets IMU orientation to the initialQ argument provided in the constructor.
All measurements from this point on will be in the frame of reference of the initial quaternion.
|
inline |
Sets gyro favoring.
favoring | Determines how much gravity should correct, in the range [0, 1]. 0 means that gravity should fully correct the error (does not mean that orientation is solely determined by gravity), and 1 means that gravity does not correct error at all. |
|
inline |
Sets rotation quaternion for the filter.
All measurements from this point on will be relative to this quaternion.
q | The rotation quaternion |
|
inline |
Updates both IMU and climate data.
It is important that the gyroscope is given in radians per second, or the orientation data will be inaccurate. The accelerometer measurement can be in any unit, but m / s^2 is preferred as it is SI.
It is important that you retrieve the data in the units listed below, or the units will not be accurate.
accel | Accelerometer reading, in <x, y, z>, where positive z is up (important for gravity corrections), and xy is translational motion. The note comes with more details specific to the Arduino Nano 33. |
gyro | Gyroscope reading (<roll, pitch, yaw> in rad/s) |
deltaT | The time between this measurement and the previous measurement, in seconds. If this is the first measurement, deltaT would refer to the time since startup (when initialQ was measured). |
temperature | Temperature, in C |
humidity | Relative humidity, in percent |
pressure | Pressure, in kPa |
|
inline |
Updates climate data.
It is important that you retrieve the data in the units listed below, or the units will not be accurate.
temperature | Temperature, in C |
humidity | Relative humidity, in percent |
pressure | Pressure, in kPa |
|
inline |
Updates IMU data.
It is important that the gyroscope is given in radians per second, or the orientation data will be inaccurate. The accelerometer measurement can be in any unit, but m / s^2 is preferred as it is SI.
accel | Accelerometer reading, in <x, y, z>, where positive z is up (important for gravity corrections), and xy is translational motion. The note comes with more details specific to the Arduino Nano 33. |
gyro | Gyroscope reading (<roll, pitch, yaw> in rad/s) |
deltaT | The time between this measurement and the previous measurement, in seconds. If this is the first measurement, deltaT would refer to the time since startup (when initialQ was measured). |
|
inline |
Updates IMU acceleration data.
accel | Accelerometer reading, in <x, y, z>, where positive z is up (important for gravity corrections), and xy is translational motion. The note comes with more details specific to the Arduino Nano 33. |
Updates IMU gyroscope data.
It is important that the gyroscope is given in radians per second, or the orientation data will be inaccurate. The accelerometer measurement can be in any unit, but m / s^2 is preferred as it is SI.
gyro | Gyroscope reading (<roll, pitch, yaw> in rad/s) |
deltaT | The time between this measurement and the previous measurement, in seconds. If this is the first measurement, deltaT would refer to the time since startup (when initialQ was measured). |
|
inline |
Sets current IMU orientation to be facing the positive X-axis..
All measurements from this point on will be relative to where you set the orientation to be the positive X-axis.