9#define TAP_DETECTED_X_AXIS(tap) ((tap) & (1U << 0U) ? 1 : 0)
10#define TAP_DETECTED_X_AXIS_POSITIVE(tap) ((tap) & (1U << 1U) ? 1 : 0)
11#define TAP_DETECTED_Y_AXIS(tap) ((tap) & (1U << 2U) ? 1 : 0)
12#define TAP_DETECTED_Y_AXIS_POSITIVE(tap) ((tap) & (1U << 3U) ? 1 : 0)
13#define TAP_DETECTED_Z_AXIS(tap) ((tap) & (1U << 4U) ? 1 : 0)
14#define TAP_DETECTED_Z_AXIS_POSITIVE(tap) ((tap) & (1U << 5U) ? 1 : 0)
15#define TAP_DETECTED_DOUBLE(tap) ((tap) & (1U << 6U) ? 1 : 0)
18#define SHAKE_DETECTED_X(tap) ((tap) & (1U << 0U) ? 1 : 0)
19#define SHAKE_DETECTED_Y(tap) ((tap) & (1U << 1U) ? 1 : 0)
20#define SHAKE_DETECTED_Z(tap) ((tap) & (1U << 2U) ? 1 : 0)
29#include <driver/gpio.h>
30#include <driver/spi_common.h>
31#include <driver/spi_master.h>
34#include "sh2_SensorValue.h"
54 ,
io_mosi(static_cast<gpio_num_t>(CONFIG_ESP32_BNO08X_GPIO_DI))
55 ,
io_miso(static_cast<gpio_num_t>(CONFIG_ESP32_BNO08X_GPIO_SDA))
56 ,
io_sclk(static_cast<gpio_num_t>(CONFIG_ESP32_BNO08X_GPIO_SCL))
57 ,
io_cs(static_cast<gpio_num_t>(CONFIG_ESP32_BNO08X_GPIO_CS))
58 ,
io_int(static_cast<gpio_num_t>(CONFIG_ESP32_BNO08X_GPIO_HINT))
59 ,
io_rst(static_cast<gpio_num_t>(CONFIG_ESP32_BNO08X_GPIO_RST))
60 ,
sclk_speed(static_cast<uint32_t>(CONFIG_ESP32_BNO08X_SCL_SPEED_HZ))
89 all = (SH2_CAL_ACCEL | SH2_CAL_GYRO | SH2_CAL_MAG | SH2_CAL_PLANAR)
180 this->real = source.
real;
184 this->rad_accuracy = source.accuracy;
191 this->real = source.
real;
195 this->rad_accuracy = 0.0f;
202 this->real = source.
real;
206 this->rad_accuracy = 0.0f;
233 this->x = atan2(2.0f * (source.
real * source.
i + source.
j * source.
k),
234 1.0f - 2.0f * (source.
i * source.
i + source.
j * source.
j));
235 this->y = asin(2.0f * (source.
real * source.
j - source.
k * source.
i));
236 this->z = atan2(2.0f * (source.
real * source.
k + source.
i * source.
j),
237 1.0f - 2.0f * (source.
j * source.
j + source.
k * source.
k));
244 template <
typename T>
247 x *=
static_cast<float>(value);
248 y *=
static_cast<float>(value);
249 z *=
static_cast<float>(value);
271 template <
typename T>
274 x *=
static_cast<float>(value);
275 y *=
static_cast<float>(value);
276 z *=
static_cast<float>(value);
283 this->x = source.angVelX;
284 this->y = source.angVelY;
285 this->z = source.angVelZ;
343 this->x = source.biasX;
344 this->y = source.biasY;
345 this->z = source.biasZ;
404 this->x = source.biasX;
405 this->y = source.biasY;
406 this->z = source.biasZ;
433 this->page = source.
page;
434 this->lastPage = source.lastPage;
435 this->mostLikelyState =
static_cast<BNO08xActivity>(source.mostLikelyState);
437 for (
int i = 0; i < 10; ++i)
438 this->confidence[i] = source.confidence[i];
491 this->double_tap =
true;
493 this->double_tap =
false;
583 this->latency = source.
latency;
584 this->steps = source.steps;
615 this->temperature = source.temperature;
616 this->timestamp_us = source.timestamp;
646 this->timestamp_us = source.timestamp;
676 this->timestamp_us = source.timestamp;
722 this->offered = source.
offered;
723 this->on = source.on;
724 this->accepted = source.accepted;
#define SHAKE_DETECTED_Y(tap)
Definition BNO08xGlobalTypes.hpp:19
struct bno08x_accel_t bno08x_accel_t
Struct to represent acceleration data from acceleration, linear acceleration, and gravity reports.
struct bno08x_quat_t bno08x_quat_t
Struct to represent unit quaternion.
struct bno08x_meta_data_t bno08x_meta_data_t
Struct to represent sensor/report meta data, returned from BNO08xRpt::get_meta_data()
struct bno08x_ang_vel_t bno08x_ang_vel_t
Struct to represent angular velocity (units in rad/s)
#define TAP_DETECTED_Y_AXIS_POSITIVE(tap)
Definition BNO08xGlobalTypes.hpp:12
struct bno08x_magf_bias_t bno08x_magf_bias_t
Struct to represent magnetic field bias data (units in uTesla)
struct bno08x_raw_gyro_t bno08x_raw_gyro_t
Struct to represent raw mems gyro data from raw gyro reports (units in ADC counts).
struct bno08x_magf_t bno08x_magf_t
Struct to represent magnetic field data (units in uTesla)
BNO08xStability
BNO08xStability states returned from BNO08x::stability_classifier.get()
Definition BNO08xGlobalTypes.hpp:147
struct bno08x_config_t bno08x_config_t
IMU configuration settings passed into constructor.
struct bno08x_raw_magf_t bno08x_raw_magf_t
Struct to represent raw mems magnetometer data from raw magnetometer reports (units in ADC counts).
#define TAP_DETECTED_Z_AXIS_POSITIVE(tap)
Definition BNO08xGlobalTypes.hpp:14
struct bno08x_activity_classifier_t bno08x_activity_classifier_t
Struct to represent activity classifier data.
struct bno08x_gyro_bias_t bno08x_gyro_bias_t
Struct to represent gyro bias data (units in rad/s)
struct bno08x_shake_detector_t bno08x_shake_detector_t
Struct to represent shake detector data (flag meaning: 0 = no shake 1 = shake detected)
#define TAP_DETECTED_X_AXIS_POSITIVE(tap)
Definition BNO08xGlobalTypes.hpp:10
struct bno08x_euler_angle_t bno08x_euler_angle_t
Struct to represent euler angle (units in degrees or rads)
#define TAP_DETECTED_DOUBLE(tap)
Definition BNO08xGlobalTypes.hpp:15
static const constexpr uint8_t TOTAL_RPT_COUNT
Amount of possible reports returned from BNO08x.
Definition BNO08xGlobalTypes.hpp:803
#define SHAKE_DETECTED_Z(tap)
Definition BNO08xGlobalTypes.hpp:20
struct bno08x_stability_classifier_t bno08x_stability_classifier_t
Struct to represent stability classifier data from stability classifier reports.
#define TAP_DETECTED_Z_AXIS(tap)
Definition BNO08xGlobalTypes.hpp:13
bno08x_config_t imu_config_t
Definition BNO08xGlobalTypes.hpp:81
BNO08xResetReason
Reason for previous IMU reset (returned by get_reset_reason())
Definition BNO08xGlobalTypes.hpp:94
@ OTHER
Previous reset was due to power other reason.
@ UNDEFINED
Undefined reset reason, this should never occur and is an error.
@ WTD
Previous reset was due to watchdog timer.
@ POR
Previous reset was due to power on reset.
@ EXT_RST
Previous reset was due to external reset.
@ INT_RST
Previous reset was due to internal reset.
BNO08xActivity
BNO08xActivity states returned from BNO08x::activity_classifier.get()
Definition BNO08xGlobalTypes.hpp:132
struct bno08x_gyro_t bno08x_gyro_t
Struct to represent gyro data (units in rad/s)
struct bno08x_raw_accel_t bno08x_raw_accel_t
Struct to represent raw mems accelerometer data from raw accelerometer reports (units in ADC counts).
#define TAP_DETECTED_X_AXIS(tap)
Definition BNO08xGlobalTypes.hpp:9
#define TAP_DETECTED_Y_AXIS(tap)
Definition BNO08xGlobalTypes.hpp:11
struct bno08x_step_counter_t bno08x_step_counter_t
Struct to represent step counter data from step counter reports.
BNO08xActivityEnable
BNO08xActivity Classifier enable bits passed to enable_activity_classifier()
Definition BNO08xGlobalTypes.hpp:117
struct bno08x_tap_detector_t bno08x_tap_detector_t
Struct to represent tap detector data (flag meaning: 0 = no tap, 1 = positive tap on axis,...
#define SHAKE_DETECTED_X(tap)
Definition BNO08xGlobalTypes.hpp:18
BNO08xAccuracy
Sensor accuracy returned from input reports, corresponds to status bits (see ref. manual 6....
Definition BNO08xGlobalTypes.hpp:106
BNO08xCalSel
Definition BNO08xGlobalTypes.hpp:84
struct bno08x_sample_counts_t bno08x_sample_counts_t
Struct to represent sample counts, returned from BNO08xRpt::get_sample_counts()
Struct to represent acceleration data from acceleration, linear acceleration, and gravity reports.
Definition BNO08xGlobalTypes.hpp:542
float z
Definition BNO08xGlobalTypes.hpp:545
bno08x_accel_t()
Definition BNO08xGlobalTypes.hpp:548
bno08x_accel_t & operator=(const sh2_Accelerometer_t &source)
Definition BNO08xGlobalTypes.hpp:557
float y
Definition BNO08xGlobalTypes.hpp:544
BNO08xAccuracy accuracy
Definition BNO08xGlobalTypes.hpp:546
float x
Definition BNO08xGlobalTypes.hpp:543
Struct to represent activity classifier data.
Definition BNO08xGlobalTypes.hpp:414
BNO08xActivity mostLikelyState
Definition BNO08xGlobalTypes.hpp:417
bno08x_activity_classifier_t()
Definition BNO08xGlobalTypes.hpp:421
BNO08xAccuracy accuracy
Definition BNO08xGlobalTypes.hpp:419
uint8_t confidence[10]
Definition BNO08xGlobalTypes.hpp:418
bool lastPage
Definition BNO08xGlobalTypes.hpp:416
uint8_t page
Definition BNO08xGlobalTypes.hpp:415
bno08x_activity_classifier_t & operator=(const sh2_PersonalActivityClassifier_t &source)
Definition BNO08xGlobalTypes.hpp:431
Struct to represent angular velocity (units in rad/s)
Definition BNO08xGlobalTypes.hpp:258
bno08x_ang_vel_t()
Definition BNO08xGlobalTypes.hpp:263
float z
Definition BNO08xGlobalTypes.hpp:261
float x
Definition BNO08xGlobalTypes.hpp:259
bno08x_ang_vel_t & operator*=(T value)
Definition BNO08xGlobalTypes.hpp:272
float y
Definition BNO08xGlobalTypes.hpp:260
bno08x_ang_vel_t & operator=(const sh2_GyroIntegratedRV_t &source)
Definition BNO08xGlobalTypes.hpp:281
IMU configuration settings passed into constructor.
Definition BNO08xGlobalTypes.hpp:38
spi_host_device_t spi_peripheral
SPI peripheral to be used.
Definition BNO08xGlobalTypes.hpp:39
bool install_isr_service
Indicates whether the ISR service for the HINT should be installed at IMU initialization,...
Definition BNO08xGlobalTypes.hpp:47
uint32_t sclk_speed
Reset pin (connects to BNO08x RST pin)
Definition BNO08xGlobalTypes.hpp:46
gpio_num_t io_int
Chip select pin (connects to BNO08x CS pin)
Definition BNO08xGlobalTypes.hpp:44
gpio_num_t io_rst
Host interrupt pin (connects to BNO08x INT pin)
Definition BNO08xGlobalTypes.hpp:45
gpio_num_t io_sclk
SCLK pin (connects to BNO08x SCL pin)
Definition BNO08xGlobalTypes.hpp:42
bno08x_config_t(bool install_isr_service=true)
Default IMU configuration settings constructor. To modify default GPIO pins, run "idf....
Definition BNO08xGlobalTypes.hpp:52
gpio_num_t io_mosi
MOSI GPIO pin (connects to BNO08x DI pin)
Definition BNO08xGlobalTypes.hpp:40
gpio_num_t io_miso
MISO GPIO pin (connects to BNO08x SDA pin)
Definition BNO08xGlobalTypes.hpp:41
gpio_num_t io_cs
Definition BNO08xGlobalTypes.hpp:43
bno08x_config_t(spi_host_device_t spi_peripheral, gpio_num_t io_mosi, gpio_num_t io_miso, gpio_num_t io_sclk, gpio_num_t io_cs, gpio_num_t io_int, gpio_num_t io_rst, uint32_t sclk_speed, bool install_isr_service=true)
Overloaded IMU configuration settings constructor for custom pin settings.
Definition BNO08xGlobalTypes.hpp:67
Struct to represent euler angle (units in degrees or rads)
Definition BNO08xGlobalTypes.hpp:214
bno08x_euler_angle_t & operator*=(T value)
Definition BNO08xGlobalTypes.hpp:245
float y
Definition BNO08xGlobalTypes.hpp:216
bno08x_euler_angle_t()
Definition BNO08xGlobalTypes.hpp:221
BNO08xAccuracy accuracy
Definition BNO08xGlobalTypes.hpp:218
float z
Definition BNO08xGlobalTypes.hpp:217
float x
Definition BNO08xGlobalTypes.hpp:215
float rad_accuracy
Definition BNO08xGlobalTypes.hpp:219
bno08x_euler_angle_t & operator=(const bno08x_quat_t &source)
Definition BNO08xGlobalTypes.hpp:231
Struct to represent gyro bias data (units in rad/s)
Definition BNO08xGlobalTypes.hpp:389
bno08x_gyro_bias_t()
Definition BNO08xGlobalTypes.hpp:394
float y
Definition BNO08xGlobalTypes.hpp:391
float x
Definition BNO08xGlobalTypes.hpp:390
bno08x_gyro_bias_t & operator=(const sh2_GyroscopeUncalibrated &source)
Definition BNO08xGlobalTypes.hpp:402
float z
Definition BNO08xGlobalTypes.hpp:392
Struct to represent gyro data (units in rad/s)
Definition BNO08xGlobalTypes.hpp:353
bno08x_gyro_t & operator=(const sh2_Gyroscope_t &source)
Definition BNO08xGlobalTypes.hpp:368
float x
Definition BNO08xGlobalTypes.hpp:354
bno08x_gyro_t & operator=(const sh2_GyroscopeUncalibrated &source)
Definition BNO08xGlobalTypes.hpp:377
BNO08xAccuracy accuracy
Definition BNO08xGlobalTypes.hpp:357
bno08x_gyro_t()
Definition BNO08xGlobalTypes.hpp:359
float y
Definition BNO08xGlobalTypes.hpp:355
float z
Definition BNO08xGlobalTypes.hpp:356
Struct to represent magnetic field bias data (units in uTesla)
Definition BNO08xGlobalTypes.hpp:328
float y
Definition BNO08xGlobalTypes.hpp:330
float z
Definition BNO08xGlobalTypes.hpp:331
bno08x_magf_bias_t()
Definition BNO08xGlobalTypes.hpp:333
float x
Definition BNO08xGlobalTypes.hpp:329
bno08x_magf_bias_t & operator=(const sh2_MagneticFieldUncalibrated_t &source)
Definition BNO08xGlobalTypes.hpp:341
Struct to represent magnetic field data (units in uTesla)
Definition BNO08xGlobalTypes.hpp:292
float y
Definition BNO08xGlobalTypes.hpp:294
float z
Definition BNO08xGlobalTypes.hpp:295
bno08x_magf_t & operator=(const sh2_MagneticFieldUncalibrated_t &source)
Definition BNO08xGlobalTypes.hpp:316
BNO08xAccuracy accuracy
Definition BNO08xGlobalTypes.hpp:296
float x
Definition BNO08xGlobalTypes.hpp:293
bno08x_magf_t()
Definition BNO08xGlobalTypes.hpp:298
bno08x_magf_t & operator=(const sh2_MagneticField_t &source)
Definition BNO08xGlobalTypes.hpp:307
Struct to represent unit quaternion.
Definition BNO08xGlobalTypes.hpp:159
bno08x_quat_t & operator=(const sh2_RotationVectorWAcc_t &source)
Definition BNO08xGlobalTypes.hpp:178
bno08x_quat_t & operator=(const sh2_RotationVector_t &source)
Definition BNO08xGlobalTypes.hpp:189
float rad_accuracy
Definition BNO08xGlobalTypes.hpp:165
float j
Definition BNO08xGlobalTypes.hpp:162
float real
Definition BNO08xGlobalTypes.hpp:160
float i
Definition BNO08xGlobalTypes.hpp:161
float k
Definition BNO08xGlobalTypes.hpp:163
bno08x_quat_t & operator=(const sh2_GyroIntegratedRV_t &source)
Definition BNO08xGlobalTypes.hpp:200
bno08x_quat_t()
Definition BNO08xGlobalTypes.hpp:167
BNO08xAccuracy accuracy
Definition BNO08xGlobalTypes.hpp:164
Struct to represent raw mems accelerometer data from raw accelerometer reports (units in ADC counts).
Definition BNO08xGlobalTypes.hpp:624
int16_t z
Definition BNO08xGlobalTypes.hpp:627
uint32_t timestamp_us
Definition BNO08xGlobalTypes.hpp:628
bno08x_raw_accel_t & operator=(const sh2_RawAccelerometer_t &source)
Definition BNO08xGlobalTypes.hpp:641
int16_t y
Definition BNO08xGlobalTypes.hpp:626
BNO08xAccuracy accuracy
Definition BNO08xGlobalTypes.hpp:629
int16_t x
Definition BNO08xGlobalTypes.hpp:625
bno08x_raw_accel_t()
Definition BNO08xGlobalTypes.hpp:631
Struct to represent raw mems gyro data from raw gyro reports (units in ADC counts).
Definition BNO08xGlobalTypes.hpp:591
bno08x_raw_gyro_t()
Definition BNO08xGlobalTypes.hpp:599
bno08x_raw_gyro_t & operator=(const sh2_RawGyroscope_t &source)
Definition BNO08xGlobalTypes.hpp:610
int16_t x
Definition BNO08xGlobalTypes.hpp:592
uint32_t timestamp_us
Definition BNO08xGlobalTypes.hpp:596
BNO08xAccuracy accuracy
Definition BNO08xGlobalTypes.hpp:597
int16_t temperature
Definition BNO08xGlobalTypes.hpp:595
int16_t y
Definition BNO08xGlobalTypes.hpp:593
int16_t z
Definition BNO08xGlobalTypes.hpp:594
Struct to represent raw mems magnetometer data from raw magnetometer reports (units in ADC counts).
Definition BNO08xGlobalTypes.hpp:654
int16_t z
Definition BNO08xGlobalTypes.hpp:657
int16_t x
Definition BNO08xGlobalTypes.hpp:655
uint32_t timestamp_us
Definition BNO08xGlobalTypes.hpp:658
bno08x_raw_magf_t()
Definition BNO08xGlobalTypes.hpp:661
int16_t y
Definition BNO08xGlobalTypes.hpp:656
bno08x_raw_magf_t & operator=(const sh2_RawMagnetometer_t &source)
Definition BNO08xGlobalTypes.hpp:671
BNO08xAccuracy accuracy
Definition BNO08xGlobalTypes.hpp:659
Struct to represent sample counts, returned from BNO08xRpt::get_sample_counts()
Definition BNO08xGlobalTypes.hpp:704
uint32_t on
Number of "offered" samples while this sensor was requested by host.
Definition BNO08xGlobalTypes.hpp:706
uint32_t accepted
Number of "on" samples that passed decimation filter.
Definition BNO08xGlobalTypes.hpp:707
uint32_t attempted
Number of "accepted" samples that passed threshold requirements and had transmission to the host atte...
Definition BNO08xGlobalTypes.hpp:709
uint32_t offered
Number of samples produced by underlying data source.
Definition BNO08xGlobalTypes.hpp:705
bno08x_sample_counts_t()
Definition BNO08xGlobalTypes.hpp:711
bno08x_sample_counts_t & operator=(const sh2_Counts_t &source)
Definition BNO08xGlobalTypes.hpp:720
Struct to represent shake detector data (flag meaning: 0 = no shake 1 = shake detected)
Definition BNO08xGlobalTypes.hpp:502
uint8_t x_flag
Definition BNO08xGlobalTypes.hpp:503
bno08x_shake_detector_t()
Definition BNO08xGlobalTypes.hpp:508
uint8_t z_flag
Definition BNO08xGlobalTypes.hpp:505
bno08x_shake_detector_t & operator=(const sh2_ShakeDetector_t &source)
Definition BNO08xGlobalTypes.hpp:517
uint8_t y_flag
Definition BNO08xGlobalTypes.hpp:504
BNO08xAccuracy accuracy
Definition BNO08xGlobalTypes.hpp:506
Struct to represent stability classifier data from stability classifier reports.
Definition BNO08xGlobalTypes.hpp:683
bno08x_stability_classifier_t()
Definition BNO08xGlobalTypes.hpp:687
BNO08xStability stability
Definition BNO08xGlobalTypes.hpp:684
BNO08xAccuracy accuracy
Definition BNO08xGlobalTypes.hpp:685
bno08x_stability_classifier_t & operator=(const sh2_StabilityClassifier_t &source)
Definition BNO08xGlobalTypes.hpp:694
Struct to represent step counter data from step counter reports.
Definition BNO08xGlobalTypes.hpp:568
bno08x_step_counter_t()
Definition BNO08xGlobalTypes.hpp:573
uint16_t steps
Definition BNO08xGlobalTypes.hpp:570
BNO08xAccuracy accuracy
Definition BNO08xGlobalTypes.hpp:571
uint32_t latency
Definition BNO08xGlobalTypes.hpp:569
bno08x_step_counter_t & operator=(const sh2_StepCounter_t &source)
Definition BNO08xGlobalTypes.hpp:581
Struct to represent tap detector data (flag meaning: 0 = no tap, 1 = positive tap on axis,...
Definition BNO08xGlobalTypes.hpp:447
int8_t x_flag
Definition BNO08xGlobalTypes.hpp:448
bno08x_tap_detector_t & operator=(const sh2_TapDetector_t &source)
Definition BNO08xGlobalTypes.hpp:464
int8_t z_flag
Definition BNO08xGlobalTypes.hpp:450
bno08x_tap_detector_t()
Definition BNO08xGlobalTypes.hpp:454
BNO08xAccuracy accuracy
Definition BNO08xGlobalTypes.hpp:452
int8_t y_flag
Definition BNO08xGlobalTypes.hpp:449
bool double_tap
Definition BNO08xGlobalTypes.hpp:451