near comprehensive report implementation
This commit is contained in:
parent
936fab897b
commit
b51d775fa3
|
|
@ -28,10 +28,23 @@
|
|||
#include "BNO08xRptLinearAcceleration.hpp"
|
||||
#include "BNO08xRptGravity.hpp"
|
||||
#include "BNO08xRptCalMagnetometer.hpp"
|
||||
#include "BNO08xRptUncalMagnetometer.hpp"
|
||||
#include "BNO08xRptCalGyro.hpp"
|
||||
#include "BNO08xRptUncalGyro.hpp"
|
||||
#include "BNO08xRptRV.hpp"
|
||||
#include "BNO08xRptGameRV.hpp"
|
||||
#include "BNO08xRptARVRStabilizedRV.hpp"
|
||||
#include "BNO08xRptARVRStabilizedGameRV.hpp"
|
||||
#include "BNO08xRptIGyroRV.hpp"
|
||||
#include "BNO08xRptRVGeomag.hpp"
|
||||
#include "BNO08xRptRawMEMSGyro.hpp"
|
||||
#include "BNO08xRptRawMEMSAccelerometer.hpp"
|
||||
#include "BNO08xRptRawMEMSMagnetometer.hpp"
|
||||
#include "BNO08xRptStepCounter.hpp"
|
||||
#include "BNO08xRptActivityClassifier.hpp"
|
||||
#include "BNO08xStabilityClassifier.hpp"
|
||||
#include "BNO08xShakeDetector.hpp"
|
||||
#include "BNO08xTapDetector.hpp"
|
||||
|
||||
/**
|
||||
* @class BNO08x
|
||||
|
|
@ -60,18 +73,34 @@ class BNO08x
|
|||
bool data_available(uint8_t& report_ID);
|
||||
void register_cb(std::function<void(void)> cb_fxn);
|
||||
void register_cb(std::function<void(uint8_t report_ID)> cb_fxn);
|
||||
void register_report_cb(uint8_t report_ID, std::function<void(void)> cb_fxn);
|
||||
|
||||
void print_product_ids();
|
||||
|
||||
// enum helper fxns
|
||||
static const char* activity_to_str(BNO08xActivity activity);
|
||||
static const char* stability_to_str(BNO08xStability stability);
|
||||
|
||||
BNO08xRptAcceleration accelerometer;
|
||||
BNO08xRptLinearAcceleration linear_accelerometer;
|
||||
BNO08xRptGravity gravity;
|
||||
BNO08xRptCalMagnetometer calibrated_magnetometer;
|
||||
BNO08xRptRV rotation_vector;
|
||||
BNO08xRptGameRV game_rotation_vector;
|
||||
BNO08xRptARVRStabilizedRV ARVR_stabilized_rotation_vector;
|
||||
BNO08xRptARVRStabilizedGameRV ARVR_stabilized_game_rotation_vector;
|
||||
BNO08xRptCalMagnetometer cal_magnetometer;
|
||||
BNO08xRptUncalMagnetometer uncal_magnetometer;
|
||||
BNO08xRptCalGyro cal_gyro;
|
||||
BNO08xRptUncalGyro uncal_gyro;
|
||||
BNO08xRptRV rv;
|
||||
BNO08xRptGameRV rv_game;
|
||||
BNO08xRptARVRStabilizedRV rv_ARVR_stabilized;
|
||||
BNO08xRptARVRStabilizedGameRV rv_ARVR_stabilized_game;
|
||||
BNO08xRptIGyroRV rv_gyro_integrated;
|
||||
BNO08xRptRVGeomag rv_geomagnetic;
|
||||
BNO08xRptRawMEMSGyro raw_gyro;
|
||||
BNO08xRptRawMEMSAccelerometer raw_accelerometer;
|
||||
BNO08xRptRawMEMSMagnetometer raw_magnetometer;
|
||||
BNO08xRptStepCounter step_counter;
|
||||
BNO08xRptActivityClassifier activity_classifier;
|
||||
BNO08xStabilityClassifier stability_classifier;
|
||||
BNO08xShakeDetector shake_detector;
|
||||
BNO08xTapDetector tap_detector;
|
||||
|
||||
private:
|
||||
/// @brief Holds info about which functionality has been successfully initialized (used by deconstructor during cleanup).
|
||||
|
|
@ -104,37 +133,6 @@ class BNO08x
|
|||
}
|
||||
} bno08x_init_status_t;
|
||||
|
||||
/// @brief Holds data returned from sensor reports.
|
||||
typedef struct bno08x_data_t
|
||||
{
|
||||
bno08x_step_counter_data_t step_counter;
|
||||
bno08x_activity_classifier_data_t activity_classifier;
|
||||
bno08x_gyro_data_t cal_gyro;
|
||||
bno08x_raw_gyro_data_t mems_raw_gyro;
|
||||
bno08x_raw_accel_data_t mems_raw_accel;
|
||||
bno08x_raw_magf_data_t mems_raw_magnetometer;
|
||||
bno08x_quat_t rv;
|
||||
bno08x_quat_t game_rv;
|
||||
bno08x_quat_t arvr_s_rv;
|
||||
bno08x_quat_t arvr_s_game_rv;
|
||||
|
||||
bno08x_data_t()
|
||||
: step_counter({0UL, 0U})
|
||||
, activity_classifier(bno08x_activity_classifier_data_t())
|
||||
, cal_gyro({0.0f, 0.0f, 0.0f})
|
||||
, mems_raw_gyro({0, 0, 0, 0, 0UL})
|
||||
, mems_raw_accel({0, 0, 0, 0UL})
|
||||
, mems_raw_magnetometer({0, 0, 0, 0UL})
|
||||
, rv(bno08x_quat_t())
|
||||
, game_rv(bno08x_quat_t())
|
||||
, arvr_s_rv(bno08x_quat_t())
|
||||
, arvr_s_game_rv(bno08x_quat_t())
|
||||
|
||||
{
|
||||
}
|
||||
|
||||
} bno08x_data_t;
|
||||
|
||||
using bno08x_cb_t = std::variant<std::function<void()>, std::function<void(uint8_t)>>;
|
||||
/// @brief Holds registered callback info.
|
||||
typedef struct bno08x_cb_data_t
|
||||
|
|
@ -144,13 +142,13 @@ class BNO08x
|
|||
} bno08x_cb_data_t;
|
||||
|
||||
// data processing task
|
||||
static const constexpr configSTACK_DEPTH_TYPE DATA_PROC_TASK_SZ = 2048; ///< Size of data_proc_task() stack in bytes
|
||||
static const constexpr configSTACK_DEPTH_TYPE DATA_PROC_TASK_SZ = 2048UL; ///< Size of data_proc_task() stack in bytes
|
||||
TaskHandle_t data_proc_task_hdl; ///<data_proc_task() task handle
|
||||
static void data_proc_task_trampoline(void* arg);
|
||||
void data_proc_task();
|
||||
|
||||
// sh2 service task
|
||||
static const constexpr configSTACK_DEPTH_TYPE SH2_HAL_SERVICE_TASK_SZ = 2048; ///< Size of sh2_HAL_service_task() stack in bytes
|
||||
static const constexpr configSTACK_DEPTH_TYPE SH2_HAL_SERVICE_TASK_SZ = 2048UL; ///< Size of sh2_HAL_service_task() stack in bytes
|
||||
TaskHandle_t sh2_HAL_service_task_hdl; ///<sh2_HAL_service_task() task handle
|
||||
static void sh2_HAL_service_task_trampoline(void* arg);
|
||||
void sh2_HAL_service_task();
|
||||
|
|
@ -219,9 +217,14 @@ class BNO08x
|
|||
uint8_t most_recent_rpt = 0U;
|
||||
|
||||
std::map<uint8_t, BNO08xRpt*> usr_reports = {{SH2_ACCELEROMETER, &accelerometer}, {SH2_LINEAR_ACCELERATION, &linear_accelerometer},
|
||||
{SH2_GRAVITY, &gravity}, {SH2_MAGNETIC_FIELD_CALIBRATED, &calibrated_magnetometer}, {SH2_ROTATION_VECTOR, &rotation_vector},
|
||||
{SH2_GAME_ROTATION_VECTOR, &game_rotation_vector}, {SH2_ARVR_STABILIZED_RV, &ARVR_stabilized_rotation_vector},
|
||||
{SH2_ARVR_STABILIZED_GRV, &ARVR_stabilized_game_rotation_vector}};
|
||||
{SH2_GRAVITY, &gravity}, {SH2_MAGNETIC_FIELD_CALIBRATED, &cal_magnetometer}, {SH2_MAGNETIC_FIELD_UNCALIBRATED, &uncal_magnetometer},
|
||||
{SH2_GYROSCOPE_CALIBRATED, &cal_gyro}, {SH2_GYROSCOPE_UNCALIBRATED, &uncal_gyro}, {SH2_ROTATION_VECTOR, &rv},
|
||||
{SH2_GAME_ROTATION_VECTOR, &rv_game}, {SH2_ARVR_STABILIZED_RV, &rv_ARVR_stabilized},
|
||||
{SH2_ARVR_STABILIZED_GRV, &rv_ARVR_stabilized_game}, {SH2_GYRO_INTEGRATED_RV, &rv_gyro_integrated},
|
||||
{SH2_GEOMAGNETIC_ROTATION_VECTOR, &rv_geomagnetic}, {SH2_RAW_GYROSCOPE, &raw_gyro}, {SH2_RAW_ACCELEROMETER, &raw_accelerometer},
|
||||
{SH2_RAW_MAGNETOMETER, &raw_magnetometer}, {SH2_STEP_COUNTER, &step_counter},
|
||||
{SH2_PERSONAL_ACTIVITY_CLASSIFIER, &activity_classifier}, {SH2_STABILITY_CLASSIFIER, &stability_classifier},
|
||||
{SH2_SHAKE_DETECTOR, &shake_detector}, {SH2_TAP_DETECTOR, &tap_detector}};
|
||||
|
||||
static void IRAM_ATTR hint_handler(void* arg);
|
||||
|
||||
|
|
@ -242,41 +245,52 @@ class BNO08x
|
|||
|
||||
// evt_grp_bno08x_task bits
|
||||
static const constexpr EventBits_t EVT_GRP_BNO08x_TASKS_RUNNING =
|
||||
(1U << 0U); ///<When this bit is set it indicates the BNO08x tasks are running, it is always set to 1 for the duration BNO08x driver object. Cleared in deconstructor for safe task deletion.
|
||||
(1UL << 0U); ///<When this bit is set it indicates the BNO08x tasks are running, it is always set to 1 for the duration BNO08x driver object. Cleared in deconstructor for safe task deletion.
|
||||
static const constexpr EventBits_t EVT_GRP_BNO08x_TASK_HINT_ASSRT_BIT =
|
||||
(1U << 1U); ///<When this bit is set it indicates the BNO08x has asserted its host interrupt pin, thus an SPI transaction should commence.
|
||||
(1UL << 1U); ///<When this bit is set it indicates the BNO08x has asserted its host interrupt pin, thus an SPI transaction should commence.
|
||||
static const constexpr EventBits_t EVT_GRP_BNO08x_TASK_RESET_OCCURRED =
|
||||
(1U << 2U); ///<When this bit is set it indicates the SH2 HAL lib has reset the IMU, any reports enabled by the user must be re-enabled.
|
||||
(1UL << 2U); ///<When this bit is set it indicates the SH2 HAL lib has reset the IMU, any reports enabled by the user must be re-enabled.
|
||||
static const constexpr EventBits_t EVT_GRP_BNO08x_TASK_DATA_AVAILABLE =
|
||||
(1U << 3U); ///<When this bit is set it indicates a report has been received for the user to read, cleared in data_available() set/cleared in handle_sensor_report()
|
||||
(1UL << 3U); ///<When this bit is set it indicates a report has been received for the user to read, cleared in data_available() set/cleared in handle_sensor_report()
|
||||
|
||||
// evt_grp_report_en bits
|
||||
static const constexpr EventBits_t EVT_GRP_RPT_RV_BIT = (1 << 0); ///< When set, rotation vector reports are active.
|
||||
static const constexpr EventBits_t EVT_GRP_RPT_GAME_RV_BIT = (1 << 1); ///< When set, game rotation vector reports are active.
|
||||
static const constexpr EventBits_t EVT_GRP_RPT_ARVR_S_RV_BIT = (1U << 2U); ///< When set, ARVR stabilized rotation vector reports are active.
|
||||
static const constexpr EventBits_t EVT_GRP_RPT_ARVR_S_GAME_RV_BIT =
|
||||
(1U << 3U); ///< When set, ARVR stabilized game rotation vector reports are active.
|
||||
static const constexpr EventBits_t EVT_GRP_RPT_GYRO_RV_BIT = (1U << 4U); ///< When set, gyro integrator rotation vector reports are active.
|
||||
static const constexpr EventBits_t EVT_GRP_RPT_ACCELEROMETER_BIT = (1U << 5U); ///< When set, accelerometer reports are active.
|
||||
static const constexpr EventBits_t EVT_GRP_RPT_LINEAR_ACCELEROMETER_BIT = (1U << 6U); ///< When set, linear accelerometer reports are active.
|
||||
static const constexpr EventBits_t EVT_GRP_RPT_GRAVITY_BIT = (1U << 7U); ///< When set, gravity reports are active.
|
||||
static const constexpr EventBits_t EVT_GRP_RPT_CAL_GYRO_BIT = (1U << 8U); ///< When set, gyro reports are active.
|
||||
static const constexpr EventBits_t EVT_GRP_RPT_GYRO_UNCALIBRATED_BIT = (1U << 9U); ///< When set, uncalibrated gyro reports are active.
|
||||
static const constexpr EventBits_t EVT_GRP_RPT_CAL_MAGNETOMETER_BIT = (1U << 10U); ///< When set, magnetometer reports are active.
|
||||
static const constexpr EventBits_t EVT_GRP_RPT_TAP_DETECTOR_BIT = (1U << 11U); ///< When set, tap detector reports are active.
|
||||
static const constexpr EventBits_t EVT_GRP_RPT_STEP_COUNTER_BIT = (1U << 12U); ///< When set, step counter reports are active.
|
||||
static const constexpr EventBits_t EVT_GRP_RPT_STABILITY_CLASSIFIER_BIT = (1U << 13U); ///< When set, stability classifier reports are active.
|
||||
static const constexpr EventBits_t EVT_GRP_RPT_ACTIVITY_CLASSIFIER_BIT = (1U << 14U); ///< When set, activity classifier reports are active.
|
||||
static const constexpr EventBits_t EVT_GRP_RPT_RAW_ACCELEROMETER_BIT = (1U << 15U); ///< When set, raw accelerometer reports are active.
|
||||
static const constexpr EventBits_t EVT_GRP_RPT_RAW_GYRO_BIT = (1U << 16U); ///< When set, raw gyro reports are active.
|
||||
static const constexpr EventBits_t EVT_GRP_RPT_RAW_MAGNETOMETER_BIT = (1U << 17U); ///< When set, raw magnetometer reports are active.
|
||||
static const constexpr EventBits_t EVT_GRP_RPT_RV_BIT = (1UL << 0U); ///< When set, rotation vector reports are active.
|
||||
static const constexpr EventBits_t EVT_GRP_RPT_RV_GAME_BIT = (1UL << 1U); ///< When set, game rotation vector reports are active.
|
||||
static const constexpr EventBits_t EVT_GRP_RPT_RV_ARVR_S_BIT = (1UL << 2U); ///< When set, ARVR stabilized rotation vector reports are active.
|
||||
static const constexpr EventBits_t EVT_GRP_RPT_RV_ARVR_S_GAME_BIT =
|
||||
(1UL << 3U); ///< When set, ARVR stabilized game rotation vector reports are active.
|
||||
static const constexpr EventBits_t EVT_GRP_RPT_GYRO_INTEGRATED_RV_BIT =
|
||||
(1UL << 4U); ///< When set, gyro integrator rotation vector reports are active.
|
||||
static const constexpr EventBits_t EVT_GRP_RPT_GEOMAG_RV_BIT = (1UL << 5U); ///< When set, gyro integrator rotation vector reports are active.
|
||||
static const constexpr EventBits_t EVT_GRP_RPT_ACCELEROMETER_BIT = (1UL << 6U); ///< When set, accelerometer reports are active.
|
||||
static const constexpr EventBits_t EVT_GRP_RPT_LINEAR_ACCELEROMETER_BIT = (1UL << 7U); ///< When set, linear accelerometer reports are active.
|
||||
static const constexpr EventBits_t EVT_GRP_RPT_GRAVITY_BIT = (1UL << 8U); ///< When set, gravity reports are active.
|
||||
|
||||
static const constexpr EventBits_t EVT_GRP_RPT_CAL_GYRO_BIT = (1UL << 9U); ///< When set, gyro reports are active.
|
||||
static const constexpr EventBits_t EVT_GRP_RPT_UNCAL_GYRO_BIT = (1UL << 10U); ///< When set, uncalibrated gyro reports are active.
|
||||
|
||||
static const constexpr EventBits_t EVT_GRP_RPT_CAL_MAGNETOMETER_BIT = (1UL << 11U); ///< When set, calibrated magnetometer reports are active.
|
||||
static const constexpr EventBits_t EVT_GRP_RPT_UNCAL_MAGNETOMETER_BIT =
|
||||
(1UL << 12U); ///< When set, uncalibrated magnetometer reports are active.
|
||||
|
||||
static const constexpr EventBits_t EVT_GRP_RPT_TAP_DETECTOR_BIT = (1UL << 13U); ///< When set, tap detector reports are active.
|
||||
static const constexpr EventBits_t EVT_GRP_RPT_STEP_COUNTER_BIT = (1UL << 14U); ///< When set, step counter reports are active.
|
||||
static const constexpr EventBits_t EVT_GRP_RPT_STABILITY_CLASSIFIER_BIT =
|
||||
(1UL << 15U); ///< When set, stability classifier reports are active.
|
||||
static const constexpr EventBits_t EVT_GRP_RPT_ACTIVITY_CLASSIFIER_BIT = (1UL << 16U); ///< When set, activity classifier reports are active.
|
||||
static const constexpr EventBits_t EVT_GRP_RPT_SHAKE_DETECTOR_BIT = (1UL << 17U); ///< When set, shake detector reports are active.
|
||||
|
||||
static const constexpr EventBits_t EVT_GRP_RPT_RAW_ACCELEROMETER_BIT = (1UL << 18U); ///< When set, raw accelerometer reports are active.
|
||||
static const constexpr EventBits_t EVT_GRP_RPT_RAW_GYRO_BIT = (1UL << 19U); ///< When set, raw gyro reports are active.
|
||||
static const constexpr EventBits_t EVT_GRP_RPT_RAW_MAGNETOMETER_BIT = (1UL << 20U); ///< When set, raw magnetometer reports are active.
|
||||
|
||||
static const constexpr EventBits_t EVT_GRP_RPT_ALL =
|
||||
EVT_GRP_RPT_RV_BIT | EVT_GRP_RPT_GAME_RV_BIT | EVT_GRP_RPT_ARVR_S_RV_BIT | EVT_GRP_RPT_ARVR_S_GAME_RV_BIT | EVT_GRP_RPT_GYRO_RV_BIT |
|
||||
EVT_GRP_RPT_ACCELEROMETER_BIT | EVT_GRP_RPT_LINEAR_ACCELEROMETER_BIT | EVT_GRP_RPT_GRAVITY_BIT | EVT_GRP_RPT_CAL_GYRO_BIT |
|
||||
EVT_GRP_RPT_GYRO_UNCALIBRATED_BIT | EVT_GRP_RPT_CAL_MAGNETOMETER_BIT | EVT_GRP_RPT_TAP_DETECTOR_BIT | EVT_GRP_RPT_STEP_COUNTER_BIT |
|
||||
EVT_GRP_RPT_RV_BIT | EVT_GRP_RPT_RV_GAME_BIT | EVT_GRP_RPT_RV_ARVR_S_BIT | EVT_GRP_RPT_RV_ARVR_S_GAME_BIT |
|
||||
EVT_GRP_RPT_LINEAR_ACCELEROMETER_BIT | EVT_GRP_RPT_GRAVITY_BIT | EVT_GRP_RPT_CAL_GYRO_BIT | EVT_GRP_RPT_UNCAL_GYRO_BIT |
|
||||
EVT_GRP_RPT_CAL_MAGNETOMETER_BIT | EVT_GRP_RPT_TAP_DETECTOR_BIT | EVT_GRP_RPT_STEP_COUNTER_BIT |
|
||||
EVT_GRP_RPT_STABILITY_CLASSIFIER_BIT | EVT_GRP_RPT_ACTIVITY_CLASSIFIER_BIT | EVT_GRP_RPT_RAW_ACCELEROMETER_BIT |
|
||||
EVT_GRP_RPT_RAW_GYRO_BIT | EVT_GRP_RPT_RAW_MAGNETOMETER_BIT;
|
||||
EVT_GRP_RPT_RAW_GYRO_BIT | EVT_GRP_RPT_RAW_MAGNETOMETER_BIT | EVT_GRP_RPT_UNCAL_MAGNETOMETER_BIT | EVT_GRP_RPT_SHAKE_DETECTOR_BIT |
|
||||
EVT_GRP_RPT_ACCELEROMETER_BIT | EVT_GRP_RPT_GEOMAG_RV_BIT | EVT_GRP_RPT_GYRO_INTEGRATED_RV_BIT;
|
||||
|
||||
static const constexpr char* TAG = "BNO08x"; ///< Class tag used for serial print statements
|
||||
|
||||
|
|
@ -292,4 +306,17 @@ class BNO08x
|
|||
friend class BNO08xRptLinearAcceleration;
|
||||
friend class BNO08xRptGravity;
|
||||
friend class BNO08xRptCalMagnetometer;
|
||||
friend class BNO08xRptUncalMagnetometer;
|
||||
friend class BNO08xRptCalGyro;
|
||||
friend class BNO08xRptUncalGyro;
|
||||
friend class BNO08xRptIGyroRV;
|
||||
friend class BNO08xRptRVGeomag;
|
||||
friend class BNO08xRptRawMEMSGyro;
|
||||
friend class BNO08xRptRawMEMSAccelerometer;
|
||||
friend class BNO08xRptRawMEMSMagnetometer;
|
||||
friend class BNO08xRptStepCounter;
|
||||
friend class BNO08xRptActivityClassifier;
|
||||
friend class BNO08xStabilityClassifier;
|
||||
friend class BNO08xShakeDetector;
|
||||
friend class BNO08xTapDetector;
|
||||
};
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <functional>
|
||||
#include "BNO08x_global_types.hpp"
|
||||
|
||||
// forward dec to prevent compile errors
|
||||
|
|
@ -25,6 +26,7 @@ class BNO08xRpt
|
|||
|
||||
bool enable(uint32_t time_between_reports, sh2_SensorConfig_t sensor_cfg = default_sensor_cfg);
|
||||
bool disable(sh2_SensorConfig_t sensor_cfg = default_sensor_cfg);
|
||||
void register_cb(std::function<void(void)> cb_fxn);
|
||||
|
||||
virtual void update_data(sh2_SensorValue_t* sensor_val) = 0;
|
||||
|
||||
|
|
|
|||
|
|
@ -13,6 +13,50 @@
|
|||
#include <esp_log.h>
|
||||
#include <esp_timer.h>
|
||||
|
||||
/**
|
||||
* @brief Clears the most significant byte of a 16-bit value.
|
||||
*
|
||||
* @param val_16bit The 16-bit value to modify.
|
||||
* @return The value with the MSB cleared.
|
||||
*/
|
||||
#define UINT16_CLR_MSB(val_16bit) ((val_16bit) & 0x00FFU)
|
||||
|
||||
/**
|
||||
* @brief Clears the least significant byte of a 16-bit value.
|
||||
*
|
||||
* @param val_16bit The 16-bit value to modify.
|
||||
* @return The value with the MSB cleared.
|
||||
*/
|
||||
#define UINT16_CLR_LSB(val_16bit) ((val_16bit) & 0xFF00U)
|
||||
|
||||
/**
|
||||
* @brief Clears a specified byte in a 32-bit value.
|
||||
*
|
||||
* @param val_32bit The 32-bit value to modify.
|
||||
* @param byte2clear The byte index to clear (0 = LSB, 3 = MSB).
|
||||
* @return The value with the specified byte cleared.
|
||||
*/
|
||||
#define UINT32_CLR_BYTE(val_32bit, byte2clear) ((val_32bit) & ~(0xFFUL << (byte2clear * 8UL)))
|
||||
|
||||
/**
|
||||
* @brief Masks a specified byte in a 32-bit value.
|
||||
*
|
||||
* @param val_32bit The 32-bit value to modify.
|
||||
* @param byte2mask The byte index to mask (0 = LSB, 3 = MSB).
|
||||
* @return The value with the specified byte masked.
|
||||
*/
|
||||
#define UINT32_MSK_BYTE(val_32bit, byte2mask) ((val_32bit) & (0xFFUL << (byte2mask * 8UL)))
|
||||
|
||||
// parsing universal to any packet
|
||||
|
||||
/**
|
||||
* @brief Parse length from SHTP packet header.
|
||||
*
|
||||
* @param packet Pointer to bno08x_rx_packet_t containing data.
|
||||
* @return Length of SHTP packet.
|
||||
*/
|
||||
#define PARSE_PACKET_LENGTH(header) (UINT16_CLR_LSB(static_cast<uint16_t>(header[1]) << 8U) | UINT16_CLR_MSB(static_cast<uint16_t>(header[0])))
|
||||
|
||||
// forward dec to prevent compile errors
|
||||
class BNO08x;
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,36 @@
|
|||
#include <driver/spi_master.h>
|
||||
#include "sh2_SensorValue.h"
|
||||
|
||||
/// @brief BNO08xActivity states returned from get_activity_classifier()
|
||||
// macros for bno08x_tap_detector_t
|
||||
#define TAP_DETECTED_X_AXIS(tap) ((tap) & (1U << 0U) ? 1 : 0)
|
||||
#define TAP_DETECTED_X_AXIS_POSITIVE(tap) ((tap) & (1U << 1U) ? 1 : 0)
|
||||
#define TAP_DETECTED_Y_AXIS(tap) ((tap) & (1U << 2U) ? 1 : 0)
|
||||
#define TAP_DETECTED_Y_AXIS_POSITIVE(tap) ((tap) & (1U << 3U) ? 1 : 0)
|
||||
#define TAP_DETECTED_Z_AXIS(tap) ((tap) & (1U << 4U) ? 1 : 0)
|
||||
#define TAP_DETECTED_Z_AXIS_POSITIVE(tap) ((tap) & (1U << 5U) ? 1 : 0)
|
||||
#define TAP_DETECTED_DOUBLE(tap) ((tap) & (1U << 6U) ? 1 : 0)
|
||||
|
||||
// macros for bno08x_shake_detector_t
|
||||
#define SHAKE_DETECTED_X(tap) ((tap) & (1U << 0U) ? 1 : 0)
|
||||
#define SHAKE_DETECTED_Y(tap) ((tap) & (1U << 1U) ? 1 : 0)
|
||||
#define SHAKE_DETECTED_Z(tap) ((tap) & (1U << 2U) ? 1 : 0)
|
||||
|
||||
/// @brief BNO08xActivity Classifier enable bits passed to enable_activity_classifier()
|
||||
enum class BNO08xActivityEnable
|
||||
{
|
||||
UNKNOWN = (1U << 0U),
|
||||
IN_VEHICLE = (1U << 1U),
|
||||
ON_BICYCLE = (1U << 2U),
|
||||
ON_FOOT = (1U << 3U),
|
||||
STILL = (1U << 4U),
|
||||
TILTING = (1U << 5U),
|
||||
WALKING = (1U << 6U),
|
||||
RUNNING = (1U << 7U),
|
||||
ON_STAIRS = (1U << 8U),
|
||||
ALL = 0x1FU
|
||||
};
|
||||
|
||||
/// @brief BNO08xActivity states returned from BNO08x::activity_classifier.get()
|
||||
enum class BNO08xActivity
|
||||
{
|
||||
UNKNOWN = 0, // 0 = unknown
|
||||
|
|
@ -25,13 +54,17 @@ enum class BNO08xActivity
|
|||
UNDEFINED = 9 // used for unit tests
|
||||
};
|
||||
|
||||
/// @brief BNO08xStability states returned from get_stability_classifier()
|
||||
/// @brief BNO08xStability states returned from BNO08x::stability_classifier.get()
|
||||
enum class BNO08xStability
|
||||
{
|
||||
UNKNOWN = 0, // 0 = unknown
|
||||
ON_TABLE = 1, // 1 = on table
|
||||
STATIONARY = 2, // 2 = stationary
|
||||
UNDEFINED = 3 // used for unit tests
|
||||
STABLE = 3, // 3 = stable
|
||||
MOTION = 4, // 4 = in motion
|
||||
RESERVED = 5, // 5 = reserved (not used)
|
||||
UNDEFINED = 6 // used for unit tests
|
||||
|
||||
};
|
||||
|
||||
/// @brief IMU configuration settings passed into constructor
|
||||
|
|
@ -83,35 +116,7 @@ typedef struct bno08x_config_t
|
|||
}
|
||||
} bno08x_config_t;
|
||||
|
||||
typedef struct bno08x_activity_classifier_data_t
|
||||
{
|
||||
uint8_t page;
|
||||
bool lastPage;
|
||||
BNO08xActivity mostLikelyState;
|
||||
uint8_t confidence[10];
|
||||
|
||||
bno08x_activity_classifier_data_t()
|
||||
: page(0U)
|
||||
, lastPage(false)
|
||||
, mostLikelyState(BNO08xActivity::UNDEFINED)
|
||||
, confidence({})
|
||||
{
|
||||
}
|
||||
|
||||
// conversion from sh2_PersonalActivityClassifier_t
|
||||
bno08x_activity_classifier_data_t& operator=(const sh2_PersonalActivityClassifier_t& source)
|
||||
{
|
||||
this->page = source.page;
|
||||
this->lastPage = source.lastPage;
|
||||
this->mostLikelyState = static_cast<BNO08xActivity>(source.mostLikelyState);
|
||||
|
||||
for (int i = 0; i < 10; ++i)
|
||||
this->confidence[i] = source.confidence[i];
|
||||
|
||||
return *this;
|
||||
}
|
||||
} bno08x_activity_classifier_data_t;
|
||||
|
||||
/// @brief Struct to represent unit quaternion.
|
||||
typedef struct bno08x_quat_t
|
||||
{
|
||||
float real;
|
||||
|
|
@ -129,8 +134,7 @@ typedef struct bno08x_quat_t
|
|||
{
|
||||
}
|
||||
|
||||
// overloaded assignment operators to handle both sh2 structs:
|
||||
|
||||
// overloaded assignment operator to handle RV with accuracy
|
||||
bno08x_quat_t& operator=(const sh2_RotationVectorWAcc_t& source)
|
||||
{
|
||||
this->real = source.real;
|
||||
|
|
@ -141,6 +145,7 @@ typedef struct bno08x_quat_t
|
|||
return *this;
|
||||
}
|
||||
|
||||
// overloaded assignment operator to handle RV with w/o accuracy
|
||||
bno08x_quat_t& operator=(const sh2_RotationVector_t& source)
|
||||
{
|
||||
this->real = source.real;
|
||||
|
|
@ -151,8 +156,22 @@ typedef struct bno08x_quat_t
|
|||
return *this;
|
||||
}
|
||||
|
||||
// overloaded assignment operator to handle IRV report
|
||||
|
||||
// overloaded assignment operator to handle RV with w/o accuracy
|
||||
bno08x_quat_t& operator=(const sh2_GyroIntegratedRV_t& source)
|
||||
{
|
||||
this->real = source.real;
|
||||
this->i = source.i;
|
||||
this->j = source.j;
|
||||
this->k = source.k;
|
||||
this->accuracy = 0.0f;
|
||||
return *this;
|
||||
}
|
||||
|
||||
} bno08x_quat_t;
|
||||
|
||||
/// @brief Struct to represent euler angle (units in degrees or rads)
|
||||
typedef struct bno08x_euler_angle_t
|
||||
{
|
||||
float x;
|
||||
|
|
@ -191,12 +210,282 @@ typedef struct bno08x_euler_angle_t
|
|||
|
||||
} bno08x_euler_angle_t;
|
||||
|
||||
typedef sh2_Accelerometer_t bno08x_accel_data_t; ///< Acceleration data.
|
||||
typedef sh2_MagneticField_t bno08x_magf_data_t; ///< Magnetic field data.
|
||||
typedef sh2_StepCounter bno08x_step_counter_data_t;
|
||||
typedef sh2_Gyroscope_t bno08x_gyro_data_t;
|
||||
typedef sh2_RawGyroscope_t bno08x_raw_gyro_data_t;
|
||||
typedef sh2_RawAccelerometer bno08x_raw_accel_data_t;
|
||||
typedef sh2_RawMagnetometer_t bno08x_raw_magf_data_t;
|
||||
/// @brief Struct to represent angular velocity (units in rad/s)
|
||||
typedef struct bno08x_ang_vel_t
|
||||
{
|
||||
float x;
|
||||
float y;
|
||||
float z;
|
||||
|
||||
bno08x_ang_vel_t()
|
||||
: x(0.0f)
|
||||
, y(0.0f)
|
||||
, z(0.0f)
|
||||
{
|
||||
}
|
||||
|
||||
// overloaded *= operator for rad2deg conversions
|
||||
template <typename T>
|
||||
bno08x_ang_vel_t& operator*=(T value)
|
||||
{
|
||||
x *= static_cast<float>(value);
|
||||
y *= static_cast<float>(value);
|
||||
z *= static_cast<float>(value);
|
||||
return *this;
|
||||
}
|
||||
|
||||
// strip sh2_GyroIntegratedRV_t of velocity data for IRV reports
|
||||
bno08x_ang_vel_t& operator=(const sh2_GyroIntegratedRV_t& source)
|
||||
{
|
||||
this->x = source.angVelX;
|
||||
this->y = source.angVelY;
|
||||
this->z = source.angVelZ;
|
||||
return *this;
|
||||
}
|
||||
} bno08x_ang_vel_t;
|
||||
|
||||
/// @brief Struct to represent magnetic field data (units in uTesla)
|
||||
typedef struct bno08x_magf_t
|
||||
{
|
||||
float x;
|
||||
float y;
|
||||
float z;
|
||||
|
||||
bno08x_magf_t()
|
||||
: x(0.0f)
|
||||
, y(0.0f)
|
||||
, z(0.0f)
|
||||
{
|
||||
}
|
||||
|
||||
// overloaded = operator for sh2_MagneticField_t conversion
|
||||
bno08x_magf_t& operator=(const sh2_MagneticField_t& source)
|
||||
{
|
||||
this->x = source.x;
|
||||
this->y = source.y;
|
||||
this->z = source.z;
|
||||
return *this;
|
||||
}
|
||||
|
||||
// overloaded = operator for sh2_MagneticFieldUncalibrated_t conversion
|
||||
bno08x_magf_t& operator=(const sh2_MagneticFieldUncalibrated_t& source)
|
||||
{
|
||||
this->x = source.x;
|
||||
this->y = source.y;
|
||||
this->z = source.z;
|
||||
return *this;
|
||||
}
|
||||
|
||||
} bno08x_magf_t;
|
||||
|
||||
/// @brief Struct to represent magnetic field bias data (units in uTesla)
|
||||
typedef struct bno08x_magf_bias_t
|
||||
{
|
||||
float x;
|
||||
float y;
|
||||
float z;
|
||||
|
||||
bno08x_magf_bias_t()
|
||||
: x(0.0f)
|
||||
, y(0.0f)
|
||||
, z(0.0f)
|
||||
{
|
||||
}
|
||||
|
||||
// overloaded = operator for sh2_MagneticFieldUncalibrated_t conversion
|
||||
bno08x_magf_bias_t& operator=(const sh2_MagneticFieldUncalibrated_t& source)
|
||||
{
|
||||
this->x = source.biasX;
|
||||
this->y = source.biasY;
|
||||
this->z = source.biasZ;
|
||||
return *this;
|
||||
}
|
||||
|
||||
} bno08x_magf_bias_t;
|
||||
|
||||
/// @brief Struct to represent gyro data (units in rad/s)
|
||||
typedef struct bno08x_gyro_t
|
||||
{
|
||||
float x;
|
||||
float y;
|
||||
float z;
|
||||
|
||||
bno08x_gyro_t()
|
||||
: x(0.0f)
|
||||
, y(0.0f)
|
||||
, z(0.0f)
|
||||
{
|
||||
}
|
||||
|
||||
// overloaded = operator for sh2_Gyroscope_t conversion
|
||||
bno08x_gyro_t& operator=(const sh2_Gyroscope_t& source)
|
||||
{
|
||||
this->x = source.x;
|
||||
this->y = source.y;
|
||||
this->z = source.z;
|
||||
return *this;
|
||||
}
|
||||
|
||||
// overloaded = operator for sh2_GyroscopeUncalibrated conversion
|
||||
bno08x_gyro_t& operator=(const sh2_GyroscopeUncalibrated& source)
|
||||
{
|
||||
this->x = source.x;
|
||||
this->y = source.y;
|
||||
this->z = source.z;
|
||||
return *this;
|
||||
}
|
||||
|
||||
} bno08x_gyro_t;
|
||||
|
||||
/// @brief Struct to represent gyro bias data (units in rad/s)
|
||||
typedef struct bno08x_gyro_bias_t
|
||||
{
|
||||
float x;
|
||||
float y;
|
||||
float z;
|
||||
|
||||
bno08x_gyro_bias_t()
|
||||
: x(0.0f)
|
||||
, y(0.0f)
|
||||
, z(0.0f)
|
||||
{
|
||||
}
|
||||
|
||||
// overloaded = operator for sh2_GyroscopeUncalibrated conversion
|
||||
bno08x_gyro_bias_t& operator=(const sh2_GyroscopeUncalibrated& source)
|
||||
{
|
||||
this->x = source.biasX;
|
||||
this->y = source.biasY;
|
||||
this->z = source.biasZ;
|
||||
return *this;
|
||||
}
|
||||
|
||||
} bno08x_gyro_bias_t;
|
||||
|
||||
/// @brief Struct to represent activity classifier data.
|
||||
typedef struct bno08x_activity_classifier_t
|
||||
{
|
||||
uint8_t page;
|
||||
bool lastPage;
|
||||
BNO08xActivity mostLikelyState;
|
||||
uint8_t confidence[10];
|
||||
|
||||
bno08x_activity_classifier_t()
|
||||
: page(0U)
|
||||
, lastPage(false)
|
||||
, mostLikelyState(BNO08xActivity::UNDEFINED)
|
||||
, confidence({})
|
||||
{
|
||||
}
|
||||
|
||||
// conversion from sh2_PersonalActivityClassifier_t
|
||||
bno08x_activity_classifier_t& operator=(const sh2_PersonalActivityClassifier_t& source)
|
||||
{
|
||||
this->page = source.page;
|
||||
this->lastPage = source.lastPage;
|
||||
this->mostLikelyState = static_cast<BNO08xActivity>(source.mostLikelyState);
|
||||
|
||||
for (int i = 0; i < 10; ++i)
|
||||
this->confidence[i] = source.confidence[i];
|
||||
|
||||
return *this;
|
||||
}
|
||||
} bno08x_activity_classifier_t;
|
||||
|
||||
/// @brief Struct to represent tap detector data (flag meaning: 0 = no tap, 1 = positive tap on axis, -1 = negative tap on axis)
|
||||
typedef struct bno08x_tap_detector_t
|
||||
{
|
||||
int8_t x_flag;
|
||||
int8_t y_flag;
|
||||
int8_t z_flag;
|
||||
bool double_tap;
|
||||
|
||||
bno08x_tap_detector_t()
|
||||
: x_flag(0)
|
||||
, y_flag(0)
|
||||
, z_flag(0)
|
||||
, double_tap(false)
|
||||
{
|
||||
}
|
||||
|
||||
// overloaded = operator for sh2_GyroscopeUncalibrated conversion
|
||||
bno08x_tap_detector_t& operator=(const sh2_TapDetector_t& source)
|
||||
{
|
||||
if (TAP_DETECTED_X_AXIS(source.flags))
|
||||
this->x_flag = -1;
|
||||
else
|
||||
this->x_flag = 0;
|
||||
|
||||
if (TAP_DETECTED_X_AXIS_POSITIVE(source.flags))
|
||||
this->x_flag = 1;
|
||||
|
||||
if (TAP_DETECTED_Y_AXIS(source.flags))
|
||||
this->y_flag = -1;
|
||||
else
|
||||
this->y_flag = 0;
|
||||
|
||||
if (TAP_DETECTED_Y_AXIS_POSITIVE(source.flags))
|
||||
this->y_flag = 1;
|
||||
|
||||
if (TAP_DETECTED_Z_AXIS(source.flags))
|
||||
this->z_flag = -1;
|
||||
else
|
||||
this->z_flag = 0;
|
||||
|
||||
if (TAP_DETECTED_Z_AXIS_POSITIVE(source.flags))
|
||||
this->z_flag = 1;
|
||||
|
||||
if (TAP_DETECTED_DOUBLE(source.flags))
|
||||
this->double_tap = true;
|
||||
else
|
||||
this->double_tap = false;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
} bno08x_tap_detector_t;
|
||||
|
||||
/// @brief Struct to represent shake detector data (flag meaning: 0 = no shake 1 = shake detected)
|
||||
typedef struct bno08x_shake_detector_t
|
||||
{
|
||||
uint8_t x_flag;
|
||||
uint8_t y_flag;
|
||||
uint8_t z_flag;
|
||||
|
||||
bno08x_shake_detector_t()
|
||||
: x_flag(0U)
|
||||
, y_flag(0U)
|
||||
, z_flag(0U)
|
||||
{
|
||||
}
|
||||
|
||||
// overloaded = operator for sh2_GyroscopeUncalibrated conversion
|
||||
bno08x_shake_detector_t& operator=(const sh2_ShakeDetector_t& source)
|
||||
{
|
||||
if (SHAKE_DETECTED_X(source.shake))
|
||||
this->x_flag = 1U;
|
||||
else
|
||||
this->x_flag = 0U;
|
||||
|
||||
if (SHAKE_DETECTED_Y(source.shake))
|
||||
this->y_flag = 1U;
|
||||
else
|
||||
this->y_flag = 0U;
|
||||
|
||||
if (SHAKE_DETECTED_Z(source.shake))
|
||||
this->z_flag = 1U;
|
||||
else
|
||||
this->z_flag = 0U;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
} bno08x_shake_detector_t;
|
||||
|
||||
typedef sh2_Accelerometer_t bno08x_accel_t; ///< Acceleration data.
|
||||
typedef sh2_StepCounter bno08x_step_counter_t;
|
||||
typedef sh2_RawGyroscope_t bno08x_raw_gyro_t;
|
||||
typedef sh2_RawAccelerometer bno08x_raw_accel_t;
|
||||
typedef sh2_RawMagnetometer_t bno08x_raw_magf_t;
|
||||
|
||||
typedef bno08x_config_t imu_config_t; // legacy version compatibility
|
||||
|
|
@ -1,58 +0,0 @@
|
|||
/**
|
||||
* @file BNO08x_macros.hpp
|
||||
* @author Myles Parfeniuk
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
// standard library includes
|
||||
#include <inttypes.h>
|
||||
|
||||
// esp-idf includes
|
||||
#include <freertos/FreeRTOS.h>
|
||||
#include <freertos/event_groups.h>
|
||||
|
||||
// packet parsing macros
|
||||
|
||||
/**
|
||||
* @brief Clears the most significant byte of a 16-bit value.
|
||||
*
|
||||
* @param val_16bit The 16-bit value to modify.
|
||||
* @return The value with the MSB cleared.
|
||||
*/
|
||||
#define UINT16_CLR_MSB(val_16bit) ((val_16bit) & 0x00FFU)
|
||||
|
||||
/**
|
||||
* @brief Clears the least significant byte of a 16-bit value.
|
||||
*
|
||||
* @param val_16bit The 16-bit value to modify.
|
||||
* @return The value with the MSB cleared.
|
||||
*/
|
||||
#define UINT16_CLR_LSB(val_16bit) ((val_16bit) & 0xFF00U)
|
||||
|
||||
/**
|
||||
* @brief Clears a specified byte in a 32-bit value.
|
||||
*
|
||||
* @param val_32bit The 32-bit value to modify.
|
||||
* @param byte2clear The byte index to clear (0 = LSB, 3 = MSB).
|
||||
* @return The value with the specified byte cleared.
|
||||
*/
|
||||
#define UINT32_CLR_BYTE(val_32bit, byte2clear) ((val_32bit) & ~(0xFFUL << (byte2clear * 8UL)))
|
||||
|
||||
/**
|
||||
* @brief Masks a specified byte in a 32-bit value.
|
||||
*
|
||||
* @param val_32bit The 32-bit value to modify.
|
||||
* @param byte2mask The byte index to mask (0 = LSB, 3 = MSB).
|
||||
* @return The value with the specified byte masked.
|
||||
*/
|
||||
#define UINT32_MSK_BYTE(val_32bit, byte2mask) ((val_32bit) & (0xFFUL << (byte2mask * 8UL)))
|
||||
|
||||
// parsing universal to any packet
|
||||
|
||||
/**
|
||||
* @brief Parse length from SHTP packet header.
|
||||
*
|
||||
* @param packet Pointer to bno08x_rx_packet_t containing data.
|
||||
* @return Length of SHTP packet.
|
||||
*/
|
||||
#define PARSE_PACKET_LENGTH(header) (UINT16_CLR_LSB(static_cast<uint16_t>(header[1]) << 8U) | UINT16_CLR_MSB(static_cast<uint16_t>(header[0])))
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#include "BNO08xRptRVGeneric.hpp" // Include the base class header
|
||||
#include "BNO08xRptRVGeneric.hpp"
|
||||
|
||||
/**
|
||||
* @brief Class to represent ARVR stabilized rotation vector reports. (See Ref. Manual 6.5.43)
|
||||
|
|
@ -8,7 +8,6 @@
|
|||
class BNO08xRptARVRStabilizedGameRV : public BNO08xRptRVGeneric
|
||||
{
|
||||
public:
|
||||
// Constructor declaration
|
||||
BNO08xRptARVRStabilizedGameRV(BNO08x* imu, uint8_t report_ID, uint32_t period_us, uint32_t rpt_bit)
|
||||
: BNO08xRptRVGeneric(imu, report_ID, period_us, rpt_bit)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#include "BNO08xRptRVGeneric.hpp" // Include the base class header
|
||||
#include "BNO08xRptRVGeneric.hpp"
|
||||
|
||||
/**
|
||||
* @brief Class to represent ARVR stabilized rotation vector reports. (See Ref. Manual 6.5.42)
|
||||
|
|
@ -8,7 +8,6 @@
|
|||
class BNO08xRptARVRStabilizedRV : public BNO08xRptRVGeneric
|
||||
{
|
||||
public:
|
||||
// Constructor declaration
|
||||
BNO08xRptARVRStabilizedRV(BNO08x* imu, uint8_t report_ID, uint32_t period_us, uint32_t rpt_bit)
|
||||
: BNO08xRptRVGeneric(imu, report_ID, period_us, rpt_bit)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#include "BNO08xRpt.hpp" // Include the base class header
|
||||
#include "BNO08xRpt.hpp"
|
||||
|
||||
/**
|
||||
* @brief Class to represent accelerometer reports. (See Ref. Manual 6.5.9)
|
||||
|
|
@ -8,16 +8,15 @@
|
|||
class BNO08xRptAcceleration : public BNO08xRpt
|
||||
{
|
||||
public:
|
||||
// Constructor declaration
|
||||
BNO08xRptAcceleration(BNO08x* imu, uint8_t report_ID, uint32_t period_us, uint32_t rpt_bit)
|
||||
: BNO08xRpt(imu, report_ID, period_us, rpt_bit)
|
||||
{
|
||||
}
|
||||
|
||||
bno08x_accel_data_t get();
|
||||
bno08x_accel_t get();
|
||||
|
||||
private:
|
||||
void update_data(sh2_SensorValue_t* sensor_val) override;
|
||||
bno08x_accel_data_t data;
|
||||
bno08x_accel_t data;
|
||||
static const constexpr char* TAG = "BNO08xRptAcceleration";
|
||||
};
|
||||
|
|
|
|||
|
|
@ -0,0 +1,24 @@
|
|||
#pragma once
|
||||
|
||||
#include "BNO08xRpt.hpp"
|
||||
|
||||
/**
|
||||
* @brief Class to represent activity classifier reports. (See Ref. Manual 6.5.36)
|
||||
*/
|
||||
class BNO08xRptActivityClassifier : public BNO08xRpt
|
||||
{
|
||||
public:
|
||||
BNO08xRptActivityClassifier(BNO08x* imu, uint8_t report_ID, uint32_t period_us, uint32_t rpt_bit)
|
||||
: BNO08xRpt(imu, report_ID, period_us, rpt_bit)
|
||||
{
|
||||
}
|
||||
|
||||
bool enable(uint32_t time_between_reports, BNO08xActivityEnable activities_to_enable, sh2_SensorConfig_t sensor_cfg = default_sensor_cfg);
|
||||
bno08x_activity_classifier_t get();
|
||||
BNO08xActivity get_most_likely_activity();
|
||||
|
||||
private:
|
||||
void update_data(sh2_SensorValue_t* sensor_val) override;
|
||||
bno08x_activity_classifier_t data; ///< Most recent report data, doesn't account for step rollover.
|
||||
static const constexpr char* TAG = "BNO08xRptActivityClassifier";
|
||||
};
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
#pragma once
|
||||
|
||||
#include "BNO08xRpt.hpp"
|
||||
|
||||
/**
|
||||
* @brief Class to represent calibrated gyro reports. (See Ref. Manual 6.5.13)
|
||||
*/
|
||||
class BNO08xRptCalGyro : public BNO08xRpt
|
||||
{
|
||||
public:
|
||||
BNO08xRptCalGyro(BNO08x* imu, uint8_t report_ID, uint32_t period_us, uint32_t rpt_bit)
|
||||
: BNO08xRpt(imu, report_ID, period_us, rpt_bit)
|
||||
{
|
||||
}
|
||||
|
||||
bno08x_gyro_t get();
|
||||
|
||||
private:
|
||||
void update_data(sh2_SensorValue_t* sensor_val) override;
|
||||
bno08x_gyro_t data;
|
||||
static const constexpr char* TAG = "BNO08xRptCalGyro";
|
||||
};
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#include "BNO08xRpt.hpp" // Include the base class header
|
||||
#include "BNO08xRpt.hpp"
|
||||
|
||||
/**
|
||||
* @brief Class to represent calibrated magnetometer reports. (See Ref. Manual 6.5.16)
|
||||
|
|
@ -8,16 +8,15 @@
|
|||
class BNO08xRptCalMagnetometer : public BNO08xRpt
|
||||
{
|
||||
public:
|
||||
// Constructor declaration
|
||||
BNO08xRptCalMagnetometer(BNO08x* imu, uint8_t report_ID, uint32_t period_us, uint32_t rpt_bit)
|
||||
: BNO08xRpt(imu, report_ID, period_us, rpt_bit)
|
||||
{
|
||||
}
|
||||
|
||||
bno08x_magf_data_t get();
|
||||
bno08x_magf_t get();
|
||||
|
||||
private:
|
||||
void update_data(sh2_SensorValue_t* sensor_val) override;
|
||||
bno08x_magf_data_t data;
|
||||
bno08x_magf_t data;
|
||||
static const constexpr char* TAG = "BNO08xRptCalMagnetometer";
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#include "BNO08xRptRVGeneric.hpp" // Include the base class header
|
||||
#include "BNO08xRptRVGeneric.hpp"
|
||||
|
||||
/**
|
||||
* @brief Class to represent game rotation vector reports. (See Ref. Manual 6.5.19)
|
||||
|
|
@ -8,7 +8,6 @@
|
|||
class BNO08xRptGameRV : public BNO08xRptRVGeneric
|
||||
{
|
||||
public:
|
||||
// Constructor declaration
|
||||
BNO08xRptGameRV(BNO08x* imu, uint8_t report_ID, uint32_t period_us, uint32_t rpt_bit)
|
||||
: BNO08xRptRVGeneric(imu, report_ID, period_us, rpt_bit)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#include "BNO08xRpt.hpp" // Include the base class header
|
||||
#include "BNO08xRpt.hpp"
|
||||
|
||||
/**
|
||||
* @brief Class to represent gravity reports. (See Ref. Manual 6.5.11)
|
||||
|
|
@ -8,16 +8,15 @@
|
|||
class BNO08xRptGravity : public BNO08xRpt
|
||||
{
|
||||
public:
|
||||
// Constructor declaration
|
||||
BNO08xRptGravity(BNO08x* imu, uint8_t report_ID, uint32_t period_us, uint32_t rpt_bit)
|
||||
: BNO08xRpt(imu, report_ID, period_us, rpt_bit)
|
||||
{
|
||||
}
|
||||
|
||||
bno08x_accel_data_t get();
|
||||
bno08x_accel_t get();
|
||||
|
||||
private:
|
||||
void update_data(sh2_SensorValue_t* sensor_val) override;
|
||||
bno08x_accel_data_t data;
|
||||
bno08x_accel_t data;
|
||||
static const constexpr char* TAG = "BNO08xRptGravity";
|
||||
};
|
||||
|
|
|
|||
|
|
@ -0,0 +1,23 @@
|
|||
#pragma once
|
||||
|
||||
#include "BNO08xRptRVGeneric.hpp"
|
||||
|
||||
/**
|
||||
* @brief Class to represent integrated gyro rotation vector reports. (See Ref. Manual 6.5.44)
|
||||
*/
|
||||
class BNO08xRptIGyroRV : public BNO08xRptRVGeneric
|
||||
{
|
||||
public:
|
||||
BNO08xRptIGyroRV(BNO08x* imu, uint8_t report_ID, uint32_t period_us, uint32_t rpt_bit)
|
||||
: BNO08xRptRVGeneric(imu, report_ID, period_us, rpt_bit)
|
||||
{
|
||||
}
|
||||
|
||||
void get(bno08x_quat_t& quat, bno08x_ang_vel_t& vel);
|
||||
bno08x_ang_vel_t get_vel();
|
||||
|
||||
private:
|
||||
void update_data(sh2_SensorValue_t* sensor_val) override;
|
||||
bno08x_ang_vel_t data_vel;
|
||||
static const constexpr char* TAG = "BNO08xRptIGyroRV";
|
||||
};
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#include "BNO08xRpt.hpp" // Include the base class header
|
||||
#include "BNO08xRpt.hpp"
|
||||
|
||||
/**
|
||||
* @brief Class to represent linear accelerometer reports. (See Ref. Manual 6.5.10)
|
||||
|
|
@ -8,16 +8,15 @@
|
|||
class BNO08xRptLinearAcceleration : public BNO08xRpt
|
||||
{
|
||||
public:
|
||||
// Constructor declaration
|
||||
BNO08xRptLinearAcceleration(BNO08x* imu, uint8_t report_ID, uint32_t period_us, uint32_t rpt_bit)
|
||||
: BNO08xRpt(imu, report_ID, period_us, rpt_bit)
|
||||
{
|
||||
}
|
||||
|
||||
bno08x_accel_data_t get();
|
||||
bno08x_accel_t get();
|
||||
|
||||
private:
|
||||
void update_data(sh2_SensorValue_t* sensor_val) override;
|
||||
bno08x_accel_data_t data;
|
||||
bno08x_accel_t data;
|
||||
static const constexpr char* TAG = "BNO08xRptLinearAcceleration";
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#include "BNO08xRptRVGeneric.hpp" // Include the base class header
|
||||
#include "BNO08xRptRVGeneric.hpp"
|
||||
|
||||
/**
|
||||
* @brief Class to represent rotation vector reports. (See Ref. Manual 6.5.18)
|
||||
|
|
@ -8,7 +8,6 @@
|
|||
class BNO08xRptRV : public BNO08xRptRVGeneric
|
||||
{
|
||||
public:
|
||||
// Constructor declaration
|
||||
BNO08xRptRV(BNO08x* imu, uint8_t report_ID, uint32_t period_us, uint32_t rpt_bit)
|
||||
: BNO08xRptRVGeneric(imu, report_ID, period_us, rpt_bit)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#include "BNO08xRpt.hpp" // Include the base class header
|
||||
#include "BNO08xRpt.hpp"
|
||||
|
||||
/**
|
||||
* @brief Class to represent rotation vector reports.
|
||||
|
|
@ -12,7 +12,6 @@ class BNO08xRptRVGeneric : public BNO08xRpt
|
|||
bno08x_euler_angle_t get_euler(bool in_degrees = true);
|
||||
|
||||
protected:
|
||||
// Constructor declaration
|
||||
BNO08xRptRVGeneric(BNO08x* imu, uint8_t report_ID, uint32_t period_us, uint32_t rpt_bit)
|
||||
: BNO08xRpt(imu, report_ID, period_us, rpt_bit)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -0,0 +1,19 @@
|
|||
#pragma once
|
||||
|
||||
#include "BNO08xRptRVGeneric.hpp"
|
||||
|
||||
/**
|
||||
* @brief Class to represent geomagnetic rotation vector reports. (See Ref. Manual 6.5.20)
|
||||
*/
|
||||
class BNO08xRptRVGeomag : public BNO08xRptRVGeneric
|
||||
{
|
||||
public:
|
||||
BNO08xRptRVGeomag(BNO08x* imu, uint8_t report_ID, uint32_t period_us, uint32_t rpt_bit)
|
||||
: BNO08xRptRVGeneric(imu, report_ID, period_us, rpt_bit)
|
||||
{
|
||||
}
|
||||
|
||||
private:
|
||||
void update_data(sh2_SensorValue_t* sensor_val) override;
|
||||
static const constexpr char* TAG = "BNO08xRptRVGeomag";
|
||||
};
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
#pragma once
|
||||
|
||||
#include "BNO08xRpt.hpp"
|
||||
|
||||
/**
|
||||
* @brief Class to represent raw accelerometer reports. (See Ref. Manual 6.5.8)
|
||||
*/
|
||||
class BNO08xRptRawMEMSAccelerometer : public BNO08xRpt
|
||||
{
|
||||
public:
|
||||
BNO08xRptRawMEMSAccelerometer(BNO08x* imu, uint8_t report_ID, uint32_t period_us, uint32_t rpt_bit)
|
||||
: BNO08xRpt(imu, report_ID, period_us, rpt_bit)
|
||||
{
|
||||
}
|
||||
|
||||
bno08x_raw_accel_t get();
|
||||
|
||||
private:
|
||||
void update_data(sh2_SensorValue_t* sensor_val) override;
|
||||
bno08x_raw_accel_t data;
|
||||
static const constexpr char* TAG = "BNO08xRptRawMEMSAccelerometer";
|
||||
};
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
#pragma once
|
||||
|
||||
#include "BNO08xRpt.hpp"
|
||||
|
||||
/**
|
||||
* @brief Class to represent raw gyro reports. (See Ref. Manual 6.5.12)
|
||||
*/
|
||||
class BNO08xRptRawMEMSGyro : public BNO08xRpt
|
||||
{
|
||||
public:
|
||||
BNO08xRptRawMEMSGyro(BNO08x* imu, uint8_t report_ID, uint32_t period_us, uint32_t rpt_bit)
|
||||
: BNO08xRpt(imu, report_ID, period_us, rpt_bit)
|
||||
{
|
||||
}
|
||||
|
||||
bno08x_raw_gyro_t get();
|
||||
|
||||
private:
|
||||
void update_data(sh2_SensorValue_t* sensor_val) override;
|
||||
bno08x_raw_gyro_t data;
|
||||
static const constexpr char* TAG = "BNO08xRptRawMEMSGyro";
|
||||
};
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
#pragma once
|
||||
|
||||
#include "BNO08xRpt.hpp"
|
||||
|
||||
/**
|
||||
* @brief Class to represent raw magnetometer reports. (See Ref. Manual 6.5.15)
|
||||
*/
|
||||
class BNO08xRptRawMEMSMagnetometer : public BNO08xRpt
|
||||
{
|
||||
public:
|
||||
BNO08xRptRawMEMSMagnetometer(BNO08x* imu, uint8_t report_ID, uint32_t period_us, uint32_t rpt_bit)
|
||||
: BNO08xRpt(imu, report_ID, period_us, rpt_bit)
|
||||
{
|
||||
}
|
||||
|
||||
bno08x_raw_magf_t get();
|
||||
|
||||
private:
|
||||
void update_data(sh2_SensorValue_t* sensor_val) override;
|
||||
bno08x_raw_magf_t data;
|
||||
static const constexpr char* TAG = "BNO08xRptRawMEMSMagnetometer";
|
||||
};
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
#pragma once
|
||||
|
||||
#include "BNO08xRpt.hpp"
|
||||
|
||||
/**
|
||||
* @brief Class to represent step counter reports. (See Ref. Manual 6.5.29)
|
||||
*/
|
||||
class BNO08xRptStepCounter : public BNO08xRpt
|
||||
{
|
||||
public:
|
||||
BNO08xRptStepCounter(BNO08x* imu, uint8_t report_ID, uint32_t period_us, uint32_t rpt_bit)
|
||||
: BNO08xRpt(imu, report_ID, period_us, rpt_bit)
|
||||
{
|
||||
}
|
||||
|
||||
bno08x_step_counter_t get();
|
||||
uint32_t get_total_steps();
|
||||
|
||||
private:
|
||||
void update_data(sh2_SensorValue_t* sensor_val) override;
|
||||
bno08x_step_counter_t data; ///< Most recent report data, doesn't account for step rollover.
|
||||
uint32_t step_accumulator =
|
||||
0UL; ///< Every time step count rolls over, the previous steps are accumulated here such that the total steps can always be calculated.
|
||||
static const constexpr char* TAG = "BNO08xRptStepCounter";
|
||||
};
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
#pragma once
|
||||
|
||||
#include "BNO08xRpt.hpp"
|
||||
|
||||
/**
|
||||
* @brief Class to represent uncalibrated gyro reports. (See Ref. Manual 6.5.14)
|
||||
*/
|
||||
class BNO08xRptUncalGyro : public BNO08xRpt
|
||||
{
|
||||
public:
|
||||
BNO08xRptUncalGyro(BNO08x* imu, uint8_t report_ID, uint32_t period_us, uint32_t rpt_bit)
|
||||
: BNO08xRpt(imu, report_ID, period_us, rpt_bit)
|
||||
{
|
||||
}
|
||||
|
||||
void get(bno08x_gyro_t& vel, bno08x_gyro_bias_t& bias);
|
||||
bno08x_gyro_t get_vel();
|
||||
bno08x_gyro_bias_t get_bias();
|
||||
|
||||
private:
|
||||
void update_data(sh2_SensorValue_t* sensor_val) override;
|
||||
bno08x_gyro_t data;
|
||||
bno08x_gyro_bias_t bias_data;
|
||||
static const constexpr char* TAG = "BNO08xRptUncalGyro";
|
||||
};
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
#pragma once
|
||||
|
||||
#include "BNO08xRpt.hpp"
|
||||
|
||||
/**
|
||||
* @brief Class to represent uncalibrated magnetometer reports. (See Ref. Manual 6.5.17)
|
||||
*/
|
||||
class BNO08xRptUncalMagnetometer : public BNO08xRpt
|
||||
{
|
||||
public:
|
||||
BNO08xRptUncalMagnetometer(BNO08x* imu, uint8_t report_ID, uint32_t period_us, uint32_t rpt_bit)
|
||||
: BNO08xRpt(imu, report_ID, period_us, rpt_bit)
|
||||
{
|
||||
}
|
||||
|
||||
void get(bno08x_magf_t& magf, bno08x_magf_bias_t& bias);
|
||||
bno08x_magf_t get_magf();
|
||||
bno08x_magf_bias_t get_bias();
|
||||
|
||||
private:
|
||||
void update_data(sh2_SensorValue_t* sensor_val) override;
|
||||
bno08x_magf_t data;
|
||||
bno08x_magf_bias_t bias_data;
|
||||
static const constexpr char* TAG = "BNO08xRptUncalMagnetometer";
|
||||
};
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
#pragma once
|
||||
|
||||
#include "BNO08xRpt.hpp"
|
||||
|
||||
/**
|
||||
* @brief Class to represent shake detector reports. (See Ref. Manual 6.5.32)
|
||||
*/
|
||||
class BNO08xShakeDetector : public BNO08xRpt
|
||||
{
|
||||
public:
|
||||
BNO08xShakeDetector(BNO08x* imu, uint8_t report_ID, uint32_t period_us, uint32_t rpt_bit)
|
||||
: BNO08xRpt(imu, report_ID, period_us, rpt_bit)
|
||||
{
|
||||
}
|
||||
|
||||
bno08x_shake_detector_t get();
|
||||
|
||||
private:
|
||||
void update_data(sh2_SensorValue_t* sensor_val) override;
|
||||
bno08x_shake_detector_t data;
|
||||
static const constexpr char* TAG = "BNO08xShakeDetector";
|
||||
};
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
#pragma once
|
||||
|
||||
#include "BNO08xRpt.hpp"
|
||||
|
||||
/**
|
||||
* @brief Class to represent stability classifier reports. (See Ref. Manual 6.5.31)
|
||||
*/
|
||||
class BNO08xStabilityClassifier : public BNO08xRpt
|
||||
{
|
||||
public:
|
||||
BNO08xStabilityClassifier(BNO08x* imu, uint8_t report_ID, uint32_t period_us, uint32_t rpt_bit)
|
||||
: BNO08xRpt(imu, report_ID, period_us, rpt_bit)
|
||||
{
|
||||
}
|
||||
|
||||
BNO08xStability get();
|
||||
|
||||
private:
|
||||
void update_data(sh2_SensorValue_t* sensor_val) override;
|
||||
sh2_StabilityClassifier_t data = {0U};
|
||||
static const constexpr char* TAG = "BNO08xStabilityClassifier";
|
||||
};
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
#pragma once
|
||||
|
||||
#include "BNO08xRpt.hpp"
|
||||
|
||||
/**
|
||||
* @brief Class to represent tap detector reports. (See Ref. Manual 6.5.27)
|
||||
*/
|
||||
class BNO08xTapDetector : public BNO08xRpt
|
||||
{
|
||||
public:
|
||||
BNO08xTapDetector(BNO08x* imu, uint8_t report_ID, uint32_t period_us, uint32_t rpt_bit)
|
||||
: BNO08xRpt(imu, report_ID, period_us, rpt_bit)
|
||||
{
|
||||
}
|
||||
|
||||
bool enable(uint32_t time_between_reports, sh2_SensorConfig_t sensor_cfg = default_sensor_cfg);
|
||||
bno08x_tap_detector_t get();
|
||||
|
||||
private:
|
||||
void update_data(sh2_SensorValue_t* sensor_val) override;
|
||||
bno08x_tap_detector_t data;
|
||||
static const constexpr char* TAG = "BNO08xTapDetector";
|
||||
};
|
||||
|
|
@ -1,5 +1,4 @@
|
|||
#include "BNO08x.hpp"
|
||||
#include "BNO08x_macros.hpp"
|
||||
|
||||
/**
|
||||
* @brief BNO08x imu constructor.
|
||||
|
|
@ -13,11 +12,24 @@ BNO08x::BNO08x(bno08x_config_t imu_config)
|
|||
: accelerometer(this, SH2_ACCELEROMETER, 0UL, EVT_GRP_RPT_ACCELEROMETER_BIT)
|
||||
, linear_accelerometer(this, SH2_LINEAR_ACCELERATION, 0UL, EVT_GRP_RPT_LINEAR_ACCELEROMETER_BIT)
|
||||
, gravity(this, SH2_GRAVITY, 0UL, EVT_GRP_RPT_GRAVITY_BIT)
|
||||
, calibrated_magnetometer(this, SH2_MAGNETIC_FIELD_CALIBRATED, 0UL, EVT_GRP_RPT_CAL_MAGNETOMETER_BIT)
|
||||
, rotation_vector(this, SH2_ROTATION_VECTOR, 0UL, EVT_GRP_RPT_RV_BIT)
|
||||
, game_rotation_vector(this, SH2_GAME_ROTATION_VECTOR, 0UL, EVT_GRP_RPT_GAME_RV_BIT)
|
||||
, ARVR_stabilized_rotation_vector(this, SH2_ARVR_STABILIZED_RV, 0UL, EVT_GRP_RPT_ARVR_S_RV_BIT)
|
||||
, ARVR_stabilized_game_rotation_vector(this, SH2_ARVR_STABILIZED_GRV, 0UL, EVT_GRP_RPT_ARVR_S_GAME_RV_BIT)
|
||||
, cal_magnetometer(this, SH2_MAGNETIC_FIELD_CALIBRATED, 0UL, EVT_GRP_RPT_CAL_MAGNETOMETER_BIT)
|
||||
, uncal_magnetometer(this, SH2_MAGNETIC_FIELD_UNCALIBRATED, 0UL, EVT_GRP_RPT_UNCAL_MAGNETOMETER_BIT)
|
||||
, cal_gyro(this, SH2_GYROSCOPE_CALIBRATED, 0UL, EVT_GRP_RPT_CAL_GYRO_BIT)
|
||||
, uncal_gyro(this, SH2_GYROSCOPE_UNCALIBRATED, 0UL, EVT_GRP_RPT_UNCAL_GYRO_BIT)
|
||||
, rv(this, SH2_ROTATION_VECTOR, 0UL, EVT_GRP_RPT_RV_BIT)
|
||||
, rv_game(this, SH2_GAME_ROTATION_VECTOR, 0UL, EVT_GRP_RPT_RV_GAME_BIT)
|
||||
, rv_ARVR_stabilized(this, SH2_ARVR_STABILIZED_RV, 0UL, EVT_GRP_RPT_RV_ARVR_S_BIT)
|
||||
, rv_ARVR_stabilized_game(this, SH2_ARVR_STABILIZED_GRV, 0UL, EVT_GRP_RPT_RV_ARVR_S_GAME_BIT)
|
||||
, rv_gyro_integrated(this, SH2_GYRO_INTEGRATED_RV, 0UL, EVT_GRP_RPT_GYRO_INTEGRATED_RV_BIT)
|
||||
, rv_geomagnetic(this, SH2_GEOMAGNETIC_ROTATION_VECTOR, 0UL, EVT_GRP_RPT_GEOMAG_RV_BIT)
|
||||
, raw_gyro(this, SH2_RAW_GYROSCOPE, 0UL, EVT_GRP_RPT_RAW_GYRO_BIT)
|
||||
, raw_accelerometer(this, SH2_RAW_ACCELEROMETER, 0UL, EVT_GRP_RPT_RAW_ACCELEROMETER_BIT)
|
||||
, raw_magnetometer(this, SH2_RAW_MAGNETOMETER, 0UL, EVT_GRP_RPT_RAW_MAGNETOMETER_BIT)
|
||||
, step_counter(this, SH2_STEP_COUNTER, 0UL, EVT_GRP_RPT_STEP_COUNTER_BIT)
|
||||
, activity_classifier(this, SH2_PERSONAL_ACTIVITY_CLASSIFIER, 0UL, EVT_GRP_RPT_ACTIVITY_CLASSIFIER_BIT)
|
||||
, stability_classifier(this, SH2_STABILITY_CLASSIFIER, 0UL, EVT_GRP_RPT_STABILITY_CLASSIFIER_BIT)
|
||||
, shake_detector(this, SH2_SHAKE_DETECTOR, 0UL, EVT_GRP_RPT_SHAKE_DETECTOR_BIT)
|
||||
, tap_detector(this, SH2_TAP_DETECTOR, 0UL, EVT_GRP_RPT_TAP_DETECTOR_BIT)
|
||||
, data_proc_task_hdl(NULL)
|
||||
, sh2_HAL_service_task_hdl(NULL)
|
||||
, cb_task_hdl(NULL)
|
||||
|
|
@ -1108,7 +1120,8 @@ esp_err_t BNO08x::re_enable_reports()
|
|||
bool BNO08x::data_available()
|
||||
{
|
||||
|
||||
if (xEventGroupWaitBits(evt_grp_bno08x_task, EVT_GRP_BNO08x_TASK_DATA_AVAILABLE, pdTRUE, pdFALSE, DATA_AVAILABLE_TIMEOUT_MS) != pdFALSE)
|
||||
if (xEventGroupWaitBits(evt_grp_bno08x_task, EVT_GRP_BNO08x_TASK_DATA_AVAILABLE, pdTRUE, pdFALSE, DATA_AVAILABLE_TIMEOUT_MS) &
|
||||
EVT_GRP_BNO08x_TASK_DATA_AVAILABLE)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
|
|
@ -1124,12 +1137,14 @@ bool BNO08x::data_available()
|
|||
bool BNO08x::data_available(uint8_t& report_ID)
|
||||
{
|
||||
|
||||
if (xEventGroupWaitBits(evt_grp_bno08x_task, EVT_GRP_BNO08x_TASK_DATA_AVAILABLE, pdTRUE, pdFALSE, DATA_AVAILABLE_TIMEOUT_MS) != pdFALSE)
|
||||
if (xEventGroupWaitBits(evt_grp_bno08x_task, EVT_GRP_BNO08x_TASK_DATA_AVAILABLE, pdTRUE, pdFALSE, DATA_AVAILABLE_TIMEOUT_MS) &
|
||||
EVT_GRP_BNO08x_TASK_DATA_AVAILABLE)
|
||||
{
|
||||
report_ID = most_recent_rpt;
|
||||
return true;
|
||||
}
|
||||
|
||||
report_ID = 0U;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -1157,19 +1172,6 @@ void BNO08x::register_cb(std::function<void(uint8_t report_ID)> cb_fxn)
|
|||
cb_list.push_back({0U, cb_fxn});
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Registers a callback to execute when new data from a specific report is received.
|
||||
*
|
||||
* @param report_ID The ID of the report the callback is to be registered to.
|
||||
* @param cb_fxn Pointer to the call-back function should be of void return type void input param.
|
||||
*
|
||||
* @return void, nothing to return
|
||||
*/
|
||||
void BNO08x::register_report_cb(uint8_t report_ID, std::function<void(void)> cb_fxn)
|
||||
{
|
||||
cb_list.push_back({report_ID, cb_fxn});
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Prints product IDs received at initialization.
|
||||
*
|
||||
|
|
@ -1193,6 +1195,68 @@ void BNO08x::print_product_ids()
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Converts a BNO08xActivity enum to string.
|
||||
*
|
||||
* @return The resulting string conversion of the enum.
|
||||
*/
|
||||
const char* BNO08x::activity_to_str(BNO08xActivity activity)
|
||||
{
|
||||
switch (activity)
|
||||
{
|
||||
case BNO08xActivity::UNKNOWN:
|
||||
return "UNKNOWN";
|
||||
case BNO08xActivity::IN_VEHICLE:
|
||||
return "IN_VEHICLE";
|
||||
case BNO08xActivity::ON_BICYCLE:
|
||||
return "ON_BICYCLE";
|
||||
case BNO08xActivity::ON_FOOT:
|
||||
return "ON_FOOT";
|
||||
case BNO08xActivity::STILL:
|
||||
return "STILL";
|
||||
case BNO08xActivity::TILTING:
|
||||
return "TILTING";
|
||||
case BNO08xActivity::WALKING:
|
||||
return "WALKING";
|
||||
case BNO08xActivity::RUNNING:
|
||||
return "RUNNING";
|
||||
case BNO08xActivity::ON_STAIRS:
|
||||
return "ON_STAIRS";
|
||||
case BNO08xActivity::UNDEFINED:
|
||||
return "UNDEFINED";
|
||||
default:
|
||||
return "UNDEFINED";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Converts a BNO08xStability enum to string.
|
||||
*
|
||||
* @return The resulting string conversion of the enum.
|
||||
*/
|
||||
const char* BNO08x::stability_to_str(BNO08xStability stability)
|
||||
{
|
||||
switch (stability)
|
||||
{
|
||||
case BNO08xStability::UNKNOWN:
|
||||
return "UNKNOWN";
|
||||
case BNO08xStability::ON_TABLE:
|
||||
return "ON_TABLE";
|
||||
case BNO08xStability::STATIONARY:
|
||||
return "STATIONARY";
|
||||
case BNO08xStability::STABLE:
|
||||
return "STABLE";
|
||||
case BNO08xStability::MOTION:
|
||||
return "MOTION";
|
||||
case BNO08xStability::RESERVED:
|
||||
return "RESERVED";
|
||||
case BNO08xStability::UNDEFINED:
|
||||
return "UNDEFINED";
|
||||
default:
|
||||
return "UNDEFINED";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief HINT interrupt service routine, handles falling edge of BNO08x HINT pin.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -4,11 +4,10 @@
|
|||
/**
|
||||
* @brief Enables a sensor report such that the BNO08x begins sending it.
|
||||
*
|
||||
* @param sensor_ID The ID of the sensor for the respective report to be enabled.
|
||||
* @param report_period_us The period/interval of the report in microseconds.
|
||||
* @param sensor_cfg Sensor special configuration.
|
||||
* @param sensor_cfg Sensor special configuration (optional, see BNO08xRpt::default_sensor_cfg for defaults).
|
||||
*
|
||||
* @return ESP_OK if report was successfully enabled.
|
||||
* @return True if report was successfully enabled.
|
||||
*/
|
||||
bool BNO08xRpt::enable(uint32_t time_between_reports, sh2_SensorConfig_t sensor_cfg)
|
||||
{
|
||||
|
|
@ -53,3 +52,15 @@ bool BNO08xRpt::disable(sh2_SensorConfig_t sensor_cfg)
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Registers a callback to execute when new data from a specific report is received.
|
||||
*
|
||||
* @param cb_fxn Pointer to the call-back function should be of void return type void input param.
|
||||
*
|
||||
* @return void, nothing to return
|
||||
*/
|
||||
void BNO08xRpt::register_cb(std::function<void(void)> cb_fxn)
|
||||
{
|
||||
imu->cb_list.push_back({ID, cb_fxn});
|
||||
}
|
||||
|
|
@ -1,5 +1,4 @@
|
|||
#include "BNO08xSH2HAL.hpp"
|
||||
#include "BNO08x_macros.hpp"
|
||||
#include "BNO08x.hpp"
|
||||
|
||||
BNO08x* BNO08xSH2HAL::imu;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#include "BNO08xRptAcceleration.hpp" // Include the header file for the class
|
||||
#include "BNO08xRptAcceleration.hpp"
|
||||
#include "BNO08x.hpp"
|
||||
|
||||
/**
|
||||
|
|
@ -20,10 +20,10 @@ void BNO08xRptAcceleration::update_data(sh2_SensorValue_t* sensor_val)
|
|||
*
|
||||
* @return Struct containing requested data.
|
||||
*/
|
||||
bno08x_accel_data_t BNO08xRptAcceleration::get()
|
||||
bno08x_accel_t BNO08xRptAcceleration::get()
|
||||
{
|
||||
imu->lock_user_data();
|
||||
bno08x_accel_data_t rqdata = data;
|
||||
bno08x_accel_t rqdata = data;
|
||||
imu->unlock_user_data();
|
||||
return rqdata;
|
||||
}
|
||||
|
|
@ -0,0 +1,58 @@
|
|||
#include "BNO08xRptActivityClassifier.hpp"
|
||||
#include "BNO08x.hpp"
|
||||
|
||||
/**
|
||||
* @brief Enables activity classifier reports such that the BNO08x begins sending them.
|
||||
*
|
||||
* @param time_between_reports The period/interval of the report in microseconds.
|
||||
* @param activities_to_enable Which activities to enable.
|
||||
* @param sensor_cfg Sensor special configuration (optional, see BNO08xRpt::default_sensor_cfg for defaults).
|
||||
*
|
||||
* @return True if report was successfully enabled.
|
||||
*/
|
||||
bool BNO08xRptActivityClassifier::enable(uint32_t time_between_reports, BNO08xActivityEnable activities_to_enable, sh2_SensorConfig_t sensor_cfg)
|
||||
{
|
||||
sensor_cfg.sensorSpecific = static_cast<uint8_t>(activities_to_enable); // this must be set regardless of user cfg or no reports will be received
|
||||
|
||||
return BNO08xRpt::enable(time_between_reports, sensor_cfg);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Updates activity classifier data from decoded sensor event.
|
||||
*
|
||||
* @param sensor_val The sh2_SensorValue_t struct used in sh2_decodeSensorEvent() call.
|
||||
*
|
||||
* @return void, nothing to return
|
||||
*/
|
||||
void BNO08xRptActivityClassifier::update_data(sh2_SensorValue_t* sensor_val)
|
||||
{
|
||||
imu->lock_user_data();
|
||||
data = sensor_val->un.personalActivityClassifier;
|
||||
imu->unlock_user_data();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Grabs most recent activity classifier data.
|
||||
*
|
||||
* @return Struct containing requested data.
|
||||
*/
|
||||
bno08x_activity_classifier_t BNO08xRptActivityClassifier::get()
|
||||
{
|
||||
imu->lock_user_data();
|
||||
bno08x_activity_classifier_t rqdata = data;
|
||||
imu->unlock_user_data();
|
||||
return rqdata;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Grabs most the most likely activity from most recent activity classifier data.
|
||||
*
|
||||
* @return BNO08xActivity object with detected state.
|
||||
*/
|
||||
BNO08xActivity BNO08xRptActivityClassifier::get_most_likely_activity()
|
||||
{
|
||||
imu->lock_user_data();
|
||||
BNO08xActivity rqdata = static_cast<BNO08xActivity>(data.mostLikelyState);
|
||||
imu->unlock_user_data();
|
||||
return rqdata;
|
||||
}
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
#include "BNO08xRptCalGyro.hpp"
|
||||
#include "BNO08x.hpp"
|
||||
|
||||
/**
|
||||
* @brief Updates calibrated gyro data from decoded sensor event.
|
||||
*
|
||||
* @param sensor_val The sh2_SensorValue_t struct used in sh2_decodeSensorEvent() call.
|
||||
*
|
||||
* @return void, nothing to return
|
||||
*/
|
||||
void BNO08xRptCalGyro::update_data(sh2_SensorValue_t* sensor_val)
|
||||
{
|
||||
imu->lock_user_data();
|
||||
data = sensor_val->un.gyroscope;
|
||||
imu->unlock_user_data();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Grabs most recent gyroscope data (velocity), units are in rad/s.
|
||||
*
|
||||
* @return Struct containing requested data.
|
||||
*/
|
||||
bno08x_gyro_t BNO08xRptCalGyro::get()
|
||||
{
|
||||
imu->lock_user_data();
|
||||
bno08x_gyro_t rqdata = data;
|
||||
imu->unlock_user_data();
|
||||
return rqdata;
|
||||
}
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
#include "BNO08xRptCalMagnetometer.hpp" // Include the header file for the class
|
||||
#include "BNO08xRptCalMagnetometer.hpp"
|
||||
#include "BNO08x.hpp"
|
||||
|
||||
/**
|
||||
* @brief Updates accelerometer data from decoded sensor event.
|
||||
* @brief Updates calibrated magnetometer data from decoded sensor event.
|
||||
*
|
||||
* @param sensor_val The sh2_SensorValue_t struct used in sh2_decodeSensorEvent() call.
|
||||
*
|
||||
|
|
@ -20,10 +20,10 @@ void BNO08xRptCalMagnetometer::update_data(sh2_SensorValue_t* sensor_val)
|
|||
*
|
||||
* @return Struct containing requested data.
|
||||
*/
|
||||
bno08x_magf_data_t BNO08xRptCalMagnetometer::get()
|
||||
bno08x_magf_t BNO08xRptCalMagnetometer::get()
|
||||
{
|
||||
imu->lock_user_data();
|
||||
bno08x_magf_data_t rqdata = data;
|
||||
bno08x_magf_t rqdata = data;
|
||||
imu->unlock_user_data();
|
||||
return rqdata;
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
#include "BNO08xRptGravity.hpp" // Include the header file for the class
|
||||
#include "BNO08xRptGravity.hpp"
|
||||
#include "BNO08x.hpp"
|
||||
|
||||
/**
|
||||
|
|
@ -20,10 +20,10 @@ void BNO08xRptGravity::update_data(sh2_SensorValue_t* sensor_val)
|
|||
*
|
||||
* @return Struct containing requested data.
|
||||
*/
|
||||
bno08x_accel_data_t BNO08xRptGravity::get()
|
||||
bno08x_accel_t BNO08xRptGravity::get()
|
||||
{
|
||||
imu->lock_user_data();
|
||||
bno08x_accel_data_t rqdata = data;
|
||||
bno08x_accel_t rqdata = data;
|
||||
imu->unlock_user_data();
|
||||
return rqdata;
|
||||
}
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
#include "BNO08xRptIGyroRV.hpp"
|
||||
#include "BNO08x.hpp"
|
||||
|
||||
/**
|
||||
* @brief Updates gyro integrated rotation vector data from decoded sensor event.
|
||||
*
|
||||
* @param sensor_val The sh2_SensorValue_t struct used in sh2_decodeSensorEvent() call.
|
||||
*
|
||||
* @return void, nothing to return
|
||||
*/
|
||||
void BNO08xRptIGyroRV::update_data(sh2_SensorValue_t* sensor_val)
|
||||
{
|
||||
imu->lock_user_data();
|
||||
data = sensor_val->un.gyroIntegratedRV;
|
||||
data_vel = sensor_val->un.gyroIntegratedRV;
|
||||
imu->unlock_user_data();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Grabs most recent gyro integrated rotation vector data.
|
||||
*
|
||||
* @param quat Struct to store requested unit quaternion data.
|
||||
* @param vel Struct to store requested velocity data (units in rad/s).
|
||||
*
|
||||
* @return void, nothing to return
|
||||
*/
|
||||
void BNO08xRptIGyroRV::get(bno08x_quat_t& quat, bno08x_ang_vel_t& vel)
|
||||
{
|
||||
imu->lock_user_data();
|
||||
quat = data;
|
||||
vel = data_vel;
|
||||
imu->unlock_user_data();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Grabs most recent gyro integrated rotation vector angular velocity data, units are in rad/s.
|
||||
*
|
||||
* @return Struct containing requested data.
|
||||
*/
|
||||
bno08x_ang_vel_t BNO08xRptIGyroRV::get_vel()
|
||||
{
|
||||
imu->lock_user_data();
|
||||
bno08x_ang_vel_t rqdata = data_vel;
|
||||
imu->unlock_user_data();
|
||||
return rqdata;
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
#include "BNO08xRptLinearAcceleration.hpp" // Include the header file for the class
|
||||
#include "BNO08xRptLinearAcceleration.hpp"
|
||||
#include "BNO08x.hpp"
|
||||
|
||||
/**
|
||||
|
|
@ -20,10 +20,10 @@ void BNO08xRptLinearAcceleration::update_data(sh2_SensorValue_t* sensor_val)
|
|||
*
|
||||
* @return Struct containing requested data.
|
||||
*/
|
||||
bno08x_accel_data_t BNO08xRptLinearAcceleration::get()
|
||||
bno08x_accel_t BNO08xRptLinearAcceleration::get()
|
||||
{
|
||||
imu->lock_user_data();
|
||||
bno08x_accel_data_t rqdata = data;
|
||||
bno08x_accel_t rqdata = data;
|
||||
imu->unlock_user_data();
|
||||
return rqdata;
|
||||
}
|
||||
|
|
@ -2,11 +2,12 @@
|
|||
#include "BNO08x.hpp"
|
||||
|
||||
/**
|
||||
* @brief Grabs most recent rotation vector data in form of unit quaternion, accuracy units in radians (if available).
|
||||
* @brief Grabs most recent rotation vector data in form of unit quaternion, accuracy units in radians (if available, else constant 0.0f).
|
||||
*
|
||||
* The following RV reports have accuracy data:
|
||||
*
|
||||
* - rotation vector
|
||||
* - geomagnetic rotation vector
|
||||
*
|
||||
*
|
||||
* @return Struct containing requested data.
|
||||
|
|
|
|||
|
|
@ -0,0 +1,16 @@
|
|||
#include "BNO08xRptRVGeomag.hpp"
|
||||
#include "BNO08x.hpp"
|
||||
|
||||
/**
|
||||
* @brief Updates geomagnetic rotation vector data from decoded sensor event.
|
||||
*
|
||||
* @param sensor_val The sh2_SensorValue_t struct used in sh2_decodeSensorEvent() call.
|
||||
*
|
||||
* @return void, nothing to return
|
||||
*/
|
||||
void BNO08xRptRVGeomag::update_data(sh2_SensorValue_t* sensor_val)
|
||||
{
|
||||
imu->lock_user_data();
|
||||
data = sensor_val->un.geoMagRotationVector;
|
||||
imu->unlock_user_data();
|
||||
}
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
#include "BNO08xRptRawMEMSAccelerometer.hpp"
|
||||
#include "BNO08x.hpp"
|
||||
|
||||
/**
|
||||
* @brief Updates raw accelerometer data from decoded sensor event.
|
||||
*
|
||||
* @param sensor_val The sh2_SensorValue_t struct used in sh2_decodeSensorEvent() call.
|
||||
*
|
||||
* @return void, nothing to return
|
||||
*/
|
||||
void BNO08xRptRawMEMSAccelerometer::update_data(sh2_SensorValue_t* sensor_val)
|
||||
{
|
||||
imu->lock_user_data();
|
||||
data = sensor_val->un.rawAccelerometer;
|
||||
imu->unlock_user_data();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Grabs most recent raw accelerometer data, units are ADC counts, time_stamp in microseconds.
|
||||
*
|
||||
* @return Struct containing requested data.
|
||||
*/
|
||||
bno08x_raw_accel_t BNO08xRptRawMEMSAccelerometer::get()
|
||||
{
|
||||
imu->lock_user_data();
|
||||
bno08x_raw_accel_t rqdata = data;
|
||||
imu->unlock_user_data();
|
||||
return rqdata;
|
||||
}
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
#include "BNO08xRptRawMEMSGyro.hpp"
|
||||
#include "BNO08x.hpp"
|
||||
|
||||
/**
|
||||
* @brief Updates raw mems gyro data from decoded sensor event.
|
||||
*
|
||||
* @param sensor_val The sh2_SensorValue_t struct used in sh2_decodeSensorEvent() call.
|
||||
*
|
||||
* @return void, nothing to return
|
||||
*/
|
||||
void BNO08xRptRawMEMSGyro::update_data(sh2_SensorValue_t* sensor_val)
|
||||
{
|
||||
imu->lock_user_data();
|
||||
data = sensor_val->un.rawGyroscope;
|
||||
imu->unlock_user_data();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Grabs most recent raw mems gyro report (units in ADC counts, time_stamp in microseconds)
|
||||
*
|
||||
* @return Struct containing requested data.
|
||||
*/
|
||||
bno08x_raw_gyro_t BNO08xRptRawMEMSGyro::get()
|
||||
{
|
||||
imu->lock_user_data();
|
||||
bno08x_raw_gyro_t rqdata = data;
|
||||
imu->unlock_user_data();
|
||||
return rqdata;
|
||||
}
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
#include "BNO08xRptRawMEMSMagnetometer.hpp"
|
||||
#include "BNO08x.hpp"
|
||||
|
||||
/**
|
||||
* @brief Updates raw magnetometer data from decoded sensor event.
|
||||
*
|
||||
* @param sensor_val The sh2_SensorValue_t struct used in sh2_decodeSensorEvent() call.
|
||||
*
|
||||
* @return void, nothing to return
|
||||
*/
|
||||
void BNO08xRptRawMEMSMagnetometer::update_data(sh2_SensorValue_t* sensor_val)
|
||||
{
|
||||
imu->lock_user_data();
|
||||
data = sensor_val->un.rawMagnetometer;
|
||||
imu->unlock_user_data();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Grabs most recent raw magnetometer data, units are ADC counts, time_stamp in microseconds.
|
||||
*
|
||||
* @return Struct containing requested data.
|
||||
*/
|
||||
bno08x_raw_magf_t BNO08xRptRawMEMSMagnetometer::get()
|
||||
{
|
||||
imu->lock_user_data();
|
||||
bno08x_raw_magf_t rqdata = data;
|
||||
imu->unlock_user_data();
|
||||
return rqdata;
|
||||
}
|
||||
|
|
@ -0,0 +1,53 @@
|
|||
#include "BNO08xRptStepCounter.hpp"
|
||||
#include "BNO08x.hpp"
|
||||
|
||||
/**
|
||||
* @brief Updates step counter data from decoded sensor event.
|
||||
*
|
||||
* @param sensor_val The sh2_SensorValue_t struct used in sh2_decodeSensorEvent() call.
|
||||
*
|
||||
* @return void, nothing to return
|
||||
*/
|
||||
void BNO08xRptStepCounter::update_data(sh2_SensorValue_t* sensor_val)
|
||||
{
|
||||
static uint16_t prev_steps = 0;
|
||||
|
||||
imu->lock_user_data();
|
||||
data = sensor_val->un.stepCounter;
|
||||
|
||||
if (prev_steps > data.steps)
|
||||
{
|
||||
// rollover detected
|
||||
step_accumulator += prev_steps;
|
||||
prev_steps = 0UL;
|
||||
}
|
||||
|
||||
prev_steps = data.steps;
|
||||
imu->unlock_user_data();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Grabs the total step count since boot, accounts for rollover in report data.
|
||||
*
|
||||
* @return Total steps since boot.
|
||||
*/
|
||||
uint32_t BNO08xRptStepCounter::get_total_steps()
|
||||
{
|
||||
imu->lock_user_data();
|
||||
uint32_t total_steps = step_accumulator + data.steps;
|
||||
imu->unlock_user_data();
|
||||
return total_steps;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Grabs most recent step counter data (rollover not accounted for in step count, just most recent report data).
|
||||
*
|
||||
* @return Struct containing requested data.
|
||||
*/
|
||||
bno08x_step_counter_t BNO08xRptStepCounter::get()
|
||||
{
|
||||
imu->lock_user_data();
|
||||
bno08x_step_counter_t rqdata = data;
|
||||
imu->unlock_user_data();
|
||||
return rqdata;
|
||||
}
|
||||
|
|
@ -0,0 +1,59 @@
|
|||
#include "BNO08xRptUncalGyro.hpp"
|
||||
#include "BNO08x.hpp"
|
||||
|
||||
/**
|
||||
* @brief Updates uncalibrated gyro data from decoded sensor event.
|
||||
*
|
||||
* @param sensor_val The sh2_SensorValue_t struct used in sh2_decodeSensorEvent() call.
|
||||
*
|
||||
* @return void, nothing to return
|
||||
*/
|
||||
void BNO08xRptUncalGyro::update_data(sh2_SensorValue_t* sensor_val)
|
||||
{
|
||||
imu->lock_user_data();
|
||||
data = sensor_val->un.gyroscopeUncal;
|
||||
bias_data = sensor_val->un.gyroscopeUncal;
|
||||
imu->unlock_user_data();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Grabs most recent uncalibrated gyroscope data, units are in rad/s.
|
||||
*
|
||||
* @param vel Reference to save velocity data.
|
||||
* @param bias Reference to save bias data.
|
||||
*
|
||||
* @return void, nothing to return
|
||||
*/
|
||||
void BNO08xRptUncalGyro::get(bno08x_gyro_t& vel, bno08x_gyro_bias_t& bias)
|
||||
{
|
||||
imu->lock_user_data();
|
||||
vel = data;
|
||||
bias = bias_data;
|
||||
imu->unlock_user_data();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Grabs most recent uncalibrated gyroscope velocity data, units are in rad/s.
|
||||
*
|
||||
* @return Struct containing requested data.
|
||||
*/
|
||||
bno08x_gyro_t BNO08xRptUncalGyro::get_vel()
|
||||
{
|
||||
imu->lock_user_data();
|
||||
bno08x_gyro_t rqdata = data;
|
||||
imu->unlock_user_data();
|
||||
return rqdata;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Grabs most recent uncalibrated gyroscope bias data, units are in rad/s.
|
||||
*
|
||||
* @return Struct containing requested data.
|
||||
*/
|
||||
bno08x_gyro_bias_t BNO08xRptUncalGyro::get_bias()
|
||||
{
|
||||
imu->lock_user_data();
|
||||
bno08x_gyro_bias_t rqdata = bias_data;
|
||||
imu->unlock_user_data();
|
||||
return rqdata;
|
||||
}
|
||||
|
|
@ -0,0 +1,59 @@
|
|||
#include "BNO08xRptUncalMagnetometer.hpp"
|
||||
#include "BNO08x.hpp"
|
||||
|
||||
/**
|
||||
* @brief Updates uncalibrated magf data from decoded sensor event.
|
||||
*
|
||||
* @param sensor_val The sh2_SensorValue_t struct used in sh2_decodeSensorEvent() call.
|
||||
*
|
||||
* @return void, nothing to return
|
||||
*/
|
||||
void BNO08xRptUncalMagnetometer::update_data(sh2_SensorValue_t* sensor_val)
|
||||
{
|
||||
imu->lock_user_data();
|
||||
data = sensor_val->un.magneticFieldUncal;
|
||||
bias_data = sensor_val->un.magneticFieldUncal;
|
||||
imu->unlock_user_data();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Grabs most recent uncalibrated magnetometer data, units are in uTesla.
|
||||
*
|
||||
* @param magf Struct to store requested magf data.
|
||||
* @param bias Struct to store requested bias data.
|
||||
*
|
||||
* @return void, nothing to return
|
||||
*/
|
||||
void BNO08xRptUncalMagnetometer::get(bno08x_magf_t& magf, bno08x_magf_bias_t& bias)
|
||||
{
|
||||
imu->lock_user_data();
|
||||
magf = data;
|
||||
bias = bias_data;
|
||||
imu->unlock_user_data();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Grabs most recent uncalibrated magnetometer magnetic field data, units are in uTesla.
|
||||
*
|
||||
* @return Struct containing requested data.
|
||||
*/
|
||||
bno08x_magf_t BNO08xRptUncalMagnetometer::get_magf()
|
||||
{
|
||||
imu->lock_user_data();
|
||||
bno08x_magf_t rqdata = data;
|
||||
imu->unlock_user_data();
|
||||
return rqdata;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Grabs most recent uncalibrated magnetometer bias data, units are in uTesla.
|
||||
*
|
||||
* @return Struct containing requested data.
|
||||
*/
|
||||
bno08x_magf_bias_t BNO08xRptUncalMagnetometer::get_bias()
|
||||
{
|
||||
imu->lock_user_data();
|
||||
bno08x_magf_bias_t rqdata = bias_data;
|
||||
imu->unlock_user_data();
|
||||
return rqdata;
|
||||
}
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
#include "BNO08xShakeDetector.hpp"
|
||||
#include "BNO08x.hpp"
|
||||
|
||||
/**
|
||||
* @brief Updates shake detector data from decoded sensor event.
|
||||
*
|
||||
* @param sensor_val The sh2_SensorValue_t struct used in sh2_decodeSensorEvent() call.
|
||||
*
|
||||
* @return void, nothing to return
|
||||
*/
|
||||
void BNO08xShakeDetector::update_data(sh2_SensorValue_t* sensor_val)
|
||||
{
|
||||
imu->lock_user_data();
|
||||
data = sensor_val->un.shakeDetector;
|
||||
imu->unlock_user_data();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Grabs most recent shake detector detector data.
|
||||
*
|
||||
* @return Struct containing the requested data.
|
||||
*/
|
||||
bno08x_shake_detector_t BNO08xShakeDetector::get()
|
||||
{
|
||||
imu->lock_user_data();
|
||||
bno08x_shake_detector_t rqdata = data;
|
||||
imu->unlock_user_data();
|
||||
return rqdata;
|
||||
}
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
#include "BNO08xStabilityClassifier.hpp"
|
||||
#include "BNO08x.hpp"
|
||||
|
||||
/**
|
||||
* @brief Updates stability classifier data from decoded sensor event.
|
||||
*
|
||||
* @param sensor_val The sh2_SensorValue_t struct used in sh2_decodeSensorEvent() call.
|
||||
*
|
||||
* @return void, nothing to return
|
||||
*/
|
||||
void BNO08xStabilityClassifier::update_data(sh2_SensorValue_t* sensor_val)
|
||||
{
|
||||
imu->lock_user_data();
|
||||
data = sensor_val->un.stabilityClassifier;
|
||||
imu->unlock_user_data();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Grabs most recent stability classifier data.
|
||||
*
|
||||
* @return BNO08xStability enum object with detected state.
|
||||
*/
|
||||
BNO08xStability BNO08xStabilityClassifier::get()
|
||||
{
|
||||
imu->lock_user_data();
|
||||
BNO08xStability rqdata = static_cast<BNO08xStability>(data.classification);
|
||||
imu->unlock_user_data();
|
||||
return rqdata;
|
||||
}
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
#include "BNO08xTapDetector.hpp"
|
||||
#include "BNO08x.hpp"
|
||||
|
||||
/**
|
||||
* @brief Enables tap detector reports such that the BNO08x begins sending them (only sends reports when a tap is detected).
|
||||
*
|
||||
* @param time_between_reports The period/interval of the report in microseconds.
|
||||
* @param sensor_cfg Sensor special configuration (optional, see BNO08xRpt::default_sensor_cfg for defaults).
|
||||
*
|
||||
* @return True if report was successfully enabled.
|
||||
*/
|
||||
bool BNO08xTapDetector::enable(uint32_t time_between_reports, sh2_SensorConfig_t sensor_cfg)
|
||||
{
|
||||
sensor_cfg.changeSensitivityEnabled = true; // this must be set regardless of user cfg or no reports will be received
|
||||
sensor_cfg.changeSensitivity = 0U; // this must be set regardless of user cfg or no reports will be received
|
||||
|
||||
return BNO08xRpt::enable(time_between_reports, sensor_cfg);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Updates tap detector data from decoded sensor event.
|
||||
*
|
||||
* @param sensor_val The sh2_SensorValue_t struct used in sh2_decodeSensorEvent() call.
|
||||
*
|
||||
* @return void, nothing to return
|
||||
*/
|
||||
void BNO08xTapDetector::update_data(sh2_SensorValue_t* sensor_val)
|
||||
{
|
||||
imu->lock_user_data();
|
||||
data = sensor_val->un.tapDetector;
|
||||
imu->unlock_user_data();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Grabs most recent tap detector detector data.
|
||||
*
|
||||
* @return Struct containing requested data;
|
||||
*/
|
||||
bno08x_tap_detector_t BNO08xTapDetector::get()
|
||||
{
|
||||
imu->lock_user_data();
|
||||
bno08x_tap_detector_t rqdata = data;
|
||||
imu->unlock_user_data();
|
||||
return rqdata;
|
||||
}
|
||||
Loading…
Reference in New Issue