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.
Dependents: IZU2020_AVIONICS IZU2020_AVIONICS
MPU9250 Class Reference
9軸センサMPU9250のライブラリ More...
#include <PQMPU9250.h>
Public Member Functions | |
| MPU9250 (I2C &i2c, AD0_t AD0) | |
| void | begin () |
| センサ動作開始 | |
| bool | test () |
| センサ通信テスト | |
| bool | test_AK8963 () |
| 磁気センサAK8963通信テスト | |
| void | set (AccelConfig_t accel_config, GyroConfig_t gyro_config, MagConfig_t mag_config) |
| センサ設定 | |
| void | set_accel (AccelConfig_t accel_config) |
| 加速度センサ設定 | |
| void | set_gyro (GyroConfig_t gyro_config) |
| 角速度センサ設定 | |
| void | set_mag (MagConfig_t mag_config) |
| 磁気センサ設定 | |
| void | offset (float *accel, float *gyro, float *mag) |
| ゼロ点補正 | |
| void | offset_accel (float *accel) |
| 加速度のゼロ点補正 | |
| void | offset_gyro (float *gyro) |
| 角速度のゼロ点補正 | |
| void | offset_mag (float *mag) |
| 磁気のゼロ点補正 | |
| void | read (float *accel, float *gyro, float *mag) |
| 測定値の読み取り | |
| void | read_accel (float *accel) |
| 加速度測定値の読み取り | |
| void | read_gyro (float *gyro) |
| 角速度測定値の読み取り | |
| void | read_mag (float *mag) |
| 磁気測定値の読み取り | |
Detailed Description
9軸センサMPU9250のライブラリ
#include "mbed.h" #include "PQMPU9250.h" Serial pc(USBTX, USBRX, 115200); I2C i2c(p9, p10); MPU9250 mpu(i2c, MPU9250::AD0_HIGH); float accel_offset[] = {0, 0, 0}; float gyro_offset[] = {0, 0, 0}; float mag_offset[] = {0, 0, 0}; float accel[3]; float gyro[3]; float mag[3]; int main() { mpu.begin(); mpu.set(_2G, _250DPS, _16B_8HZ); mpu.offset(accel_offset, gyro_offset, mag_offset); if(!mpu.test()){ pc.printf("[ FAIL ] MPU9250 cannot be reached.\r\n"); } if(!mpu.test_AK8963()){ pc.printf("[ FAIL ] AK8963 cannot be reached.\r\n"); } while(1) { mpu.read(accel, gyro, mag); pc.printf("%f\t%f\t%f\t%f\t%f\t%f\t%f\t%f\t%f\r\n", accel[0], accel[1], accel[2], gyro[0], gyro[1], gyro[2], mag[0], mag[1], mag[2]); } }
Definition at line 57 of file PQMPU9250.h.
Constructor & Destructor Documentation
| MPU9250 | ( | I2C & | i2c, |
| AD0_t | AD0 | ||
| ) |
- Parameters:
-
i2c I2Cのインスタンスへの参照 AD0 AD0ピンのH/Lレベル
Definition at line 4 of file PQMPU9250.cpp.
Member Function Documentation
| void begin | ( | ) |
センサ動作開始
Definition at line 11 of file PQMPU9250.cpp.
| void offset | ( | float * | accel, |
| float * | gyro, | ||
| float * | mag | ||
| ) |
ゼロ点補正
- Parameters:
-
accel 加速度のオフセット配列 gyro 角速度のオフセット配列 mag 磁気のオフセット配列
Definition at line 93 of file PQMPU9250.cpp.
| void offset_accel | ( | float * | accel ) |
| void offset_gyro | ( | float * | gyro ) |
| void offset_mag | ( | float * | mag ) |
| void read | ( | float * | accel, |
| float * | gyro, | ||
| float * | mag | ||
| ) |
測定値の読み取り
- Parameters:
-
accel 加速度を格納する配列 gyro 角速度を格納する配列 mag 磁気を格納する配列
Definition at line 121 of file PQMPU9250.cpp.
| void read_accel | ( | float * | accel ) |
| void read_gyro | ( | float * | gyro ) |
| void read_mag | ( | float * | mag ) |
| void set | ( | AccelConfig_t | accel_config, |
| GyroConfig_t | gyro_config, | ||
| MagConfig_t | mag_config | ||
| ) |
センサ設定
- Parameters:
-
accel_config 加速度の測定レンジ gyro_config 角速度の測定レンジ mag_config 磁気センサの分解能/データレート
Definition at line 46 of file PQMPU9250.cpp.
| void set_accel | ( | AccelConfig_t | accel_config ) |
| void set_gyro | ( | GyroConfig_t | gyro_config ) |
| void set_mag | ( | MagConfig_t | mag_config ) |
| bool test | ( | ) |
| bool test_AK8963 | ( | ) |
Generated on Tue Jul 12 2022 18:30:55 by
1.7.2