Skip to content

Commit

Permalink
Make the trigger of the DDS Pipe callbacks configurable (#56)
Browse files Browse the repository at this point in the history
* Use builtin topics for internal communication

Signed-off-by: tempate <[email protected]>

* Make the DdsPipeConfiguration required

Signed-off-by: tempate <[email protected]>

* Rebase fix

Signed-off-by: tempate <[email protected]>

* Uncrustify

Signed-off-by: tempate <[email protected]>

* WRITER discovery trigger

Signed-off-by: tempate <[email protected]>

* Internal communication through built-in topics

Signed-off-by: tempate <[email protected]>

* Fix windows error

Signed-off-by: tempate <[email protected]>

* Apply suggestions

Signed-off-by: tempate <[email protected]>

* Apply suggestions

Signed-off-by: tempate <[email protected]>

* Remove outdated warning

Signed-off-by: tempate <[email protected]>

* Apply suggestions

Signed-off-by: tempate <[email protected]>

* Apply suggestions

Signed-off-by: tempate <[email protected]>

---------

Signed-off-by: tempate <[email protected]>
  • Loading branch information
Tempate authored Nov 22, 2023
1 parent 26f4bb2 commit 76bd140
Show file tree
Hide file tree
Showing 9 changed files with 66 additions and 46 deletions.
4 changes: 0 additions & 4 deletions docs/rst/user_manual/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -243,10 +243,6 @@ Example:
See `Interface Whitelist <https://fast-dds.docs.eprosima.com/en/latest/fastdds/transport/whitelist.html>`_ for more information.

.. warning::

When providing an interface whitelist, external participants with which communication is desired must also be configured with interface whitelisting.

Topic type format
-----------------

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ struct EndpointInfoData : public ddspipe::core::IRoutingData
EndpointInfo info{};
};

FASTDDSSPY_PARTICIPANTS_DllAPI
ddspipe::core::types::DdsTopic endpoint_info_topic() noexcept;

FASTDDSSPY_PARTICIPANTS_DllAPI
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ struct ParticipantInfoData : public ddspipe::core::IRoutingData
ParticipantInfo info{};
};

FASTDDSSPY_PARTICIPANTS_DllAPI
ddspipe::core::types::DdsTopic participant_info_topic() noexcept;

FASTDDSSPY_PARTICIPANTS_DllAPI
Expand Down
12 changes: 2 additions & 10 deletions fastddsspy_participants/src/cpp/participant/SpyParticipant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ SpyParticipant::SpyParticipant(
{
return this->new_participant_info_(data);
};

participants_writer_ = std::make_shared<InternalWriter>(
participant_configuration->id,
participant_callback);
Expand All @@ -43,19 +44,10 @@ SpyParticipant::SpyParticipant(
{
return this->new_endpoint_info_(data);
};

endpoints_writer_ = std::make_shared<InternalWriter>(
participant_configuration->id,
endpoint_callback);

// Simulate that there is a reader of participants to force this track creation
discovery_database_->add_endpoint(
ddspipe::participants::rtps::CommonParticipant::simulate_endpoint(participant_info_topic(), this->id())
);

// Simulate that there is a reader of endpoints to force this track creation
discovery_database_->add_endpoint(
ddspipe::participants::rtps::CommonParticipant::simulate_endpoint(endpoint_info_topic(), this->id())
);
}

std::shared_ptr<ddspipe::core::IWriter> SpyParticipant::create_writer(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,18 @@ std::shared_ptr<DdsPipe> create_pipe(
DdsPipeConfiguration ddspipe_configuration;
ddspipe_configuration.init_enabled = true;

// Create a built-in topic to transmit endpoint information
ddspipe_configuration.builtin_topics.insert(
utils::Heritable<types::DistributedTopic>::make_heritable(
spy::participants::endpoint_info_topic()));

std::shared_ptr<DdsPipe> pipe =
std::make_unique<DdsPipe>(
ddspipe_configuration,
discovery_database,
payload_pool,
participant_database,
thread_pool
);
thread_pool);

return pipe;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ std::shared_ptr<DdsPipe> create_pipe(
// Create participants
std::shared_ptr<spy::participants::SpyParticipantConfiguration> spy_configuration =
std::make_shared<spy::participants::SpyParticipantConfiguration>();

std::shared_ptr<spy::participants::SpyParticipant> spy_participant =
std::make_shared<spy::participants::SpyParticipant>(
spy_configuration,
Expand All @@ -116,14 +117,19 @@ std::shared_ptr<DdsPipe> create_pipe(
DdsPipeConfiguration ddspipe_configuration;
ddspipe_configuration.init_enabled = true;

// Create a built-in topic to transmit participant information
ddspipe_configuration.builtin_topics.insert(
utils::Heritable<types::DistributedTopic>::make_heritable(
spy::participants::participant_info_topic()));

std::shared_ptr<DdsPipe> pipe =
std::make_unique<DdsPipe>(
ddspipe_configuration,
discovery_database,
payload_pool,
participant_database,
thread_pool
);
thread_pool);

return pipe;
}

Expand Down
45 changes: 42 additions & 3 deletions fastddsspy_tool/src/cpp/tool/Backend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
// limitations under the License.

#include <ddspipe_core/configuration/DdsPipeConfiguration.hpp>
#include <ddspipe_core/types/dynamic_types/types.hpp>

#include "Backend.hpp"

Expand Down Expand Up @@ -62,11 +63,49 @@ Backend::Backend(
spy_participant_
);

// Create and initialize Pipe
ddspipe::core::DdsPipeConfiguration ddspipe_configuration;
// Create a built-in topic to transmit participant information
configuration_.ddspipe_configuration.builtin_topics.insert(
utils::Heritable<eprosima::ddspipe::core::types::DistributedTopic>::make_heritable(
spy::participants::participant_info_topic()));

// Create a built-in topic to transmit endpoint information
configuration_.ddspipe_configuration.builtin_topics.insert(
utils::Heritable<eprosima::ddspipe::core::types::DistributedTopic>::make_heritable(
spy::participants::endpoint_info_topic()));

// Create an internal topic to transmit the dynamic types
configuration_.ddspipe_configuration.builtin_topics.insert(
utils::Heritable<eprosima::ddspipe::core::types::DistributedTopic>::make_heritable(
eprosima::ddspipe::core::types::type_object_topic()));

if (!configuration_.ddspipe_configuration.allowlist.empty())
{
// The allowlist is not empty. Add the internal topics.
eprosima::ddspipe::core::types::WildcardDdsFilterTopic type_object_topic;
type_object_topic.topic_name.set_value(eprosima::ddspipe::core::types::TYPE_OBJECT_TOPIC_NAME);

configuration_.ddspipe_configuration.allowlist.insert(
utils::Heritable<eprosima::ddspipe::core::types::WildcardDdsFilterTopic>::make_heritable(
type_object_topic));

eprosima::ddspipe::core::types::WildcardDdsFilterTopic participant_info_topic;
participant_info_topic.topic_name.set_value(participants::PARTICIPANT_INFO_TOPIC_NAME);

configuration_.ddspipe_configuration.allowlist.insert(
utils::Heritable<eprosima::ddspipe::core::types::WildcardDdsFilterTopic>::make_heritable(
participant_info_topic));

eprosima::ddspipe::core::types::WildcardDdsFilterTopic endpoint_info_topic;
endpoint_info_topic.topic_name.set_value(participants::ENDPOINT_INFO_TOPIC_NAME);

configuration_.ddspipe_configuration.allowlist.insert(
utils::Heritable<eprosima::ddspipe::core::types::WildcardDdsFilterTopic>::make_heritable(
endpoint_info_topic));
}

// Create and initialize Pipe
pipe_ = std::make_unique<ddspipe::core::DdsPipe>(
ddspipe_configuration,
configuration_.ddspipe_configuration,
discovery_database_,
payload_pool_,
participant_database_,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,10 @@
#include <cpp_utils/memory/Heritable.hpp>
#include <cpp_utils/time/time_utils.hpp>

#include <ddspipe_core/types/dds/TopicQoS.hpp>
#include <ddspipe_core/types/topic/filter/IFilterTopic.hpp>
#include <ddspipe_core/types/topic/dds/DistributedTopic.hpp>
#include <ddspipe_core/configuration/DdsPipeConfiguration.hpp>
#include <ddspipe_core/configuration/IConfiguration.hpp>
#include <ddspipe_core/types/topic/filter/IFilterTopic.hpp>
#include <ddspipe_core/types/topic/dds/DistributedTopic.hpp>

#include <ddspipe_participants/configuration/SimpleParticipantConfiguration.hpp>
#include <ddspipe_participants/configuration/ParticipantConfiguration.hpp>
Expand All @@ -30,6 +29,8 @@
#include <ddspipe_yaml/YamlReader.hpp>

#include <fastddsspy_participants/configuration/SpyParticipantConfiguration.hpp>
#include <fastddsspy_participants/types/EndpointInfo.hpp>
#include <fastddsspy_participants/types/ParticipantInfo.hpp>

#include <fastddsspy_yaml/library/library_dll.h>

Expand Down
24 changes: 2 additions & 22 deletions fastddsspy_yaml/src/cpp/YamlReaderConfiguration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
#include <ddspipe_core/types/dds/TopicQoS.hpp>
#include <ddspipe_core/types/dynamic_types/types.hpp>
#include <ddspipe_core/types/topic/dds/DdsTopic.hpp>
#include <ddspipe_core/types/topic/filter/IFilterTopic.hpp>
#include <ddspipe_core/types/topic/filter/ManualTopic.hpp>
#include <ddspipe_core/types/topic/filter/WildcardDdsFilterTopic.hpp>
#include <ddspipe_participants/types/address/Address.hpp>
Expand All @@ -25,9 +24,6 @@
#include <ddspipe_yaml/YamlManager.hpp>
#include <ddspipe_yaml/YamlReader.hpp>

#include <fastddsspy_participants/types/EndpointInfo.hpp>
#include <fastddsspy_participants/types/ParticipantInfo.hpp>

#include <fastddsspy_yaml/yaml_configuration_tags.hpp>

#include <fastddsspy_yaml/YamlReaderConfiguration.hpp>
Expand Down Expand Up @@ -109,6 +105,8 @@ void Configuration::load_configuration_(
ddspipe_configuration.blocklist.insert(
utils::Heritable<WildcardDdsFilterTopic>::make_heritable(rpc_response_topic));

// Only trigger the DdsPipe's callbacks with the discovery (and removal) of writers.
ddspipe_configuration.discovery_trigger = DiscoveryTrigger::WRITER;
}
catch (const std::exception& e)
{
Expand All @@ -127,24 +125,6 @@ void Configuration::load_dds_configuration_(
{
ddspipe_configuration.allowlist = YamlReader::get_set<utils::Heritable<IFilterTopic>>(yml, ALLOWLIST_TAG,
version);

// Add to allowlist always the type object topic
WildcardDdsFilterTopic type_object_topic;
type_object_topic.topic_name.set_value(TYPE_OBJECT_TOPIC_NAME);
ddspipe_configuration.allowlist.insert(
utils::Heritable<WildcardDdsFilterTopic>::make_heritable(type_object_topic));

// Add to allowlist always the participant info internal topic
WildcardDdsFilterTopic participant_info_topic;
participant_info_topic.topic_name.set_value(participants::PARTICIPANT_INFO_TOPIC_NAME);
ddspipe_configuration.allowlist.insert(
utils::Heritable<WildcardDdsFilterTopic>::make_heritable(participant_info_topic));

// Add to allowlist always the endpoint info internal topic
WildcardDdsFilterTopic endpoint_info_topic;
endpoint_info_topic.topic_name.set_value(participants::ENDPOINT_INFO_TOPIC_NAME);
ddspipe_configuration.allowlist.insert(
utils::Heritable<WildcardDdsFilterTopic>::make_heritable(endpoint_info_topic));
}

/////
Expand Down

0 comments on commit 76bd140

Please sign in to comment.