Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
IMU6050.cpp
00001 #include "IMU6050.h" 00002 00003 IMU6050::IMU6050(PinName sda_pin, PinName scl_pin, Serial* out, Timer* time){ 00004 usb = out; 00005 t = time; 00006 //imu = new BNO055(sda_pin, scl_pin); 00007 00008 accelD = accelData; 00009 gyroD = gyroData; 00010 } 00011 00012 void IMU6050::setup() { 00013 00014 00015 00016 //timer 00017 t->start(); 00018 } 00019 00020 //Get the x component of the angular acceleration from IMU. Stores the component 00021 //in a float array 00022 //Returns a double, the value of the x-acceleration (m/s^2) 00023 double IMU6050::accel_x() { 00024 imu -> getAccelero(accelD); //Change the values in accelerationArray 00025 return (double)accelData[0]; 00026 } 00027 00028 //Get the y component of the angular acceleration from IMU. Stores the component 00029 //in a float array 00030 //Returns a double, the value of the y-acceleration (m/s^2) 00031 double IMU6050::accel_y() { 00032 imu -> getAccelero(accelD); //Change the values in accelerationArray 00033 return (double)accelData[1]; 00034 } 00035 00036 //Get the z component of the angular acceleration from IMU. Stores the component 00037 //in a float array 00038 //Returns a double, the value of the z-acceleration (m/s^2) 00039 double IMU6050::accel_z() { 00040 imu -> getAccelero(accelD); //Change the values in accelerationArray 00041 return (double)accelData[2]; 00042 } 00043 00044 //Get the x component of the angular velocity from IMU's gyroscope. Stores the 00045 //component in a float array 00046 //Returns a double, the value of the x-angular velocity (rad/s) 00047 double IMU6050::gyro_x() { 00048 imu -> getGyro(gyroD); //Change the values in gyroArray 00049 return (double)gyroData[0]; 00050 00051 } 00052 00053 //Get the y component of the angular velocity from IMU's gyroscope. Stores the 00054 //component in a float array 00055 //Returns a double, the value of the y-angular velocity (rad/s) 00056 double IMU6050::gyro_y() { 00057 imu -> getGyro(gyroD); //Change the values in gyroArray 00058 return (double)gyroData[1]; 00059 00060 } 00061 00062 //Get the z component of the angular velocity from IMU's gyroscope. Stores the 00063 //component in a float array 00064 //Returns a double, the value of the z-angular velocity (rad/s) 00065 double IMU6050::gyro_z() { 00066 imu -> getGyro(gyroD); //Change the values in gyroArray 00067 return (double)gyroData[2]; 00068 } 00069 00070 //Get the yaw, or the angle turned at a certain time interval 00071 //Return double, the angle or yaw, (degree) 00072 00073 /* 00074 double IMU6050::yaw() { 00075 00076 imu -> computeAngle(); 00077 return 00078 } 00079 00080 double IMU6050::pitch() { 00081 00082 } 00083 00084 double IMU6050::roll() { 00085 00086 } 00087 00088 */
Generated on Fri Jul 15 2022 05:53:38 by
 1.7.2
 1.7.2