-
Notifications
You must be signed in to change notification settings - Fork 132
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1187 from luxonis/v3_imu_rvc4
Add IMU support for RVC4
- Loading branch information
Showing
5 changed files
with
58 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#include <catch2/catch_all.hpp> | ||
#include <catch2/catch_test_macros.hpp> | ||
#include <initializer_list> | ||
#include "depthai/depthai.hpp" | ||
#include "depthai/properties/IMUProperties.hpp" | ||
|
||
|
||
void basicIMUTest(float fps, std::initializer_list<dai::IMUSensor> sensors) { | ||
dai::Pipeline p; | ||
auto imu = p.create<dai::node::IMU>(); | ||
for(auto sensor : sensors) { | ||
imu->enableIMUSensor(sensor, fps); | ||
} | ||
auto benchmarkIn = p.create<dai::node::BenchmarkIn>(); | ||
imu->out.link(benchmarkIn->input); | ||
auto reportQueue = benchmarkIn->report.createOutputQueue(); | ||
p.start(); | ||
for(int i = 0; i < 10; i++) { | ||
auto reportData = reportQueue->get<dai::BenchmarkReport>(); | ||
REQUIRE(reportData != nullptr); | ||
REQUIRE(reportData->numMessagesReceived > 1); | ||
REQUIRE(reportData->fps == Catch::Approx(fps).epsilon(0.3)); | ||
REQUIRE(reportData->averageLatency > 0.0); | ||
REQUIRE(reportData->averageLatency < 1.0); // Sanity check that the latency measurement works correctly | ||
} | ||
} | ||
|
||
TEST_CASE("Test IMU, 30Hz, accelerometer, gyroscope") { | ||
basicIMUTest(30.0f, {dai::IMUSensor::ACCELEROMETER_RAW, dai::IMUSensor::GYROSCOPE_RAW}); | ||
} | ||
|
||
TEST_CASE("Test IMU, 100Hz, accelerometer, gyroscope") { | ||
basicIMUTest(100.0f, {dai::IMUSensor::ACCELEROMETER_RAW, dai::IMUSensor::GYROSCOPE_RAW}); | ||
} | ||
|
||
TEST_CASE("Test IMU, all sensors") { | ||
basicIMUTest(50.0f, {dai::IMUSensor::ACCELEROMETER_RAW, dai::IMUSensor::GYROSCOPE_RAW, dai::IMUSensor::MAGNETOMETER_RAW, dai::IMUSensor::ROTATION_VECTOR}); | ||
} | ||
|
||
TEST_CASE("Test IMU, gyroscope 480 Hz") { | ||
basicIMUTest(480.0f, {dai::IMUSensor::GYROSCOPE_RAW}); | ||
} |