クオータニオンを出力してくれる9軸センサ,BNO055のライブラリ
BNO055_lib.h@0:4c82133c291f, 2019-01-22 (annotated)
- Committer:
- Sigma884
- Date:
- Tue Jan 22 11:47:28 2019 +0000
- Revision:
- 0:4c82133c291f
- Child:
- 1:6de1be86a23f
minimum function was mounted
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Sigma884 | 0:4c82133c291f | 1 | #ifndef BNO055_LIB_ |
Sigma884 | 0:4c82133c291f | 2 | #define BNO055_LIB_ |
Sigma884 | 0:4c82133c291f | 3 | |
Sigma884 | 0:4c82133c291f | 4 | #define BNO055_ADDR_LOW 0x28 |
Sigma884 | 0:4c82133c291f | 5 | #define BNO055_ADDR_HIGH 0x29 |
Sigma884 | 0:4c82133c291f | 6 | |
Sigma884 | 0:4c82133c291f | 7 | #define BNO055_CHIP_ID 0x00 |
Sigma884 | 0:4c82133c291f | 8 | #define BNO055_PAGE_ID 0x07 |
Sigma884 | 0:4c82133c291f | 9 | |
Sigma884 | 0:4c82133c291f | 10 | ///////////////////////PAGE 0 |
Sigma884 | 0:4c82133c291f | 11 | #define BNO055_ACC_DATA 0x08 |
Sigma884 | 0:4c82133c291f | 12 | #define BNO055_MAG_DATA 0x0E |
Sigma884 | 0:4c82133c291f | 13 | #define BNO055_GYR_DATA 0x14 |
Sigma884 | 0:4c82133c291f | 14 | #define BNO055_EUL_DATA 0x1A |
Sigma884 | 0:4c82133c291f | 15 | #define BNO055_QUA_DATA 0x20 |
Sigma884 | 0:4c82133c291f | 16 | #define BNO055_LIA_DATA 0x28 |
Sigma884 | 0:4c82133c291f | 17 | #define BNO055_GRV_DATA 0x2E |
Sigma884 | 0:4c82133c291f | 18 | |
Sigma884 | 0:4c82133c291f | 19 | #define BNO055_CALIB_STAT 0x35 |
Sigma884 | 0:4c82133c291f | 20 | |
Sigma884 | 0:4c82133c291f | 21 | #define BNO055_OPR_MODE 0x3D |
Sigma884 | 0:4c82133c291f | 22 | #define BNO055_PWR_MODE 0x3E |
Sigma884 | 0:4c82133c291f | 23 | |
Sigma884 | 0:4c82133c291f | 24 | ///////////////////////PAGE 1 |
Sigma884 | 0:4c82133c291f | 25 | #define BNO055_ACC_CONFIG 0x08 |
Sigma884 | 0:4c82133c291f | 26 | |
Sigma884 | 0:4c82133c291f | 27 | class BNO055_lib{ |
Sigma884 | 0:4c82133c291f | 28 | |
Sigma884 | 0:4c82133c291f | 29 | public: |
Sigma884 | 0:4c82133c291f | 30 | |
Sigma884 | 0:4c82133c291f | 31 | typedef enum{ |
Sigma884 | 0:4c82133c291f | 32 | AD0_LOW = BNO055_ADDR_LOW, |
Sigma884 | 0:4c82133c291f | 33 | AD0_HIGH = BNO055_ADDR_HIGH |
Sigma884 | 0:4c82133c291f | 34 | }AD0; |
Sigma884 | 0:4c82133c291f | 35 | |
Sigma884 | 0:4c82133c291f | 36 | typedef enum{ |
Sigma884 | 0:4c82133c291f | 37 | _2G = 0x00, |
Sigma884 | 0:4c82133c291f | 38 | _4G = 0x01, |
Sigma884 | 0:4c82133c291f | 39 | _8G = 0x02, |
Sigma884 | 0:4c82133c291f | 40 | _16G = 0x03 |
Sigma884 | 0:4c82133c291f | 41 | }ACC_RANGE; |
Sigma884 | 0:4c82133c291f | 42 | |
Sigma884 | 0:4c82133c291f | 43 | typedef enum{ |
Sigma884 | 0:4c82133c291f | 44 | CONFIG = 0x00, |
Sigma884 | 0:4c82133c291f | 45 | ACCONLY = 0x01, |
Sigma884 | 0:4c82133c291f | 46 | MAGONLY = 0x02, |
Sigma884 | 0:4c82133c291f | 47 | GYROONLY = 0x03, |
Sigma884 | 0:4c82133c291f | 48 | ACCMAG = 0x04, |
Sigma884 | 0:4c82133c291f | 49 | ACCGYRO = 0x05, |
Sigma884 | 0:4c82133c291f | 50 | MAGGYRO = 0x06, |
Sigma884 | 0:4c82133c291f | 51 | AMG = 0x07, |
Sigma884 | 0:4c82133c291f | 52 | IMU = 0x08, |
Sigma884 | 0:4c82133c291f | 53 | COMPASS = 0x09, |
Sigma884 | 0:4c82133c291f | 54 | M4G = 0x0A, |
Sigma884 | 0:4c82133c291f | 55 | NDOF_FMC_OFF = 0x0B, |
Sigma884 | 0:4c82133c291f | 56 | NDOF = 0x0C |
Sigma884 | 0:4c82133c291f | 57 | }OPERATION_MODE; |
Sigma884 | 0:4c82133c291f | 58 | |
Sigma884 | 0:4c82133c291f | 59 | BNO055_lib(I2C &user_i2c, AD0 ad0); |
Sigma884 | 0:4c82133c291f | 60 | int connectCheck(); |
Sigma884 | 0:4c82133c291f | 61 | void setAccRange(ACC_RANGE range); |
Sigma884 | 0:4c82133c291f | 62 | void setOperationMode(OPERATION_MODE mode); |
Sigma884 | 0:4c82133c291f | 63 | |
Sigma884 | 0:4c82133c291f | 64 | void getAcc(float *acc); |
Sigma884 | 0:4c82133c291f | 65 | void getAcc(double *acc); |
Sigma884 | 0:4c82133c291f | 66 | void getMag(float *mag); |
Sigma884 | 0:4c82133c291f | 67 | void getMag(double *mag); |
Sigma884 | 0:4c82133c291f | 68 | void getGyro(float *gyro); |
Sigma884 | 0:4c82133c291f | 69 | void getGyro(double *gyro); |
Sigma884 | 0:4c82133c291f | 70 | void getAMG(float *amg); |
Sigma884 | 0:4c82133c291f | 71 | void getAMG(double *amg); |
Sigma884 | 0:4c82133c291f | 72 | |
Sigma884 | 0:4c82133c291f | 73 | void getEuler(float *euler); |
Sigma884 | 0:4c82133c291f | 74 | void getEuler(double *euler); |
Sigma884 | 0:4c82133c291f | 75 | void getQuart(float *quart); |
Sigma884 | 0:4c82133c291f | 76 | void getQuart(double *quart); |
Sigma884 | 0:4c82133c291f | 77 | void getEulerFromQ(float *euler); |
Sigma884 | 0:4c82133c291f | 78 | void getEulerFromQ(double *euler); |
Sigma884 | 0:4c82133c291f | 79 | void getLinearAcc(float *lia); |
Sigma884 | 0:4c82133c291f | 80 | void getLinearAcc(double *lia); |
Sigma884 | 0:4c82133c291f | 81 | void getGravity(float *grv); |
Sigma884 | 0:4c82133c291f | 82 | void getGravity(double *grv); |
Sigma884 | 0:4c82133c291f | 83 | |
Sigma884 | 0:4c82133c291f | 84 | |
Sigma884 | 0:4c82133c291f | 85 | private: |
Sigma884 | 0:4c82133c291f | 86 | |
Sigma884 | 0:4c82133c291f | 87 | char slave; |
Sigma884 | 0:4c82133c291f | 88 | I2C *i2c; |
Sigma884 | 0:4c82133c291f | 89 | |
Sigma884 | 0:4c82133c291f | 90 | char cmd[2]; |
Sigma884 | 0:4c82133c291f | 91 | char buff[18]; |
Sigma884 | 0:4c82133c291f | 92 | short data[4]; |
Sigma884 | 0:4c82133c291f | 93 | |
Sigma884 | 0:4c82133c291f | 94 | double data_d[4]; |
Sigma884 | 0:4c82133c291f | 95 | double t0, t1, yy; |
Sigma884 | 0:4c82133c291f | 96 | }; |
Sigma884 | 0:4c82133c291f | 97 | |
Sigma884 | 0:4c82133c291f | 98 | |
Sigma884 | 0:4c82133c291f | 99 | #endif |