Skip to content

Unify notification and control messages using "flexible-message" - #11063

Merged
maloel merged 14 commits into
realsenseai:ddsfrom
maloel:dds
Nov 6, 2022
Merged

Unify notification and control messages using "flexible-message"#11063
maloel merged 14 commits into
realsenseai:ddsfrom
maloel:dds

Conversation

@maloel

@maloel maloel commented Nov 3, 2022

Copy link
Copy Markdown
Contributor
  • removed dds_stream_uid - context-side code now generates them automatically
  • fix bug in rs-dds-server when device was disconnected
  • added operator<() for rs2::device (otherwise std::map would use operator bool() and won't complain)

@maloel
maloel requested a review from OhadMeir November 3, 2022 14:58
Comment thread src/context.cpp
{
}

int add_dds_stream( std::shared_ptr< realdds::dds_stream > const & stream )

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 int and not size_t? No need to cast

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.

It's the stream index, which is usually an int in libRS and the profile. We'll need to cast at some point. Might as well be here.

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.

You cast the sensor index at to_rs2_video_stream, I think this cast should be don't there too

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 this is not exactly how USB device indexes work, still need to work it out. Here you can have depth or color with index other than 0, and infrared with index 3 or 4. OK for this pull request, but needs more thinking

Comment thread src/context.cpp
{
for( auto & sp : _streams[stream_index]->profiles() )
{
auto vsp = std::static_pointer_cast< realdds::dds_video_stream_profile >( sp );

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.

Need to check if stream type is video

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.

Right now it assumes the streams are all uniform: they're created from a dds_device which gets its streams from a stream-header that defines the type of its profiles.

@maloel

maloel commented Nov 5, 2022

Copy link
Copy Markdown
Contributor Author

The previous message size was >10K for D435i. For L515, the color stream had a json that was 6741 characters (5034 CBOR).
Most of that is the key strings which, in the case of profiles, is very repetitive.
I decided to try and optimize a bit: the profile to_json() now gives an array instead of a map. 6741 becomes 2409 (1614 CBOR): much better and even more so for the D435i.
I also moved the json profile parsing into the profile code (from_json()) so nobody has to deal with it. Usage is much simpler.

: _uid( uid )
, _format( format )
dds_stream_profile( dds_stream_format format, int16_t frequency )
: _format( format )

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.

It is more efficient to initialize members by declaration order.

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.

AFAIK the init order is the order of decl, whatever order you write them in.

{
int it = 0;
auto profile = std::make_shared< final_stream_profile >( j, it );
verify_end_of_json( j, it ); // just so it's not in the header

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 not put all of from_json implementation in the cpp? It is not inlined anyway

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.

It's a template...

raw::flexible flexible_msg::to_raw()
{
raw::flexible raw_msg;
raw_msg.data_format( (raw::flexible_data_format) _data_format );

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.

Prefer cpp style casts

# the uid is not communicated any more... therefore 0x1 (the first profile)
test.check_equal( '<pyrealdds.motion_stream_profile 0x1 RGB8 30 Hz>', str(profiles[0]) )
test.check_equal( len( profiles ), 1 )
test.check_equal( str(profiles[0]), '<pyrealdds.motion_stream_profile RGB8 @ 30 Hz>' )

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.

Its just a communication test but RGB8 for motion is wierd :-)
Maybe we need to add a motion format specification?

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.

There is... but like you said it's not important here.
The next PR will have a whole D435i emulation, with all the profiles including motion.

@maloel
maloel merged commit 51179a9 into realsenseai:dds Nov 6, 2022
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.

2 participants