Terrapin-Rocket-Team / Multi-Mission-Flight-Software

An arudino library used by the Terrapin Rocket Team as the foundation of the team's flight software.
5 stars 0 forks source link

Breakup IMU into different classes #83

Open varun-un opened 3 weeks ago

varun-un commented 3 weeks ago

Right now, it's kind of awkward to have multiple sensors combine to be one 9 dof IMU, and it also means that those sensors' operations are tied together (one fails, the entire class fails). An alternate structure is this:

3 classes:

IMU class now takes in an instance of each of these 3 classes as members:

public:
        IMU(Accelerometer* accelSensor, Gyroscope* gyroSensor, Magnetometer* magSensor = nullptr)
                : accel(accelSensor), gyro(gyroSensor), mag(magSensor) {...}

private:
        Accelerometer* accel;
        Gyroscope* gyro;
        Magnetometer* mag;

And hardware implementation classes extend >= 1 of the accel, gyro, or mag classes that they provide data for

DrewBrandt commented 5 days ago

This still doesn't really fix the "if one fails they all fail" issue, as the imu itself on init() would need to check if each of its sub-sensors properly init()s. We could write more in-depth code to throw a warning on mag fail, for example, but we could do that when they are all a single class combined as well. I'm not sure the overhead of abstracting out three new classes is worth it, but I guess idk.

Edit: I guess this might be useful if we were to add i2c bus and address parameters into their constructors as #82 suggests