Browse Source

Implemented NDI Aurora navigation.

jcsyshc 1 year ago
parent
commit
f1419e08e7

+ 10 - 0
data/config_remote_ar_20240410.yaml

@@ -46,5 +46,15 @@ augment_list:
     model: /home/tpx/project/TransparentAR/data/E1_AR/E1_Implant.obj
 #    background: Bone
 
+probe_model: /home/tpx/project/RemoteAR3/data/models/Probe.stl
+
+registration_list:
+  - name: Bone
+    model_file: /home/tpx/project/TransparentAR/data/E1_AR/E1_Model.obj
+    collect_obj: point_picker_in_femur_ref
+    collect_var: picked_point_in_femur_ref
+    target_var: femur_in_femur_ref
+    probe_var: probe_in_femur
+
 output_width: 1920
 output_height: 1080

+ 18 - 5
data/sophiar_config.json

@@ -143,13 +143,24 @@
           {
             "name": "probe",
             "parent": "probe_ref",
+            // for polaris probe
+//            "transform": [
+//              -0.23,
+//              -13.98,
+//              -119.65,
+//              1,
+//              0,
+//              0,
+//              0
+//            ],
+            // for aurora probe
             "transform": [
-              -0.23,
-              -13.98,
-              -119.65,
-              1,
               0,
               0,
+              0,
+              0,
+              1,
+              0,
               0
             ]
           },
@@ -260,13 +271,14 @@
       "type": "ndi_interface",
       "name": "ndi",
       "init_config": {
-        "address_type": "ethernet",
+        "address_type": "serial",
         "ip": "10.0.0.5",
         "tcp_port": 8765,
         "com_port": "/dev/ttyUSB0",
         "tool_list": [
           {
             "rom_path": "/home/tpx/data/roms/GlassProbe_4Ball_4.rom",
+            "serial_number": "3DD50000",
             "outputs": {
               "transform": "probe_ref_in_tracker"
             }
@@ -279,6 +291,7 @@
           },
           {
             "rom_path": "/home/tpx/data/roms/Glass_4Ball_2.rom",
+            "serial_number": "39B33001",
             "outputs": {
               "transform": "femur_ref_in_tracker"
             }

+ 18 - 0
src/impl/apps/remote_ar/remote_ar.cpp

@@ -199,6 +199,16 @@ app_remote_ar::app_remote_ar(const create_config &_conf) {
     saver_conf.img_list.emplace_back("Left", rgb_left);
     saver_conf.img_list.emplace_back("Right", rgb_right);
     debug_saver = std::make_unique<image_saver>(saver_conf);
+
+    auto reg_conf = registration_config{
+            .conn = sophiar_conn.get(),
+            .probe_model_path = LOAD_STR("probe_model"),
+    };
+    reg.reset(registration::create(reg_conf));
+    for (auto reg_item: LOAD_LIST("registration_list")) {
+        auto item_conf = registration_target::from_yaml(reg_item);
+        reg->add_target(item_conf);
+    }
 }
 
 void app_remote_ar::start_tracking() {
@@ -227,6 +237,8 @@ void app_remote_ar::show_ui() {
             if (ImGui::Button("Start")) {
                 start_tracking();
             }
+            ImGui::SameLine();
+            ImGui::Checkbox("Registration", &enable_reg);
             {
                 ImGui::SeparatorText("Scene");
                 auto id_guard = imgui_id_guard("augment_scene");
@@ -280,6 +292,12 @@ void app_remote_ar::show_ui() {
         ImGui::PopItemWidth();
     }
     ImGui::End();
+
+    if (enable_reg) {
+        reg->process();
+        reg->show();
+    }
+
     perf_timer.record();
 }
 

+ 4 - 0
src/impl/apps/remote_ar/remote_ar.h

@@ -12,6 +12,7 @@
 #include "module/image_saver.h"
 #include "module/image_streamer.h"
 #include "module/image_viewer.h"
+#include "module_v3/registration.h"
 #include "image_process/image_process_ui.h"
 #include "image_process/versatile_convertor.h"
 #include "impl/app_base.h"
@@ -83,6 +84,9 @@ private:
     std::unique_ptr<versatile_convertor> guide_decode;
     std::unique_ptr<depth_guide_controller> guide_controller;
 
+    bool enable_reg = false;
+    std::unique_ptr<registration> reg;
+
     std::unique_ptr<image_saver> debug_saver;
 
     camera_module cam_left;

+ 9 - 0
src/module_v3/registration.cpp

@@ -17,6 +17,15 @@
 
 using namespace vtk_viewer_helper;
 
+void registration_target::fill_from_yaml(const YAML::Node &conf) {
+    name = LOAD_STR("name");
+    model_path = LOAD_STR("model_file");
+    target_var_name = LOAD_STR("target_var");
+    collect_var_name = LOAD_STR("collect_var");
+    collect_obj_name = LOAD_STR("collect_obj");
+    probe_var_name = LOAD_STR("probe_var");
+}
+
 struct registration::impl {
 
     static constexpr auto MIN_REG_POINTS = 3;

+ 7 - 0
src/module_v3/registration.h

@@ -1,6 +1,9 @@
 #ifndef REMOTEAR3_REGISTRATION_H
 #define REMOTEAR3_REGISTRATION_H
 
+#include "core/yaml_utility.hpp"
+
+// for sophiar
 #include "core/local_connection.h"
 
 #include <vtkPolyData.h>
@@ -24,6 +27,10 @@ struct registration_target {
     std::string collect_var_name;
     std::string collect_obj_name;
     std::string probe_var_name;
+
+    void fill_from_yaml(const YAML::Node &conf);
+
+    FROM_YAML_IMPL(registration_target)
 };
 
 class registration {