activity classifier calibration routine bugfix

This commit is contained in:
myles-parfeniuk 2024-07-25 01:17:50 -07:00
parent aedfbd846c
commit 18a1a6cff0
2 changed files with 32 additions and 31 deletions

View File

@ -452,9 +452,9 @@ bool BNO08x::receive_packet()
* *
* @return void, nothing to return * @return void, nothing to return
*/ */
void BNO08x::enable_report(uint8_t report_ID, uint32_t time_between_reports, const EventBits_t report_evt_grp_bit) void BNO08x::enable_report(uint8_t report_ID, uint32_t time_between_reports, const EventBits_t report_evt_grp_bit, uint32_t special_config)
{ {
queue_feature_command(report_ID, time_between_reports); queue_feature_command(report_ID, time_between_reports, special_config);
if (wait_for_tx_done()) // wait for transmit operation to complete if (wait_for_tx_done()) // wait for transmit operation to complete
{ {
xEventGroupSetBits(evt_grp_report_en, report_evt_grp_bit); xEventGroupSetBits(evt_grp_report_en, report_evt_grp_bit);
@ -494,6 +494,10 @@ void BNO08x::disable_report(uint8_t report_ID, const EventBits_t report_evt_grp_
/** /**
* @brief Queues an SHTP packet to be sent via SPI. * @brief Queues an SHTP packet to be sent via SPI.
*
* @param SHTP channel number
* @param data_length data length in bytes
* @param commands array containing data to be sent
* *
* @return void, nothing to return * @return void, nothing to return
*/ */
@ -770,10 +774,10 @@ bool BNO08x::run_full_calibration_routine()
calibrate_all(); // Turn on cal for Accel, Gyro, and Mag calibrate_all(); // Turn on cal for Accel, Gyro, and Mag
// Enable Game Rotation Vector output // Enable Game Rotation Vector output
enable_game_rotation_vector(100); // Send data update every 100ms enable_game_rotation_vector(100000UL); // Send data update every 100ms
// Enable Magnetic Field output // Enable Magnetic Field output
enable_magnetometer(100); // Send data update every 100ms enable_magnetometer(100000UL); // Send data update every 100ms
while (1) while (1)
{ {
@ -1354,7 +1358,7 @@ void BNO08x::enable_stability_classifier(uint32_t time_between_reports)
void BNO08x::enable_activity_classifier(uint32_t time_between_reports, uint32_t activities_to_enable, uint8_t (&activity_confidence_vals)[9]) void BNO08x::enable_activity_classifier(uint32_t time_between_reports, uint32_t activities_to_enable, uint8_t (&activity_confidence_vals)[9])
{ {
activity_confidences = activity_confidence_vals; // Store pointer to array activity_confidences = activity_confidence_vals; // Store pointer to array
enable_report(SENSOR_REPORT_ID_PERSONAL_ACTIVITY_CLASSIFIER, time_between_reports, EVT_GRP_RPT_ACTIVITY_CLASSIFIER_BIT); enable_report(SENSOR_REPORT_ID_PERSONAL_ACTIVITY_CLASSIFIER, time_between_reports, EVT_GRP_RPT_ACTIVITY_CLASSIFIER_BIT, activities_to_enable);
} }
/** /**
@ -2744,20 +2748,6 @@ void BNO08x::queue_tare_command(uint8_t command, uint8_t axis, uint8_t rotation_
queue_command(COMMAND_TARE, commands); queue_command(COMMAND_TARE, commands);
} }
/**
* @brief Queues a packet containing a command with a request for sensor reports, reported periodically. (See Ref.
* Manual 6.5.4)
*
* @param report_ID ID of sensor report being requested.
* @param time_between_reports Desired time between reports.
*
* @return void, nothing to return
*/
void BNO08x::queue_feature_command(uint8_t report_ID, uint32_t time_between_reports)
{
queue_feature_command(report_ID, time_between_reports, 0); // No specific config
}
/** /**
* @brief Static function used to launch spi task. * @brief Static function used to launch spi task.
* *

View File

@ -56,15 +56,15 @@ typedef struct bno08x_config_t
/// To modify default GPIO pins, run "idf.py menuconfig" esp32_BNO08x->GPIO Configuration. /// To modify default GPIO pins, run "idf.py menuconfig" esp32_BNO08x->GPIO Configuration.
/// Alternatively, edit the default values in "Kconfig.projbuild" /// Alternatively, edit the default values in "Kconfig.projbuild"
bno08x_config_t() bno08x_config_t()
: spi_peripheral((spi_host_device_t)CONFIG_ESP32_BNO08x_SPI_HOST) : spi_peripheral((spi_host_device_t) CONFIG_ESP32_BNO08x_SPI_HOST)
, io_mosi((gpio_num_t)CONFIG_ESP32_BNO08X_GPIO_DI) // default: , io_mosi((gpio_num_t) CONFIG_ESP32_BNO08X_GPIO_DI) // default:
, io_miso((gpio_num_t)CONFIG_ESP32_BNO08X_GPIO_SDA) // default: , io_miso((gpio_num_t) CONFIG_ESP32_BNO08X_GPIO_SDA) // default:
, io_sclk((gpio_num_t)CONFIG_ESP32_BNO08X_GPIO_SCL) // default: , io_sclk((gpio_num_t) CONFIG_ESP32_BNO08X_GPIO_SCL) // default:
, io_cs((gpio_num_t)CONFIG_ESP32_BNO08X_GPIO_CS) // default: , io_cs((gpio_num_t) CONFIG_ESP32_BNO08X_GPIO_CS) // default:
, io_int((gpio_num_t)CONFIG_ESP32_BNO08X_GPIO_HINT) // default: , io_int((gpio_num_t) CONFIG_ESP32_BNO08X_GPIO_HINT) // default:
, io_rst((gpio_num_t)CONFIG_ESP32_BNO08X_GPIO_RST) // default: , io_rst((gpio_num_t) CONFIG_ESP32_BNO08X_GPIO_RST) // default:
, io_wake((gpio_num_t)CONFIG_ESP32_BNO08X_GPIO_WAKE) // default: -1 (unused) , io_wake((gpio_num_t) CONFIG_ESP32_BNO08X_GPIO_WAKE) // default: -1 (unused)
, sclk_speed((uint32_t)CONFIG_ESP32_BNO08X_SCL_SPEED_HZ) // default: 2MH , sclk_speed((uint32_t) CONFIG_ESP32_BNO08X_SCL_SPEED_HZ) // default: 2MH
{ {
} }
@ -255,6 +255,18 @@ class BNO08x
static const constexpr uint16_t FRS_RECORD_ID_ROTATION_VECTOR = static const constexpr uint16_t FRS_RECORD_ID_ROTATION_VECTOR =
0xE30B; ///< Rotation vector record ID, to be passed in metadata functions like get_Q1() 0xE30B; ///< Rotation vector record ID, to be passed in metadata functions like get_Q1()
// Activity classifier bits
static const constexpr uint16_t ACTIVITY_CLASSIFIER_UNKNOWN_EN = (1 << 0);
static const constexpr uint16_t ACTIVITY_CLASSIFIER_IN_VEHICLE_EN = (1 << 1);
static const constexpr uint16_t ACTIVITY_CLASSIFIER_ON_BICYCLE_EN = (1 << 2);
static const constexpr uint16_t ACTIVITY_CLASSIFIER_ON_FOOT_EN = (1 << 3);
static const constexpr uint16_t ACTIVITY_CLASSIFIER_STILL_EN = (1 << 4);
static const constexpr uint16_t ACTIVITY_CLASSIFIER_TILTING_EN = (1 << 5);
static const constexpr uint16_t ACTIVITY_CLASSIFIER_WALKING_EN = (1 << 6);
static const constexpr uint16_t ACTIVITY_CLASSIFIER_RUNNING_EN = (1 << 7);
static const constexpr uint16_t ACTIVITY_CLASSIFIER_ON_STAIRS_EN = (1 << 8);
static const constexpr uint16_t ACTIVITY_CLASSIFIER_ALL_EN = 0x1F;
static const constexpr uint8_t TARE_AXIS_ALL = 0x07; ///< Tare all axes (used with tare now command) static const constexpr uint8_t TARE_AXIS_ALL = 0x07; ///< Tare all axes (used with tare now command)
static const constexpr uint8_t TARE_AXIS_Z = 0x04; ///< Tar yaw axis only (used with tare now command) static const constexpr uint8_t TARE_AXIS_Z = 0x04; ///< Tar yaw axis only (used with tare now command)
@ -296,12 +308,11 @@ class BNO08x
bool wait_for_data(); bool wait_for_data();
bool receive_packet(); bool receive_packet();
void send_packet(bno08x_tx_packet_t* packet); void send_packet(bno08x_tx_packet_t* packet);
void enable_report(uint8_t report_ID, uint32_t time_between_reports, const EventBits_t report_evt_grp_bit); void enable_report(uint8_t report_ID, uint32_t time_between_reports, const EventBits_t report_evt_grp_bit, uint32_t special_config = 0);
void disable_report(uint8_t report_ID, const EventBits_t report_evt_grp_bit); void disable_report(uint8_t report_ID, const EventBits_t report_evt_grp_bit);
void queue_packet(uint8_t channel_number, uint8_t data_length, uint8_t* commands); void queue_packet(uint8_t channel_number, uint8_t data_length, uint8_t* commands);
void queue_command(uint8_t command, uint8_t* commands); void queue_command(uint8_t command, uint8_t* commands);
void queue_feature_command(uint8_t report_ID, uint32_t time_between_reports); void queue_feature_command(uint8_t report_ID, uint32_t time_between_reports, uint32_t specific_config = 0);
void queue_feature_command(uint8_t report_ID, uint32_t time_between_reports, uint32_t specific_config);
void queue_calibrate_command(uint8_t _to_calibrate); void queue_calibrate_command(uint8_t _to_calibrate);
void queue_tare_command(uint8_t command, uint8_t axis = TARE_AXIS_ALL, uint8_t rotation_vector_basis = TARE_ROTATION_VECTOR); void queue_tare_command(uint8_t command, uint8_t axis = TARE_AXIS_ALL, uint8_t rotation_vector_basis = TARE_ROTATION_VECTOR);
void queue_request_product_id_command(); void queue_request_product_id_command();