Robot Control Library
mpu.h
Go to the documentation of this file.
1 /**
2  * <rc/mpu.h>
3  *
4  * @brief A userspace C interface for the invensense MPU6050, MPU6500,
5  * MPU9150, and MPU9250.
6  *
7  * This API allows the user to configure this IMU in two modes: NORMAL and DMP
8  *
9  * ##Normal Mode
10  *
11  * The accelerometer, gyroscope, magnetometer, and thermometer can be
12  * read directly at any time. To use this mode, call rc_mpu_initialize() with
13  * your imu_config and imu_data structs as arguments as defined below. You can
14  * then call rc_mpu_read_accel, rc_mpu_read_gyro, rc_mpu_read_mag, or
15  * rc_mpu_read_temp at any time to get the latest sensor values.
16  *
17  * ##DMP Mode
18  *
19  * Stands for Digital Motion Processor which is a feature of the MPU9250.
20  * in this mode, the DMP will sample the sensors internally and fill a FIFO
21  * buffer with the data at a fixed rate. Furthermore, the DMP will also
22  * calculate a filtered orientation quaternion which is placed in the same
23  * buffer. When new data is ready in the buffer, the IMU sends an interrupt to
24  * the BeagleBone triggering the buffer read followed by the execution of a
25  * function of your choosing set with the rc_mpu_set_dmp_callback() function.
26  *
27  * @author James Strawson
28  * @date 1/19/2018
29  *
30  * @addtogroup IMU_MPU
31  * @{
32  */
33 
34 #ifndef RC_MPU_H
35 #define RC_MPU_H
36 
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
40 
41 #include <stdint.h>
42 #include <pthread.h>
43 
44 #define RC_MPU_DEFAULT_I2C_ADDR 0x68 ///< default i2c address if AD0 is left low
45 #define RC_MPU_ALT_I2C_ADDR 0x69 ///< alternate i2c address if AD0 pin pulled high
46 
47 
48 // defines for index location within TaitBryan and quaternion vectors
49 #define TB_PITCH_X 0 ///< Index of the dmp_TaitBryan[] array corresponding to the Pitch (X) axis.
50 #define TB_ROLL_Y 1 ///< Index of the dmp_TaitBryan[] array corresponding to the Roll (Y) axis.
51 #define TB_YAW_Z 2 ///< Index of the dmp_TaitBryan[] array corresponding to the Yaw (Z) axis.
52 #define QUAT_W 0 ///< First index of the dmp_quat[] quaternion vector
53 #define QUAT_X 1 ///< Second index of the dmp_quat[] quaternion vector
54 #define QUAT_Y 2 ///< Third index of the dmp_quat[] quaternion vector
55 #define QUAT_Z 3 ///< Fourth index of the dmp_quat[] quaternion vector
56 
57 #define DEG_TO_RAD 0.0174532925199 ///< multiply to convert degrees to radians
58 #define RAD_TO_DEG 57.295779513 ///< multiply to convert radians to degrees
59 #define MS2_TO_G 0.10197162129 ///< multiply to convert m/s^2 to G
60 #define G_TO_MS2 9.80665 ///< multiply to convert G to m/s^2, standard gravity definition
61 
62 /**
63  * @brief accelerometer full scale range options
64  *
65  * The user may choose from 4 full scale ranges of the accelerometer and
66  * gyroscope. They have units of gravity (G) and degrees per second (DPS) The
67  * defaults values are A_FSR_2G and G_FSR_2000DPS respectively.
68  */
69 typedef enum rc_mpu_accel_fsr_t{
75 
76 /**
77  * @brief gyroscope full scale range options
78  *
79  * The user may choose from 4 full scale ranges of the accelerometer and
80  * gyroscope. They have units of gravity (G) and degrees per second (DPS) The
81  * defaults values are A_FSR_2G and G_FSR_2000DPS respectively.
82  */
83 typedef enum rc_mpu_gyro_fsr_t{
89 
90 /**
91  * @brief accelerometer digital low-pass filter options
92  *
93  * The user may choose from 7 digital low pass filter constants for the
94  * accelerometer and gyroscope. The filter runs at 1kz and helps to reduce
95  * sensor noise when sampling more slowly. The default values are ACCEL_DLPF_184
96  * GYRO_DLPF_184. Lower cut-off frequencies incur phase-loss in measurements.
97  * Number is cutoff frequency in hz.
98  */
99 typedef enum rc_mpu_accel_dlpf_t{
109 
110 /**
111  * @brief gyroscope digital low-pass filter options
112  *
113  * The user may choose from 7 digital low pass filter constants for the
114  * accelerometer and gyroscope. The filter runs at 1kz and helps to reduce
115  * sensor noise when sampling more slowly. The default values are ACCEL_DLPF_184
116  * GYRO_DLPF_184. Lower cut-off frequencies incur phase-loss in measurements.
117  * Number is cutoff frequency in hz.
118  */
119 typedef enum rc_mpu_gyro_dlpf_t{
129 
130 
131 /**
132  * @brief Orientation of the sensor.
133  *
134  * This is only applicable when operating in DMP mode. This is the orientation
135  * that the DMP consideres neutral, aka where roll/pitch/yaw are zero.
136  */
137 typedef enum rc_mpu_orientation_t{
147 
148 /**
149  * @brief configuration of the mpu sensor
150  *
151  * Configuration struct passed to rc_mpu_initialize and rc_mpu_initialize_dmp.
152  * It is best to get the default config with rc_mpu_default_config() function
153  * first and modify from there.
154  */
155 typedef struct rc_mpu_config_t{
156  /** @name physical connection configuration */
157  ///@{
158  int gpio_interrupt_pin_chip; ///< gpio pin, default 3 on Robotics Cape and BB Blue
159  int gpio_interrupt_pin; ///< gpio pin, default 21 on Robotics Cape and BB Blue
160  int i2c_bus; ///< which bus to use, default 2 on Robotics Cape and BB Blue
161  uint8_t i2c_addr; ///< default is 0x68, pull pin ad0 high to make it 0x69
162  int show_warnings; ///< set to 1 to print i2c_bus warnings for debug
163  ///@}
164 
165  /** @name accelerometer, gyroscope, and magnetometer configuration */
166  ///@{
167  rc_mpu_accel_fsr_t accel_fsr; ///< accelerometer full scale range, default ACCEL_FSR_8G
168  rc_mpu_gyro_fsr_t gyro_fsr; ///< gyroscope full scale range, default GYRO_FSR_2000DPS
169  rc_mpu_accel_dlpf_t accel_dlpf; ///< internal low pass filter cutoff, default ACCEL_DLPF_184
170  rc_mpu_gyro_dlpf_t gyro_dlpf; ///< internal low pass filter cutoff, default GYRO_DLPF_184
171  int enable_magnetometer; ///< magnetometer use is optional, set to 1 to enable, default 0 (off)
172  ///@}
173 
174  /** @name DMP settings, only used with DMP mode */
175  ///@{
176  int dmp_sample_rate; ///< sample rate in hertz, 200,100,50,40,25,20,10,8,5,4
177  int dmp_fetch_accel_gyro; ///< set to 1 to optionally raw accel/gyro when reading DMP quaternion, default: 0 (off)
178  int dmp_auto_calibrate_gyro; ///< set to 1 to let DMP auto calibrate the gyro while in use, default: 0 (off)
179  rc_mpu_orientation_t orient; ///< DMP orientation matrix, see rc_mpu_orientation_t
180  double compass_time_constant; ///< time constant (seconds) for filtering compass with gyroscope yaw value, default 25
181  int dmp_interrupt_sched_policy; ///< Scheduler policy for DMP interrupt handler and user callback, default SCHED_OTHER
182  int dmp_interrupt_priority; ///< scheduler priority for DMP interrupt handler and user callback, default 0
183  int read_mag_after_callback; ///< reads magnetometer after DMP callback function to improve latency, default 1 (true)
184  int mag_sample_rate_div; ///< magnetometer_sample_rate = dmp_sample_rate/mag_sample_rate_div, default: 4
185  int tap_threshold; ///< threshold impulse for triggering a tap in units of mg/ms
186  ///@}
187 
189 
190 
191 /**
192  * @brief data struct populated with new sensor data
193  *
194  * This is the container for holding the sensor data. The user is intended to
195  * make their own instance of this struct and pass its pointer to imu read
196  * functions. new data will then be written back into the user's instance of the
197  * data struct.
198  */
199 typedef struct rc_mpu_data_t{
200  /** @name base sensor readings in real units */
201  ///@{
202  double accel[3]; ///< accelerometer (XYZ) in units of m/s^2
203  double gyro[3]; ///< gyroscope (XYZ) in units of degrees/s
204  double mag[3]; ///< magnetometer (XYZ) in units of uT
205  double temp; ///< thermometer, in units of degrees Celsius
206  ///@}
207 
208  /** @name 16 bit raw adc readings and conversion rates*/
209  ///@{
210  int16_t raw_gyro[3]; ///< raw gyroscope (XYZ)from 16-bit ADC
211  int16_t raw_accel[3]; ///< raw accelerometer (XYZ) from 16-bit ADC
212  double accel_to_ms2; ///< conversion rate from raw accelerometer to m/s^2
213  double gyro_to_degs; ///< conversion rate from raw gyroscope to degrees/s
214  ///@}
215 
216  /** @name DMP data */
217  ///@{
218  double dmp_quat[4]; ///< normalized quaternion from DMP based on ONLY Accel/Gyro
219  double dmp_TaitBryan[3];///< Tait-Bryan angles (roll pitch yaw) in radians from DMP based on ONLY Accel/Gyro
220  int tap_detected; ///< set to 1 if there was a tap detect on the last dmp sample, reset to 0 on next sample
221  int last_tap_direction; ///< direction of last tap, 1-6 corresponding to X+ X- Y+ Y- Z+ Z-
222  int last_tap_count; ///< current counter of rapid consecutive taps
223  ///@}
224 
225  /** @name fused DMP data filtered with magnetometer */
226  ///@{
227  double fused_quat[4]; ///< fused and normalized quaternion
228  double fused_TaitBryan[3]; ///< fused Tait-Bryan angles (roll pitch yaw) in radians
229  double compass_heading; ///< fused heading filtered with gyro and accel data, same as Tait-Bryan yaw
230  double compass_heading_raw; ///< unfiltered heading from magnetometer
231  ///@}
232 } rc_mpu_data_t;
233 
234 
235 /** @name common functions */
236 ///@{
237 
238 /**
239  * @brief Returns an rc_mpu_config_t struct with default settings.
240  *
241  * Use this as a starting point and modify as you wish.
242  *
243  * @return Returns an rc_mpu_config_t struct with default settings.
244  */
246 
247 /**
248  * @brief Resets a config struct to defaults.
249  *
250  * @param[out] conf Pointer to config struct to be overwritten
251  *
252  * @return 0 on success or -1 on failure.
253  */
255 
256 /**
257  * @brief Powers off the MPU
258  *
259  * Only call this after powering on the MPU with rc_mpu_initialize or
260  * rc_mpu_initialize_dmp. This should geenrally be called at the end of your
261  * main function to make sure the MPU is put to sleep.
262  *
263  * @return 0 on success or -1 on failure.
264  */
265 int rc_mpu_power_off(void);
266 ///@} end common functions
267 
268 
269 /** @name normal one-shot sampling functions */
270 ///@{
271 
272 /**
273  * @brief Sets up the MPU in normal one-shot sampling mode.
274  *
275  * First create an instance of the rc_mpu_data_t struct and pass its pointer to
276  * rc_mpu_initialize which will then write to. Also pass an rc_mpu_config_t
277  * struct with your configruation settings.
278  *
279  * This function will populate the accel_to_ms2 and gyro_to_deg fields of the
280  * rc_mpu_data_t struct appropriately based on the user-configured full scale
281  * ranges.
282  *
283  * After this, you may read sensor data at any time with the functions
284  * rc_mpu_read_accel(), rc_mpu_read_gyro(), and rc_mpu_read_temp(). The magentometer
285  * can also be read with rc_mpu_read_mag() if using an MPU9150 or MPU9250 and the
286  * enable_magnetometer field in the rc_mpu_config_t struct has been set to 1.
287  *
288  * Be sure to power off the MPU at the end of your program with
289  * rc_mpu_power_off().
290  *
291  * @param data pointer to user's data struct
292  * @param[in] conf user congiguration data
293  *
294  * @return 0 on success or -1 on failure.
295  */
297 
298 
299 /**
300  * @brief Reads accelerometer data from the MPU
301  *
302  * @param data Pointer to user's data struct where new data will be
303  * written
304  *
305  * @return 0 on success or -1 on failure.
306  */
308 
309 
310 /**
311  * @brief Reads gyroscope data from the MPU
312  *
313  * @param data Pointer to user's data struct where new data will be
314  * written
315  *
316  * @return 0 on success or -1 on failure.
317  */
319 
320 
321 /**
322  * @brief Reads thermometer data from the MPU
323  *
324  * Note this is the internal termperature of the chip, not abient temperature.
325  *
326  * @param data Pointer to user's data struct where new data will be
327  * written
328  *
329  * @return 0 on success or -1 on failure.
330  */
332 
333 
334 /**
335  * @brief Reads magnetometer data from the MPU
336  *
337  * Note this requires use of an MPU9150 or MPU9250, the MPU6050 and MPU6500 do
338  * not have magnetometers. Additionally, the enable_magnetometer flag must has
339  * been set in the user's rc_mpu_config_t when it was passed to
340  * rc_mpu_initialize()
341  *
342  * @param data Pointer to user's data struct where new data will be
343  * written
344  *
345  * @return 0 on success or -1 on failure.
346  */
347 int rc_mpu_read_mag(rc_mpu_data_t* data);
348 ///@} end normal one-shot sampling functions
349 
350 
351 /** @name interrupt-driven DMP mode functions */
352 ///@{
353 
354 /**
355  * @brief Initializes the MPU in DMP mode, see rc_test_dmp example
356  *
357  * After calling this the user does not need to call the normal read functions
358  * rc_mpu_read_accel(), rc_mpu_read_gyro(), or rc_mpu_read mag(). Instead the
359  * data will automatically be read into the user's data struct at the
360  * dmp_sample_rate set in the config struct.
361  *
362  * @param data Pointer to user's data struct where new data will be
363  * written
364  * @param[in] conf User's configuration struct
365  *
366  * @return 0 on success or -1 on failure.
367  */
369 
370 
371 /**
372  * @brief Sets the callback function that will be triggered when new DMP
373  * data is ready.
374  *
375  * @param[in] func user's callback function
376  *
377  * @return 0 on success or -1 on failure.
378  */
379 int rc_mpu_set_dmp_callback(void (*func)(void));
380 
381 
382 /**
383  * @brief blocking function that returns once new DMP data is available
384  *
385  * @return Returns 0 once new data is available, 1 if the MPU is shutting
386  * down due to rc_mpu_power_off, or -1 on error.
387  */
389 
390 
391 /**
392  * @brief calculates number of nanoseconds since the last DMP interrupt
393  *
394  * @return nanoseconds since last interrupt, or -1 if no interrupt received
395  * yet.
396  */
398 
399 
400 /**
401  * @brief sets the callback function triggered when a tap is detected
402  *
403  * @param[in] func user's callback function
404  *
405  * @return 0 on success or -1 on failure.
406  */
407 int rc_mpu_set_tap_callback(void (*func)(int direction, int counter));
408 
409 
410 /**
411  * @brief blocking function that returns when a tap is detected
412  *
413  * @return Returns 0 once a tap is detected, 1 if the MPU is shutting down
414  * due to rc_mpu_power_off(), or -1 on error.
415  */
416 int rc_mpu_block_until_tap(void);
417 
418 
419 /**
420  * @brief calculates nanoseconds since last tap was detected
421  *
422  * @return nanoseconds since last tap, or -1 if no tap has been detected
423  * yet.
424  */
425 int64_t rc_mpu_nanos_since_last_tap(void);
426 ///@} end interrupt-driven DMP mode functions
427 
428 
429 
430 /** @name calibration functions */
431 ///@{
432 
433 /**
434  * @brief Runs gyroscope calibration routine
435  *
436  * This should generally not be used by the user unless they absolutely want to
437  * calibrate the gyroscope inside their own program. Instead call the
438  * rc_calibrate_gyro example program.
439  *
440  * @param[in] conf Config struct, only used to configure i2c bus and address.
441  *
442  * @return 0 on success, -1 on failure
443  */
445 
446 
447 /**
448  * @brief Runs magnetometer calibration routine
449  *
450  * This should generally not be used by the user unless they absolutely want to
451  * calibrate the magnetometer inside their own program. Instead call the
452  * rc_calibrate_mag example program.
453  *
454  * @param[in] conf Config struct, only used to configure i2c bus and address.
455  *
456  * @return 0 on success, -1 on failure
457  */
459 
460 
461 /**
462  * @brief Runs accelerometer calibration routine
463  *
464  * This should generally not be used by the user unless they absolutely want to
465  * calibrate the accelerometer inside their own program. Instead call the
466  * rc_calibrate_accel example program.
467  *
468  * @param[in] conf Config struct, only used to configure i2c bus and address.
469  *
470  * @return 0 on success, -1 on failure
471  */
473 
474 
475 /**
476  * @brief Checks if a gyro calibration file is saved to disk
477  *
478  * generally used to warn the user that they are running a program without
479  * calibration. Can also be used to decide if calibration should be done at the
480  * beginning of user's program.
481  *
482  * @return 1 if calibrated, 0 if not
483  */
484 int rc_mpu_is_gyro_calibrated(void);
485 
486 
487 /**
488  * @brief Checks if a magnetometer calibration file is saved to disk
489  *
490  * generally used to warn the user that they are running a program without
491  * calibration. Can also be used to decide if calibration should be done at the
492  * beginning of user's program.
493  *
494  * @return 1 if calibrated, 0 if not
495  */
496 int rc_mpu_is_mag_calibrated(void);
497 
498 
499 /**
500  * @brief Checks if an accelerometer calibration file is saved to disk
501  *
502  * generally used to warn the user that they are running a program without
503  * calibration. Can also be used to decide if calibration should be done at the
504  * beginning of user's program.
505  *
506  * @return 1 if calibrated, 0 if not
507  */
509 
510 
511 
512 ///@} end calibration functions
513 
514 #ifdef __cplusplus
515 }
516 #endif
517 
518 #endif // RC_MPU_H
519 
520 /** @} end group IMU_MPU*/
521 
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.
Definition: mpu.h:125
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
Definition: mpu.h:123
Definition: mpu.h:140
int dmp_sample_rate
sample rate in hertz, 200,100,50,40,25,20,10,8,5,4
Definition: mpu.h:176
Definition: mpu.h:127
Definition: mpu.h:103
Definition: mpu.h:145
Definition: mpu.h:126
int rc_mpu_is_gyro_calibrated(void)
Checks if a gyro calibration file is saved to disk.
Definition: mpu.h:70
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.
Definition: mpu.h:102
int gpio_interrupt_pin
gpio pin, default 21 on Robotics Cape and BB Blue
Definition: mpu.h:159
Definition: mpu.h:72
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
Definition: mpu.h:120
int read_mag_after_callback
reads magnetometer after DMP callback function to improve latency, default 1 (true) ...
Definition: mpu.h:183
Definition: mpu.h:138
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
Definition: mpu.h:107
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.
Definition: mpu.h:104
Definition: mpu.h:105
Definition: mpu.h:142
Definition: mpu.h:86
int rc_mpu_power_off(void)
Powers off the MPU.
Definition: mpu.h:87
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.
Definition: mpu.h:100
Definition: mpu.h:141
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.
Definition: mpu.h:85
int dmp_interrupt_priority
scheduler priority for DMP interrupt handler and user callback, default 0
Definition: mpu.h:182
Definition: mpu.h:84
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
Definition: mpu.h:139
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
Definition: mpu.h:101
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.
Definition: mpu.h:106
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
Definition: mpu.h:124
Definition: mpu.h:73
Definition: mpu.h:144
Definition: mpu.h:71
Definition: mpu.h:121
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
Definition: mpu.h:143
int gpio_interrupt_pin_chip
gpio pin, default 3 on Robotics Cape and BB Blue
Definition: mpu.h:158
Definition: mpu.h:122