Skip to content

Commit 1bdf8f4

Browse files
committed
add Tare calib
1 parent 145f6e5 commit 1bdf8f4

File tree

4 files changed

+36
-33
lines changed

4 files changed

+36
-33
lines changed

common/calibration-model.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,17 @@ void calibration_model::d400_update(ux_window& window, std::string& error_messag
536536
}
537537
ImGui::SameLine();
538538

539-
auto streams = dev.first<rs2::depth_sensor>().get_active_streams();
539+
rs2::sensor depth_sensor;
540+
try
541+
{
542+
depth_sensor = dev.first<rs2::depth_sensor>();
543+
}
544+
catch (const std::exception& ex)
545+
{
546+
error_message = ex.what();
547+
ImGui::CloseCurrentPopup();
548+
}
549+
auto streams = depth_sensor.get_active_streams();
540550
if (_accept && streams.size())
541551
{
542552
if (ImGui::Button(u8"\uF2DB Write Table", ImVec2(120, 25)))

common/device-model.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3181,7 +3181,7 @@ namespace rs2
31813181
if (ImGui::IsItemHovered())
31823182
RsImGui::CustomTooltip("Focal length calibration is used to adjust camera focal length with specific target.");
31833183

3184-
if (ImGui::Selectable("Tare Calibration"))
3184+
if (ImGui::Selectable("Tare Calibration", false, avoid_selection_flag))
31853185
{
31863186
try
31873187
{

common/on-chip-calib.cpp

Lines changed: 24 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1428,6 +1428,10 @@ namespace rs2
14281428
if (action == RS2_CALIB_ACTION_FL_CALIB || action == RS2_CALIB_ACTION_UVMAPPING_CALIB || action == RS2_CALIB_ACTION_FL_PLUS_CALIB)
14291429
stop_viewer(invoke);
14301430

1431+
if( action == RS2_CALIB_ACTION_ON_CHIP_CALIB || action == RS2_CALIB_ACTION_TARE_CALIB )
1432+
if( _model.is_color_streaming() )
1433+
throw std::runtime_error( "Turn off RGB Camera streaming before calibrating." );
1434+
14311435
update_last_used();
14321436

14331437
if (action == RS2_CALIB_ACTION_ON_CHIP_FL_CALIB || action == RS2_CALIB_ACTION_FL_CALIB)
@@ -2192,39 +2196,30 @@ namespace rs2
21922196
//if (ImGui::IsItemHovered())
21932197
// RsImGui::CustomTooltip("%s", "On-Chip Calibration Extended");
21942198

2195-
if( get_manager().get_device_model().is_color_streaming() )
2196-
{
2197-
dismiss(false);
2198-
ImGui::PopStyleColor(7);
2199-
ImGui::PopFont();
2200-
throw std::runtime_error("Turn off \"RGB Camera\" streaming before using on-chip calibration.");
2201-
}
2202-
else
2203-
{
2204-
auto sat = 1.f + sin(duration_cast<milliseconds>(system_clock::now() - created_time).count() / 700.f) * 0.1f;
2205-
ImGui::PushStyleColor(ImGuiCol_Button, saturate(sensor_header_light_blue, sat));
2206-
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, saturate(sensor_header_light_blue, 1.5f));
2207-
2208-
std::string button_name = rsutils::string::from() << "Calibrate" << "##self" << index;
22092199

2210-
ImGui::SetCursorScreenPos({ float(x + 5), float(y + height - 28) });
2211-
if (ImGui::Button(button_name.c_str(), { float(bar_width), 20.f }))
2212-
{
2213-
get_manager().restore_workspace([this](std::function<void()> a) { a(); });
2214-
get_manager().reset();
2215-
get_manager().retry_times = 0;
2216-
auto _this = shared_from_this();
2217-
auto invoke = [_this](std::function<void()> action) {_this->invoke(action); };
2218-
get_manager().start(invoke);
2219-
update_state = RS2_CALIB_STATE_CALIB_IN_PROCESS;
2220-
enable_dismiss = false;
2221-
}
2200+
auto sat = 1.f + sin(duration_cast<milliseconds>(system_clock::now() - created_time).count() / 700.f) * 0.1f;
2201+
ImGui::PushStyleColor(ImGuiCol_Button, saturate(sensor_header_light_blue, sat));
2202+
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, saturate(sensor_header_light_blue, 1.5f));
22222203

2223-
ImGui::PopStyleColor(2);
2204+
std::string button_name = rsutils::string::from() << "Calibrate" << "##self" << index;
22242205

2225-
if (ImGui::IsItemHovered())
2226-
RsImGui::CustomTooltip("%s", "Begin On-Chip Calibration");
2206+
ImGui::SetCursorScreenPos({ float(x + 5), float(y + height - 28) });
2207+
if (ImGui::Button(button_name.c_str(), { float(bar_width), 20.f }))
2208+
{
2209+
get_manager().restore_workspace([this](std::function<void()> a) { a(); });
2210+
get_manager().reset();
2211+
get_manager().retry_times = 0;
2212+
auto _this = shared_from_this();
2213+
auto invoke = [_this](std::function<void()> action) {_this->invoke(action);};
2214+
get_manager().start(invoke);
2215+
update_state = RS2_CALIB_STATE_CALIB_IN_PROCESS;
2216+
enable_dismiss = false;
22272217
}
2218+
2219+
ImGui::PopStyleColor(2);
2220+
2221+
if (ImGui::IsItemHovered())
2222+
RsImGui::CustomTooltip("%s", "Begin On-Chip Calibration");
22282223
}
22292224
else if (update_state == RS2_CALIB_STATE_FL_INPUT)
22302225
{

common/on-chip-calib.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,6 @@ namespace rs2
122122
void stop_viewer();
123123
void reset_device() { _dev.hardware_reset(); }
124124

125-
const device_model& get_device_model() const { return _model; }
126-
127125
private:
128126
void save_laser_emitter_state();
129127
void save_thermal_loop_state();

0 commit comments

Comments
 (0)