#define BOOST_TEST_DYN_LINK #define BOOST_TEST_MAIN // in only one cpp file #include "utility/variable_helper.hpp" #include "core/basic_obj_types.hpp" #include #include #include #include #include #include #include #include #include #include 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 coro_ndi_test() { // auto interface = std::make_unique(); // 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( // 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) { spdlog::set_level(spdlog::level::trace); std::ifstream config_file("data/ndi_interface_config.json"); assert(config_file.is_open()); auto config = nlohmann::json::parse(config_file); auto ok = initialize(config); assert(ok); global_context->run(); }