New version of quadcopter software written to OO principles
Dependencies: mbed MODSERIAL filter mbed-rtos ConfigFile PID PPM FreeIMU_external_magnetometer TinyGPS
Diff: Sensors/Sensors.h
- Revision:
- 2:969dfa4f2436
- Parent:
- 0:c6a85bb2a827
- Child:
- 3:4823d6750629
--- a/Sensors/Sensors.h Wed Mar 04 18:53:43 2015 +0000 +++ b/Sensors/Sensors.h Wed Apr 01 11:19:21 2015 +0000 @@ -0,0 +1,72 @@ +#include "mbed.h" +#include "Global.h" +#include "rtos.h" +#include "Gps.h" +#include "Imu.h" +#include "Status.h" +#include "LidarLitePwm.h" +#include "Kalman.h" + +#ifndef Sensors_H +#define Sensors_H + +#define PI 3.14159265 + +class Sensors +{ + public: + Sensors(Status& status, ConfigFileWrapper& configFileWrapper, PinName gpsPinTx, PinName gpsPinRx, PinName i2cSda, PinName i2cScl, PinName lidarInterrupt); + ~Sensors(); + + struct Position + { + double accelX; + double accelY; + double accelZ; + double latitude; + double longitude; + double computedX; + double computedY; + }; + + struct Altitude + { + double lidar; + double barometer; + double gps; + double computed; + }; + + void update(); + Imu::Rate getRate(); + Imu::Angle getAngle(); + Gps::Value getGpsValues(); + double getZVelocity(); + Sensors::Altitude getAltitude(); + Sensors::Position getPosition(); + void enable(bool enable); + void zeroBarometer(); + void updateImu(); + void zeroAccel(); + + private: + void zeroGyro(); + void updateGpsValues(); + void updateAltitude(); + void updateVelocity(); + void updatePosition(); + int getLidarAltitude(); + + Status& _status; + Imu::Rate _rate; + Imu::Angle _angle; + Position _position; + Altitude _altitude; + Gps::Value _gpsValues; + Imu* _imu; + Gps* _gps; + LidarLitePwm* _lidar; + Kalman* _altitudeKalmanFilter; +}; + +#endif \ No newline at end of file