Skip to content

Commit dde3263

Browse files
authored
PR #13386 from Eran: DDS changes and fixes
2 parents 099e775 + 5f16421 commit dde3263

File tree

20 files changed

+189
-121
lines changed

20 files changed

+189
-121
lines changed

src/backend-device-factory.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,14 +145,14 @@ backend_device_factory::backend_device_factory( std::shared_ptr< context > const
145145
for( auto & device_removed : subtract_sets( old_list, new_list ) )
146146
{
147147
devices_removed.push_back( device_removed );
148-
LOG_DEBUG( "Device disconnected: " << device_removed->get_address() );
148+
LOG_INFO( "Device disconnected: " << device_removed->get_address() );
149149
}
150150

151151
std::vector< std::shared_ptr< device_info > > devices_added;
152152
for( auto & device_added : subtract_sets( new_list, old_list ) )
153153
{
154154
devices_added.push_back( device_added );
155-
LOG_DEBUG( "Device connected: " << device_added->get_address() );
155+
LOG_INFO( "Device connected: " << device_added->get_address() );
156156
}
157157

158158
if( devices_removed.size() + devices_added.size() )

src/context.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,20 +116,20 @@ namespace librealsense {
116116
{
117117
for( auto & dev_info : factory->query_devices( requested_mask ) )
118118
{
119-
LOG_INFO( "... " << dev_info->get_address() );
119+
LOG_DEBUG( "... " << dev_info->get_address() );
120120
list.push_back( dev_info );
121121
}
122122
}
123123
for( auto & item : _user_devices )
124124
{
125125
if( auto dev_info = item.second.lock() )
126126
{
127-
LOG_INFO( "... " << dev_info->get_address() );
127+
LOG_DEBUG( "... " << dev_info->get_address() );
128128
list.push_back( dev_info );
129129
}
130130
}
131-
LOG_INFO( "Found " << list.size() << " RealSense devices (0x" << std::hex << requested_mask << " requested & 0x"
132-
<< get_device_mask() << " from device-mask in settings)" << std::dec );
131+
LOG_DEBUG( "Found " << list.size() << " RealSense devices (0x" << std::hex << requested_mask
132+
<< " requested & 0x" << get_device_mask() << " from device-mask in settings)" << std::dec );
133133
return list;
134134
}
135135

src/dds/rs-dds-device-proxy.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ dds_device_proxy::dds_device_proxy( std::shared_ptr< const device_info > const &
149149
, auto_calibrated_proxy()
150150
, _dds_dev( dev )
151151
{
152-
LOG_DEBUG( "=====> dds-device-proxy " << this << " created on top of dds-device " << _dds_dev.get() );
152+
//LOG_DEBUG( "=====> dds-device-proxy " << this << " created on top of dds-device " << _dds_dev.get() );
153153
register_info( RS2_CAMERA_INFO_NAME, dev->device_info().name() );
154154
register_info( RS2_CAMERA_INFO_PHYSICAL_PORT, dev->device_info().topic_root() );
155155
register_info( RS2_CAMERA_INFO_PRODUCT_ID, "DDS" );
@@ -236,8 +236,8 @@ dds_device_proxy::dds_device_proxy( std::shared_ptr< const device_info > const &
236236
sensor_info.proxy->add_dds_stream( sidx, stream );
237237
_stream_name_to_owning_sensor[stream->name()] = sensor_info.proxy;
238238
type_and_index_to_dds_stream_sidx.insert( { type_and_index, sidx } );
239-
LOG_DEBUG( sidx.to_string() << " " << get_string( sensor_info.type ) << " '" << stream->sensor_name()
240-
<< "' : '" << stream->name() << "' " << get_string( stream_type ) );
239+
//LOG_DEBUG( sidx.to_string() << " " << get_string( sensor_info.type ) << " '" << stream->sensor_name()
240+
// << "' : '" << stream->name() << "' " << get_string( stream_type ) );
241241

242242
software_sensor & sensor = get_software_sensor( sensor_info.sensor_index );
243243
auto video_stream = std::dynamic_pointer_cast< realdds::dds_video_stream >( stream );
@@ -281,7 +281,7 @@ dds_device_proxy::dds_device_proxy( std::shared_ptr< const device_info > const &
281281

282282
for( auto & sensor_info : sensor_name_to_info )
283283
{
284-
LOG_DEBUG( sensor_info.first );
284+
//LOG_DEBUG( sensor_info.first );
285285

286286
// Set profile's ID based on the dds_stream's ID (index already set). Connect the profile to the extrinsics graph.
287287
for( auto & profile : sensor_info.second.proxy->get_stream_profiles() )
@@ -348,7 +348,7 @@ dds_device_proxy::dds_device_proxy( std::shared_ptr< const device_info > const &
348348
auto const dds_extr = _dds_dev->get_extrinsics( from_stream.first, to_stream.first );
349349
if( ! dds_extr )
350350
{
351-
LOG_DEBUG( "missing extrinsics from " << from_stream.first << " to " << to_stream.first );
351+
//LOG_DEBUG( "missing extrinsics from " << from_stream.first << " to " << to_stream.first );
352352
continue;
353353
}
354354
rs2_extrinsics extr = to_rs2_extrinsics( dds_extr );

src/dds/rs-dds-sensor-proxy.cpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -306,30 +306,29 @@ void dds_sensor_proxy::handle_video_data( realdds::topics::image_msg && dds_fram
306306
data.backend_timestamp // time when the underlying backend (DDS) received it
307307
= static_cast<rs2_time_t>(realdds::time_to_double( dds_sample.reception_timestamp ) * 1e3);
308308
data.timestamp // in ms
309-
= static_cast< rs2_time_t >( realdds::time_to_double( dds_frame.timestamp ) * 1e3 );
309+
= static_cast< rs2_time_t >( realdds::time_to_double( dds_frame.timestamp() ) * 1e3 );
310310
data.last_timestamp = streaming.last_timestamp.exchange( data.timestamp );
311311
data.timestamp_domain; // from metadata, or leave default (hardware domain)
312312
data.depth_units; // from metadata
313313
data.frame_number; // filled in only once metadata is known
314-
data.raw_size = static_cast< uint32_t >( dds_frame.raw_data.size() );
314+
data.raw_size = static_cast< uint32_t >( dds_frame.raw().data().size() );
315315

316316
auto vid_profile = dynamic_cast< video_stream_profile_interface * >( profile.get() );
317317
if( ! vid_profile )
318318
throw invalid_value_exception( "non-video profile provided to on_video_frame" );
319319

320-
auto stride = static_cast< int >( dds_frame.height > 0 ? dds_frame.raw_data.size() / dds_frame.height
321-
: dds_frame.raw_data.size() );
322-
auto bpp = dds_frame.width > 0 ? stride / dds_frame.width : stride;
320+
auto stride = static_cast< int >( dds_frame.height() > 0 ? data.raw_size / dds_frame.height() : data.raw_size );
321+
auto bpp = dds_frame.width() > 0 ? stride / dds_frame.width() : stride;
323322
auto new_frame_interface = allocate_new_video_frame( vid_profile, stride, bpp, std::move( data ) );
324323
if( ! new_frame_interface )
325324
return;
326325

327326
auto new_frame = static_cast< frame * >( new_frame_interface );
328-
new_frame->data = std::move( dds_frame.raw_data );
327+
new_frame->data = std::move( dds_frame.raw().data() );
329328

330329
if( _md_enabled )
331330
{
332-
streaming.syncer.enqueue_frame( dds_frame.timestamp.to_ns(), streaming.syncer.hold( new_frame ) );
331+
streaming.syncer.enqueue_frame( dds_frame.timestamp().to_ns(), streaming.syncer.hold( new_frame ) );
333332
}
334333
else
335334
{
@@ -610,7 +609,7 @@ void dds_sensor_proxy::add_option( std::shared_ptr< realdds::dds_option > option
610609
if( get_option_handler( option_id ) )
611610
throw std::runtime_error( "option '" + option->get_name() + "' already exists in sensor" );
612611

613-
LOG_DEBUG( "... option -> " << option->get_name() );
612+
//LOG_DEBUG( "... option -> " << option->get_name() );
614613
auto opt = std::make_shared< rs_dds_option >(
615614
option,
616615
[=]( json value )

src/dds/rsdds-device-factory.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,15 @@ rsdds_device_factory::rsdds_device_factory( std::shared_ptr< context > const & c
157157
std::vector< std::shared_ptr< device_info > > infos_removed;
158158
auto dev_info = std::make_shared< dds_device_info >( ctx, dev );
159159
if( added )
160+
{
160161
infos_added.push_back( dev_info );
162+
LOG_INFO( "Device connected: " << dev_info->get_address() );
163+
}
161164
else
165+
{
162166
infos_removed.push_back( dev_info );
167+
LOG_INFO( "Device disconnected: " << dev_info->get_address() );
168+
}
163169
cb( infos_removed, infos_added );
164170
} );
165171
}

src/environment.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ namespace librealsense
133133
}
134134

135135
if (!invalid_ids.empty())
136-
LOG_INFO("Found " << invalid_ids.size() << " unreachable streams, " << std::dec << counter << " extrinsics deleted");
136+
LOG_DEBUG("Found " << invalid_ids.size() << " unreachable streams, " << std::dec << counter << " extrinsics deleted");
137137
}
138138

139139
int extrinsics_graph::find_stream_profile(const stream_interface& p, bool add_if_not_there)

src/proc/formats-converter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ stream_profiles formats_converter::get_all_possible_profiles( const stream_profi
9797

9898
for( auto & raw_profile : raw_profiles )
9999
{
100-
LOG_DEBUG( "Raw profile: " << raw_profile );
100+
//LOG_DEBUG( "Raw profile: " << raw_profile );
101101
for( auto & pbf : _pb_factories )
102102
{
103103
const auto & sources = pbf->get_source_info();
@@ -129,7 +129,7 @@ stream_profiles formats_converter::get_all_possible_profiles( const stream_profi
129129
target.resolution_transform( width, height );
130130
cloned_vsp->set_dims( width, height );
131131
}
132-
LOG_DEBUG( " -> " << cloned_profile );
132+
//LOG_DEBUG( " -> " << cloned_profile );
133133

134134
// Cache pbf supported profiles for efficiency in find_pbf_matching_most_profiles
135135
_pbf_supported_profiles[pbf.get()].push_back( cloned_profile );

third-party/realdds/include/realdds/dds-stream-server.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ class dds_video_stream_server : public dds_stream_server
9292
void stop_streaming() override;
9393
image_header const & get_image_header() const { return _image_header; }
9494

95-
virtual void publish_image( topics::image_msg && );
95+
virtual void publish_image( topics::image_msg & );
9696

9797
private:
9898
void check_profile( std::shared_ptr< dds_stream_profile > const & ) const override;

third-party/realdds/include/realdds/topics/image-msg.h

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
#include <realdds/dds-defines.h>
66
#include <fastdds/rtps/common/Time_t.h>
77

8+
#include <realdds/topics/ros2/ros2image.h>
9+
810
#include <string>
911
#include <memory>
1012
#include <vector>
@@ -13,7 +15,6 @@
1315
namespace sensor_msgs {
1416
namespace msg {
1517
class ImagePubSubType;
16-
class Image;
1718
} // namespace msg
1819
} // namespace sensor_msgs
1920

@@ -31,6 +32,8 @@ namespace topics {
3132

3233
class image_msg
3334
{
35+
sensor_msgs::msg::Image _raw;
36+
3437
public:
3538
using type = sensor_msgs::msg::ImagePubSubType;
3639

@@ -46,8 +49,34 @@ class image_msg
4649
image_msg & operator=( image_msg && ) = default;
4750
image_msg & operator=( sensor_msgs::msg::Image && );
4851

49-
bool is_valid() const { return width != -1 && height != -1; }
50-
void invalidate() { width = -1; }
52+
bool is_valid() const { return ! _raw.data().empty(); }
53+
void invalidate() { _raw.data().clear(); }
54+
55+
sensor_msgs::msg::Image & raw() { return _raw; }
56+
sensor_msgs::msg::Image const & raw() const { return _raw; }
57+
58+
auto width() const { return _raw.width(); }
59+
void set_width( uint32_t w ) { _raw.width( w ); }
60+
auto height() const { return _raw.height(); }
61+
void set_height( uint32_t h ) { _raw.height( h ); }
62+
auto step() const { return _raw.step(); }
63+
void set_step( uint32_t step ) { _raw.step( step ); }
64+
65+
std::string const & frame_id() const { return _raw.header().frame_id(); }
66+
void set_frame_id( std::string new_id ) { _raw.header().frame_id( std::move( new_id ) ); }
67+
68+
std::string const & encoding() const { return _raw.encoding(); }
69+
void set_encoding( std::string new_encoding ) { _raw.encoding( std::move( new_encoding ) ); }
70+
71+
bool is_bigendian() const { return _raw.is_bigendian(); }
72+
73+
void set_timestamp( dds_time const & t )
74+
{
75+
_raw.header().stamp().sec( t.seconds );
76+
_raw.header().stamp().nanosec( t.nanosec );
77+
}
78+
dds_time timestamp() const { return { _raw.header().stamp().sec(), _raw.header().stamp().nanosec() }; }
79+
5180

5281
static std::shared_ptr< dds_topic > create_topic( std::shared_ptr< dds_participant > const & participant,
5382
char const * topic_name );
@@ -63,11 +92,6 @@ class image_msg
6392
static bool take_next( dds_topic_reader &,
6493
image_msg * output,
6594
dds_sample * optional_sample = nullptr );
66-
67-
std::vector< uint8_t > raw_data;
68-
int width = -1;
69-
int height = -1;
70-
dds_time timestamp;
7195
};
7296

7397

third-party/realdds/include/realdds/topics/ros2/ros2header.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
#include "ros2time.h"
1515

16-
#include <fastrtps/utils/fixed_size_string.hpp>
16+
//#include <fastrtps/utils/fixed_size_string.hpp>
1717

1818
#include <stdint.h>
1919
#include <array>

0 commit comments

Comments
 (0)