Skip to content

Conversation

@maloel
Copy link
Contributor

@maloel maloel commented Oct 30, 2022

There's still a uid but it's no longer transmitted with profiles. To be removed in another PR.
Notifications are now topics::notification (no longer inside device::).
Notifications now primarily have a data_type and version, nothing else. The data can be in the format specified in the data_type (which currently supports CUSTOM, JSON, and CBOR). The data is bound at 4096 bytes (from what I saw in the code, it was at 100 before, but that obviously wasn't a limit -- this needs more looking into). Testing shows that, for a L515, the color stream has the most profiles (114) and this comes out to 6741 in raw json or 5034 in CBOR.
Notifications now communicate using JSON. This code mostly resides in the device and device-server. Should be a lot more flexible.

Additionally:

  • guard against device-server::init() failures

  • add L515 stream-format

  • move expected stream number out of device-impl (only used in init())

  • notification-server no longer starts automatically; on-discovery notifications can only be added when stopped

    • I actually saw this happen: we saw the reader before all on-discovery messages were defined, so only some of them got sent and the rest got lost
  • change device destruction in device-watcher to another thread

    • This was another weird bug that still needs to be understood
    • I got hangups when exiting python for some reason, and traced it to device destruction
    • A remote participant crashed (ctrl+c, on purpose) and, when dropping in the current process, the device writer first get removed. This triggers the callback in the watcher and, since it's the only holder of the device, the device gets destroyed...
    • Placing the destruction in a separate thread seems to alleviate this
    • Tried using a dispatcher to do this, which didn't work for some weird reason...

@maloel maloel requested a review from OhadMeir October 30, 2022 06:04
@Nir-Az
Copy link
Collaborator

Nir-Az commented Oct 30, 2022

There's still a uid but it's no longer transmitted with profiles. To be removed in another PR. Notifications are now topics::notification (no longer inside device::). Notifications now primarily have a data_type and version, nothing else. The data can be in the format specified in the data_type (which currently supports CUSTOM, JSON, and CBOR). The data is bound at 4096 bytes (from what I saw in the code, it was at 100 before, but that obviously wasn't a limit -- this needs more looking into). Testing shows that, for a L515, the color stream has the most profiles (114) and this comes out to 6741 in raw json or 5034 in CBOR. Notifications now communicate using JSON. This code mostly resides in the device and device-server. Should be a lot more flexible.

Additionally:

  • guard against device-server::init() failures

  • add L515 stream-format

  • move expected stream number out of device-impl (only used in init())

  • notification-server no longer starts automatically; on-discovery notifications can only be added when stopped

    • I actually saw this happen: we saw the reader before all on-discovery messages were defined, so only some of them got sent and the rest got lost
  • change device destruction in device-watcher to another thread

    • This was another weird bug that still needs to be understood
    • I got hangups when exiting python for some reason, and traced it to device destruction
    • A remote participant crashed (ctrl+c, on purpose) and, when dropping in the current process, the device writer first get removed. This triggers the callback in the watcher and, since it's the only holder of the device, the device gets destroyed...
    • Placing the destruction in a separate thread seems to alleviate this
    • Tried using a dispatcher to do this, which didn't work for some weird reason...

About the data side, I saw a d4xx device with more than 200 profiles,
Not sure I understand you say the previous notification size was 100 bytes? it was a dynamic size and the max profiles was 400 IMO no? or I misunderstood your comment.

So you say you have currently 5034/6741 but the limit is 4096?


// Forward declaration
namespace topics {
class notification;
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you explain when is a topic "raw"?
Why is device_info raw but notification not?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the non-raw notification you're looking at. There's a raw::notification, too

{
module raw
{
module device
Copy link
Contributor

Choose a reason for hiding this comment

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

Notification topic name does not include the device name? e.g. /realsense/D455/notification?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Topic name? Not sure what you mean. This is a general-purpose notification topic. What does it have to do with a device?

static void construct_raw_message( msg_type msg_id, const T& msg, raw::device::notification& raw_msg )
// Get the custom data with casting to the desired type
// Syntax: auto stream_info = msg.get< STREAM_INFO >();
// if ( msg ) do something with it;
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure I understand. What is get? Shouldn't it be
// Syntax: auto stream_info = msg.custom_data< STREAM_INFO >();
// if ( stream_info ) do something with it;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy paste issue - get was renamed to custom_data. I'll update.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

using type = raw::device::notificationPubSubType;
using type = raw::notificationPubSubType;

enum class data_type
Copy link
Contributor

Choose a reason for hiding this comment

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

I think data_formatting will be a better name

Copy link
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 type of the data... data_format is OK I guess but why?

Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds better to me :-)
Data type might mean other stuff as well. Format just means "the way in which something is arranged or set out."
Also when looking JSON and CBOR, wikipedia specifies they are data formats

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed.

~dds_notification_server();

// By default we're not started, to avoid on-discovery before all discovery messages have been collected
void start();
Copy link
Contributor

Choose a reason for hiding this comment

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

In other classes it is called run()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, will change.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed.

"more streams than expected (" + std::to_string( n_streams_expected )
+ ") received" );
auto type = utilities::json::get< std::string >( j, "type" );
auto stream_name = utilities::json::get< std::string >( j, "name" );
Copy link
Contributor

@OhadMeir OhadMeir Oct 31, 2022

Choose a reason for hiding this comment

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

Are the messages defined somewhere, like a readme? Can we pass it to Yoram's group so they will know what we expect?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, eventually. :)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Just making sure, this PR still keeps the profiles transfer works server --> client right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What other option is there? Everything is always server --> client...

Copy link
Collaborator

Choose a reason for hiding this comment

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

I mean that the functionality still works? like before this PR?

Copy link
Contributor Author

@maloel maloel Nov 1, 2022

Choose a reason for hiding this comment

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

Unit-tests pass. Functionality is still there. Notifications are sent, processed, etc. and streams are created on the client.
I don't understand the question, I guess.

profiles += sp->to_json();
json msg = {
{ "id", "stream-header" },
{ "type", stream->profiles().front()->type_to_string() },
Copy link
Contributor

@OhadMeir OhadMeir Oct 31, 2022

Choose a reason for hiding this comment

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

To support rs2 features we will need to add a dds_stream_xxx type system and a conversion back to rs2_stream+index (like we convert dds_stream_format to and from rs2_format)

This will be able to replace the changes I made in my PR ( #11045, you did add some comments about it)

Copy link
Contributor

Choose a reason for hiding this comment

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

Will also need some factory to create all the different stream types

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Once both our PRs are in, I'll add all the other classes

auto & stream = _streams[stream_name];
if( stream )
DDS_THROW( runtime_error, "stream '" + stream_name + "' already exists" );
stream = std::make_shared< dds_video_stream >( stream_name, sensor_name );
Copy link
Contributor

Choose a reason for hiding this comment

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

Hard to see in this UI
Where is dds_motion_stream created?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was a bug. Once we have it working we need to add some unit-tests with motion streams...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added a test-case.
Moved profile type_to_string() into stream-base type_string().
Added type-check: when creating a stream in device-impl, it checks that its type is now the same as that given in the json.

@maloel maloel merged commit 792e4df into realsenseai:dds Nov 3, 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.

3 participants