Skip to content

Commit

Permalink
use dds-adapter-watcher in dds-participant with refresh_qos()
Browse files Browse the repository at this point in the history
  • Loading branch information
maloel committed Sep 3, 2024
1 parent 0ce7468 commit 6eaea58
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 2 deletions.
10 changes: 10 additions & 0 deletions third-party/realdds/include/realdds/dds-participant.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ class slice;
namespace realdds {


class dds_adapter_watcher;


// The starting point for any DDS interaction, a participant has a name and is the focal point for creating, destroying,
// and managing other DDS objects. It defines the DDS domain (ID) in which every other object lives.
//
Expand All @@ -53,6 +56,7 @@ class dds_participant
struct listener_impl;

rsutils::json _settings;
std::shared_ptr< dds_adapter_watcher > _adapter_watcher;

public:
dds_participant() = default;
Expand All @@ -71,6 +75,12 @@ class dds_participant
qos( std::string const & participant_name );
};

// Return the QoS (so user won't have to actually know about the DomainParticipant)
eprosima::fastdds::dds::DomainParticipantQos const & get_qos() const;

// Refresh the QoS, so it will pick up any changes in the system (e.g., if adapters have changed)
void refresh_qos();

// Creates the underlying DDS participant and sets the QoS.
// If callbacks are needed, set them before calling init. Note they may be called before init returns!
//
Expand Down
28 changes: 26 additions & 2 deletions third-party/realdds/src/dds-participant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <realdds/dds-guid.h>
#include <realdds/dds-time.h>
#include <realdds/dds-serialization.h>
#include <realdds/dds-adapter-watcher.h>

#include <fastdds/dds/domain/DomainParticipantFactory.hpp>
#include <fastdds/dds/domain/DomainParticipantListener.hpp>
Expand Down Expand Up @@ -209,6 +210,10 @@ dds_participant::qos::qos( std::string const & participant_name )
//udp_transport->maxMessageSize = 1470; TODO this affects reading, too! We need writer-only property for this...
transport().use_builtin_transports = false;
transport().user_transports.push_back( udp_transport );

// If the user has many local interfaces (possible: I have 5!) then anything over the limit will not get
// communicated and end-point discovery will be affected. We want to avoid this so increase the limit:
allocation().locators.max_unicast_locators = 10;
}


Expand Down Expand Up @@ -253,6 +258,13 @@ void dds_participant::init( dds_domain_id domain_id, qos & pqos, rsutils::json c
else
DDS_THROW( runtime_error, "provided settings are invalid: " << settings );

_adapter_watcher = std::make_shared< dds_adapter_watcher >(
[this]
{
LOG_DEBUG( name() << ": refreshing QoS" );
refresh_qos();
} );

LOG_DEBUG( "participant " << realdds::print_raw_guid( guid() ) << " " << pqos << "\nis up on domain " << domain_id
<< " from settings: " << std::setw( 4 ) << _settings );

Expand Down Expand Up @@ -293,17 +305,23 @@ dds_domain_id dds_participant::domain_id() const
}


eprosima::fastdds::dds::DomainParticipantQos const & dds_participant::get_qos() const
{
return get()->get_qos();
}


rsutils::string::slice dds_participant::name() const
{
auto & string_255 = get()->get_qos().name();
auto & string_255 = get_qos().name();
return rsutils::string::slice( string_255.c_str(), string_255.size() );
}


std::shared_ptr< const eprosima::fastdds::rtps::FlowControllerDescriptor >
dds_participant::find_flow_controller( char const * name ) const
{
for( auto & controller : get()->get_qos().flow_controllers() )
for( auto & controller : get_qos().flow_controllers() )
{
if( ! strcmp( name, controller->name ) )
return controller;
Expand All @@ -312,6 +330,12 @@ dds_participant::find_flow_controller( char const * name ) const
}


void dds_participant::refresh_qos()
{
get()->set_qos( get_qos() );
}


std::string dds_participant::print( dds_guid const & guid_to_print ) const
{
return rsutils::string::from( realdds::print_guid( guid_to_print, guid() ) );
Expand Down

0 comments on commit 6eaea58

Please sign in to comment.