more report tests
This commit is contained in:
parent
be5f8789b6
commit
7f47cff1ed
|
|
@ -423,7 +423,7 @@ class BNO08x
|
|||
portTICK_PERIOD_MS; ///<Max wait between HINT being asserted by BNO08x before transaction is considered failed (in miliseconds)
|
||||
|
||||
static const constexpr TickType_t HARD_RESET_DELAY_MS =
|
||||
200UL /
|
||||
100UL /
|
||||
portTICK_PERIOD_MS; ///<How long RST pin is held low during hard reset (min 10ns according to datasheet, but should be longer for stable operation)
|
||||
|
||||
static const constexpr TickType_t CMD_EXECUTION_DELAY_MS =
|
||||
|
|
|
|||
|
|
@ -2397,10 +2397,11 @@ void BNO08x::reset_all_data()
|
|||
raw_gyro_Z = 0U;
|
||||
gyro_accuracy = static_cast<uint16_t>(IMUAccuracy::UNDEFINED);
|
||||
|
||||
//reset quaternion to nan
|
||||
raw_quat_I = 0U;
|
||||
raw_quat_J = 0U;
|
||||
raw_quat_K = 0U;
|
||||
raw_quat_real = 1U;
|
||||
raw_quat_real = 0U;
|
||||
raw_quat_radian_accuracy = static_cast<uint16_t>(IMUAccuracy::UNDEFINED);
|
||||
quat_accuracy = static_cast<uint16_t>(IMUAccuracy::UNDEFINED);
|
||||
|
||||
|
|
@ -3673,7 +3674,11 @@ void BNO08x::data_proc_task()
|
|||
}
|
||||
else
|
||||
{
|
||||
print_packet(&packet);
|
||||
// clang-format on
|
||||
#ifdef CONFIG_ESP32_BNO08x_DEBUG_STATEMENTS
|
||||
print_packet(&packet);
|
||||
#endif
|
||||
//clang-format off
|
||||
xEventGroupSetBits(evt_grp_spi, EVT_GRP_SPI_RX_INVALID_PACKET_BIT); // indicated invalid packet to wait_for_data()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,16 +14,32 @@ typedef struct imu_report_data_t
|
|||
IMUAccuracy raw_quat_radian_accuracy;
|
||||
IMUAccuracy quat_accuracy;
|
||||
|
||||
float gyro_vel_x;
|
||||
float gyro_vel_y;
|
||||
float gyro_vel_z;
|
||||
|
||||
float accel_x;
|
||||
float accel_y;
|
||||
float accel_z;
|
||||
IMUAccuracy accel_accuracy;
|
||||
|
||||
} imu_report_data_t;
|
||||
|
||||
void update_report_data(imu_report_data_t* report_data, BNO08x* imu)
|
||||
{
|
||||
uint8_t accel_accuracy = 0;
|
||||
|
||||
report_data->quat_I = imu->get_quat_I();
|
||||
report_data->quat_J = imu->get_quat_J();
|
||||
report_data->quat_K = imu->get_quat_K();
|
||||
report_data->quat_real = imu->get_quat_real();
|
||||
report_data->raw_quat_radian_accuracy = static_cast<IMUAccuracy>(imu->get_raw_quat_radian_accuracy());
|
||||
report_data->quat_accuracy = static_cast<IMUAccuracy>(imu->get_quat_accuracy());
|
||||
|
||||
imu->get_gyro_velocity(report_data->gyro_vel_x, report_data->gyro_vel_y, report_data->gyro_vel_z);
|
||||
|
||||
imu->get_accel(report_data->accel_x, report_data->accel_y, report_data->accel_z, accel_accuracy);
|
||||
report_data->accel_accuracy = static_cast<IMUAccuracy>(accel_accuracy);
|
||||
}
|
||||
|
||||
TEST_CASE("Enable/Disable Rotation Vector", "[ReportEnableDisable]")
|
||||
|
|
@ -102,7 +118,7 @@ TEST_CASE("Enable/Disable Rotation Vector", "[ReportEnableDisable]")
|
|||
new_data = false;
|
||||
|
||||
// use "true" argument to force wait for data even if no reports are enabled
|
||||
if (imu->data_available(true))
|
||||
if (imu->data_available())
|
||||
{
|
||||
update_report_data(&report_data, imu);
|
||||
|
||||
|
|
@ -213,8 +229,7 @@ TEST_CASE("Enable/Disable Game Rotation Vector", "[ReportEnableDisable]")
|
|||
{
|
||||
new_data = false;
|
||||
|
||||
// use "true" argument to force wait for data even if no reports are enabled
|
||||
if (imu->data_available(true))
|
||||
if (imu->data_available())
|
||||
{
|
||||
update_report_data(&report_data, imu);
|
||||
|
||||
|
|
@ -252,5 +267,446 @@ TEST_CASE("Enable/Disable Game Rotation Vector", "[ReportEnableDisable]")
|
|||
|
||||
BNO08xTestHelper::print_test_msg(TEST_TAG, "Report disabled testing phase completed.");
|
||||
|
||||
BNO08xTestHelper::print_test_end_banner(TEST_TAG);
|
||||
}
|
||||
|
||||
TEST_CASE("Enable/Disable ARVR Stabilized Rotation Vector", "[ReportEnableDisable]")
|
||||
{
|
||||
const constexpr char* TEST_TAG = "Enable/Disable ARVR Stabilized Rotation Vector";
|
||||
BNO08x* imu = nullptr;
|
||||
imu_report_data_t report_data;
|
||||
bool new_data = false;
|
||||
char msg_buff[200] = {};
|
||||
|
||||
BNO08xTestHelper::print_test_start_banner(TEST_TAG);
|
||||
|
||||
imu = BNO08xTestHelper::get_test_imu();
|
||||
|
||||
// reset all data used in report test
|
||||
imu->reset_all_data();
|
||||
update_report_data(&report_data, imu);
|
||||
|
||||
BNO08xTestHelper::print_test_msg(TEST_TAG, "Report enabled testing phase started.");
|
||||
/*enable respective report to test and ensure it reports new data */
|
||||
imu->enable_ARVR_stabilized_rotation_vector(100000UL);
|
||||
|
||||
for (int i = 0; i < RX_REPORT_TRIAL_CNT; i++)
|
||||
{
|
||||
new_data = false;
|
||||
|
||||
if (imu->data_available())
|
||||
{
|
||||
update_report_data(&report_data, imu);
|
||||
|
||||
// check if any default values have been overwritten, implying new data from respective report
|
||||
if (report_data.quat_I != 0.0f)
|
||||
new_data = true;
|
||||
|
||||
if (report_data.quat_J != 0.0f)
|
||||
new_data = true;
|
||||
|
||||
if (report_data.quat_K != 0.0f)
|
||||
new_data = true;
|
||||
|
||||
if (report_data.quat_real != 1.0f)
|
||||
new_data = true;
|
||||
|
||||
// if the accuracy still contains its default value, something has gone wrong, a defined accuracy should be received with every report
|
||||
if (report_data.quat_accuracy == IMUAccuracy::UNDEFINED)
|
||||
new_data = false;
|
||||
|
||||
if (report_data.raw_quat_radian_accuracy == IMUAccuracy::UNDEFINED)
|
||||
new_data = false;
|
||||
}
|
||||
|
||||
// assert whether new data was received or not
|
||||
TEST_ASSERT_EQUAL(true, new_data);
|
||||
|
||||
sprintf(msg_buff, "Enabled Report Rx Data Trial %d Success: I: %.2lf J: %.2lf K: %.2lf real: %.2lf", (i + 1), report_data.quat_I,
|
||||
report_data.quat_J, report_data.quat_K, report_data.quat_real);
|
||||
BNO08xTestHelper::print_test_msg(TEST_TAG, msg_buff);
|
||||
|
||||
// reset all data used in report test
|
||||
imu->reset_all_data();
|
||||
update_report_data(&report_data, imu);
|
||||
}
|
||||
|
||||
BNO08xTestHelper::print_test_msg(TEST_TAG, "Report enabled testing phase completed.");
|
||||
|
||||
BNO08xTestHelper::print_test_msg(TEST_TAG, "Report disabled testing phase started.");
|
||||
/*disable respective report to test and ensure it stops reporting new data */
|
||||
imu->disable_ARVR_stabilized_rotation_vector();
|
||||
for (int i = 0; i < RX_REPORT_TRIAL_CNT; i++)
|
||||
{
|
||||
new_data = false;
|
||||
|
||||
if (imu->data_available())
|
||||
{
|
||||
update_report_data(&report_data, imu);
|
||||
|
||||
// check if any default values have been overwritten, implying new data from respective report
|
||||
if (report_data.quat_I != 0.0f)
|
||||
new_data = true;
|
||||
|
||||
if (report_data.quat_J != 0.0f)
|
||||
new_data = true;
|
||||
|
||||
if (report_data.quat_K != 0.0f)
|
||||
new_data = true;
|
||||
|
||||
if (report_data.quat_real != 1.0f)
|
||||
new_data = true;
|
||||
|
||||
// if the accuracy does not contain its default value, something has gone wrong, respective report should be disabled
|
||||
if (report_data.quat_accuracy != IMUAccuracy::UNDEFINED)
|
||||
new_data = true;
|
||||
|
||||
if (report_data.raw_quat_radian_accuracy != IMUAccuracy::UNDEFINED)
|
||||
new_data = true;
|
||||
}
|
||||
|
||||
// assert that no new data from this report has been received
|
||||
TEST_ASSERT_NOT_EQUAL(true, new_data);
|
||||
|
||||
sprintf(msg_buff, "Disabled Report No Rx Data Trial %d Success", (i + 1));
|
||||
BNO08xTestHelper::print_test_msg(TEST_TAG, msg_buff);
|
||||
|
||||
// reset all data used in report test
|
||||
imu->reset_all_data();
|
||||
update_report_data(&report_data, imu);
|
||||
}
|
||||
|
||||
BNO08xTestHelper::print_test_msg(TEST_TAG, "Report disabled testing phase completed.");
|
||||
|
||||
BNO08xTestHelper::print_test_end_banner(TEST_TAG);
|
||||
}
|
||||
|
||||
TEST_CASE("Enable/Disable ARVR Stabilized Game Rotation Vector", "[ReportEnableDisable]")
|
||||
{
|
||||
const constexpr char* TEST_TAG = "Enable/Disable ARVR Stabilized Game Rotation Vector";
|
||||
BNO08x* imu = nullptr;
|
||||
imu_report_data_t report_data;
|
||||
bool new_data = false;
|
||||
char msg_buff[200] = {};
|
||||
|
||||
BNO08xTestHelper::print_test_start_banner(TEST_TAG);
|
||||
|
||||
imu = BNO08xTestHelper::get_test_imu();
|
||||
|
||||
// reset all data used in report test
|
||||
imu->reset_all_data();
|
||||
update_report_data(&report_data, imu);
|
||||
|
||||
BNO08xTestHelper::print_test_msg(TEST_TAG, "Report enabled testing phase started.");
|
||||
/*enable respective report to test and ensure it reports new data */
|
||||
imu->enable_ARVR_stabilized_game_rotation_vector(100000UL);
|
||||
|
||||
for (int i = 0; i < RX_REPORT_TRIAL_CNT; i++)
|
||||
{
|
||||
new_data = false;
|
||||
|
||||
if (imu->data_available())
|
||||
{
|
||||
update_report_data(&report_data, imu);
|
||||
|
||||
// check if any default values have been overwritten, implying new data from respective report
|
||||
if (report_data.quat_I != 0.0f)
|
||||
new_data = true;
|
||||
|
||||
if (report_data.quat_J != 0.0f)
|
||||
new_data = true;
|
||||
|
||||
if (report_data.quat_K != 0.0f)
|
||||
new_data = true;
|
||||
|
||||
if (report_data.quat_real != 1.0f)
|
||||
new_data = true;
|
||||
|
||||
// if the accuracy still contains its default value, something has gone wrong, a defined accuracy should be received with every report
|
||||
if (report_data.quat_accuracy == IMUAccuracy::UNDEFINED)
|
||||
new_data = false;
|
||||
|
||||
if (report_data.raw_quat_radian_accuracy == IMUAccuracy::UNDEFINED)
|
||||
new_data = false;
|
||||
}
|
||||
|
||||
// assert whether new data was received or not
|
||||
TEST_ASSERT_EQUAL(true, new_data);
|
||||
|
||||
sprintf(msg_buff, "Enabled Report Rx Data Trial %d Success: I: %.2lf J: %.2lf K: %.2lf real: %.2lf", (i + 1), report_data.quat_I,
|
||||
report_data.quat_J, report_data.quat_K, report_data.quat_real);
|
||||
BNO08xTestHelper::print_test_msg(TEST_TAG, msg_buff);
|
||||
|
||||
// reset all data used in report test
|
||||
imu->reset_all_data();
|
||||
update_report_data(&report_data, imu);
|
||||
}
|
||||
|
||||
BNO08xTestHelper::print_test_msg(TEST_TAG, "Report enabled testing phase completed.");
|
||||
|
||||
BNO08xTestHelper::print_test_msg(TEST_TAG, "Report disabled testing phase started.");
|
||||
/*disable respective report to test and ensure it stops reporting new data */
|
||||
imu->disable_ARVR_stabilized_game_rotation_vector();
|
||||
for (int i = 0; i < RX_REPORT_TRIAL_CNT; i++)
|
||||
{
|
||||
new_data = false;
|
||||
|
||||
if (imu->data_available())
|
||||
{
|
||||
update_report_data(&report_data, imu);
|
||||
|
||||
// check if any default values have been overwritten, implying new data from respective report
|
||||
if (report_data.quat_I != 0.0f)
|
||||
new_data = true;
|
||||
|
||||
if (report_data.quat_J != 0.0f)
|
||||
new_data = true;
|
||||
|
||||
if (report_data.quat_K != 0.0f)
|
||||
new_data = true;
|
||||
|
||||
if (report_data.quat_real != 1.0f)
|
||||
new_data = true;
|
||||
|
||||
// if the accuracy does not contain its default value, something has gone wrong, respective report should be disabled
|
||||
if (report_data.quat_accuracy != IMUAccuracy::UNDEFINED)
|
||||
new_data = true;
|
||||
|
||||
if (report_data.raw_quat_radian_accuracy != IMUAccuracy::UNDEFINED)
|
||||
new_data = true;
|
||||
}
|
||||
|
||||
// assert that no new data from this report has been received
|
||||
TEST_ASSERT_NOT_EQUAL(true, new_data);
|
||||
|
||||
sprintf(msg_buff, "Disabled Report No Rx Data Trial %d Success", (i + 1));
|
||||
BNO08xTestHelper::print_test_msg(TEST_TAG, msg_buff);
|
||||
|
||||
// reset all data used in report test
|
||||
imu->reset_all_data();
|
||||
update_report_data(&report_data, imu);
|
||||
}
|
||||
|
||||
BNO08xTestHelper::print_test_msg(TEST_TAG, "Report disabled testing phase completed.");
|
||||
|
||||
BNO08xTestHelper::print_test_end_banner(TEST_TAG);
|
||||
}
|
||||
|
||||
TEST_CASE("Enable/Disable Gyro Integrated Roation Vector", "[ReportEnableDisable]")
|
||||
{
|
||||
const constexpr char* TEST_TAG = "Enable/Disable Gyro Integrated Roation Vector";
|
||||
BNO08x* imu = nullptr;
|
||||
imu_report_data_t report_data;
|
||||
bool new_data = false;
|
||||
char msg_buff[200] = {};
|
||||
|
||||
BNO08xTestHelper::print_test_start_banner(TEST_TAG);
|
||||
|
||||
imu = BNO08xTestHelper::get_test_imu();
|
||||
|
||||
// reset all data used in report test
|
||||
imu->reset_all_data();
|
||||
update_report_data(&report_data, imu);
|
||||
|
||||
BNO08xTestHelper::print_test_msg(TEST_TAG, "Report enabled testing phase started.");
|
||||
/*enable respective report to test and ensure it reports new data */
|
||||
imu->enable_gyro_integrated_rotation_vector(100000UL);
|
||||
|
||||
for (int i = 0; i < RX_REPORT_TRIAL_CNT; i++)
|
||||
{
|
||||
new_data = false;
|
||||
|
||||
if (imu->data_available())
|
||||
{
|
||||
update_report_data(&report_data, imu);
|
||||
|
||||
// check if any default values have been overwritten, implying new data from respective report
|
||||
if (report_data.quat_I != 0.0f)
|
||||
new_data = true;
|
||||
|
||||
if (report_data.quat_J != 0.0f)
|
||||
new_data = true;
|
||||
|
||||
if (report_data.quat_K != 0.0f)
|
||||
new_data = true;
|
||||
|
||||
if (report_data.quat_real != 1.0f)
|
||||
new_data = true;
|
||||
|
||||
if (report_data.gyro_vel_x != 0.0f)
|
||||
new_data = true;
|
||||
|
||||
if (report_data.gyro_vel_y != 0.0f)
|
||||
new_data = true;
|
||||
|
||||
if (report_data.gyro_vel_z != 0.0f)
|
||||
new_data = true;
|
||||
}
|
||||
|
||||
// assert whether new data was received or not
|
||||
TEST_ASSERT_EQUAL(true, new_data);
|
||||
|
||||
sprintf(msg_buff,
|
||||
"Enabled Report Rx Data Trial %d Success: I: %.2lf J: %.2lf K: %.2lf real: %.2lf gyro vel X: %.2lf gyro vel Y: %.2lf gyro vel Z: "
|
||||
"%.2lf ",
|
||||
(i + 1), report_data.quat_I, report_data.quat_J, report_data.quat_K, report_data.quat_real, report_data.gyro_vel_x,
|
||||
report_data.gyro_vel_y, report_data.gyro_vel_z);
|
||||
BNO08xTestHelper::print_test_msg(TEST_TAG, msg_buff);
|
||||
|
||||
// reset all data used in report test
|
||||
imu->reset_all_data();
|
||||
update_report_data(&report_data, imu);
|
||||
}
|
||||
|
||||
BNO08xTestHelper::print_test_msg(TEST_TAG, "Report enabled testing phase completed.");
|
||||
|
||||
BNO08xTestHelper::print_test_msg(TEST_TAG, "Report disabled testing phase started.");
|
||||
/*disable respective report to test and ensure it stops reporting new data */
|
||||
imu->disable_gyro_integrated_rotation_vector();
|
||||
for (int i = 0; i < RX_REPORT_TRIAL_CNT; i++)
|
||||
{
|
||||
new_data = false;
|
||||
|
||||
if (imu->data_available())
|
||||
{
|
||||
update_report_data(&report_data, imu);
|
||||
|
||||
// check if any default values have been overwritten, implying new data from respective report
|
||||
if (report_data.quat_I != 0.0f)
|
||||
new_data = true;
|
||||
|
||||
if (report_data.quat_J != 0.0f)
|
||||
new_data = true;
|
||||
|
||||
if (report_data.quat_K != 0.0f)
|
||||
new_data = true;
|
||||
|
||||
if (report_data.quat_real != 1.0f)
|
||||
new_data = true;
|
||||
|
||||
if (report_data.gyro_vel_x != 0.0f)
|
||||
new_data = true;
|
||||
|
||||
if (report_data.gyro_vel_y != 0.0f)
|
||||
new_data = true;
|
||||
|
||||
if (report_data.gyro_vel_z != 0.0f)
|
||||
new_data = true;
|
||||
}
|
||||
|
||||
// assert that no new data from this report has been received
|
||||
TEST_ASSERT_NOT_EQUAL(true, new_data);
|
||||
|
||||
sprintf(msg_buff, "Disabled Report No Rx Data Trial %d Success", (i + 1));
|
||||
BNO08xTestHelper::print_test_msg(TEST_TAG, msg_buff);
|
||||
|
||||
// reset all data used in report test
|
||||
imu->reset_all_data();
|
||||
update_report_data(&report_data, imu);
|
||||
}
|
||||
|
||||
BNO08xTestHelper::print_test_msg(TEST_TAG, "Report disabled testing phase completed.");
|
||||
|
||||
BNO08xTestHelper::print_test_end_banner(TEST_TAG);
|
||||
}
|
||||
|
||||
TEST_CASE("Enable/Disable Accelerometer", "[ReportEnableDisable]")
|
||||
{
|
||||
const constexpr char* TEST_TAG = "Enable/Disable Accelerometer";
|
||||
BNO08x* imu = nullptr;
|
||||
imu_report_data_t report_data;
|
||||
bool new_data = false;
|
||||
char msg_buff[200] = {};
|
||||
|
||||
BNO08xTestHelper::print_test_start_banner(TEST_TAG);
|
||||
|
||||
imu = BNO08xTestHelper::get_test_imu();
|
||||
|
||||
// reset all data used in report test
|
||||
imu->reset_all_data();
|
||||
update_report_data(&report_data, imu);
|
||||
|
||||
BNO08xTestHelper::print_test_msg(TEST_TAG, "Report enabled testing phase started.");
|
||||
/*enable respective report to test and ensure it reports new data */
|
||||
imu->enable_accelerometer(100000UL);
|
||||
|
||||
for (int i = 0; i < RX_REPORT_TRIAL_CNT; i++)
|
||||
{
|
||||
new_data = false;
|
||||
|
||||
if (imu->data_available())
|
||||
{
|
||||
update_report_data(&report_data, imu);
|
||||
|
||||
// check if any default values have been overwritten, implying new data from respective report
|
||||
if (report_data.accel_x != 0.0f)
|
||||
new_data = true;
|
||||
|
||||
if (report_data.accel_y != 0.0f)
|
||||
new_data = true;
|
||||
|
||||
if (report_data.accel_z != 0.0f)
|
||||
new_data = true;
|
||||
|
||||
// if the accuracy still contains its default value, something has gone wrong, a defined accuracy should be received with every report
|
||||
if (report_data.accel_accuracy == IMUAccuracy::UNDEFINED)
|
||||
new_data = false;
|
||||
}
|
||||
|
||||
// assert whether new data was received or not
|
||||
TEST_ASSERT_EQUAL(true, new_data);
|
||||
|
||||
sprintf(msg_buff,
|
||||
"Enabled Report Rx Data Trial %d Success: accel X: %.2lf accel Y: %.2lf accel Z: "
|
||||
"%.2lf ",
|
||||
(i + 1), report_data.accel_x, report_data.accel_y, report_data.accel_z);
|
||||
BNO08xTestHelper::print_test_msg(TEST_TAG, msg_buff);
|
||||
|
||||
// reset all data used in report test
|
||||
imu->reset_all_data();
|
||||
update_report_data(&report_data, imu);
|
||||
}
|
||||
|
||||
BNO08xTestHelper::print_test_msg(TEST_TAG, "Report enabled testing phase completed.");
|
||||
|
||||
BNO08xTestHelper::print_test_msg(TEST_TAG, "Report disabled testing phase started.");
|
||||
/*disable respective report to test and ensure it stops reporting new data */
|
||||
imu->disable_accelerometer();
|
||||
for (int i = 0; i < RX_REPORT_TRIAL_CNT; i++)
|
||||
{
|
||||
new_data = false;
|
||||
|
||||
if (imu->data_available())
|
||||
{
|
||||
update_report_data(&report_data, imu);
|
||||
|
||||
// check if any default values have been overwritten, implying new data from respective report
|
||||
if (report_data.accel_x != 0.0f)
|
||||
new_data = true;
|
||||
|
||||
if (report_data.accel_y != 0.0f)
|
||||
new_data = true;
|
||||
|
||||
if (report_data.accel_z != 0.0f)
|
||||
new_data = true;
|
||||
|
||||
// if the accuracy does not contain its default value, something has gone wrong, respective report should be disabled
|
||||
if (report_data.accel_accuracy != IMUAccuracy::UNDEFINED)
|
||||
new_data = true;
|
||||
}
|
||||
|
||||
// assert that no new data from this report has been received
|
||||
TEST_ASSERT_NOT_EQUAL(true, new_data);
|
||||
|
||||
sprintf(msg_buff, "Disabled Report No Rx Data Trial %d Success", (i + 1));
|
||||
BNO08xTestHelper::print_test_msg(TEST_TAG, msg_buff);
|
||||
|
||||
// reset all data used in report test
|
||||
imu->reset_all_data();
|
||||
update_report_data(&report_data, imu);
|
||||
}
|
||||
|
||||
BNO08xTestHelper::print_test_msg(TEST_TAG, "Report disabled testing phase completed.");
|
||||
|
||||
BNO08xTestHelper::print_test_end_banner(TEST_TAG);
|
||||
}
|
||||
Loading…
Reference in New Issue