Skip to content

Can update options automatically, get notification of value change - #12483

Merged
maloel merged 20 commits into
realsenseai:developmentfrom
OhadMeir:development
Jan 2, 2024
Merged

Can update options automatically, get notification of value change#12483
maloel merged 20 commits into
realsenseai:developmentfrom
OhadMeir:development

Conversation

@OhadMeir

@OhadMeir OhadMeir commented Dec 5, 2023

Copy link
Copy Markdown
Contributor

Added option_updater class that handles auto query of registered options.
Added C and CPP API to register a value change notification callback .

Added Python API and unit test

Also fixed bug in cpp unit tests - on restart_first_device_and_return_depth_sensor old device was used after HW reset instead of new device.

@OhadMeir
OhadMeir requested review from Nir-Az and maloel December 5, 2023 12:22
Comment thread include/librealsense2/h/rs_option.h Outdated
Comment thread include/librealsense2/hpp/rs_options.hpp Outdated
Comment thread src/core/options-updater.h Outdated
Comment thread src/core/options-updater.h Outdated
Comment thread src/sensor.h
Comment thread include/librealsense2/hpp/rs_options.hpp
Comment thread src/core/CMakeLists.txt Outdated
Comment thread src/core/options-updater.cpp Outdated
Comment thread src/core/options-updater.cpp Outdated
Comment thread include/librealsense2/hpp/rs_options.hpp Outdated
Comment thread include/librealsense2/h/rs_option.h Outdated
Comment thread include/librealsense2/h/rs_option.h
Comment thread include/librealsense2/h/rs_option.h Outdated
Comment thread src/rs.cpp Outdated
Comment thread include/librealsense2/hpp/rs_types.hpp Outdated
Comment thread src/core/options-watcher.h Outdated
Comment thread src/core/options-watcher.h Outdated
Comment thread src/core/options-watcher.cpp Outdated
Comment thread src/core/options-watcher.cpp Outdated
Comment thread src/core/options-watcher.cpp
Comment thread src/core/options-watcher.h Outdated
Comment thread src/sensor.h Outdated
Comment thread src/core/options-watcher.h Outdated
Comment thread src/sensor.h Outdated
Comment thread src/core/options-watcher.cpp Outdated
Comment thread src/core/options-watcher.h Outdated
Comment thread src/core/options-watcher.cpp Outdated
Comment thread unit-tests/unit-tests-common.cpp
Comment thread src/core/options-watcher.cpp Outdated
Comment thread src/core/options-watcher.cpp
Comment thread src/CMakeLists.txt Outdated
Comment thread src/core/options-watcher.cpp Outdated
Comment thread src/core/options-watcher.cpp
Comment thread src/sensor.h Outdated
Comment thread src/core/options-watcher.h Outdated
Comment thread src/core/options-watcher.cpp Outdated

options_watcher::~options_watcher()
{
_alive = false;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't need to clear _options inside a mutex any more; don't need the try-catch, either.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not locking before clear. try-catch needed because clear and join might throw.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But you don't need the clear()...

@maloel maloel Dec 26, 2023

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And if join() might throw, please catch it inside stop()...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer to clear explicitly, but locking is not needed.
Also found out clear has a noexcept overload. Catching join errors in stop.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm sorry, I don't agree - if you clear, then a lock is necessary.
You don't need to clear.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed

Comment thread src/media/playback/playback_sensor.h Outdated
rsutils::subscription register_options_changed_callback( options_watcher::callback && cb ) override
{
throw not_implemented_exception( "Registering options value changed callback is not implemented for this sensor" );
LOG_ERROR( "Registering options value changed callback is not implemented for this sensor" );

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why? I don't think this is good...?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we throw then the viewer cannot play recorded files

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reverted change. Viewer handling the exception

Comment thread unit-tests/live/options/test-options-watcher.py Outdated
Comment thread unit-tests/live/options/test-options-watcher.py
Comment thread unit-tests/live/options/test-options-watcher.py Outdated
Comment thread unit-tests/live/options/test-options-watcher.py
@maloel
maloel merged commit ee5b8cb into realsenseai:development Jan 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants