From d9721e236806edf8fe11f720f4cd9873f2d63f17 Mon Sep 17 00:00:00 2001 From: Manuel Valch Date: Sun, 3 Nov 2024 16:51:08 +0100 Subject: [PATCH 1/4] Add plugins/fastdds class diagram In order to try to make a more rationnal implementation of the support of keyed topics into visualizer code. Tryied to document the code so that it will be more clear to me what has to be done. Signed-off-by: Manuel Valch --- .dev/design/backend.plantuml | 106 +++++++++++++++++++++++++++++++++++ 1 file changed, 106 insertions(+) create mode 100644 .dev/design/backend.plantuml diff --git a/.dev/design/backend.plantuml b/.dev/design/backend.plantuml new file mode 100644 index 0000000..1325bcc --- /dev/null +++ b/.dev/design/backend.plantuml @@ -0,0 +1,106 @@ +@startuml + +' --------------------------------------------------------- + +class FastDdsDataStreamer +{ + + on_double_data_read(, double>) + + on_string_data_read(, double>) + + on_topic_discovery() + # Backend::Handler fastdds_handler_ +} + + +' --------------------------------------------------------- +package Backend +{ + +class Handler +{ + + connect_to_domain( domain_id) + + register_type_from_xml( path) + + create_subscription() + -- + # clean_discovery_database() + __ + # std::shared_ptr discovery_database_ + # std::unique_ptr participant_ + # FastDdsListener* listener_ + # std::set xml_data_types_paths_added_ +} + +class Participants +{ + + register_type_from_xml( path) + + create_subscription() + + std::vector numeric_data_series_names() + + std::vector string_data_series_names () + -- + + on_publisher_discovery() + + on_type_information_received() + + on_type_discovery() + -- + # on_topic_discovery() + __ Internal Variables __ + # std::shared_ptr discovery_database_ + # FastDdsListener* listener_; + __ Fast DDS pointers __ + # DomainParticipant* participant_ + # Subscriber* subscriber_ + # std::unordered_map readers_ +} + +class ReaderHandler +{ + + stop() + + on_data_available() + -- + __ Internal Variables __ + __ Fast DDS pointers __ + # Topic* topic_ + # DataReader* reader_ + # DynamicType_ptr type_ + # DynamicData* data_ + __ + # std::atomic stop_ + # TypeIntrospectionCollection numeric_data_info_ + # TypeIntrospectionCollection string_data_info_ + # TypeIntrospectionNumericStruct numeric_data_ + # TypeIntrospectionStringStruct string_data_ +} + +interface FastDdsListener +{ + + {abstract} on_double_data_read(, double>) + + {abstract} on_string_data_read(, double>) + + {abstract} on_topic_discovery() +} + +FastDdsDataStreamer <|-- FastDdsListener +FastDdsDataStreamer *-- "1" Handler +FastDdsDataStreamer *-- "1" Participants +Handler "1" *-- Participants +Participants "many" *-- ReaderHandler + +} + +' --------------------------------------------------------- + +package FastDDS +{ + class DomainParticipantListener + { + + {abstract} on_publisher_discovery() + + {abstract} on_type_information_received() + + {abstract} on_type_discovery() + } + + class DataReaderListener + { + + {abstract} on_data_available() + } + + ReaderHandler <|-- DataReaderListener + Participants <|-- DomainParticipantListener +} +@enduml \ No newline at end of file From 6883a555f60c104f66d65b9307051532756da7e9 Mon Sep 17 00:00:00 2001 From: Manuel Valch Date: Sun, 3 Nov 2024 17:57:54 +0100 Subject: [PATCH 2/4] Add startup sequence with object creations Tried to describe series, and dds object creation so that I might have a better idea on how to implemented keyed topics and where to move object creation. Signed-off-by: Manuel Valch --- .dev/sequences/onStart.plantuml | 139 ++++++++++++++++++++++++++++++++ 1 file changed, 139 insertions(+) create mode 100644 .dev/sequences/onStart.plantuml diff --git a/.dev/sequences/onStart.plantuml b/.dev/sequences/onStart.plantuml new file mode 100644 index 0000000..992a870 --- /dev/null +++ b/.dev/sequences/onStart.plantuml @@ -0,0 +1,139 @@ +@startuml + +' --------------------------------------------------------- +actor plotjuggler +participant FastDdsDataStreamer +participant Handler +participant Participant +participant ReaderHandler + +box "FastDDS" +participant DomainParticipantFactory +participant DynamicPubSubType +participant DomainParticipant +participant Subscriber +end box + +' --------------------------------------------------------- + +plotjuggler -> FastDdsDataStreamer: start +activate FastDdsDataStreamer + +FastDdsDataStreamer -> FastDdsDataStreamer: connect_to_domain_ +activate FastDdsDataStreamer + + FastDdsDataStreamer -> Handler: connect_to_domain(domain_id) + activate Handler + + Handler -> Participant**: create + Participant -> DomainParticipant**: create + Participant -> Subscriber**: create + + Handler --> FastDdsDataStreamer + deactivate Handler + +FastDdsDataStreamer --> FastDdsDataStreamer +deactivate FastDdsDataStreamer + +FastDdsDataStreamer -> FastDdsDataStreamer: read user configuration + +loop selected_topics + FastDdsDataStreamer -> Handler: create_subscription + activate Handler + + Handler -> Participant: create_subscription(topic_name, data_type_configuration) + activate Participant + + Participant -> Participant: check if topic is registered + Participant -> Participant: check if type is registered + + alt type is registered + Participant -> DomainParticipantFactory: get_dynamic_type() + activate DomainParticipantFactory + + DomainParticipantFactory --> Participant: dyn_type + deactivate DomainParticipantFactory + else type not registered + Participant -> DynamicPubSubType** : new + Participant -> DynamicPubSubType: register_type(participant_) + activate DynamicPubSubType + DynamicPubSubType --> Participant + deactivate DynamicPubSubType + end + + Participant -> DomainParticipant: create_topic(topic_name, type_name, default_topic_qos) + activate DomainParticipant + + DomainParticipant --> Participant: topic* + deactivate DomainParticipant + + Participant -> Subscriber: create_datareader(topic, default_datareader_qos_, this) + activate Subscriber + + Subscriber --> Participant: datareader* + deactivate Subscriber + + Participant -> ReaderHandler**: create(topic, datareader, dyn_type, ...) + Participant -> Participant: insert created reader into readers_ + + Participant --> Handler + deactivate Participant + + Handler --> FastDdsDataStreamer + deactivate Handler +end +note across: Series creation also happen during runtime with:\non_data_available() methods that is called uppon data reception + +FastDdsDataStreamer -> FastDdsDataStreamer: create_series_ +activate FastDdsDataStreamer + + FastDdsDataStreamer -> Handler: numeric_data_series_names + activate Handler + + Handler -> Participant: numeric_data_series_names + activate Participant + + loop for reader in readers_ + Participant -> ReaderHandler: numeric_data_series_names + activate ReaderHandler + + ReaderHandler --> Participant: vector + deactivate ReaderHandler + end + + Participant --> Handler: std::vector numeric_series + deactivate Participant + + Handler --> FastDdsDataStreamer: numeric_series + deactivate Handler + + FastDdsDataStreamer -> FastDdsDataStreamer: addNumeric(numeric_series) + + FastDdsDataStreamer -> Handler: string_data_series_names + activate Handler + + Handler -> Participant: string_data_series_names + activate Participant + + loop for reader in readers_ + Participant -> ReaderHandler: string_data_series_names + activate ReaderHandler + + ReaderHandler --> Participant: vector + deactivate ReaderHandler + end + + Participant --> Handler: std::vector string_series + deactivate Participant + + Handler --> FastDdsDataStreamer: string_series + deactivate Handler + + FastDdsDataStreamer -> FastDdsDataStreamer: addStringSeries(numeric_series) +FastDdsDataStreamer --> FastDdsDataStreamer +deactivate FastDdsDataStreamer + +FastDdsDataStreamer --> plotjuggler: true +deactivate FastDdsDataStreamer + +@enduml \ No newline at end of file From bb57bb23ce2e79735f0dc86b33c64cff248d84f9 Mon Sep 17 00:00:00 2001 From: Manuel Valch Date: Tue, 5 Nov 2024 22:01:22 +0100 Subject: [PATCH 3/4] Document data reception process within plugin If this commit si applied, then data reception sequence will be documented as it is much easier for me to plan necessary modifications for keyed topics handling. Signed-off-by: Manuel Valch --- .dev/sequences/dataReception.plantuml | 148 ++++++++++++++++++++++++++ 1 file changed, 148 insertions(+) create mode 100644 .dev/sequences/dataReception.plantuml diff --git a/.dev/sequences/dataReception.plantuml b/.dev/sequences/dataReception.plantuml new file mode 100644 index 0000000..f2e671c --- /dev/null +++ b/.dev/sequences/dataReception.plantuml @@ -0,0 +1,148 @@ +@startuml +' --------------------------------------------------------- + + +box "FastDDS" + +participant DataReader +participant DynamicDataFactory + +end box + +participant ReaderHandler +participant FastDdsDataStreamer +participant Handler +participant Participant +participant Plotjuggler +entity utils + +' --------------------------------------------------------- + +DataReader -> ReaderHandler: on_data_available(DataReader* reader) +activate ReaderHandler + + ReaderHandler -> DynamicDataFactory: delete_data(data_) + ReaderHandler -> DynamicDataFactory: create_data() + activate DynamicDataFactory + DynamicDataFactory --> ReaderHandler: data_ + deactivate DynamicDataFactory + + loop data reading OK and continue + ReaderHandler -> DataReader: take_next_sample(&data_, &info) + activate DataReader + DataReader --> ReaderHandler: reading result + deactivate DataReader + + ReaderHandler -> Plotjuggler: numeric_data_info_.clear() + ReaderHandler -> Plotjuggler: string_data_info_.clear() + + ReaderHandler -> ReaderHandler: create_data_structures_(data_) + activate ReaderHandler + + ReaderHandler -> ReaderHandler: serialize_data(_data) + ReaderHandler -> utils: get_formatted_data(topic_name, data_type_confguration_, numeric_data_info_, string_data_info_, serialized_data) + activate utils + note over utils + This methods prepare numeric_data_info_ or string_data_info_ + with data description and data itself (see type: TypeIntrospectionNumericStruct and TypeIntrospectionStringStruct) + to be sent sent to plotjuggler through upper backend layers + end note + utils --> ReaderHandler + deactivate utils + + ReaderHandler --> ReaderHandler + deactivate ReaderHandler + + ReaderHandler -> FastDdsDataStreamer: on_data_available() + activate FastDdsDataStreamer + + FastDdsDataStreamer -> FastDdsDataStreamer: create_series_() + activate FastDdsDataStreamer + + FastDdsDataStreamer -> Handler: numeric_data_series_names + activate Handler + + Handler -> Participant: numeric_data_series_names + activate Participant + + loop for reader in readers_ + Participant -> ReaderHandler: numeric_data_series_names + activate ReaderHandler + + ReaderHandler --> Participant: vector + deactivate ReaderHandler + end + + Participant --> Handler: std::vector numeric_series + deactivate Participant + + Handler --> FastDdsDataStreamer: numeric_series + deactivate Handler + + FastDdsDataStreamer -> FastDdsDataStreamer: addNumeric(numeric_series) + + FastDdsDataStreamer -> Handler: string_data_series_names + activate Handler + + Handler -> Participant: string_data_series_names + activate Participant + + loop for reader in readers_ + Participant -> ReaderHandler: string_data_series_names + activate ReaderHandler + + ReaderHandler --> Participant: vector + deactivate ReaderHandler + end + + Participant --> Handler: std::vector string_series + deactivate Participant + + Handler --> FastDdsDataStreamer: string_series + deactivate Handler + + FastDdsDataStreamer -> FastDdsDataStreamer: addStringSeries(numeric_series) + + FastDdsDataStreamer --> FastDdsDataStreamer + deactivate FastDdsDataStreamer + + FastDdsDataStreamer --> ReaderHandler + deactivate FastDdsDataStreamer + + alt numeric_data not empty + ReaderHandler -> FastDdsDataStreamer: on_double_data_read(numeric_data_info_, timestamp) + activate FastDdsDataStreamer + + note over FastDdsDataStreamer + Save data into fastDdsDataStreamer internal series and then emit a signal to PLotjuggler + for data to be plotted + end note + + FastDdsDataStreamer->PLotjuggler: emit dataReceived() + + FastDdsDataStreamer --> ReaderHandler + deactivate FastDdsDataStreamer + end + + alt string_data not empty + ReaderHandler -> FastDdsDataStreamer + ReaderHandler -> FastDdsDataStreamer: on_string_data_read(numeric_data_info_, timestamp) + activate FastDdsDataStreamer + + note over FastDdsDataStreamer + Save data into fastDdsDataStreamer internal series and then emit a signal to PLotjuggler + for data to be plotted + end note + + FastDdsDataStreamer->PLotjuggler: emit dataReceived() + + FastDdsDataStreamer --> ReaderHandler + deactivate FastDdsDataStreamer + end + + + end + +ReaderHandler --> DataReader +deactivate ReaderHandler +@enduml \ No newline at end of file From b18c216af339ddfbc270ca5363b635e96a342e44 Mon Sep 17 00:00:00 2001 From: Manuel Valch Date: Tue, 5 Nov 2024 23:04:05 +0100 Subject: [PATCH 4/4] Update startup .dev with Keyed topics Updated dev documentation on how I plan to add key topics handling at startup so that It si more clear for everyone Signed-off-by: Manuel Valch --- .dev/sequences/onStart.plantuml | 91 +++++++++++++-------------------- 1 file changed, 36 insertions(+), 55 deletions(-) diff --git a/.dev/sequences/onStart.plantuml b/.dev/sequences/onStart.plantuml index 992a870..15d409a 100644 --- a/.dev/sequences/onStart.plantuml +++ b/.dev/sequences/onStart.plantuml @@ -11,6 +11,8 @@ box "FastDDS" participant DomainParticipantFactory participant DynamicPubSubType participant DomainParticipant +participant XMLProfileManager +participant DynamicDataFactory participant Subscriber end box @@ -54,84 +56,63 @@ loop selected_topics DomainParticipantFactory --> Participant: dyn_type deactivate DomainParticipantFactory else type not registered - Participant -> DynamicPubSubType** : new + Participant -> DomainParticipantFactory : newDynamicType + activate DomainParticipantFactory + + DomainParticipantFactory --> Participant + deactivate DomainParticipantFactory + Participant -> DynamicPubSubType: register_type(participant_) activate DynamicPubSubType - DynamicPubSubType --> Participant + DynamicPubSubType --> Participant: dyn_type deactivate DynamicPubSubType end - Participant -> DomainParticipant: create_topic(topic_name, type_name, default_topic_qos) + Participant -> DynamicPubSubType: dyn_type->m_isGetKeyDefined + activate DynamicPubSubType + + DynamicPubSubType --> Participant: is_keyed + deactivate DynamicPubSubType + + alt is_keyed is true + Participant -> Participant: topic_qos = key_topic_qos_() + Participant -> Participant: reader_qos = key_datareader_qos_() + else + Participant -> Participant: topic_qos = default_topic_qos_() + Participant -> Participant: reader_qos = default_datareader_qos_() + end + + Participant -> DomainParticipant: create_topic(topic_name, type_name, topic_qos) activate DomainParticipant DomainParticipant --> Participant: topic* deactivate DomainParticipant - Participant -> Subscriber: create_datareader(topic, default_datareader_qos_, this) + Participant -> Subscriber: create_datareader(topic, reader_qos, this) activate Subscriber Subscriber --> Participant: datareader* deactivate Subscriber - Participant -> ReaderHandler**: create(topic, datareader, dyn_type, ...) - Participant -> Participant: insert created reader into readers_ - - Participant --> Handler - deactivate Participant - - Handler --> FastDdsDataStreamer - deactivate Handler -end -note across: Series creation also happen during runtime with:\non_data_available() methods that is called uppon data reception - -FastDdsDataStreamer -> FastDdsDataStreamer: create_series_ -activate FastDdsDataStreamer - - FastDdsDataStreamer -> Handler: numeric_data_series_names - activate Handler - - Handler -> Participant: numeric_data_series_names - activate Participant - - loop for reader in readers_ - Participant -> ReaderHandler: numeric_data_series_names - activate ReaderHandler - - ReaderHandler --> Participant: vector - deactivate ReaderHandler - end - - Participant --> Handler: std::vector numeric_series - deactivate Participant + Participant -> ReaderHandler**: create(topic, datareader, dyn_type, ..., is_keyed) + activate ReaderHandler - Handler --> FastDdsDataStreamer: numeric_series - deactivate Handler + ReaderHandler -> DynamicDataFactory: create_data(type_) + activate DynamicDataFactory - FastDdsDataStreamer -> FastDdsDataStreamer: addNumeric(numeric_series) + DynamicDataFactory -> ReaderHandler: data_ + deactivate DynamicDataFactory - FastDdsDataStreamer -> Handler: string_data_series_names - activate Handler - - Handler -> Participant: string_data_series_names - activate Participant + deactivate ReaderHandler - loop for reader in readers_ - Participant -> ReaderHandler: string_data_series_names - activate ReaderHandler - - ReaderHandler --> Participant: vector - deactivate ReaderHandler - end + Participant -> Participant: insert created reader into readers_ - Participant --> Handler: std::vector string_series + Participant --> Handler deactivate Participant - Handler --> FastDdsDataStreamer: string_series + Handler --> FastDdsDataStreamer deactivate Handler - - FastDdsDataStreamer -> FastDdsDataStreamer: addStringSeries(numeric_series) -FastDdsDataStreamer --> FastDdsDataStreamer -deactivate FastDdsDataStreamer +end FastDdsDataStreamer --> plotjuggler: true deactivate FastDdsDataStreamer