Isabella Gomez Torres / Mbed OS IMU6050
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers IMU6050.h Source File

IMU6050.h

00001 #ifndef IMU6050_H
00002 #define IMU6050_H
00003 
00004 #include "filter.h"
00005 //#include  "mbed.h"
00006 #include  "math.h"
00007 #include  <MPU6050.h>
00008 
00009 #define PI 3.141593
00010 
00011 #define SDA PB_9
00012 #define SCL PB_8
00013 #define SAMPLEFREQ 50
00014 #define CAL_TIME 3
00015 
00016 class IMU6050 {
00017     public:
00018         //The constructor for this class
00019         IMU6050(Serial* out, Timer* time);
00020         IMU6050(PinName sda_pin, PinName scl_pin, Serial* out, Timer* time);
00021         
00022         //Set up the IMU, check if it connects
00023         void setup();
00024         
00025         //Get the x-component of the angular acceleration
00026         double accel_x();
00027         
00028         //Get the y-component of the angular acceleration
00029         double accel_y();
00030         
00031         //Get the z-component of the angular acceleration
00032         double accel_z();
00033         
00034         //Get the x-component of gyro, angular velocity
00035         double gyro_x();
00036         
00037         //Get the y-component of gyro, angular velocity
00038         double gyro_y();
00039         
00040         //Get the z-component of gyro, angular velocity
00041         double gyro_z();
00042         
00043         //Magnometer to find angle relative to North to compare to gyroscope
00044         //double angle_north();
00045         
00046         //Get the YAW, or angle (theta), direction facing
00047         double yaw();
00048         
00049         //Get the pitch, (Up and down component)
00050         double pitch();
00051         
00052         //Get the roll, the tilt
00053         double roll();
00054   
00055         MPU6050* imu; //The IMU we're testing from, MPU6050  
00056         
00057     private:
00058         Serial* usb; //the connection port
00059         Timer* t;//to calculate the time
00060         float accelData[3];   // stores the angular acceleration component
00061         float gyroData[3];    //stores the gyro data x,y,z
00062         float* accelD;        //Pointer that points to either accelData 
00063         float* gyroD;         //Ptr to the gyroData array
00064         
00065         float angleData[3]; //Contains the pitch, roll, yaw angle
00066         float* angleD;//Ptr to angleData array
00067         
00068         void calibrate_yaw();
00069     
00070 };
00071 
00072 #endif