クオータニオンを出力してくれる9軸センサ,BNO055のライブラリ
BNO055_lib.h@1:6de1be86a23f, 2019-02-19 (annotated)
- Committer:
- Sigma884
- Date:
- Tue Feb 19 14:57:28 2019 +0000
- Revision:
- 1:6de1be86a23f
- Parent:
- 0:4c82133c291f
MODE -> BNO_MODE
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 | 1:6de1be86a23f | 4 | /******************************************************************************* |
Sigma884 | 1:6de1be86a23f | 5 | 付け加える予定の機能(未実装) |
Sigma884 | 1:6de1be86a23f | 6 | ・単位の変更 |
Sigma884 | 1:6de1be86a23f | 7 | ・オフセットの回り |
Sigma884 | 1:6de1be86a23f | 8 | *******************************************************************************/ |
Sigma884 | 1:6de1be86a23f | 9 | |
Sigma884 | 0:4c82133c291f | 10 | #define BNO055_ADDR_LOW 0x28 |
Sigma884 | 0:4c82133c291f | 11 | #define BNO055_ADDR_HIGH 0x29 |
Sigma884 | 0:4c82133c291f | 12 | |
Sigma884 | 0:4c82133c291f | 13 | #define BNO055_CHIP_ID 0x00 |
Sigma884 | 0:4c82133c291f | 14 | #define BNO055_PAGE_ID 0x07 |
Sigma884 | 0:4c82133c291f | 15 | |
Sigma884 | 0:4c82133c291f | 16 | ///////////////////////PAGE 0 |
Sigma884 | 0:4c82133c291f | 17 | #define BNO055_ACC_DATA 0x08 |
Sigma884 | 0:4c82133c291f | 18 | #define BNO055_MAG_DATA 0x0E |
Sigma884 | 0:4c82133c291f | 19 | #define BNO055_GYR_DATA 0x14 |
Sigma884 | 0:4c82133c291f | 20 | #define BNO055_EUL_DATA 0x1A |
Sigma884 | 0:4c82133c291f | 21 | #define BNO055_QUA_DATA 0x20 |
Sigma884 | 0:4c82133c291f | 22 | #define BNO055_LIA_DATA 0x28 |
Sigma884 | 0:4c82133c291f | 23 | #define BNO055_GRV_DATA 0x2E |
Sigma884 | 0:4c82133c291f | 24 | |
Sigma884 | 0:4c82133c291f | 25 | #define BNO055_CALIB_STAT 0x35 |
Sigma884 | 0:4c82133c291f | 26 | |
Sigma884 | 0:4c82133c291f | 27 | #define BNO055_OPR_MODE 0x3D |
Sigma884 | 0:4c82133c291f | 28 | #define BNO055_PWR_MODE 0x3E |
Sigma884 | 0:4c82133c291f | 29 | |
Sigma884 | 1:6de1be86a23f | 30 | #define BNO055_AXIS_MAP_CONFIG 0x41 |
Sigma884 | 1:6de1be86a23f | 31 | #define BNO055_AXIS_MAP_SIGN 0x42 |
Sigma884 | 1:6de1be86a23f | 32 | |
Sigma884 | 0:4c82133c291f | 33 | ///////////////////////PAGE 1 |
Sigma884 | 0:4c82133c291f | 34 | #define BNO055_ACC_CONFIG 0x08 |
Sigma884 | 0:4c82133c291f | 35 | |
Sigma884 | 0:4c82133c291f | 36 | class BNO055_lib{ |
Sigma884 | 0:4c82133c291f | 37 | |
Sigma884 | 0:4c82133c291f | 38 | public: |
Sigma884 | 0:4c82133c291f | 39 | |
Sigma884 | 0:4c82133c291f | 40 | typedef enum{ |
Sigma884 | 0:4c82133c291f | 41 | AD0_LOW = BNO055_ADDR_LOW, |
Sigma884 | 0:4c82133c291f | 42 | AD0_HIGH = BNO055_ADDR_HIGH |
Sigma884 | 0:4c82133c291f | 43 | }AD0; |
Sigma884 | 0:4c82133c291f | 44 | |
Sigma884 | 0:4c82133c291f | 45 | typedef enum{ |
Sigma884 | 0:4c82133c291f | 46 | _2G = 0x00, |
Sigma884 | 0:4c82133c291f | 47 | _4G = 0x01, |
Sigma884 | 0:4c82133c291f | 48 | _8G = 0x02, |
Sigma884 | 0:4c82133c291f | 49 | _16G = 0x03 |
Sigma884 | 0:4c82133c291f | 50 | }ACC_RANGE; |
Sigma884 | 0:4c82133c291f | 51 | |
Sigma884 | 0:4c82133c291f | 52 | typedef enum{ |
Sigma884 | 0:4c82133c291f | 53 | CONFIG = 0x00, |
Sigma884 | 0:4c82133c291f | 54 | ACCONLY = 0x01, |
Sigma884 | 0:4c82133c291f | 55 | MAGONLY = 0x02, |
Sigma884 | 0:4c82133c291f | 56 | GYROONLY = 0x03, |
Sigma884 | 0:4c82133c291f | 57 | ACCMAG = 0x04, |
Sigma884 | 0:4c82133c291f | 58 | ACCGYRO = 0x05, |
Sigma884 | 0:4c82133c291f | 59 | MAGGYRO = 0x06, |
Sigma884 | 0:4c82133c291f | 60 | AMG = 0x07, |
Sigma884 | 0:4c82133c291f | 61 | IMU = 0x08, |
Sigma884 | 0:4c82133c291f | 62 | COMPASS = 0x09, |
Sigma884 | 0:4c82133c291f | 63 | M4G = 0x0A, |
Sigma884 | 0:4c82133c291f | 64 | NDOF_FMC_OFF = 0x0B, |
Sigma884 | 0:4c82133c291f | 65 | NDOF = 0x0C |
Sigma884 | 0:4c82133c291f | 66 | }OPERATION_MODE; |
Sigma884 | 0:4c82133c291f | 67 | |
Sigma884 | 1:6de1be86a23f | 68 | typedef enum{ |
Sigma884 | 1:6de1be86a23f | 69 | X = 0x00, |
Sigma884 | 1:6de1be86a23f | 70 | Y = 0x01, |
Sigma884 | 1:6de1be86a23f | 71 | Z = 0x02 |
Sigma884 | 1:6de1be86a23f | 72 | }AXIS; |
Sigma884 | 1:6de1be86a23f | 73 | |
Sigma884 | 0:4c82133c291f | 74 | BNO055_lib(I2C &user_i2c, AD0 ad0); |
Sigma884 | 0:4c82133c291f | 75 | int connectCheck(); |
Sigma884 | 0:4c82133c291f | 76 | void setAccRange(ACC_RANGE range); |
Sigma884 | 0:4c82133c291f | 77 | void setOperationMode(OPERATION_MODE mode); |
Sigma884 | 1:6de1be86a23f | 78 | void setAxis(AXIS x, AXIS y, AXIS z); |
Sigma884 | 1:6de1be86a23f | 79 | void setAxisPM(int x_pm, int y_pm, int z_pm); |
Sigma884 | 0:4c82133c291f | 80 | |
Sigma884 | 0:4c82133c291f | 81 | void getAcc(float *acc); |
Sigma884 | 0:4c82133c291f | 82 | void getAcc(double *acc); |
Sigma884 | 0:4c82133c291f | 83 | void getMag(float *mag); |
Sigma884 | 0:4c82133c291f | 84 | void getMag(double *mag); |
Sigma884 | 0:4c82133c291f | 85 | void getGyro(float *gyro); |
Sigma884 | 0:4c82133c291f | 86 | void getGyro(double *gyro); |
Sigma884 | 0:4c82133c291f | 87 | void getAMG(float *amg); |
Sigma884 | 0:4c82133c291f | 88 | void getAMG(double *amg); |
Sigma884 | 0:4c82133c291f | 89 | |
Sigma884 | 0:4c82133c291f | 90 | void getEuler(float *euler); |
Sigma884 | 0:4c82133c291f | 91 | void getEuler(double *euler); |
Sigma884 | 0:4c82133c291f | 92 | void getQuart(float *quart); |
Sigma884 | 0:4c82133c291f | 93 | void getQuart(double *quart); |
Sigma884 | 0:4c82133c291f | 94 | void getEulerFromQ(float *euler); |
Sigma884 | 0:4c82133c291f | 95 | void getEulerFromQ(double *euler); |
Sigma884 | 0:4c82133c291f | 96 | void getLinearAcc(float *lia); |
Sigma884 | 0:4c82133c291f | 97 | void getLinearAcc(double *lia); |
Sigma884 | 0:4c82133c291f | 98 | void getGravity(float *grv); |
Sigma884 | 0:4c82133c291f | 99 | void getGravity(double *grv); |
Sigma884 | 0:4c82133c291f | 100 | |
Sigma884 | 0:4c82133c291f | 101 | |
Sigma884 | 0:4c82133c291f | 102 | private: |
Sigma884 | 0:4c82133c291f | 103 | |
Sigma884 | 0:4c82133c291f | 104 | char slave; |
Sigma884 | 0:4c82133c291f | 105 | I2C *i2c; |
Sigma884 | 0:4c82133c291f | 106 | |
Sigma884 | 0:4c82133c291f | 107 | char cmd[2]; |
Sigma884 | 0:4c82133c291f | 108 | char buff[18]; |
Sigma884 | 0:4c82133c291f | 109 | short data[4]; |
Sigma884 | 0:4c82133c291f | 110 | |
Sigma884 | 0:4c82133c291f | 111 | double data_d[4]; |
Sigma884 | 0:4c82133c291f | 112 | double t0, t1, yy; |
Sigma884 | 0:4c82133c291f | 113 | }; |
Sigma884 | 0:4c82133c291f | 114 | |
Sigma884 | 0:4c82133c291f | 115 | |
Sigma884 | 0:4c82133c291f | 116 | #endif |