44 #define RC_MPU_DEFAULT_I2C_ADDR 0x68 45 #define RC_MPU_ALT_I2C_ADDR 0x69
57 #define DEG_TO_RAD 0.0174532925199 58 #define RAD_TO_DEG 57.295779513
59 #define MS2_TO_G 0.10197162129
60 #define G_TO_MS2 9.80665
211 int16_t raw_accel[3];
219 double dmp_TaitBryan[3];
227 double fused_quat[4];
228 double fused_TaitBryan[3];
int rc_mpu_set_dmp_callback(void(*func)(void))
Sets the callback function that will be triggered when new DMP data is ready.
int rc_mpu_read_temp(rc_mpu_data_t *data)
Reads thermometer data from the MPU.
int rc_mpu_read_accel(rc_mpu_data_t *data)
Reads accelerometer data from the MPU.
int dmp_fetch_accel_gyro
set to 1 to optionally raw accel/gyro when reading DMP quaternion, default: 0 (off) ...
Definition: mpu.h:177
int tap_threshold
threshold impulse for triggering a tap in units of mg/ms
Definition: mpu.h:185
int dmp_sample_rate
sample rate in hertz, 200,100,50,40,25,20,10,8,5,4
Definition: mpu.h:176
int rc_mpu_is_gyro_calibrated(void)
Checks if a gyro calibration file is saved to disk.
int dmp_interrupt_sched_policy
Scheduler policy for DMP interrupt handler and user callback, default SCHED_OTHER.
Definition: mpu.h:181
double compass_heading
fused heading filtered with gyro and accel data, same as Tait-Bryan yaw
Definition: mpu.h:229
rc_mpu_config_t rc_mpu_default_config(void)
Returns an rc_mpu_config_t struct with default settings.
int mag_sample_rate_div
magnetometer_sample_rate = dmp_sample_rate/mag_sample_rate_div, default: 4
Definition: mpu.h:184
int rc_mpu_calibrate_mag_routine(rc_mpu_config_t conf)
Runs magnetometer calibration routine.
int gpio_interrupt_pin
gpio pin, default 21 on Robotics Cape and BB Blue
Definition: mpu.h:159
int dmp_auto_calibrate_gyro
set to 1 to let DMP auto calibrate the gyro while in use, default: 0 (off)
Definition: mpu.h:178
int enable_magnetometer
magnetometer use is optional, set to 1 to enable, default 0 (off)
Definition: mpu.h:171
double compass_time_constant
time constant (seconds) for filtering compass with gyroscope yaw value, default 25 ...
Definition: mpu.h:180
double accel_to_ms2
conversion rate from raw accelerometer to m/s^2
Definition: mpu.h:212
int64_t rc_mpu_nanos_since_last_dmp_interrupt(void)
calculates number of nanoseconds since the last DMP interrupt
int read_mag_after_callback
reads magnetometer after DMP callback function to improve latency, default 1 (true) ...
Definition: mpu.h:183
int show_warnings
set to 1 to print i2c_bus warnings for debug
Definition: mpu.h:162
rc_mpu_gyro_fsr_t
gyroscope full scale range options
Definition: mpu.h:83
int rc_mpu_initialize_dmp(rc_mpu_data_t *data, rc_mpu_config_t conf)
Initializes the MPU in DMP mode, see rc_test_dmp example.
int rc_mpu_power_off(void)
Powers off the MPU.
rc_mpu_orientation_t
Orientation of the sensor.
Definition: mpu.h:137
rc_mpu_accel_fsr_t
accelerometer full scale range options
Definition: mpu.h:69
struct rc_mpu_config_t rc_mpu_config_t
configuration of the mpu sensor
configuration of the mpu sensor
Definition: mpu.h:155
int rc_mpu_calibrate_gyro_routine(rc_mpu_config_t conf)
Runs gyroscope calibration routine.
double gyro_to_degs
conversion rate from raw gyroscope to degrees/s
Definition: mpu.h:213
int rc_mpu_is_accel_calibrated(void)
Checks if an accelerometer calibration file is saved to disk.
int dmp_interrupt_priority
scheduler priority for DMP interrupt handler and user callback, default 0
Definition: mpu.h:182
double temp
thermometer, in units of degrees Celsius
Definition: mpu.h:205
int rc_mpu_block_until_tap(void)
blocking function that returns when a tap is detected
data struct populated with new sensor data
Definition: mpu.h:199
double compass_heading_raw
unfiltered heading from magnetometer
Definition: mpu.h:230
int rc_mpu_read_mag(rc_mpu_data_t *data)
Reads magnetometer data from the MPU.
uint8_t i2c_addr
default is 0x68, pull pin ad0 high to make it 0x69
Definition: mpu.h:161
rc_mpu_gyro_dlpf_t gyro_dlpf
internal low pass filter cutoff, default GYRO_DLPF_184
Definition: mpu.h:170
struct rc_mpu_data_t rc_mpu_data_t
data struct populated with new sensor data
int rc_mpu_is_mag_calibrated(void)
Checks if a magnetometer calibration file is saved to disk.
rc_mpu_gyro_fsr_t gyro_fsr
gyroscope full scale range, default GYRO_FSR_2000DPS
Definition: mpu.h:168
rc_mpu_gyro_dlpf_t
gyroscope digital low-pass filter options
Definition: mpu.h:119
int rc_mpu_set_config_to_default(rc_mpu_config_t *conf)
Resets a config struct to defaults.
rc_mpu_accel_dlpf_t accel_dlpf
internal low pass filter cutoff, default ACCEL_DLPF_184
Definition: mpu.h:169
rc_mpu_orientation_t orient
DMP orientation matrix, see rc_mpu_orientation_t.
Definition: mpu.h:179
int rc_mpu_calibrate_accel_routine(rc_mpu_config_t conf)
Runs accelerometer calibration routine.
int tap_detected
set to 1 if there was a tap detect on the last dmp sample, reset to 0 on next sample ...
Definition: mpu.h:220
int rc_mpu_set_tap_callback(void(*func)(int direction, int counter))
sets the callback function triggered when a tap is detected
int last_tap_direction
direction of last tap, 1-6 corresponding to X+ X- Y+ Y- Z+ Z-
Definition: mpu.h:221
int i2c_bus
which bus to use, default 2 on Robotics Cape and BB Blue
Definition: mpu.h:160
int rc_mpu_initialize(rc_mpu_data_t *data, rc_mpu_config_t conf)
Sets up the MPU in normal one-shot sampling mode.
rc_mpu_accel_dlpf_t
accelerometer digital low-pass filter options
Definition: mpu.h:99
int last_tap_count
current counter of rapid consecutive taps
Definition: mpu.h:222
int64_t rc_mpu_nanos_since_last_tap(void)
calculates nanoseconds since last tap was detected
int rc_mpu_block_until_dmp_data(void)
blocking function that returns once new DMP data is available
int rc_mpu_read_gyro(rc_mpu_data_t *data)
Reads gyroscope data from the MPU.
rc_mpu_accel_fsr_t accel_fsr
accelerometer full scale range, default ACCEL_FSR_8G
Definition: mpu.h:167
int gpio_interrupt_pin_chip
gpio pin, default 3 on Robotics Cape and BB Blue
Definition: mpu.h:158