imumaths - Terrapin-Rocket-Team/SRAD-Avionics GitHub Wiki

Home/Documentation/imumaths

TODO:

  • Expand on how to use

imumaths

The imumaths library (read I-M-U maths) is a library provided by Adafruit that is used for vector math and storage. We use it any time we need to store a "mathematical" (as opposed to list-like) vector, such as a position or velocity vector.

Usage

Start by including the library

#include <imumaths.h>

Then, you can use the Vector class to store vectors. The Vector class has a number of useful functions, such as normalize(), dot(), and cross(). You can also use the Quaternion class to store quaternions. The Quaternion class has functions to convert to and from Euler angles, as well as to normalize the quaternion.

Example:

#include <imumaths.h>

imu::Vector<3> position;

void updatePosition() {
    position.x() = 1.0;
    position.y() = 2.0;
    position.z() = 3.0;
}

Serial.println(position.x()); // 1.0

// ... etc.

Note that this vector is NOT a list-like vector, such as std::vector. It is a mathematical vector, and as such, it has mathematical operations defined on it.

⚠️ **GitHub.com Fallback** ⚠️