|
@@ -0,0 +1,72 @@
|
|
|
|
|
+#define BOOST_TEST_DYN_LINK
|
|
|
|
|
+#define BOOST_TEST_MAIN // in only one cpp file
|
|
|
|
|
+
|
|
|
|
|
+#include "tracker/ndi/ndi_interface.h"
|
|
|
|
|
+#include "utility/debug_utility.hpp"
|
|
|
|
|
+#include "utility/global_obj_helper.hpp"
|
|
|
|
|
+#include "core/basic_obj_types.hpp"
|
|
|
|
|
+
|
|
|
|
|
+#include <boost/asio/co_spawn.hpp>
|
|
|
|
|
+#include <boost/asio/detached.hpp>
|
|
|
|
|
+#include <boost/asio/this_coro.hpp>
|
|
|
|
|
+#include <boost/asio/use_awaitable.hpp>
|
|
|
|
|
+#include <boost/test/unit_test.hpp>
|
|
|
|
|
+
|
|
|
|
|
+#include <chrono>
|
|
|
|
|
+#include <iostream>
|
|
|
|
|
+#include <vector>
|
|
|
|
|
+
|
|
|
|
|
+using boost::asio::awaitable;
|
|
|
|
|
+using boost::asio::co_spawn;
|
|
|
|
|
+using boost::asio::detached;
|
|
|
|
|
+using boost::asio::use_awaitable;
|
|
|
|
|
+
|
|
|
|
|
+using namespace sophiar;
|
|
|
|
|
+using namespace std::chrono_literals;
|
|
|
|
|
+
|
|
|
|
|
+awaitable<void> coro_ndi_test() {
|
|
|
|
|
+ auto interface = std::make_unique<ndi_interface>();
|
|
|
|
|
+ auto init_config = nlohmann::json::parse(
|
|
|
|
|
+ R"({"address_type":"ethernet","ip":"169.254.132.51","tcp_port":8765,"com_port":"COM3","tool_list":[{"rom_path":"D:\\Program\\Robot\\Tools\\roms\\Probe_Small_4Ball.rom","outputs":{"transform":"tracker_probe_transform","marker_uncertainty":"tracker_probe_transform_uncertainty"}},{"rom_path":"D:\\Program\\Robot\\Tools\\roms\\Head_3Ball_2.rom","outputs":{"transform":"tracker_model_ref_transform","marker_uncertainty":"tracker_model_ref_transform_uncertainty"}}]})");
|
|
|
|
|
+ auto start_config = nlohmann::json::parse(
|
|
|
|
|
+ R"({"allow_unreliable":true,"prefer_stream_tracking":true})");
|
|
|
|
|
+
|
|
|
|
|
+ BOOST_TEST(co_await interface->init(init_config));
|
|
|
|
|
+ BOOST_TEST(co_await interface->start(start_config));
|
|
|
|
|
+ auto trans_obj = global_obj_auto_sync_delegate<transform_obj>(
|
|
|
|
|
+ global_sophiar_manager,
|
|
|
|
|
+ "tracker_probe_transform");
|
|
|
|
|
+ int cnt = 0;
|
|
|
|
|
+ FILE_LINE_TRACE
|
|
|
|
|
+ for (;;) {
|
|
|
|
|
+ co_await trans_obj.coro_wait_update();
|
|
|
|
|
+// if (!trans_obj.empty()) {
|
|
|
|
|
+// std::cout << trans_obj->value.matrix() << std::endl;
|
|
|
|
|
+// } else {
|
|
|
|
|
+// std::cout << "empty" << std::endl;
|
|
|
|
|
+// }
|
|
|
|
|
+ if (++cnt == 250) break;
|
|
|
|
|
+ }
|
|
|
|
|
+ FILE_LINE_TRACE
|
|
|
|
|
+ co_await interface->reset();
|
|
|
|
|
+
|
|
|
|
|
+ start_config = nlohmann::json::parse(
|
|
|
|
|
+ R"({"allow_unreliable":true,"prefer_stream_tracking":false})");
|
|
|
|
|
+ BOOST_TEST(co_await interface->init(init_config));
|
|
|
|
|
+ BOOST_TEST(co_await interface->start(start_config));
|
|
|
|
|
+ cnt = 0;
|
|
|
|
|
+ FILE_LINE_TRACE
|
|
|
|
|
+ for (;;) {
|
|
|
|
|
+ co_await trans_obj.coro_wait_update();
|
|
|
|
|
+ if (++cnt == 60) break;
|
|
|
|
|
+ }
|
|
|
|
|
+ FILE_LINE_TRACE
|
|
|
|
|
+ co_await interface->reset();
|
|
|
|
|
+
|
|
|
|
|
+ co_return;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+BOOST_AUTO_TEST_CASE(test_ndi) {
|
|
|
|
|
+ co_spawn(global_context, coro_ndi_test(), detached);
|
|
|
|
|
+ global_context.run();
|
|
|
|
|
+}
|