diff --git a/msg/templates/urtps/Publisher.cpp.em b/msg/templates/urtps/Publisher.cpp.em index 1733309e37..b1247d39e8 100644 --- a/msg/templates/urtps/Publisher.cpp.em +++ b/msg/templates/urtps/Publisher.cpp.em @@ -139,8 +139,7 @@ void @(topic)_Publisher::PubListener::onPublicationMatched(Publisher* pub, Match // If the matching happens for the same entity, do not make a match if (is_different_endpoint) { - if (info.status == MATCHED_MATCHING) - { + if (info.status == MATCHED_MATCHING) { n_matched++; std::cout << " - @(topic) publisher matched" << std::endl; } else { diff --git a/msg/templates/urtps/RtpsTopics.cpp.em b/msg/templates/urtps/RtpsTopics.cpp.em index 4b9dcc6484..554c40be08 100644 --- a/msg/templates/urtps/RtpsTopics.cpp.em +++ b/msg/templates/urtps/RtpsTopics.cpp.em @@ -82,7 +82,7 @@ bool RtpsTopics::init(std::condition_variable* t_send_queue_cv, std::mutex* t_se @[for topic in send_topics]@ if (_@(topic)_pub.init()) { std::cout << "- @(topic) publisher started" << std::endl; -@[ if topic == 'Timesync']@ +@[ if topic == 'Timesync' or topic == 'timesync']@ _timesync->start(&_@(topic)_pub); @[ end if]@ } else { @@ -119,7 +119,7 @@ void RtpsTopics::publish(uint8_t topic_ID, char data_buffer[], size_t len) eprosima::fastcdr::FastBuffer cdrbuffer(data_buffer, len); eprosima::fastcdr::Cdr cdr_des(cdrbuffer); st.deserialize(cdr_des); -@[ if topic == 'Timesync']@ +@[ if topic == 'Timesync' or topic == 'timesync']@ _timesync->processTimesyncMsg(&st); @[ end if]@ // apply timestamp offset diff --git a/msg/templates/urtps/Subscriber.cpp.em b/msg/templates/urtps/Subscriber.cpp.em index c67fa68cfa..90a23fb56d 100644 --- a/msg/templates/urtps/Subscriber.cpp.em +++ b/msg/templates/urtps/Subscriber.cpp.em @@ -127,6 +127,9 @@ bool @(topic)_Subscriber::init(uint8_t topic_ID, std::condition_variable* t_send void @(topic)_Subscriber::SubListener::onSubscriptionMatched(Subscriber* sub, MatchingInfo& info) { +@# Since the time sync runs on the bridge itself, it is required that there is a +@# match between two topics of the same entity +@[if topic != 'Timesync' and topic != 'timesync']@ // The first 6 values of the ID guidPrefix of an entity in a DDS-RTPS Domain // are the same for all its subcomponents (publishers, subscribers) bool is_different_endpoint = false; @@ -139,8 +142,7 @@ void @(topic)_Subscriber::SubListener::onSubscriptionMatched(Subscriber* sub, Ma // If the matching happens for the same entity, do not make a match if (is_different_endpoint) { - if (info.status == MATCHED_MATCHING) - { + if (info.status == MATCHED_MATCHING) { n_matched++; std::cout << " - @(topic) subscriber matched" << std::endl; } else { @@ -148,6 +150,15 @@ void @(topic)_Subscriber::SubListener::onSubscriptionMatched(Subscriber* sub, Ma std::cout << " - @(topic) subscriber unmatched" << std::endl; } } +@[else]@ + (void)sub; + + if (info.status == MATCHED_MATCHING) { + n_matched++; + } else { + n_matched--; + } +@[end if]@ } void @(topic)_Subscriber::SubListener::onNewDataMessage(Subscriber* sub)