diff --git a/include/librealsense2/h/rs_context.h b/include/librealsense2/h/rs_context.h index d2bf74e066..78c1c3d04f 100644 --- a/include/librealsense2/h/rs_context.h +++ b/include/librealsense2/h/rs_context.h @@ -29,6 +29,9 @@ rs2_context* rs2_create_context(int api_version, rs2_error** error); * Possible settings: * dds-discovery - (bool) false to disable DDS discovery; defaults to true (requires BUILD_WITH_DDS) * dds-domain - (int) the number of the domain discovery is on (requires BUILD_WITH_DDS) +* use-basic-formats - (bool) true to make sensors stream only "basic" types without converting to formats +* other then the raw camera formats; defaults to false. +* Convert only interleaved formats (Y8I, Y12I), no colored infrared. * \param[out] error If non-null, receives any error that occurs during this call, otherwise, errors are ignored. * \return Context object */ diff --git a/src/context.cpp b/src/context.cpp index 79329ac870..0ed61cba80 100644 --- a/src/context.cpp +++ b/src/context.cpp @@ -163,6 +163,8 @@ namespace librealsense context::context( json const & settings ) : context() { + _settings = settings; + _backend = platform::create_backend(); // standard type environment::get_instance().set_time_service( _backend->create_time_service() ); diff --git a/src/context.h b/src/context.h index d8398af743..e40f0dbd3f 100644 --- a/src/context.h +++ b/src/context.h @@ -8,7 +8,7 @@ #include "core/streaming.h" #include -#include +#include #include "media/playback/playback_device.h" namespace librealsense @@ -136,6 +136,7 @@ namespace librealsense void add_software_device(std::shared_ptr software_device); + const nlohmann::json & get_settings() const { return _settings; } private: void on_device_changed(platform::backend_device_group old, @@ -158,6 +159,8 @@ namespace librealsense void start_dds_device_watcher( size_t message_timeout_ms ); #endif + nlohmann::json _settings; // Save operation settings + devices_changed_callback_ptr _devices_changed_callback; std::map> _streams; std::map>>> _extrinsics; diff --git a/src/dds/rs-dds-device-proxy.cpp b/src/dds/rs-dds-device-proxy.cpp index 67a8e82111..b3636c08c7 100644 --- a/src/dds/rs-dds-device-proxy.cpp +++ b/src/dds/rs-dds-device-proxy.cpp @@ -211,7 +211,7 @@ dds_device_proxy::dds_device_proxy( std::shared_ptr< context > ctx, std::shared_ for( auto & sensor_info : sensor_name_to_info ) { - sensor_info.second.proxy->initialization_done( dev->device_info().product_id, dev->device_info().product_line ); + sensor_info.second.proxy->initialization_done(); // Set profile's ID based on the dds_stream's ID (index already set). Connect the profile to the extrinsics graph. for( auto & profile : sensor_info.second.proxy->get_stream_profiles() ) @@ -233,6 +233,8 @@ dds_device_proxy::dds_device_proxy( std::shared_ptr< context > ctx, std::shared_ set_profile_intrinsics( profile, stream_iter->second ); _stream_name_to_profiles[stream_iter->second->name()].push_back( profile ); // For extrinsics + + tag_default_profile_of_stream( profile, stream_iter->second ); } } @@ -366,4 +368,31 @@ std::shared_ptr< dds_sensor_proxy > dds_device_proxy::create_sensor( const std:: } +// Tagging converted profiles. dds_sensor_proxy::add_video/motion_stream tagged the raw profiles. +void dds_device_proxy::tag_default_profile_of_stream( const std::shared_ptr & profile, + const std::shared_ptr< const realdds::dds_stream > & stream ) const +{ + auto const & dds_default_profile = stream->default_profile(); + + if( profile->get_stream_type() == to_rs2_stream_type( stream->type_string() ) && + profile->get_format() == dds_default_profile->format().to_rs2() && + profile->get_framerate() == dds_default_profile->frequency() ) + { + auto vsp = std::dynamic_pointer_cast< video_stream_profile >( profile ); + auto dds_vsp = std::dynamic_pointer_cast< realdds::dds_video_stream_profile >( dds_default_profile ); + if( vsp && dds_vsp && + ( vsp->get_width() != dds_vsp->width() || vsp->get_height() != dds_vsp->height() ) ) + return; // Video profiles of incompatible resolutions + + profile->tag_profile( PROFILE_TAG_DEFAULT ); + } +} + + +void dds_device_proxy::tag_profiles( stream_profiles profiles ) const +{ + //Do nothing. PROFILE_TAG_DEFAULT is already added in tag_default_profile_of_stream. +} + + } // namespace librealsense \ No newline at end of file diff --git a/src/dds/rs-dds-device-proxy.h b/src/dds/rs-dds-device-proxy.h index 3505f6b3b8..f74ca771c4 100644 --- a/src/dds/rs-dds-device-proxy.h +++ b/src/dds/rs-dds-device-proxy.h @@ -15,6 +15,7 @@ class dds_device; class dds_stream; class dds_video_stream; class dds_motion_stream; +class dds_stream_profile; } // namespace realdds @@ -51,7 +52,12 @@ class dds_device_proxy : public software_device public: dds_device_proxy( std::shared_ptr< context > ctx, std::shared_ptr< realdds::dds_device > const & dev ); + void tag_default_profile_of_stream( const std::shared_ptr< stream_profile_interface > & profile, + const std::shared_ptr< const realdds::dds_stream > & stream ) const; + std::shared_ptr< dds_sensor_proxy > create_sensor( const std::string & sensor_name ); + + void tag_profiles( stream_profiles profiles ) const override; }; diff --git a/src/dds/rs-dds-sensor-proxy.cpp b/src/dds/rs-dds-sensor-proxy.cpp index 8be72a5755..3e2fe1068c 100644 --- a/src/dds/rs-dds-sensor-proxy.cpp +++ b/src/dds/rs-dds-sensor-proxy.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #include @@ -106,47 +107,59 @@ std::shared_ptr< stream_profile_interface > dds_sensor_proxy::add_motion_stream( } -void dds_sensor_proxy::initialization_done( const std::string & product_id, const std::string & product_line ) +void dds_sensor_proxy::initialization_done() { - auto converters = dds_rs_internal_data::get_profile_converters( product_id, product_line ); - handle_no_converters( converters ); - _formats_converter.register_converters( converters ); + register_basic_converters(); _profiles = _formats_converter.get_all_possible_profiles( _raw_rs_profiles ); - - auto tags = dds_rs_internal_data::get_profiles_tags( product_id, product_line ); - tag_profiles( tags ); } -void dds_sensor_proxy::handle_no_converters( std::vector & converters ) +void dds_sensor_proxy::register_basic_converters() { - if( converters.empty() ) - // Create "identity converter" for each raw profile - for( auto & raw_profile : _raw_rs_profiles ) - converters.push_back( processing_block_factory::create_id_pbf( raw_profile->get_format(), - raw_profile->get_stream_type(), - raw_profile->get_stream_index() ) ); -} + std::vector< librealsense::processing_block_factory > converters; + std::vector< processing_block_factory > tmp; + + // Color + converters.push_back( processing_block_factory::create_id_pbf( RS2_FORMAT_YUYV, RS2_STREAM_COLOR ) ); + converters.push_back( processing_block_factory::create_id_pbf( RS2_FORMAT_UYVY, RS2_STREAM_COLOR ) ); + converters.push_back( processing_block_factory::create_id_pbf( RS2_FORMAT_RGB8, RS2_STREAM_COLOR ) ); + converters.push_back( processing_block_factory::create_id_pbf( RS2_FORMAT_RGBA8, RS2_STREAM_COLOR ) ); + converters.push_back( processing_block_factory::create_id_pbf( RS2_FORMAT_BGR8, RS2_STREAM_COLOR ) ); + converters.push_back( processing_block_factory::create_id_pbf( RS2_FORMAT_BGRA8, RS2_STREAM_COLOR ) ); + + converters.push_back( { { { RS2_FORMAT_UYVY } }, { { RS2_FORMAT_RGB8, RS2_STREAM_COLOR } }, + []() { return std::make_shared< uyvy_converter >( RS2_FORMAT_RGB8 ); } } ); + converters.push_back( { { { RS2_FORMAT_YUYV } }, { { RS2_FORMAT_RGB8, RS2_STREAM_COLOR } }, + []() { return std::make_shared< yuy2_converter >( RS2_FORMAT_RGB8 ); } } ); + + // Depth + converters.push_back( processing_block_factory::create_id_pbf( RS2_FORMAT_Z16, RS2_STREAM_DEPTH ) ); + + // Infrared (converter source needs type to be handled properly by formats_converter) + converters.push_back( { { { RS2_FORMAT_Y8, RS2_STREAM_INFRARED } }, + { { RS2_FORMAT_Y8, RS2_STREAM_INFRARED, 0 }, + { RS2_FORMAT_Y8, RS2_STREAM_INFRARED, 1 }, + { RS2_FORMAT_Y8, RS2_STREAM_INFRARED, 2 } }, + []() { return std::make_shared< identity_processing_block >(); } } ); + converters.push_back( { { { RS2_FORMAT_Y16, RS2_STREAM_INFRARED } }, + { { RS2_FORMAT_Y16, RS2_STREAM_INFRARED, 1 }, + { RS2_FORMAT_Y16, RS2_STREAM_INFRARED, 2 } }, + []() { return std::make_shared< identity_processing_block >(); } } ); + + // Motion + converters.push_back( { { { RS2_FORMAT_MOTION_XYZ32F, RS2_STREAM_ACCEL } }, + { { RS2_FORMAT_MOTION_XYZ32F, RS2_STREAM_ACCEL } }, + []() { return std::make_shared< identity_processing_block >(); } } ); + converters.push_back( { { { RS2_FORMAT_MOTION_XYZ32F, RS2_STREAM_GYRO } }, + { { RS2_FORMAT_MOTION_XYZ32F, RS2_STREAM_GYRO } }, + []() { return std::make_shared< identity_processing_block >(); } } ); + + // Confidence + converters.push_back( { { { RS2_FORMAT_RAW8, RS2_STREAM_CONFIDENCE } }, + { { RS2_FORMAT_RAW8, RS2_STREAM_CONFIDENCE } }, + []() { return std::make_shared< identity_processing_block >(); } } ); - -void dds_sensor_proxy::tag_profiles( const std::vector & tags ) -{ - for( auto & profile : _profiles ) - for( auto & tag : tags ) - if( ( tag.stream == RS2_STREAM_ANY || tag.stream == profile->get_stream_type() ) && - ( tag.format == RS2_FORMAT_ANY || tag.format == profile->get_format() ) && - ( tag.fps == -1 || tag.fps == profile->get_framerate() ) && - ( tag.stream_index == -1 || tag.stream_index == profile->get_stream_index() ) ) - { - if( auto vp = dynamic_cast< video_stream_profile_interface * >( profile.get() ) ) - { // For video the resolution should match as well - if( ( tag.width == -1 || tag.width == vp->get_width() ) && - ( tag.height == -1 || tag.height == vp->get_height() ) ) - profile->tag_profile( tag.tag ); - } - else - profile->tag_profile( tag.tag ); - } + _formats_converter.register_converters( converters ); } @@ -466,6 +479,11 @@ void dds_sensor_proxy::stop() { auto & dds_stream = _streams[sid_index( profile->get_unique_id(), profile->get_stream_index() )]; + dds_stream->stop_streaming(); + dds_stream->close(); + + _streaming_by_name[dds_stream->name()].syncer.on_frame_ready( nullptr ); + if( auto dds_video_stream = std::dynamic_pointer_cast< realdds::dds_video_stream >( dds_stream ) ) { dds_video_stream->on_data_available( nullptr ); @@ -476,11 +494,6 @@ void dds_sensor_proxy::stop() } else throw std::runtime_error( "Unsupported stream type" ); - - dds_stream->stop_streaming(); - dds_stream->close(); - - _streaming_by_name[dds_stream->name()].syncer.on_frame_ready( nullptr ); } // Resets frame source. Nullify streams on_data_available before calling stop. diff --git a/src/dds/rs-dds-sensor-proxy.h b/src/dds/rs-dds-sensor-proxy.h index fbac9f2fc3..9635fb64f5 100644 --- a/src/dds/rs-dds-sensor-proxy.h +++ b/src/dds/rs-dds-sensor-proxy.h @@ -67,7 +67,7 @@ class dds_sensor_proxy : public software_sensor std::shared_ptr add_video_stream( rs2_video_stream video_stream, bool is_default ) override; std::shared_ptr add_motion_stream( rs2_motion_stream motion_stream, bool is_default ) override; // Not adding streams or profiles after this - void initialization_done( const std::string & product_id, const std::string & product_line ); + void initialization_done(); void open( const stream_profiles & profiles ) override; void start( frame_callback_ptr callback ) override; @@ -84,9 +84,7 @@ class dds_sensor_proxy : public software_sensor const std::map< sid_index, std::shared_ptr< realdds::dds_stream > > & streams() const { return _streams; } private: - void handle_no_converters( std::vector & converters ); - - void tag_profiles( const std::vector & tags ); + void register_basic_converters(); std::shared_ptr< realdds::dds_video_stream_profile > find_profile( sid_index sidx, realdds::dds_video_stream_profile const & profile ) const; diff --git a/src/device.cpp b/src/device.cpp index 1ee48c698f..60e9e05ee5 100644 --- a/src/device.cpp +++ b/src/device.cpp @@ -5,6 +5,7 @@ #include "core/video.h" #include "core/motion.h" #include "device.h" + #include using namespace librealsense; diff --git a/src/proc/formats-converter.cpp b/src/proc/formats-converter.cpp index c991d66a93..df1b2a8dfa 100644 --- a/src/proc/formats-converter.cpp +++ b/src/proc/formats-converter.cpp @@ -8,8 +8,8 @@ namespace librealsense { void formats_converter::register_converter( const std::vector< stream_profile > & source, - const std::vector< stream_profile > & target, - std::function< std::shared_ptr< processing_block >( void ) > generate_func ) + const std::vector< stream_profile > & target, + std::function< std::shared_ptr< processing_block >( void ) > generate_func ) { _pb_factories.push_back( std::make_shared< processing_block_factory >( source, target, generate_func ) ); } @@ -21,10 +21,42 @@ void formats_converter::register_converter( const processing_block_factory & pbf void formats_converter::register_converters( const std::vector< processing_block_factory > & pbfs ) { - for( auto && pbf : pbfs ) + for( auto & pbf : pbfs ) register_converter( pbf ); } +void formats_converter::clear_registered_converters() +{ + _pb_factories.clear(); +} + +void formats_converter::drop_non_basic_formats() +{ + for( size_t i = 0; i < _pb_factories.size(); ++i ) + { + const auto & source = _pb_factories[i]->get_source_info(); + const auto & target = _pb_factories[i]->get_target_info(); + if( target.size() == 1 && + source[0].format == target[0].format ) + { + // Identity, does not actually convert, keep this converter, unless it is colored infrared. + bool colored_infrared = target[0].stream == RS2_STREAM_INFRARED && source[0].format == RS2_FORMAT_UYVY; + + if( ! colored_infrared ) + continue; + } + + if( source[0].format == RS2_FORMAT_Y8I || source[0].format == RS2_FORMAT_Y12I ) + continue; // Convert interleaved formats. + + // Remove unwanted converters. Move to last element in vector and pop it out. + if( i != ( _pb_factories.size() -1 ) ) + std::swap( _pb_factories[i], _pb_factories.back() ); + _pb_factories.pop_back(); + --i; // Don't advance the counter because we reduce the vector size. + } +} + stream_profiles formats_converter::get_all_possible_profiles( const stream_profiles & raw_profiles ) { // For each profile that can be used as input check all registered factories if they can create @@ -35,40 +67,41 @@ stream_profiles formats_converter::get_all_possible_profiles( const stream_profi for( auto & raw_profile : raw_profiles ) { - for( auto && pbf : _pb_factories ) + for( auto & pbf : _pb_factories ) { - const auto && sources = pbf->get_source_info(); - for( auto && source : sources ) + const auto & sources = pbf->get_source_info(); + for( auto & source : sources ) { if( source.format == raw_profile->get_format() && ( source.stream == raw_profile->get_stream_type() || source.stream == RS2_STREAM_ANY ) ) { - const auto & targets = pbf->get_target_info(); - // targets are saved with format and type only. Updating fps and resolution before using as key - for( auto target : targets ) + // targets are saved with format, type and sometimes index. Updating fps and resolution before using as key + for( const auto & target : pbf->get_target_info() ) { - target.fps = raw_profile->get_framerate(); + // When interleaved streams are seperated to two distinct streams (e.g. sent as DDS streams), + // same converters are registered for both stream. We handle the relevant one based on index. + // Currently for infrared streams only. + if( source.stream == RS2_STREAM_INFRARED && raw_profile->get_stream_index() != target.index ) + continue; - auto && cloned_profile = clone_profile( raw_profile ); + auto cloned_profile = clone_profile( raw_profile ); cloned_profile->set_format( target.format ); - cloned_profile->set_stream_index( target.index ); //TODO - shouldn't be from_profile.index? + cloned_profile->set_stream_index( target.index ); cloned_profile->set_stream_type( target.stream ); - auto && cloned_vsp = As< video_stream_profile, stream_profile_interface >( cloned_profile ); + auto cloned_vsp = As< video_stream_profile, stream_profile_interface >( cloned_profile ); if( cloned_vsp ) { // Converter may rotate the image, invoke stream_resolution function to get actual result const auto res = target.stream_resolution( { cloned_vsp->get_width(), cloned_vsp->get_height() } ); - target.height = res.height; - target.width = res.width; - cloned_vsp->set_dims( target.width, target.height ); + cloned_vsp->set_dims( res.width, res.height ); } // Cache pbf supported profiles for efficiency in find_pbf_matching_most_profiles _pbf_supported_profiles[pbf.get()].push_back( cloned_profile ); // Cache mapping of each target profile to profiles it is converting from. - _target_profiles_to_raw_profiles[target].push_back( raw_profile ); + _target_profiles_to_raw_profiles[cloned_profile].push_back( raw_profile ); // TODO - Duplicates in the list happen when 2 raw_profiles have conversion to same target. // In this case it is faster to check if( _target_to_source_profiles_map[target].size() > 1 ) @@ -139,7 +172,7 @@ bool formats_converter::is_profile_in_list( const std::shared_ptr< stream_profil const stream_profiles & profiles ) const { // Converting to stream_profile to avoid dynamic casting to video/motion_stream_profile - const auto && is_duplicate_predicate = [&profile]( const std::shared_ptr< stream_profile_interface > & spi ) { + auto is_duplicate_predicate = [&profile]( const std::shared_ptr< stream_profile_interface > & spi ) { return to_profile( spi.get() ) == to_profile( profile.get() ); }; @@ -177,18 +210,12 @@ void formats_converter::prepare_to_convert( stream_profiles from_profiles ) auto best_pb = factory_of_best_match->generate(); for( const auto & from_profile : from_profiles_of_best_match ) { - auto & mapped_raw_profiles = _target_profiles_to_raw_profiles[to_profile( from_profile.get() )]; + auto & mapped_raw_profiles = _target_profiles_to_raw_profiles[from_profile]; for( const auto & raw_profile : mapped_raw_profiles ) { if( factory_of_best_match->has_source( raw_profile ) ) { - // When using DDS the server may split one stream of data into multiple dds_streams, e.g. Y8I - // infrared data. When grouping these dds_streams under one sensor we get multiple instances of the - // same profile, but the server should only open one to streaming - if( is_profile_in_list( raw_profile, { current_resolved_reqs.begin(), current_resolved_reqs.end() } ) ) - continue; - current_resolved_reqs.insert( raw_profile ); // Caching converters to invoke appropriate converters for received frames @@ -205,7 +232,7 @@ void formats_converter::update_target_profiles_data( const stream_profiles & fro { for( auto & from_profile : from_profiles ) { - for( auto & raw_profile : _target_profiles_to_raw_profiles[to_profile( from_profile.get() )] ) + for( auto & raw_profile : _target_profiles_to_raw_profiles[from_profile] ) { raw_profile->set_stream_index( from_profile->get_stream_index() ); raw_profile->set_unique_id( from_profile->get_unique_id() ); @@ -232,7 +259,7 @@ void formats_converter::update_target_profiles_data( const stream_profiles & fro void formats_converter::cache_from_profiles( const stream_profiles & from_profiles ) { - for( auto && from_profile : from_profiles ) + for( auto & from_profile : from_profiles ) { _format_mapping_to_from_profiles[from_profile->get_format()].push_back( from_profile ); } @@ -286,7 +313,7 @@ formats_converter::find_pbf_matching_most_profiles( const stream_profiles & from for( auto & pbf : _pb_factories ) { - stream_profiles && satisfied_req = pbf->find_satisfied_requests( from_profiles, _pbf_supported_profiles[pbf.get()] ); + stream_profiles satisfied_req = pbf->find_satisfied_requests( from_profiles, _pbf_supported_profiles[pbf.get()] ); size_t satisfied_count = satisfied_req.size(); size_t source_size = pbf->get_source_info().size(); if( satisfied_count > max_satisfied_count || @@ -314,7 +341,7 @@ void formats_converter::set_frames_callback( frame_callback_ptr callback ) _converted_frames_callback = callback; // After processing callback - const auto && output_cb = make_callback( [&]( frame_holder f ) { + auto output_cb = make_callback( [&]( frame_holder f ) { std::vector< frame_interface * > frames_to_be_processed; frames_to_be_processed.push_back( f.frame ); @@ -328,7 +355,7 @@ void formats_converter::set_frames_callback( frame_callback_ptr callback ) } // Process only frames which aren't composite. - for( auto && fr : frames_to_be_processed ) + for( auto & fr : frames_to_be_processed ) { if( ! dynamic_cast< composite_frame * >( fr ) ) { @@ -369,7 +396,7 @@ void formats_converter::convert_frame( frame_holder & f ) return; auto & converters = _raw_profile_to_converters[f->get_stream()]; - for( auto && converter : converters ) + for( auto & converter : converters ) { f->acquire(); converter->invoke( f.frame ); diff --git a/src/proc/formats-converter.h b/src/proc/formats-converter.h index b011b8e7a1..ebeb5fae75 100644 --- a/src/proc/formats-converter.h +++ b/src/proc/formats-converter.h @@ -26,6 +26,11 @@ namespace librealsense std::function< std::shared_ptr< processing_block >( void ) > generate_func ); void register_converter( const processing_block_factory & pbf ); void register_converters( const std::vector< processing_block_factory > & pbfs ); + void clear_registered_converters(); + + // Don't convert to types other then the raw camera formats (use only identity formats) + // Convert only interleaved formats (Y8I, Y12I), no colored infrared. + void drop_non_basic_formats(); stream_profiles get_all_possible_profiles( const stream_profiles & raw_profiles ); void prepare_to_convert( stream_profiles to_profiles ); @@ -48,11 +53,11 @@ namespace librealsense std::pair< std::shared_ptr< processing_block_factory >, stream_profiles > find_pbf_matching_most_profiles( const stream_profiles & profiles ); - std::shared_ptr find_cached_profile_for_frame( const frame_interface * f ); + std::shared_ptr< stream_profile_interface > find_cached_profile_for_frame( const frame_interface * f ); std::vector< std::shared_ptr< processing_block_factory > > _pb_factories; std::unordered_map< processing_block_factory *, stream_profiles > _pbf_supported_profiles; - std::unordered_map< stream_profile, stream_profiles > _target_profiles_to_raw_profiles; + std::unordered_map< std::shared_ptr< stream_profile_interface >, stream_profiles > _target_profiles_to_raw_profiles; std::unordered_map< std::shared_ptr< stream_profile_interface >, std::unordered_set< std::shared_ptr< processing_block > > > _raw_profile_to_converters; diff --git a/src/proc/processing-blocks-factory.cpp b/src/proc/processing-blocks-factory.cpp index 7d953d7267..c704bc2ea9 100644 --- a/src/proc/processing-blocks-factory.cpp +++ b/src/proc/processing-blocks-factory.cpp @@ -50,16 +50,16 @@ namespace librealsense bool processing_block_factory::operator==(const processing_block_factory & rhs) const { - const auto&& rhs_src = rhs.get_source_info(); - for (auto&& src : _source_info) + const auto & rhs_src = rhs.get_source_info(); + for (auto & src : _source_info) { auto equals = [&src](const stream_profile& prof) { return prof == src; }; if (std::none_of(begin(rhs_src), end(rhs_src), equals)) return false; } - const auto&& rhs_tgt = rhs.get_target_info(); - for (auto&& tgt : _target_info) + const auto & rhs_tgt = rhs.get_target_info(); + for (auto & tgt : _target_info) { auto equals = [&tgt](const stream_profile& prof) { return prof == tgt; }; if (std::none_of(begin(rhs_tgt), end(rhs_tgt), equals)) diff --git a/src/proc/processing-blocks-factory.h b/src/proc/processing-blocks-factory.h index 9e0a4407e9..59e588978f 100644 --- a/src/proc/processing-blocks-factory.h +++ b/src/proc/processing-blocks-factory.h @@ -25,8 +25,8 @@ namespace librealsense bool operator==(const processing_block_factory& rhs) const; - std::vector get_source_info() const { return _source_info; } - std::vector get_target_info() const { return _target_info; } + const std::vector & get_source_info() const { return _source_info; } + const std::vector & get_target_info() const { return _target_info; } std::shared_ptr generate(); static processing_block_factory create_id_pbf(rs2_format format, rs2_stream stream, int idx = 0); diff --git a/src/sensor.cpp b/src/sensor.cpp index f6684f868d..f531627ec0 100644 --- a/src/sensor.cpp +++ b/src/sensor.cpp @@ -13,6 +13,7 @@ #include "device-calibration.h" #include +#include #include #include @@ -1354,8 +1355,13 @@ void log_callback_end( uint32_t fps, stream_profiles synthetic_sensor::init_stream_profiles() { - stream_profiles from_profiles = _raw_sensor->get_stream_profiles( PROFILE_TAG_ANY | PROFILE_TAG_DEBUG ); - stream_profiles result_profiles = _formats_converter.get_all_possible_profiles( from_profiles ); + stream_profiles raw_profiles = _raw_sensor->get_stream_profiles( PROFILE_TAG_ANY | PROFILE_TAG_DEBUG ); + if( should_use_basic_formats() ) + { + _formats_converter.drop_non_basic_formats(); + } + + stream_profiles result_profiles = _formats_converter.get_all_possible_profiles( raw_profiles ); _owner->tag_profiles( result_profiles ); sort_profiles( &result_profiles ); @@ -1363,12 +1369,12 @@ void log_callback_end( uint32_t fps, return result_profiles; } - void synthetic_sensor::open(const stream_profiles& requests) + void synthetic_sensor::open(const stream_profiles & requests) { std::lock_guard lock(_synthetic_configure_lock); _formats_converter.prepare_to_convert( requests ); - + const auto & resolved_req = _formats_converter.get_active_source_profiles(); std::vector< std::shared_ptr< processing_block > > active_pbs = _formats_converter.get_active_converters(); for( auto & pb : active_pbs ) @@ -1377,7 +1383,7 @@ void log_callback_end( uint32_t fps, _raw_sensor->set_source_owner(this); try { - _raw_sensor->open(resolved_req); + _raw_sensor->open( resolved_req ); } catch (const std::runtime_error& e) { @@ -1427,11 +1433,10 @@ void log_callback_end( uint32_t fps, set_frames_callback(callback); _formats_converter.set_frames_callback( callback ); - // Invoke processing blocks callback - const auto&& process_cb = make_callback([&, this](frame_holder f) { + auto process_cb = make_callback( [&, this]( frame_holder f ) { _formats_converter.convert_frame( f ); - }); + } ); // Call the processing block on the frame _raw_sensor->start(process_cb); @@ -1519,4 +1524,14 @@ void log_callback_end( uint32_t fps, { snapshot = std::make_shared(); } + + bool synthetic_sensor::should_use_basic_formats() const + { + if( _owner->get_context() ) + { + return rsutils::json::get< bool >( _owner->get_context()->get_settings(), std::string( "use-basic-formats", 17 ), false ); + } + + return false; + } } diff --git a/src/sensor.h b/src/sensor.h index aa2ccbfd34..5185dabd4a 100644 --- a/src/sensor.h +++ b/src/sensor.h @@ -238,16 +238,13 @@ namespace librealsense bool is_streaming() const override; bool is_opened() const override; - protected: - void add_source_profiles_missing_data(); - private: - stream_profiles resolve_requests(const stream_profiles& requests); - std::shared_ptr filter_frame_by_requests(const frame_interface* f); void sort_profiles(stream_profiles * profiles); void register_processing_block_options(const processing_block& pb); void unregister_processing_block_options(const processing_block& pb); + bool should_use_basic_formats() const; + std::mutex _synthetic_configure_lock; frame_callback_ptr _post_process_callback; diff --git a/third-party/realdds/include/realdds/dds-stream-base.h b/third-party/realdds/include/realdds/dds-stream-base.h index e1f516e688..405b263849 100644 --- a/third-party/realdds/include/realdds/dds-stream-base.h +++ b/third-party/realdds/include/realdds/dds-stream-base.h @@ -27,7 +27,7 @@ class dds_stream_base : public std::enable_shared_from_this< dds_stream_base > protected: std::string const _name; std::string const _sensor_name; - int _default_profile_index = 0; + size_t _default_profile_index = 0; dds_stream_profiles _profiles; dds_options _options; std::vector< std::string > _recommended_filters; @@ -40,14 +40,14 @@ class dds_stream_base : public std::enable_shared_from_this< dds_stream_base > // Init functions can only be called once! void enable_metadata(); // Must call before init_profiles - void init_profiles( dds_stream_profiles const & profiles, int default_profile_index = 0 ); + void init_profiles( dds_stream_profiles const & profiles, size_t default_profile_index = 0 ); void init_options( dds_options const & options ); void set_recommended_filters( std::vector< std::string > && recommended_filters ); std::string const & name() const { return _name; } std::string const & sensor_name() const { return _sensor_name; } dds_stream_profiles const & profiles() const { return _profiles; } - int default_profile_index() const { return _default_profile_index; } + size_t default_profile_index() const { return _default_profile_index; } dds_options const & options() const { return _options; } std::vector< std::string > const & recommended_filters() const { return _recommended_filters; } bool metadata_enabled() const { return _metadata_enabled; } @@ -55,7 +55,7 @@ class dds_stream_base : public std::enable_shared_from_this< dds_stream_base > std::shared_ptr< dds_stream_profile > default_profile() const { std::shared_ptr< dds_stream_profile > profile; - if( default_profile_index() >= 0 && default_profile_index() < profiles().size() ) + if( default_profile_index() < profiles().size() ) profile = profiles()[default_profile_index()]; return profile; } diff --git a/third-party/realdds/src/dds-device-impl.cpp b/third-party/realdds/src/dds-device-impl.cpp index 8f543304f3..3539bc0883 100644 --- a/third-party/realdds/src/dds-device-impl.cpp +++ b/third-party/realdds/src/dds-device-impl.cpp @@ -515,7 +515,7 @@ void dds_device::impl::handle_stream_header( init_context & init, nlohmann::json DDS_THROW( runtime_error, "stream '" + stream_name + "' already exists" ); auto sensor_name = rsutils::json::get< std::string >( j, "sensor-name" ); - auto default_profile_index = rsutils::json::get< int >( j, "default-profile-index" ); + size_t default_profile_index = rsutils::json::get< size_t >( j, "default-profile-index" ); dds_stream_profiles profiles; #define TYPE2STREAM( S, P ) \ @@ -545,7 +545,7 @@ void dds_device::impl::handle_stream_header( init_context & init, nlohmann::json stream->enable_metadata(); // Call before init_profiles } - if( default_profile_index >= 0 && default_profile_index < profiles.size() ) + if( default_profile_index < profiles.size() ) stream->init_profiles( profiles, default_profile_index ); else DDS_THROW( runtime_error, diff --git a/third-party/realdds/src/dds-stream-base.cpp b/third-party/realdds/src/dds-stream-base.cpp index c88d24d894..0e53984fce 100644 --- a/third-party/realdds/src/dds-stream-base.cpp +++ b/third-party/realdds/src/dds-stream-base.cpp @@ -26,7 +26,7 @@ void dds_stream_base::enable_metadata() } -void dds_stream_base::init_profiles( dds_stream_profiles const & profiles, int default_profile_index ) +void dds_stream_base::init_profiles( dds_stream_profiles const & profiles, size_t default_profile_index ) { if( !_profiles.empty() ) DDS_THROW( runtime_error, "stream '" + _name + "' profiles are already initialized" ); @@ -34,10 +34,10 @@ void dds_stream_base::init_profiles( dds_stream_profiles const & profiles, int d DDS_THROW( runtime_error, "at least one profile is required to initialize stream '" + _name + "'" ); _default_profile_index = default_profile_index; - if( _default_profile_index < 0 || _default_profile_index >= profiles.size() ) + if( _default_profile_index >= profiles.size() ) DDS_THROW( runtime_error, - "invalid default profile index (" + std::to_string( _default_profile_index ) + " for " - + std::to_string( profiles.size() ) + " stream profiles" ); + "invalid default profile index (" + std::to_string( _default_profile_index ) + " for " + + std::to_string( profiles.size() ) + " stream profiles" ); auto self = weak_from_this(); for( auto const & profile : profiles ) diff --git a/tools/dds/dds-adapter/lrs-device-controller.cpp b/tools/dds/dds-adapter/lrs-device-controller.cpp index 8539c7ff6e..f3a7605af0 100644 --- a/tools/dds/dds-adapter/lrs-device-controller.cpp +++ b/tools/dds/dds-adapter/lrs-device-controller.cpp @@ -99,7 +99,7 @@ static std::string stream_name_from_rs2( const rs2::stream_profile & profile ) std::vector< std::shared_ptr< realdds::dds_stream_server > > lrs_device_controller::get_supported_streams() { std::map< std::string, realdds::dds_stream_profiles > stream_name_to_profiles; - std::map< std::string, int > stream_name_to_default_profile; + std::map< std::string, size_t > stream_name_to_default_profile; std::map< std::string, std::set< realdds::video_intrinsics > > stream_name_to_video_intrinsics; std::map< std::string, realdds::motion_intrinsics > stream_name_to_motion_intrinsics; @@ -166,19 +166,21 @@ std::vector< std::shared_ptr< realdds::dds_stream_server > > lrs_device_controll return; } if( sp.is_default() ) - stream_name_to_default_profile[stream_name] = static_cast< int >( profiles.size() ); + stream_name_to_default_profile[stream_name] = profiles.size(); profiles.push_back( profile ); LOG_DEBUG( stream_name << ": " << profile->to_string() ); } ); } + override_default_profiles( stream_name_to_profiles, stream_name_to_default_profile ); + // Iterate over the mapped streams and initialize std::vector< std::shared_ptr< realdds::dds_stream_server > > servers; for( auto & it : stream_name_to_profiles ) { auto const & stream_name = it.first; - int default_profile_index = 0; + size_t default_profile_index = 0; auto default_profile_it = stream_name_to_default_profile.find( stream_name ); if( default_profile_it != stream_name_to_default_profile.end() ) default_profile_index = default_profile_it->second; @@ -656,3 +658,70 @@ float lrs_device_controller::query_option( const std::shared_ptr< realdds::dds_o rs2_option opt_type = option_name_to_type( option->get_name(), sensor ); return sensor.get_option( opt_type ); } + + +void lrs_device_controller::override_default_profiles( const std::map< std::string, realdds::dds_stream_profiles > & stream_name_to_profiles, + std::map< std::string, size_t > & stream_name_to_default_profile ) const +{ + static const std::string RS410_PID = "0AD2"; + static const std::string RS415_PID = "0AD3"; + + std::string product_line = _rs_dev.get_info( RS2_CAMERA_INFO_PRODUCT_LINE ); + std::string product_id = _rs_dev.get_info( RS2_CAMERA_INFO_PRODUCT_ID ); + + // Default resolution for RealSense modules, set according to system SW architect definitions + if( product_line == "D400" ) + { + // For best image quality global shutter should use 848x480 resolution, rolling shutter 1280x720 + uint16_t fps = 30; + uint16_t width = 848; + uint16_t height = 480; + if( product_id == RS415_PID || product_id == RS410_PID ) + { + width = 1280; + height = 720; + } + stream_name_to_default_profile["Depth"] = get_index_of_profile( stream_name_to_profiles.at( "Depth" ), + realdds::dds_video_stream_profile( fps, realdds::dds_stream_format::from_rs2( RS2_FORMAT_Z16 ), width, height ) ); + stream_name_to_default_profile["Infrared_1"] = get_index_of_profile( stream_name_to_profiles.at( "Infrared_1" ), + realdds::dds_video_stream_profile( fps, realdds::dds_stream_format::from_rs2( RS2_FORMAT_Y8 ), width, height ) ); + stream_name_to_default_profile["Infrared_2"] = get_index_of_profile( stream_name_to_profiles.at( "Infrared_2" ), + realdds::dds_video_stream_profile( fps, realdds::dds_stream_format::from_rs2( RS2_FORMAT_Y8 ), width, height ) ); + + width = 1280; + height = 720; + stream_name_to_default_profile["Color"] = get_index_of_profile( stream_name_to_profiles.at( "Color" ), + realdds::dds_video_stream_profile( fps, realdds::dds_stream_format::from_rs2( RS2_FORMAT_YUYV ), width, height ) ); + } +} + + +size_t lrs_device_controller::get_index_of_profile( const realdds::dds_stream_profiles & profiles, + const realdds::dds_video_stream_profile & profile ) const +{ + for( size_t i = 0; i < profiles.size(); ++i ) + { + auto dds_vp = std::dynamic_pointer_cast< dds_video_stream_profile >( profiles[i] ); + if( dds_vp->frequency() == profile.frequency() + && dds_vp->format() == profile.format() + && dds_vp->width() == profile.width() + && dds_vp->height() == profile.height() ) + return i; + } + + return 0; +} + + +size_t lrs_device_controller::get_index_of_profile( const realdds::dds_stream_profiles & profiles, + const realdds::dds_motion_stream_profile & profile ) const +{ + for( size_t i = 0; i < profiles.size(); ++i ) + { + if( profiles[i]->frequency() == profile.frequency() + && profiles[i]->format() == profile.format() ) + return i; + } + + return 0; +} diff --git a/tools/dds/dds-adapter/lrs-device-controller.h b/tools/dds/dds-adapter/lrs-device-controller.h index eb5966b031..8ceb261f71 100644 --- a/tools/dds/dds-adapter/lrs-device-controller.h +++ b/tools/dds/dds-adapter/lrs-device-controller.h @@ -4,6 +4,7 @@ #pragma once #include // Include RealSense Cross Platform API #include +#include #include #include @@ -17,7 +18,6 @@ namespace realdds { class dds_device_server; class dds_stream_server; -class dds_stream_profile; class dds_option; } // namespace realdds @@ -41,6 +41,13 @@ class lrs_device_controller void start_streaming( const nlohmann::json & msg ); void publish_frame_metadata( const rs2::frame & f, realdds::dds_time const & ); + void override_default_profiles( const std::map< std::string, realdds::dds_stream_profiles > & stream_name_to_profiles, + std::map< std::string, size_t > & stream_name_to_default_profile ) const; + size_t get_index_of_profile( const realdds::dds_stream_profiles & profiles, + const realdds::dds_video_stream_profile & profile ) const; + size_t get_index_of_profile( const realdds::dds_stream_profiles & profiles, + const realdds::dds_motion_stream_profile & profile ) const; + rs2::device _rs_dev; std::map< std::string, rs2::sensor > _rs_sensors; std::string _device_sn; diff --git a/tools/dds/dds-adapter/rs-dds-adapter.cpp b/tools/dds/dds-adapter/rs-dds-adapter.cpp index dfcb771f01..63cb733299 100644 --- a/tools/dds/dds-adapter/rs-dds-adapter.cpp +++ b/tools/dds/dds-adapter/rs-dds-adapter.cpp @@ -2,6 +2,7 @@ // Copyright(c) 2022 Intel Corporation. All Rights Reserved. #include +#include #include #include @@ -119,9 +120,11 @@ try std::cout << "Start listening to RS devices.." << std::endl; // Create a RealSense context - rs2::context ctx( "{" - "\"dds-discovery\" : false" - "}" ); + nlohmann::json j = { + { "dds-discovery", false }, // Don't discover DDS devices from the network, we want local devices only + { "use-basic-formats", true } // Don't convert raw sensor formats (except interleaved) will be done by receiver + }; + rs2::context ctx( j.dump() ); // Run the LRS device watcher tools::lrs_device_watcher dev_watcher( ctx ); diff --git a/unit-tests/dds/d405.py b/unit-tests/dds/d405.py index 92f2debfd7..2900343d4b 100644 --- a/unit-tests/dds/d405.py +++ b/unit-tests/dds/d405.py @@ -1,5 +1,5 @@ # License: Apache 2.0. See LICENSE file in root directory. -# Copyright(c) 2022 Intel Corporation. All Rights Reserved. +# Copyright(c) 2023 Intel Corporation. All Rights Reserved. import pyrealdds as dds from rspy import log, test @@ -17,20 +17,21 @@ def build( participant ): Build a D405 device server for use in DDS """ depth = depth_stream() - ir0 = colored_infrared_stream() + # ir0 = colored_infrared_stream() # Colored infrared currently not sent on DDS ir1 = ir_stream( 1 ) ir2 = ir_stream( 2 ) color = color_stream() extrinsics = get_extrinsics() # d405 = dds.device_server( participant, device_info.topic_root ) - d405.init( [ir0, ir1, ir2, color, depth], [], extrinsics ) + # d405.init( [ir0, ir1, ir2, color, depth], [], extrinsics ) # Colored infrared currently not sent on DDS + d405.init( [ir1, ir2, color, depth], [], extrinsics ) return d405 def colored_infrared_stream(): stream = dds.ir_stream_server( "Infrared", "Stereo Module" ) - stream.init_profiles( colored_infrared_stream_profiles(), 0 ) + stream.init_profiles( colored_infrared_stream_profiles(), 11 ) stream.init_options( stereo_module_options() ) return stream @@ -225,43 +226,46 @@ def depth_stream(): def ir_stream_profiles(): return [ - dds.video_stream_profile( 25, dds.stream_format("Y12I"), 1288, 808 ), - dds.video_stream_profile( 15, dds.stream_format("Y12I"), 1288, 808 ), - dds.video_stream_profile( 30, dds.stream_format("Y8I"), 1280, 720 ), - dds.video_stream_profile( 15, dds.stream_format("Y8I"), 1280, 720 ), - dds.video_stream_profile( 5, dds.stream_format("Y8I"), 1280, 720 ), - dds.video_stream_profile( 90, dds.stream_format("Y8I"), 848, 480 ), - dds.video_stream_profile( 60, dds.stream_format("Y8I"), 848, 480 ), - dds.video_stream_profile( 30, dds.stream_format("Y8I"), 848, 480 ), - dds.video_stream_profile( 15, dds.stream_format("Y8I"), 848, 480 ), - dds.video_stream_profile( 5, dds.stream_format("Y8I"), 848, 480 ), - dds.video_stream_profile( 90, dds.stream_format("Y8I"), 640, 480 ), - dds.video_stream_profile( 60, dds.stream_format("Y8I"), 640, 480 ), - dds.video_stream_profile( 30, dds.stream_format("Y8I"), 640, 480 ), - dds.video_stream_profile( 15, dds.stream_format("Y8I"), 640, 480 ), - dds.video_stream_profile( 5, dds.stream_format("Y8I"), 640, 480 ), - dds.video_stream_profile( 90, dds.stream_format("Y8I"), 640, 360 ), - dds.video_stream_profile( 60, dds.stream_format("Y8I"), 640, 360 ), - dds.video_stream_profile( 30, dds.stream_format("Y8I"), 640, 360 ), - dds.video_stream_profile( 15, dds.stream_format("Y8I"), 640, 360 ), - dds.video_stream_profile( 5, dds.stream_format("Y8I"), 640, 360 ), - dds.video_stream_profile( 90, dds.stream_format("Y8I"), 480, 270 ), - dds.video_stream_profile( 60, dds.stream_format("Y8I"), 480, 270 ), - dds.video_stream_profile( 30, dds.stream_format("Y8I"), 480, 270 ), - dds.video_stream_profile( 15, dds.stream_format("Y8I"), 480, 270 ), - dds.video_stream_profile( 5, dds.stream_format("Y8I"), 480, 270 ), - dds.video_stream_profile( 90, dds.stream_format("Y8I"), 424, 240 ), - dds.video_stream_profile( 60, dds.stream_format("Y8I"), 424, 240 ), - dds.video_stream_profile( 30, dds.stream_format("Y8I"), 424, 240 ), - dds.video_stream_profile( 15, dds.stream_format("Y8I"), 424, 240 ), - dds.video_stream_profile( 5, dds.stream_format("Y8I"), 424, 240 ), - dds.video_stream_profile( 5, dds.stream_format("mono8"), 256, 148 ) + dds.video_stream_profile( 25, dds.stream_format("Y16"), 1288, 808 ), + dds.video_stream_profile( 15, dds.stream_format("Y16"), 1288, 808 ), + dds.video_stream_profile( 30, dds.stream_format("mono8"), 1280, 720 ), + dds.video_stream_profile( 15, dds.stream_format("mono8"), 1280, 720 ), + dds.video_stream_profile( 5, dds.stream_format("mono8"), 1280, 720 ), + dds.video_stream_profile( 90, dds.stream_format("mono8"), 848, 480 ), + dds.video_stream_profile( 60, dds.stream_format("mono8"), 848, 480 ), + dds.video_stream_profile( 30, dds.stream_format("mono8"), 848, 480 ), + dds.video_stream_profile( 15, dds.stream_format("mono8"), 848, 480 ), + dds.video_stream_profile( 5, dds.stream_format("mono8"), 848, 480 ), + dds.video_stream_profile( 90, dds.stream_format("mono8"), 640, 480 ), + dds.video_stream_profile( 60, dds.stream_format("mono8"), 640, 480 ), + dds.video_stream_profile( 30, dds.stream_format("mono8"), 640, 480 ), + dds.video_stream_profile( 15, dds.stream_format("mono8"), 640, 480 ), + dds.video_stream_profile( 5, dds.stream_format("mono8"), 640, 480 ), + dds.video_stream_profile( 90, dds.stream_format("mono8"), 640, 360 ), + dds.video_stream_profile( 60, dds.stream_format("mono8"), 640, 360 ), + dds.video_stream_profile( 30, dds.stream_format("mono8"), 640, 360 ), + dds.video_stream_profile( 15, dds.stream_format("mono8"), 640, 360 ), + dds.video_stream_profile( 5, dds.stream_format("mono8"), 640, 360 ), + dds.video_stream_profile( 90, dds.stream_format("mono8"), 480, 270 ), + dds.video_stream_profile( 60, dds.stream_format("mono8"), 480, 270 ), + dds.video_stream_profile( 30, dds.stream_format("mono8"), 480, 270 ), + dds.video_stream_profile( 15, dds.stream_format("mono8"), 480, 270 ), + dds.video_stream_profile( 5, dds.stream_format("mono8"), 480, 270 ), + dds.video_stream_profile( 90, dds.stream_format("mono8"), 424, 240 ), + dds.video_stream_profile( 60, dds.stream_format("mono8"), 424, 240 ), + dds.video_stream_profile( 30, dds.stream_format("mono8"), 424, 240 ), + dds.video_stream_profile( 15, dds.stream_format("mono8"), 424, 240 ), + dds.video_stream_profile( 5, dds.stream_format("mono8"), 424, 240 ) ] def ir_stream( number ): stream = dds.ir_stream_server( "Infrared_" + str(number), "Stereo Module" ) - stream.init_profiles( ir_stream_profiles(), 0 ) + profiles = ir_stream_profiles() + if number == 1: + calibration_profile = dds.video_stream_profile( 90, dds.stream_format("mono8"), 256, 144 ) + profiles.append( calibration_profile ) + stream.init_profiles( profiles, 7 ) stream.init_options( stereo_module_options() ) stream.set_intrinsics( ir_stream_intrinsics() ) return stream @@ -442,7 +446,7 @@ def color_stream_profiles(): def color_stream(): stream = dds.color_stream_server( "Color", "Stereo Module" ) - stream.init_profiles( color_stream_profiles(), 5 ) + stream.init_profiles( color_stream_profiles(), 1 ) stream.init_options( stereo_module_options() ) stream.set_intrinsics( color_stream_intrinsics() ) return stream diff --git a/unit-tests/dds/d435i.py b/unit-tests/dds/d435i.py index 3640628723..e57a4a6912 100644 --- a/unit-tests/dds/d435i.py +++ b/unit-tests/dds/d435i.py @@ -1,5 +1,5 @@ # License: Apache 2.0. See LICENSE file in root directory. -# Copyright(c) 2022 Intel Corporation. All Rights Reserved. +# Copyright(c) 2023 Intel Corporation. All Rights Reserved. import pyrealdds as dds from rspy import log, test @@ -40,8 +40,8 @@ def build_options(): def accel_stream_profiles(): return [ - dds.motion_stream_profile( 200, dds.stream_format("MXYZ") ), - dds.motion_stream_profile( 100, dds.stream_format("MXYZ") ) + dds.motion_stream_profile( 100, dds.stream_format("MXYZ") ), + dds.motion_stream_profile( 200, dds.stream_format("MXYZ") ) ] @@ -59,8 +59,8 @@ def accel_stream(): def gyro_stream_profiles(): return [ - dds.motion_stream_profile( 400, dds.stream_format("MXYZ") ), - dds.motion_stream_profile( 200, dds.stream_format("MXYZ") ) + dds.motion_stream_profile( 200, dds.stream_format("MXYZ") ), + dds.motion_stream_profile( 400, dds.stream_format("MXYZ") ) ] @@ -115,7 +115,7 @@ def depth_stream_profiles(): def depth_stream(): stream = dds.depth_stream_server( "Depth", "Stereo Module" ) - stream.init_profiles( depth_stream_profiles(), 0 ) + stream.init_profiles( depth_stream_profiles(), 5 ) stream.init_options( stereo_module_options() ) stream.set_intrinsics( depth_stream_intrinsics() ) return stream @@ -123,48 +123,48 @@ def depth_stream(): def ir_stream_profiles(): return [ - dds.video_stream_profile( 30, dds.stream_format("Y8I"), 1280,800 ), - dds.video_stream_profile( 25, dds.stream_format("Y12I"), 1280,800 ), - dds.video_stream_profile( 15, dds.stream_format("Y12I"), 1280,800 ), - dds.video_stream_profile( 15, dds.stream_format("Y8I"), 1280,800 ), - dds.video_stream_profile( 30, dds.stream_format("Y8I"), 1280,720 ), - dds.video_stream_profile( 15, dds.stream_format("Y8I"), 1280,720 ), - dds.video_stream_profile( 6, dds.stream_format("Y8I"), 1280,720 ), - dds.video_stream_profile( 90, dds.stream_format("Y8I"), 848,480 ), - dds.video_stream_profile( 60, dds.stream_format("Y8I"), 848,480 ), - dds.video_stream_profile( 30, dds.stream_format("Y8I"), 848,480 ), - dds.video_stream_profile( 15, dds.stream_format("Y8I"), 848,480 ), - dds.video_stream_profile( 6, dds.stream_format("Y8I"), 848,480 ), - dds.video_stream_profile( 300, dds.stream_format("Y8I"), 848,100 ), - dds.video_stream_profile( 100, dds.stream_format("Y8I"), 848,100 ), - dds.video_stream_profile( 90, dds.stream_format("Y8I"), 640,480 ), - dds.video_stream_profile( 60, dds.stream_format("Y8I"), 640,480 ), - dds.video_stream_profile( 30, dds.stream_format("Y8I"), 640,480 ), - dds.video_stream_profile( 15, dds.stream_format("Y8I"), 640,480 ), - dds.video_stream_profile( 6, dds.stream_format("Y8I"), 640,480 ), - dds.video_stream_profile( 25, dds.stream_format("Y12I"), 640,400 ), - dds.video_stream_profile( 15, dds.stream_format("Y12I"), 640,400 ), - dds.video_stream_profile( 90, dds.stream_format("Y8I"), 640,360 ), - dds.video_stream_profile( 60, dds.stream_format("Y8I"), 640,360 ), - dds.video_stream_profile( 30, dds.stream_format("Y8I"), 640,360 ), - dds.video_stream_profile( 15, dds.stream_format("Y8I"), 640,360 ), - dds.video_stream_profile( 6, dds.stream_format("Y8I"), 640,360 ), - dds.video_stream_profile( 90, dds.stream_format("Y8I"), 480,270 ), - dds.video_stream_profile( 60, dds.stream_format("Y8I"), 480,270 ), - dds.video_stream_profile( 30, dds.stream_format("Y8I"), 480,270 ), - dds.video_stream_profile( 15, dds.stream_format("Y8I"), 480,270 ), - dds.video_stream_profile( 6, dds.stream_format("Y8I"), 480,270 ), - dds.video_stream_profile( 90, dds.stream_format("Y8I"), 424,240 ), - dds.video_stream_profile( 60, dds.stream_format("Y8I"), 424,240 ), - dds.video_stream_profile( 30, dds.stream_format("Y8I"), 424,240 ), - dds.video_stream_profile( 15, dds.stream_format("Y8I"), 424,240 ), - dds.video_stream_profile( 6, dds.stream_format("Y8I"), 424,240 ) + dds.video_stream_profile( 30, dds.stream_format("mono8"), 1280,800 ), + dds.video_stream_profile( 25, dds.stream_format("Y16"), 1280,800 ), + dds.video_stream_profile( 15, dds.stream_format("Y16"), 1280,800 ), + dds.video_stream_profile( 15, dds.stream_format("mono8"), 1280,800 ), + dds.video_stream_profile( 30, dds.stream_format("mono8"), 1280,720 ), + dds.video_stream_profile( 15, dds.stream_format("mono8"), 1280,720 ), + dds.video_stream_profile( 6, dds.stream_format("mono8"), 1280,720 ), + dds.video_stream_profile( 90, dds.stream_format("mono8"), 848,480 ), + dds.video_stream_profile( 60, dds.stream_format("mono8"), 848,480 ), + dds.video_stream_profile( 30, dds.stream_format("mono8"), 848,480 ), + dds.video_stream_profile( 15, dds.stream_format("mono8"), 848,480 ), + dds.video_stream_profile( 6, dds.stream_format("mono8"), 848,480 ), + dds.video_stream_profile( 300, dds.stream_format("mono8"), 848,100 ), + dds.video_stream_profile( 100, dds.stream_format("mono8"), 848,100 ), + dds.video_stream_profile( 90, dds.stream_format("mono8"), 640,480 ), + dds.video_stream_profile( 60, dds.stream_format("mono8"), 640,480 ), + dds.video_stream_profile( 30, dds.stream_format("mono8"), 640,480 ), + dds.video_stream_profile( 15, dds.stream_format("mono8"), 640,480 ), + dds.video_stream_profile( 6, dds.stream_format("mono8"), 640,480 ), + dds.video_stream_profile( 25, dds.stream_format("Y16"), 640,400 ), + dds.video_stream_profile( 15, dds.stream_format("Y16"), 640,400 ), + dds.video_stream_profile( 90, dds.stream_format("mono8"), 640,360 ), + dds.video_stream_profile( 60, dds.stream_format("mono8"), 640,360 ), + dds.video_stream_profile( 30, dds.stream_format("mono8"), 640,360 ), + dds.video_stream_profile( 15, dds.stream_format("mono8"), 640,360 ), + dds.video_stream_profile( 6, dds.stream_format("mono8"), 640,360 ), + dds.video_stream_profile( 90, dds.stream_format("mono8"), 480,270 ), + dds.video_stream_profile( 60, dds.stream_format("mono8"), 480,270 ), + dds.video_stream_profile( 30, dds.stream_format("mono8"), 480,270 ), + dds.video_stream_profile( 15, dds.stream_format("mono8"), 480,270 ), + dds.video_stream_profile( 6, dds.stream_format("mono8"), 480,270 ), + dds.video_stream_profile( 90, dds.stream_format("mono8"), 424,240 ), + dds.video_stream_profile( 60, dds.stream_format("mono8"), 424,240 ), + dds.video_stream_profile( 30, dds.stream_format("mono8"), 424,240 ), + dds.video_stream_profile( 15, dds.stream_format("mono8"), 424,240 ), + dds.video_stream_profile( 6, dds.stream_format("mono8"), 424,240 ) ] def ir_stream( number ): stream = dds.ir_stream_server( "Infrared_" + str(number), "Stereo Module" ) - stream.init_profiles( ir_stream_profiles(), 0 ) + stream.init_profiles( ir_stream_profiles(), 9 ) stream.init_options( stereo_module_options() ) stream.set_intrinsics( ir_stream_intrinsics() ) return stream @@ -323,7 +323,7 @@ def color_stream_profiles(): # dds.video_stream_profile( 15, dds.stream_format("RGBA"), 424,240 ), # dds.video_stream_profile( 15, dds.stream_format("RGB2"), 424,240 ), dds.video_stream_profile( 15, dds.stream_format("yuv422_yuy2"), 424,240 ), - # dds.video_stream_profile( 6, dds.stream_format("rgb8"), 424,240 ), + #dds.video_stream_profile( 6, dds.stream_format("rgb8"), 424,240 ), # dds.video_stream_profile( 6, dds.stream_format("Y16"), 424,240 ), # dds.video_stream_profile( 6, dds.stream_format("BGRA"), 424,240 ), # dds.video_stream_profile( 6, dds.stream_format("RGBA"), 424,240 ), @@ -370,7 +370,7 @@ def color_stream_profiles(): def color_stream(): stream = dds.color_stream_server( "Color", "RGB Camera" ) - stream.init_profiles( color_stream_profiles(), 0 ) + stream.init_profiles( color_stream_profiles(), 8 ) stream.init_options( rgb_camera_options() ) stream.set_intrinsics( color_stream_intrinsics() ) return stream diff --git a/unit-tests/dds/d455.py b/unit-tests/dds/d455.py index 6686285586..214bf2b7c9 100644 --- a/unit-tests/dds/d455.py +++ b/unit-tests/dds/d455.py @@ -1,5 +1,5 @@ # License: Apache 2.0. See LICENSE file in root directory. -# Copyright(c) 2022 Intel Corporation. All Rights Reserved. +# Copyright(c) 2023 Intel Corporation. All Rights Reserved. import pyrealdds as dds from rspy import log, test @@ -19,14 +19,15 @@ def build( participant ): accel = accel_stream() gyro = gyro_stream() depth = depth_stream() - ir0 = colored_infrared_stream() + # ir0 = colored_infrared_stream() # Colored infrared currently not sent on DDS ir1 = ir_stream( 1 ) ir2 = ir_stream( 2 ) color = color_stream() extrinsics = get_extrinsics() # d455 = dds.device_server( participant, device_info.topic_root ) - d455.init( [accel, gyro, depth, ir0, ir1, ir2, color], [], extrinsics ) + # d455.init( [accel, gyro, depth, ir0, ir1, ir2, color], [], extrinsics ) # Colored infrared currently not sent on DDS + d455.init( [accel, gyro, depth, ir1, ir2, color], [], extrinsics ) return d455 @@ -60,7 +61,7 @@ def gyro_stream(): def colored_infrared_stream(): stream = dds.ir_stream_server( "Infrared", "Stereo Module" ) - stream.init_profiles( colored_infrared_stream_profiles(), 0 ) + stream.init_profiles( colored_infrared_stream_profiles(), 11 ) stream.init_options( stereo_module_options() ) return stream @@ -207,7 +208,7 @@ def colored_infrared_stream_profiles(): # dds.video_stream_profile( 15, dds.stream_format("RGBA"), 424, 240 ), # dds.video_stream_profile( 15, dds.stream_format("RGB2"), 424, 240 ), # dds.video_stream_profile( 15, dds.stream_format("rgb8"), 424, 240 ), - dds.video_stream_profile( 5 , dds.stream_format("UYVY"), 424, 240 ) #, + dds.video_stream_profile( 5 , dds.stream_format("UYVY"), 424, 240 ), # dds.video_stream_profile( 5 , dds.stream_format("BGRA"), 424, 240 ), # dds.video_stream_profile( 5 , dds.stream_format("RGBA"), 424, 240 ), # dds.video_stream_profile( 5 , dds.stream_format("RGB2"), 424, 240 ), @@ -259,47 +260,47 @@ def depth_stream(): def ir_stream_profiles(): return [ - dds.video_stream_profile( 30, dds.stream_format("Y8I"), 1280, 800 ), - dds.video_stream_profile( 25, dds.stream_format("Y12I"), 1280, 800 ), - dds.video_stream_profile( 15, dds.stream_format("Y12I"), 1280, 800 ), - dds.video_stream_profile( 15, dds.stream_format("Y8I"), 1280, 800 ), - dds.video_stream_profile( 30, dds.stream_format("Y8I"), 1280, 720 ), - dds.video_stream_profile( 15, dds.stream_format("Y8I"), 1280, 720 ), - dds.video_stream_profile( 5 , dds.stream_format("Y8I"), 1280, 720 ), - dds.video_stream_profile( 90, dds.stream_format("Y8I"), 848, 480 ), - dds.video_stream_profile( 60, dds.stream_format("Y8I"), 848, 480 ), - dds.video_stream_profile( 30, dds.stream_format("Y8I"), 848, 480 ), - dds.video_stream_profile( 15, dds.stream_format("Y8I"), 848, 480 ), - dds.video_stream_profile( 5 , dds.stream_format("Y8I"), 848, 480 ), - dds.video_stream_profile( 100, dds.stream_format("Y8I"), 848, 100 ), - dds.video_stream_profile( 90, dds.stream_format("Y8I"), 640, 480 ), - dds.video_stream_profile( 60, dds.stream_format("Y8I"), 640, 480 ), - dds.video_stream_profile( 30, dds.stream_format("Y8I"), 640, 480 ), - dds.video_stream_profile( 15, dds.stream_format("Y8I"), 640, 480 ), - dds.video_stream_profile( 5 , dds.stream_format("Y8I"), 640, 480 ), - dds.video_stream_profile( 25, dds.stream_format("Y12I"), 640, 400 ), - dds.video_stream_profile( 15, dds.stream_format("Y12I"), 640, 400 ), - dds.video_stream_profile( 90, dds.stream_format("Y8I"), 640, 360 ), - dds.video_stream_profile( 60, dds.stream_format("Y8I"), 640, 360 ), - dds.video_stream_profile( 30, dds.stream_format("Y8I"), 640, 360 ), - dds.video_stream_profile( 15, dds.stream_format("Y8I"), 640, 360 ), - dds.video_stream_profile( 5 , dds.stream_format("Y8I"), 640, 360 ), - dds.video_stream_profile( 90, dds.stream_format("Y8I"), 480, 270 ), - dds.video_stream_profile( 60, dds.stream_format("Y8I"), 480, 270 ), - dds.video_stream_profile( 30, dds.stream_format("Y8I"), 480, 270 ), - dds.video_stream_profile( 15, dds.stream_format("Y8I"), 480, 270 ), - dds.video_stream_profile( 5 , dds.stream_format("Y8I"), 480, 270 ), - dds.video_stream_profile( 90, dds.stream_format("Y8I"), 424, 240 ), - dds.video_stream_profile( 60, dds.stream_format("Y8I"), 424, 240 ), - dds.video_stream_profile( 30, dds.stream_format("Y8I"), 424, 240 ), - dds.video_stream_profile( 15, dds.stream_format("Y8I"), 424, 240 ), - dds.video_stream_profile( 5 , dds.stream_format("Y8I"), 424, 240 ) + dds.video_stream_profile( 30, dds.stream_format("mono8"), 1280, 800 ), + dds.video_stream_profile( 25, dds.stream_format("Y16"), 1280, 800 ), + dds.video_stream_profile( 15, dds.stream_format("Y16"), 1280, 800 ), + dds.video_stream_profile( 15, dds.stream_format("mono8"), 1280, 800 ), + dds.video_stream_profile( 30, dds.stream_format("mono8"), 1280, 720 ), + dds.video_stream_profile( 15, dds.stream_format("mono8"), 1280, 720 ), + dds.video_stream_profile( 5 , dds.stream_format("mono8"), 1280, 720 ), + dds.video_stream_profile( 90, dds.stream_format("mono8"), 848, 480 ), + dds.video_stream_profile( 60, dds.stream_format("mono8"), 848, 480 ), + dds.video_stream_profile( 30, dds.stream_format("mono8"), 848, 480 ), + dds.video_stream_profile( 15, dds.stream_format("mono8"), 848, 480 ), + dds.video_stream_profile( 5 , dds.stream_format("mono8"), 848, 480 ), + dds.video_stream_profile( 100, dds.stream_format("mono8"), 848, 100 ), + dds.video_stream_profile( 90, dds.stream_format("mono8"), 640, 480 ), + dds.video_stream_profile( 60, dds.stream_format("mono8"), 640, 480 ), + dds.video_stream_profile( 30, dds.stream_format("mono8"), 640, 480 ), + dds.video_stream_profile( 15, dds.stream_format("mono8"), 640, 480 ), + dds.video_stream_profile( 5 , dds.stream_format("mono8"), 640, 480 ), + dds.video_stream_profile( 25, dds.stream_format("Y16"), 640, 400 ), + dds.video_stream_profile( 15, dds.stream_format("Y16"), 640, 400 ), + dds.video_stream_profile( 90, dds.stream_format("mono8"), 640, 360 ), + dds.video_stream_profile( 60, dds.stream_format("mono8"), 640, 360 ), + dds.video_stream_profile( 30, dds.stream_format("mono8"), 640, 360 ), + dds.video_stream_profile( 15, dds.stream_format("mono8"), 640, 360 ), + dds.video_stream_profile( 5 , dds.stream_format("mono8"), 640, 360 ), + dds.video_stream_profile( 90, dds.stream_format("mono8"), 480, 270 ), + dds.video_stream_profile( 60, dds.stream_format("mono8"), 480, 270 ), + dds.video_stream_profile( 30, dds.stream_format("mono8"), 480, 270 ), + dds.video_stream_profile( 15, dds.stream_format("mono8"), 480, 270 ), + dds.video_stream_profile( 5 , dds.stream_format("mono8"), 480, 270 ), + dds.video_stream_profile( 90, dds.stream_format("mono8"), 424, 240 ), + dds.video_stream_profile( 60, dds.stream_format("mono8"), 424, 240 ), + dds.video_stream_profile( 30, dds.stream_format("mono8"), 424, 240 ), + dds.video_stream_profile( 15, dds.stream_format("mono8"), 424, 240 ), + dds.video_stream_profile( 5 , dds.stream_format("mono8"), 424, 240 ) ] def ir_stream( number ): stream = dds.ir_stream_server( "Infrared_" + str(number), "Stereo Module" ) - stream.init_profiles( ir_stream_profiles(), 0 ) + stream.init_profiles( ir_stream_profiles(), 9 ) stream.init_options( stereo_module_options() ) return stream @@ -498,7 +499,7 @@ def color_stream_profiles(): def color_stream(): stream = dds.color_stream_server( "Color", "RGB Camera" ) - stream.init_profiles( color_stream_profiles(), 5 ) + stream.init_profiles( color_stream_profiles(), 10 ) stream.init_options( rgb_camera_options() ) return stream diff --git a/unit-tests/dds/test-librs-device-properties.py b/unit-tests/dds/test-librs-device-properties.py index 3bc2a6b12c..dd65ec771b 100644 --- a/unit-tests/dds/test-librs-device-properties.py +++ b/unit-tests/dds/test-librs-device-properties.py @@ -44,7 +44,7 @@ test.check_equal( len(sensor.get_stream_profiles()), 104 ) # As measured running rs-sensor-control example if test.check( 'RGB Camera' in sensors ): sensor = sensors['RGB Camera'] - test.check_equal( len(sensor.get_stream_profiles()), 225 ) # As measured running rs-sensor-control example + test.check_equal( len(sensor.get_stream_profiles()), 64 ) # As measured running rs-sensor-control example if test.check( 'Motion Module' in sensors ): sensor = sensors['Motion Module'] test.check_equal( len(sensor.get_stream_profiles()), 4 ) # As measured running rs-sensor-control example @@ -70,7 +70,7 @@ test.check_equal( len(sensors), 1 ) if test.check( 'Stereo Module' in sensors ): sensor = sensors.get('Stereo Module') - test.check_equal( len(sensor.get_stream_profiles()), 431 ) # As measured running rs-sensor-control example + test.check_equal( len(sensor.get_stream_profiles()), 146 ) # As measured running rs-sensor-control example remote.run( 'close_server( instance )' ) except: test.unexpected_exception() @@ -93,10 +93,10 @@ test.check_equal( len(sensors), 3 ) if test.check( 'Stereo Module' in sensors ): sensor = sensors.get('Stereo Module') - test.check_equal( len(sensor.get_stream_profiles()), 245 ) # As measured running rs-sensor-control example + test.check_equal( len(sensor.get_stream_profiles()), 100 ) # As measured running rs-sensor-control example if test.check( 'RGB Camera' in sensors ): sensor = sensors['RGB Camera'] - test.check_equal( len(sensor.get_stream_profiles()), 218 ) # As measured running rs-sensor-control example + test.check_equal( len(sensor.get_stream_profiles()), 62 ) # As measured running rs-sensor-control example if test.check( 'Motion Module' in sensors ): sensor = sensors['Motion Module'] test.check_equal( len(sensor.get_stream_profiles()), 4 ) # As measured running rs-sensor-control example diff --git a/unit-tests/dds/test-librs-formats-conversion.py b/unit-tests/dds/test-librs-formats-conversion.py index c91fa3182b..e33d314508 100644 --- a/unit-tests/dds/test-librs-formats-conversion.py +++ b/unit-tests/dds/test-librs-formats-conversion.py @@ -36,35 +36,9 @@ sensor = sensors.get('Y8-sensor') profiles = sensor.get_stream_profiles() - test.check_equal( len( profiles ), 1 ) # Y8 stays Y8, for infrared stream indexed 1 + test.check_equal( len( profiles ), 1 ) test.check_equal( profiles[0].format(), rs.format.y8 ) - test.check_equal( profiles[0].stream_index(), 1 ) - # - ############################################################################################# - # - with test.closure( "Test Y8I conversion"): - if test.check( 'Y8I-sensor' in sensors ): - sensor = sensors.get('Y8I-sensor') - profiles = sensor.get_stream_profiles() - - test.check_equal( len( profiles ), 2 ) # Y8I is converted into two Y8 streams - test.check_equal( profiles[0].format(), rs.format.y8 ) - test.check_equal( profiles[0].stream_index(), 1 ) - test.check_equal( profiles[1].format(), rs.format.y8 ) - test.check_equal( profiles[1].stream_index(), 2 ) - # - ############################################################################################# - # - with test.closure( "Test Y12I conversion"): - if test.check( 'Y12I-sensor' in sensors ): - sensor = sensors.get('Y12I-sensor') - profiles = sensor.get_stream_profiles() - - test.check_equal( len( profiles ), 2 ) # Y12I is converted into two Y162 streams - test.check_equal( profiles[0].format(), rs.format.y16 ) - test.check_equal( profiles[0].stream_index(), 1 ) - test.check_equal( profiles[1].format(), rs.format.y16 ) - test.check_equal( profiles[1].stream_index(), 2 ) + test.check_equal( profiles[0].stream_index(), 0 ) # ############################################################################################# # @@ -73,14 +47,9 @@ sensor = sensors.get('YUYV-sensor') profiles = sensor.get_stream_profiles() - test.check_equal( len( profiles ), 7 ) # YUYV is converted into 7 streams - RGB8, RGBA8, BGR8, BGRA8, YUYV, Y16, Y8 - test.check_equal( profiles[0].format(), rs.format.rgb8 ) - test.check_equal( profiles[1].format(), rs.format.rgba8 ) - test.check_equal( profiles[2].format(), rs.format.bgr8 ) - test.check_equal( profiles[3].format(), rs.format.bgra8 ) - test.check_equal( profiles[4].format(), rs.format.yuyv ) - test.check_equal( profiles[5].format(), rs.format.y16 ) - test.check_equal( profiles[6].format(), rs.format.y8 ) + test.check_equal( len( profiles ), 2 ) # YUYV can stay YUYV or be converted into RGB8 + test.check_equal( profiles[0].format(), rs.format.yuyv ) + test.check_equal( profiles[1].format(), rs.format.rgb8 ) # ############################################################################################# # @@ -89,12 +58,9 @@ sensor = sensors.get('UYVY-sensor') profiles = sensor.get_stream_profiles() - test.check_equal( len( profiles ), 5 ) # UYVY is converted into 5 streams - RGB8, RGBA8, BGR8, BGRA8, UYVY - test.check_equal( profiles[0].format(), rs.format.rgb8 ) - test.check_equal( profiles[1].format(), rs.format.rgba8 ) - test.check_equal( profiles[2].format(), rs.format.bgr8 ) - test.check_equal( profiles[3].format(), rs.format.bgra8 ) - test.check_equal( profiles[4].format(), rs.format.uyvy ) + test.check_equal( len( profiles ), 2 ) # UYVY can stay UYVY or be converted into RGB8 + test.check_equal( profiles[0].format(), rs.format.uyvy ) + test.check_equal( profiles[1].format(), rs.format.rgb8 ) # ############################################################################################# # @@ -148,15 +114,10 @@ sensor = sensors.get('multiple-color-sensor') profiles = sensor.get_stream_profiles() - test.check_equal( len( profiles ), 21 ) + test.check_equal( len( profiles ), 6 ) for i in range(3): - test.check_equal( profiles[i * 7 + 0].format(), rs.format.rgb8 ) - test.check_equal( profiles[i * 7 + 1].format(), rs.format.rgba8 ) - test.check_equal( profiles[i * 7 + 2].format(), rs.format.bgr8 ) - test.check_equal( profiles[i * 7 + 3].format(), rs.format.bgra8 ) - test.check_equal( profiles[i * 7 + 4].format(), rs.format.yuyv ) - test.check_equal( profiles[i * 7 + 5].format(), rs.format.y16 ) - test.check_equal( profiles[i * 7 + 6].format(), rs.format.y8 ) + test.check_equal( profiles[i * 2 + 0].format(), rs.format.yuyv ) + test.check_equal( profiles[i * 2 + 1].format(), rs.format.rgb8 ) # ############################################################################################# # diff --git a/unit-tests/dds/test-stream-sensor-bridge.py b/unit-tests/dds/test-stream-sensor-bridge.py index 080b3fb6f0..a94579f65e 100644 --- a/unit-tests/dds/test-stream-sensor-bridge.py +++ b/unit-tests/dds/test-stream-sensor-bridge.py @@ -189,17 +189,17 @@ def find_server_profile( stream_name, profile_string ): try: bridge.open( find_server_profile( 'Depth', '640x480 16UC1 @ 30 Hz' )), test.check_throws( lambda: - bridge.open( servers['Depth'].default_profile() ), # 1280x720 16UC1 @ 30 Hz - RuntimeError, "profile <'Depth' 1280x720 16UC1 @ 30 Hz> is incompatible with already-open <'Depth' 640x480 16UC1 @ 30 Hz>" ) + bridge.open( servers['Depth'].default_profile() ), # 848x480 16UC1 @ 30 Hz + RuntimeError, "profile <'Depth' 848x480 16UC1 @ 30 Hz> is incompatible with already-open <'Depth' 640x480 16UC1 @ 30 Hz>" ) bridge.close( servers['Depth'] ) - bridge.open( servers['Depth'].default_profile() ) # 1280x720 16UC1 @ 30 Hz + bridge.open( servers['Depth'].default_profile() ) # 848x480 16UC1 @ 30 Hz bridge.commit() test.check_equal( len(active_sensors), 0 ) # not streaming yet start_stream( 'Depth' ) ( test.check_equal( len(active_sensors), 1 ) and test.check_equal( next(iter(active_sensors)), 'Stereo Module' ) and test.check_equal( len(active_sensors['Stereo Module']), 1 ) # Depth - and test.check_equal( find_active_profile( 'Depth' ).to_string(), "<'Depth' 1280x720 16UC1 @ 30 Hz>" ) + and test.check_equal( find_active_profile( 'Depth' ).to_string(), "<'Depth' 848x480 16UC1 @ 30 Hz>" ) ) # IR1 and IR2 are not open test.check_throws( lambda: @@ -215,12 +215,12 @@ def find_server_profile( stream_name, profile_string ): # test.start( "explicit+implicit streams, all compatible" ) try: - bridge.open( servers['Depth'].default_profile() ) # 1280x720 16UC1 @ 30 Hz + bridge.open( servers['Depth'].default_profile() ) # 848x480 16UC1 @ 30 Hz bridge.add_implicit_profiles() # adds IR1, IR2 test.check_throws( lambda: - bridge.open( servers['Infrared_1'].default_profile() ), - RuntimeError, "profile <'Infrared_1' 1280x800 Y8I @ 30 Hz> is incompatible with already-open <'Depth' 1280x720 16UC1 @ 30 Hz>" ) - bridge.open( find_server_profile( 'Infrared_1', '1280x720 Y8I @ 30 Hz' )) # same profile, makes it explicit! + bridge.open( find_server_profile( 'Infrared_1', '1280x800 mono8 @ 30 Hz' ) ), + RuntimeError, "profile <'Infrared_1' 1280x800 mono8 @ 30 Hz> is incompatible with already-open <'Depth' 848x480 16UC1 @ 30 Hz>" ) + bridge.open( find_server_profile( 'Infrared_1', '848x480 mono8 @ 30 Hz' )) # same profile, makes it explicit! bridge.commit() test.check_equal( len(active_sensors), 0 ) # not streaming yet start_stream( 'Depth' ) @@ -240,7 +240,7 @@ def find_server_profile( stream_name, profile_string ): # test.start( "stream profiles reset" ) try: - bridge.open( find_server_profile( 'Infrared_1', '640x480 Y8I @ 60 Hz' )) + bridge.open( find_server_profile( 'Infrared_1', '640x480 mono8 @ 60 Hz' ) ) bridge.add_implicit_profiles() # adds Depth, IR2 bridge.commit() test.check_equal( len(active_sensors), 0 ) # not streaming yet @@ -249,7 +249,7 @@ def find_server_profile( stream_name, profile_string ): and test.check_equal( next(iter(active_sensors)), 'Stereo Module' ) and test.check_equal( len(active_sensors['Stereo Module']), 3 ) ) - test.check_equal( find_active_profile( 'Infrared_2' ).to_string(), "<'Infrared_2' 640x480 Y8I @ 60 Hz>" ) + test.check_equal( find_active_profile( 'Infrared_2' ).to_string(), "<'Infrared_2' 640x480 mono8 @ 60 Hz>" ) stop_stream( 'Infrared_1' ) test.check_equal( len(active_sensors), 0 ) # not streaming again # We don't reset - last commit should still stand! @@ -258,7 +258,7 @@ def find_server_profile( stream_name, profile_string ): and test.check_equal( next(iter(active_sensors)), 'Stereo Module' ) and test.check_equal( len(active_sensors['Stereo Module']), 3 ) ) - test.check_equal( find_active_profile( 'Infrared_2' ).to_string(), "<'Infrared_2' 640x480 Y8I @ 60 Hz>" ) + test.check_equal( find_active_profile( 'Infrared_2' ).to_string(), "<'Infrared_2' 640x480 mono8 @ 60 Hz>" ) stop_stream( 'Infrared_2' ) test.check_equal( len(active_sensors), 0 ) # not streaming again # Now reset - commit should be lost and we should be back to the default profile @@ -297,18 +297,8 @@ def find_server_profile( stream_name, profile_string ): # test.start( "motion module" ) try: - start_stream( 'Accel' ) # MXYZ @ 200 Hz - test.check_equal( len(active_sensors), 1 ) - start_stream( 'Gyro' ) - test.check_equal( len(active_sensors), 1 ) # same sensor - stop_stream( 'Accel' ) - test.check_equal( len(active_sensors), 1 ) - stop_stream( 'Gyro' ) - test.check_equal( len(active_sensors), 0 ) - - bridge.open( servers['Gyro'].default_profile() ) # MXYZ @ 400 Hz - # Gyro has no 400 Hz - with bridge_error_expected( "failure trying to start/stop 'Accel': profile <'Accel' MXYZ @ 200 Hz> is incompatible with already-open <'Gyro' MXYZ @ 400 Hz>" ): + bridge.open( servers['Gyro'].default_profile() ) # MXYZ @ 200 Hz + with bridge_error_expected( "failure trying to start/stop 'Accel': profile <'Accel' MXYZ @ 100 Hz> is incompatible with already-open <'Gyro' MXYZ @ 200 Hz>" ): start_stream( 'Accel' ) # Note that while the stream shouldn't be streaming because the _SERVER_ failed, the stream still # has the reader open and therefore we still think is streaming...! This requires handling on @@ -326,7 +316,7 @@ def find_server_profile( stream_name, profile_string ): # test.start( "motion + color" ) try: - start_stream( 'Gyro' ) # MXYZ @ 400 Hz + start_stream( 'Gyro' ) # MXYZ @ 200 Hz test.check_equal( len(active_sensors), 1 ) start_stream( 'Color' ) test.check_equal( len(active_sensors), 2 ) @@ -344,21 +334,21 @@ def find_server_profile( stream_name, profile_string ): # test.start( "incompatible streams" ) try: - bridge.open( servers['Infrared_1'].default_profile() ) # 1280x800 Y8I @ 30 Hz + bridge.open( find_server_profile( 'Infrared_1', '1280x800 mono8 @ 30 Hz' ) ) bridge.add_implicit_profiles() # IR2 test.check_equal( len(active_sensors), 0 ) # not streaming yet - with bridge_error_expected( "failure trying to start/stop 'Depth': profile <'Depth' 1280x720 16UC1 @ 30 Hz> is incompatible with already-open <'Infrared_1' 1280x800 Y8I @ 30 Hz>" ): + with bridge_error_expected( "failure trying to start/stop 'Depth': profile <'Depth' 848x480 16UC1 @ 30 Hz> is incompatible with already-open <'Infrared_1' 1280x800 mono8 @ 30 Hz>" ): start_stream( 'Depth' ) # no depth at 1280x800, so no stream! test.check_equal( len(active_sensors), 0 ) test.check_throws( lambda: bridge.open( servers['Depth'].default_profile() ), - RuntimeError, "profile <'Depth' 1280x720 16UC1 @ 30 Hz> is incompatible with already-open <'Infrared_1' 1280x800 Y8I @ 30 Hz>" ) + RuntimeError, "profile <'Depth' 848x480 16UC1 @ 30 Hz> is incompatible with already-open <'Infrared_1' 1280x800 mono8 @ 30 Hz>" ) test.check_throws( lambda: - bridge.open( find_server_profile( 'Infrared_2', '848x480 Y8I @ 30 Hz' )), - RuntimeError, "profile <'Infrared_2' 848x480 Y8I @ 30 Hz> is incompatible with already-open <'Infrared_1' 1280x800 Y8I @ 30 Hz>" ) + bridge.open( find_server_profile( 'Infrared_2', '848x480 mono8 @ 30 Hz' )), + RuntimeError, "profile <'Infrared_2' 848x480 mono8 @ 30 Hz> is incompatible with already-open <'Infrared_1' 1280x800 mono8 @ 30 Hz>" ) test.check_throws( lambda: - bridge.open( find_server_profile( 'Infrared_2', '1280x800 Y8I @ 15 Hz' )), - RuntimeError, "profile <'Infrared_2' 1280x800 Y8I @ 15 Hz> is incompatible with already-open <'Infrared_1' 1280x800 Y8I @ 30 Hz>" ) + bridge.open( find_server_profile( 'Infrared_2', '1280x800 mono8 @ 15 Hz' )), + RuntimeError, "profile <'Infrared_2' 1280x800 mono8 @ 15 Hz> is incompatible with already-open <'Infrared_1' 1280x800 mono8 @ 30 Hz>" ) start_stream( 'Infrared_2' ) ( test.check_equal( len(active_sensors), 1 ) and test.check_equal( next(iter(active_sensors)), 'Stereo Module' ) @@ -377,18 +367,18 @@ def find_server_profile( stream_name, profile_string ): # test.start( "open and close" ) try: - bridge.open( servers['Infrared_1'].default_profile() ) # 1280x800 Y8I @ 30 Hz + bridge.open( servers['Infrared_1'].default_profile() ) # 848x480 mono8 @ 30 Hz bridge.open( servers['Infrared_1'].default_profile() ) # "compatible" bridge.close( servers['Infrared_1'] ) - bridge.open( find_server_profile( 'Infrared_1', '1280x800 Y8I @ 30 Hz' )) + bridge.open( find_server_profile( 'Infrared_1', '1280x800 mono8 @ 30 Hz' )) bridge.close( servers['Infrared_1'] ) bridge.close( servers['Infrared_1'] ) - bridge.open( find_server_profile( 'Infrared_1', '1280x800 Y12I @ 25 Hz' )) + bridge.open( find_server_profile( 'Infrared_1', '1280x800 Y16 @ 25 Hz' )) bridge.reset() - bridge.open( find_server_profile( 'Infrared_1', '1280x800 Y12I @ 15 Hz' )) + bridge.open( find_server_profile( 'Infrared_1', '1280x800 Y16 @ 15 Hz' )) test.check_throws( lambda: - bridge.open( find_server_profile( 'Infrared_1', '1280x800 Y12I @ 25 Hz' )), - RuntimeError, "profile <'Infrared_1' 1280x800 Y12I @ 25 Hz> is incompatible with already-open <'Infrared_1' 1280x800 Y12I @ 15 Hz>" ) + bridge.open( find_server_profile( 'Infrared_1', '1280x800 Y16 @ 25 Hz' )), + RuntimeError, "profile <'Infrared_1' 1280x800 Y16 @ 25 Hz> is incompatible with already-open <'Infrared_1' 1280x800 Y16 @ 15 Hz>" ) except Exception: test.unexpected_exception() finally: