New version of quadcopter software written to OO principles

Dependencies:   mbed MODSERIAL filter mbed-rtos ConfigFile PID PPM FreeIMU_external_magnetometer TinyGPS

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Sensors.h Source File

Sensors.h

00001 #include "mbed.h"
00002 #include "Global.h"
00003 #include "rtos.h"
00004 #include "Gps.h"
00005 #include "Imu.h"
00006 #include "Status.h"
00007 #include "LidarLitePwm.h"
00008 #include "Kalman.h"
00009 #include <math.h>
00010 
00011 #ifndef Sensors_H
00012 #define Sensors_H
00013 
00014 //#define PI 3.14159265
00015 
00016 using namespace std;
00017 
00018 class Sensors                
00019 {
00020   public:             
00021     Sensors(Status& status, ConfigFileWrapper& configFileWrapper, PinName gpsPinTx, PinName gpsPinRx, PinName i2cSda, PinName i2cScl, PinName lidarInterrupt);    
00022     ~Sensors();
00023     
00024     struct Position
00025     {
00026         Gps::Value gpsPosition;
00027         double computedX;
00028         double computedY;  
00029     };
00030     
00031     struct Altitude
00032     {
00033         double lidar;
00034         double barometer;
00035         double gps;
00036         double computed;
00037     };
00038     
00039     void update();
00040     Imu::Rate getRate();
00041     Imu::Angle getAngle();
00042     Gps::Value getGpsValues();
00043     Imu::Velocity getImuVelocity();
00044     Sensors::Altitude getAltitude();
00045     Sensors::Position getPosition();
00046     Imu::Acceleration getImuAcceleration();
00047     void enable(bool enable);
00048     void zeroBarometer();
00049     void updateImu();
00050     void zeroAccel();
00051     void zeroPos();
00052     
00053   private:
00054     void zeroGyro();
00055     void updateGpsValues();
00056     void updateAltitude();
00057     void updateVelocity();
00058     void updatePosition();
00059     int getLidarAltitude();
00060     double toRadian(double deg);
00061     
00062     Status& _status;
00063     Imu::Rate _rate;
00064     Imu::Angle _angle;
00065     Position _position;
00066     Position _startingPosition;
00067     Altitude _altitude;
00068     Gps::Value _gpsValues;
00069     Imu* _imu;
00070     Gps* _gps;
00071     LidarLitePwm* _lidar;
00072     Kalman* _altitudeKalmanFilter;
00073     Kalman* _xPosKalmanFilter;
00074     Kalman* _yPosKalmanFilter;
00075 };
00076 
00077 #endif