Skip to content

Commit 07cebd6

Browse files
author
Evgeni Raikhel
committed
Update viewer panel and mock example to the new composite-option API surface
- realsense-viewer's HKR Temporal Filter DPP panel now goes through sub->s->option_ref(RS2_OPTION_HKR_TEMPORAL_FILTER_DPP).is/as<rs2::composite_option>() instead of the removed rs2::composite_option_sensor, and casts to/from the now- public rs2_temporal_filter_dpp_config struct instead of a viewer-local copy of it. - The standalone mock example no longer bypasses into an internal transport class (xu_structured_control) directly - it now drives the mechanism through the real public entry points: rs2_set_composite_option/rs2_get_composite_option (C) and option_ref()/is<rs2::composite_option>()/as<rs2::composite_option>() (C++), backed by a minimal fake librealsense::option + composite_option_interface + options_interface standing in for a real device. Round-trip correctness and exactly-one-set+one-get atomicity are asserted across both API paths. Since it now needs the real public API/DLL entry points, it links against realsense2 like any other example instead of compiling an isolated internal source file directly.
1 parent 3c782db commit 07cebd6

4 files changed

Lines changed: 224 additions & 173 deletions

File tree

common/device-model.cpp

Lines changed: 19 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -29,25 +29,6 @@ using namespace rs400;
2929
using rsutils::json;
3030
using namespace rs2::sw_update;
3131

32-
namespace {
33-
34-
// PROTOTYPE / DEMO: this viewer's OWN local struct matching the wire layout documented as a
35-
// comment on RS2_COMPOSITE_OPTION_HKR_TEMPORAL_FILTER_DPP in
36-
// include/librealsense2/h/rs_composite_option.h. The SDK ships no public type for composite
37-
// options - every caller (this viewer, the mock example under examples/) independently
38-
// defines its own copy of this struct matching the documented byte layout.
39-
#pragma pack( push, 1 )
40-
struct hkr_temporal_filter_dpp_layout
41-
{
42-
int32_t enabled; // 0 = Off, 1 = On
43-
float smooth_alpha; // range [0,1], default 0.4, step 0.01
44-
int32_t smooth_delta; // range [1,100], default 20, step 1
45-
int32_t persistency_index; // range [0,8], default 3, step 1
46-
};
47-
#pragma pack( pop )
48-
49-
} // namespace
50-
5132
namespace rs2
5233
{
5334
// RAII guard pairing BeginDisabled/EndDisabled: keeps them balanced even if an exception is
@@ -2791,19 +2772,20 @@ namespace rs2
27912772
}
27922773

27932774
// PROTOTYPE / DEMO: HKR Temporal Filter DPP "structured API" panel. Only
2794-
// rendered for a sensor that actually exposes composite options (gated the
2795-
// same way as other per-sensor extension features in this loop, e.g.
2796-
// depth_sensor above). Goes through the GENERIC rs2::composite_option_sensor
2797-
// get_composite_option/set_composite_option entry points, keyed by
2798-
// RS2_COMPOSITE_OPTION_HKR_TEMPORAL_FILTER_DPP. The SDK ships no struct for
2799-
// this - this viewer casts the raw bytes to/from its own local
2800-
// hkr_temporal_filter_dpp_layout (defined above), matching the layout
2801-
// documented as a comment on the enumerator. All fields are sent together in
2802-
// ONE atomic UVC transaction when "Apply" is clicked - never as separate
2803-
// per-field option writes.
2804-
if (sub->s->is<rs2::composite_option_sensor>())
2805-
{
2806-
auto composite_sensor = sub->s->as<rs2::composite_option_sensor>();
2775+
// rendered for a sensor that actually exposes RS2_OPTION_HKR_TEMPORAL_FILTER_DPP
2776+
// as a composite option. Goes through the GENERIC option_ref()/is<T>()/as<T>()
2777+
// C++ path (mirrors rs2::frame's is<T>()/as<T>() dispatch) to obtain an
2778+
// rs2::composite_option, then its get()/set() - which call
2779+
// rs2_get_composite_option/rs2_set_composite_option under the hood. The SDK
2780+
// ships a public struct for this one prototype control
2781+
// (rs2_temporal_filter_dpp_config, see rs_hkr_temporal_filter_dpp.h) that this
2782+
// viewer casts the raw bytes to/from. All fields are sent together in ONE atomic
2783+
// UVC transaction when "Apply" is clicked - never as separate per-field option
2784+
// writes.
2785+
auto temporal_filter_dpp_handle = sub->s->option_ref(RS2_OPTION_HKR_TEMPORAL_FILTER_DPP);
2786+
if (temporal_filter_dpp_handle.is<rs2::composite_option>())
2787+
{
2788+
auto composite_opt = temporal_filter_dpp_handle.as<rs2::composite_option>();
28072789

28082790
label = rsutils::string::from() << "HKR Temporal Filter DPP (prototype)##" << id;
28092791
if (ImGui::TreeNode(label.c_str()))
@@ -2812,11 +2794,11 @@ namespace rs2
28122794
{
28132795
if (!sub->temporal_filter_dpp_populated)
28142796
{
2815-
auto bytes = composite_sensor.get_composite_option(RS2_COMPOSITE_OPTION_HKR_TEMPORAL_FILTER_DPP);
2816-
if (bytes.size() != sizeof(hkr_temporal_filter_dpp_layout))
2797+
auto bytes = composite_opt.get();
2798+
if (bytes.size() != sizeof(rs2_temporal_filter_dpp_config))
28172799
throw std::runtime_error("HKR Temporal Filter DPP: unexpected payload size from get_composite_option");
28182800

2819-
hkr_temporal_filter_dpp_layout cfg{};
2801+
rs2_temporal_filter_dpp_config cfg{};
28202802
memcpy(&cfg, bytes.data(), sizeof(cfg));
28212803
sub->temporal_filter_dpp_enabled = cfg.enabled;
28222804
sub->temporal_filter_dpp_smooth_alpha = cfg.smooth_alpha;
@@ -2842,12 +2824,12 @@ namespace rs2
28422824
label = rsutils::string::from() << "Send##temporal_filter_dpp_send" << id;
28432825
if (ImGui::Button(label.c_str()))
28442826
{
2845-
hkr_temporal_filter_dpp_layout cfg{};
2827+
rs2_temporal_filter_dpp_config cfg{};
28462828
cfg.enabled = sub->temporal_filter_dpp_enabled;
28472829
cfg.smooth_alpha = sub->temporal_filter_dpp_smooth_alpha;
28482830
cfg.smooth_delta = sub->temporal_filter_dpp_smooth_delta;
28492831
cfg.persistency_index = sub->temporal_filter_dpp_persistency_index;
2850-
composite_sensor.set_composite_option(RS2_COMPOSITE_OPTION_HKR_TEMPORAL_FILTER_DPP, &cfg, sizeof(cfg));
2832+
composite_opt.set(&cfg, sizeof(cfg));
28512833
}
28522834
}
28532835
catch (const error& e)

common/subdevice-model.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -230,9 +230,10 @@ namespace rs2
230230
bool embedded_filters_enabled = true;
231231

232232
// PROTOTYPE / DEMO: UI state for the HKR Temporal Filter DPP "structured API" panel
233-
// (gated on sub->s->is<rs2::composite_option_sensor>() - see device-model.cpp).
234-
// Widget values only change locally until "Apply" is pressed; that single click issues
235-
// one set_composite_option() call, i.e. one atomic UVC transaction.
233+
// (gated on sub->s->option_ref(RS2_OPTION_HKR_TEMPORAL_FILTER_DPP).is<rs2::composite_option>()
234+
// - see device-model.cpp). Widget values only change locally until "Apply" is pressed;
235+
// that single click issues one composite_option::set() call, i.e. one atomic UVC
236+
// transaction.
236237
bool temporal_filter_dpp_populated = false;
237238
int temporal_filter_dpp_enabled = 0;
238239
float temporal_filter_dpp_smooth_alpha = 0.4f;

examples/hkr-temporal-filter-dpp-mock/CMakeLists.txt

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,18 @@ cmake_minimum_required(VERSION 3.10)
55
project(RealsenseExamplesHkrTemporalFilterDppMock)
66

77
# PROTOTYPE / DEMO test scaffolding: proves the atomicity + round-trip behavior of the generic
8-
# "composite option" mechanism (src/ds/structured-xu-control.*) as applied to the HKR Temporal
9-
# Filter DPP control, against a fake in-memory platform::uvc_device standing in for real
10-
# HKR/D555 hardware, which is not present on this dev machine. This executable deliberately
11-
# does NOT link against the realsense2 library/DLL: the control class under test is
12-
# transport-agnostic (it only needs a platform::uvc_device&), so it can be exercised directly
13-
# without a live backend/uvc_sensor stack. It compiles the real production source file
14-
# directly so it is testing actual SDK code, not a reimplementation.
8+
# "composite option" mechanism (include/librealsense2/h/rs_composite_option.h,
9+
# src/composite-option-interface.h) as applied to RS2_OPTION_HKR_TEMPORAL_FILTER_DPP, against a
10+
# fake in-memory librealsense::option/composite_option_interface implementation standing in for
11+
# real HKR/D555 hardware (librealsense::composite_xu_option, src/ds/composite-xu-option.h), which
12+
# is not present on this dev machine. Unlike the earlier iteration, this drives the mechanism
13+
# through the REAL PUBLIC ENTRY POINTS (rs2_set_composite_option/rs2_get_composite_option and the
14+
# option_ref()/is<T>()/as<T>() C++ path) rather than bypassing into an internal transport class
15+
# directly, so it links against realsense2 like any other example.
1516
add_executable(rs-hkr-temporal-filter-dpp-mock
1617
rs-hkr-temporal-filter-dpp-mock.cpp
17-
${CMAKE_SOURCE_DIR}/src/ds/structured-xu-control.cpp
1818
)
1919
set_property(TARGET rs-hkr-temporal-filter-dpp-mock PROPERTY CXX_STANDARD 14)
20-
target_include_directories(rs-hkr-temporal-filter-dpp-mock PRIVATE ${CMAKE_SOURCE_DIR}/include)
21-
target_link_libraries(rs-hkr-temporal-filter-dpp-mock PRIVATE rsutils)
20+
target_link_libraries(rs-hkr-temporal-filter-dpp-mock PRIVATE ${LRS_TARGET})
2221
set_target_properties (rs-hkr-temporal-filter-dpp-mock PROPERTIES FOLDER Examples)
2322
install(TARGETS rs-hkr-temporal-filter-dpp-mock RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})

0 commit comments

Comments
 (0)