additional edits to James’ code

Committer:
isagmz
Date:
Wed Jul 03 18:14:34 2019 +0000
Revision:
13:f9a20b88455c
Parent:
12:6efce6d008f8
additional edits

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jahutchi 12:6efce6d008f8 1 #ifndef IMU6050_H
jahutchi 12:6efce6d008f8 2 #define IMU6050_H
jahutchi 12:6efce6d008f8 3
jahutchi 12:6efce6d008f8 4 #include "filter.h"
jahutchi 12:6efce6d008f8 5 //#include "mbed.h"
jahutchi 12:6efce6d008f8 6 #include "math.h"
jahutchi 12:6efce6d008f8 7 #include <MPU6050.h>
jahutchi 12:6efce6d008f8 8
jahutchi 12:6efce6d008f8 9 #define PI 3.141593
jahutchi 12:6efce6d008f8 10
jahutchi 12:6efce6d008f8 11 #define SDA PB_9
jahutchi 12:6efce6d008f8 12 #define SCL PB_8
jahutchi 12:6efce6d008f8 13 #define SAMPLEFREQ 50
jahutchi 12:6efce6d008f8 14 #define CAL_TIME 3
jahutchi 12:6efce6d008f8 15
jahutchi 12:6efce6d008f8 16 class IMU6050 {
jahutchi 12:6efce6d008f8 17 public:
jahutchi 12:6efce6d008f8 18 //The constructor for this class
jahutchi 12:6efce6d008f8 19 IMU6050(Serial* out, Timer* time);
jahutchi 12:6efce6d008f8 20 IMU6050(PinName sda_pin, PinName scl_pin, Serial* out, Timer* time);
jahutchi 12:6efce6d008f8 21
jahutchi 12:6efce6d008f8 22 //Set up the IMU, check if it connects
jahutchi 12:6efce6d008f8 23 void setup();
jahutchi 12:6efce6d008f8 24
jahutchi 12:6efce6d008f8 25 //Get the x-component of the angular acceleration
jahutchi 12:6efce6d008f8 26 double accel_x();
jahutchi 12:6efce6d008f8 27
jahutchi 12:6efce6d008f8 28 //Get the y-component of the angular acceleration
jahutchi 12:6efce6d008f8 29 double accel_y();
jahutchi 12:6efce6d008f8 30
jahutchi 12:6efce6d008f8 31 //Get the z-component of the angular acceleration
jahutchi 12:6efce6d008f8 32 double accel_z();
jahutchi 12:6efce6d008f8 33
jahutchi 12:6efce6d008f8 34 //Get the x-component of gyro, angular velocity
jahutchi 12:6efce6d008f8 35 double gyro_x();
jahutchi 12:6efce6d008f8 36
jahutchi 12:6efce6d008f8 37 //Get the y-component of gyro, angular velocity
jahutchi 12:6efce6d008f8 38 double gyro_y();
jahutchi 12:6efce6d008f8 39
jahutchi 12:6efce6d008f8 40 //Get the z-component of gyro, angular velocity
jahutchi 12:6efce6d008f8 41 double gyro_z();
jahutchi 12:6efce6d008f8 42
jahutchi 12:6efce6d008f8 43 //Magnometer to find angle relative to North to compare to gyroscope
jahutchi 12:6efce6d008f8 44 //double angle_north();
jahutchi 12:6efce6d008f8 45
jahutchi 12:6efce6d008f8 46 //Get the YAW, or angle (theta), direction facing
jahutchi 12:6efce6d008f8 47 double yaw();
jahutchi 12:6efce6d008f8 48
jahutchi 12:6efce6d008f8 49 //Get the pitch, (Up and down component)
jahutchi 12:6efce6d008f8 50 double pitch();
jahutchi 12:6efce6d008f8 51
jahutchi 12:6efce6d008f8 52 //Get the roll, the tilt
jahutchi 12:6efce6d008f8 53 double roll();
jahutchi 12:6efce6d008f8 54
jahutchi 12:6efce6d008f8 55 MPU6050* imu; //The IMU we're testing from, MPU6050
jahutchi 12:6efce6d008f8 56
jahutchi 12:6efce6d008f8 57 private:
jahutchi 12:6efce6d008f8 58 Serial* usb; //the connection port
jahutchi 12:6efce6d008f8 59 Timer* t;//to calculate the time
jahutchi 12:6efce6d008f8 60 float accelData[3]; // stores the angular acceleration component
jahutchi 12:6efce6d008f8 61 float gyroData[3]; //stores the gyro data x,y,z
jahutchi 12:6efce6d008f8 62 float* accelD; //Pointer that points to either accelData
jahutchi 12:6efce6d008f8 63 float* gyroD; //Ptr to the gyroData array
jahutchi 12:6efce6d008f8 64
jahutchi 12:6efce6d008f8 65 float angleData[3]; //Contains the pitch, roll, yaw angle
jahutchi 12:6efce6d008f8 66 float* angleD;//Ptr to angleData array
jahutchi 12:6efce6d008f8 67
jahutchi 12:6efce6d008f8 68 void calibrate_yaw();
jahutchi 12:6efce6d008f8 69
jahutchi 12:6efce6d008f8 70 };
jahutchi 12:6efce6d008f8 71
jahutchi 12:6efce6d008f8 72 #endif