Skip to content
This repository was archived by the owner on Jan 7, 2023. It is now read-only.

Commit c0006d8

Browse files
committed
Fix node discovery with dps middleware in ROS2
Currently node discovery does not work with dps middleware in ROS2. The issue is as follows: When a subscriber comes online it sends out a multicast discovery message. All the subscriber topics (bloom filter outputs) are merged in a union and sent out as an "interest" message. When the multicast message is received by the publishing node, it checks whether any topic is in the set of the received interest. If a match is found a unicast connection is created and the published message is sent to the subscriber. However at the moment, the publisher's bloom filter output takes into account wildcards whereas they are not considered in the subscriber. Thus the publishers bloom filter output will not be in the set of the subscriber's interests. Hence, the unicast connection is not created. This commit makes sure the subscriber's interests are created in a symmetrical way to the publisher side which solves the discovery problem. Also when creating the publisher's discovery interest use the wildcard option. This is primarily so that discovery information is sent out on localhost given the above change. Signed-off-by: Andriy Gelman <[email protected]>
1 parent dcfe679 commit c0006d8

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

src/discovery.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,6 @@ static DPS_Status DecodeDiscoveryPayload(DPS_DiscoveryService* service, uint8_t
288288

289289
DPS_DiscoveryService* DPS_CreateDiscoveryService(DPS_Node* node, const char* serviceId)
290290
{
291-
static const int noWildcard = DPS_TRUE;
292291
DPS_DiscoveryService* service;
293292
DPS_Status ret;
294293

@@ -325,7 +324,7 @@ DPS_DiscoveryService* DPS_CreateDiscoveryService(DPS_Node* node, const char* ser
325324
if (ret != DPS_OK) {
326325
goto Exit;
327326
}
328-
ret = DPS_InitPublication(service->pub, (const char**)&service->topic, 1, noWildcard, OnAck);
327+
ret = DPS_InitPublication(service->pub, (const char**)&service->topic, 1, DPS_FALSE, OnAck);
329328
if (ret != DPS_OK) {
330329
goto Exit;
331330
}

src/topics.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -144,20 +144,21 @@ DPS_Status DPS_AddTopic(DPS_BitVector* bf, const char* topic, const char* separa
144144
tp = topic + strcspn(topic, separators);
145145
if (!wc) {
146146
DPS_BitVectorBloomInsert(bf, (const uint8_t*)topic, tlen);
147-
if (topicType != DPS_PubTopic) {
148-
return DPS_OK;
149-
}
150147
} else if (wc != topic) {
151148
DPS_BitVectorBloomInsert(bf, (const uint8_t*)topic, wc - topic);
152149
}
150+
if (topicType == DPS_PubNoWild) {
151+
return DPS_OK;
152+
}
153+
153154
segment = malloc(tlen + 1);
154155
if (!segment) {
155156
return DPS_ERR_RESOURCES;
156157
}
157158
while (*tp) {
158159
size_t len;
159160
segment[prefix++] = *tp++;
160-
if (topicType == DPS_PubTopic) {
161+
if (wc != topic) {
161162
DPS_BitVectorBloomInsert(bf, (const uint8_t*)topic, tp - topic);
162163
}
163164
len = strcspn(tp, separators);
@@ -176,15 +177,13 @@ DPS_Status DPS_AddTopic(DPS_BitVector* bf, const char* topic, const char* separa
176177
tp += len;
177178
}
178179
if (ret == DPS_OK) {
179-
if (topicType == DPS_PubTopic) {
180180
segment[prefix] = INFIX_WILDC;
181181
DPS_BitVectorBloomInsert(bf, (uint8_t*)segment, prefix + 1);
182182
while (prefix >= 0) {
183183
segment[prefix] = FINAL_WILDC;
184184
DPS_BitVectorBloomInsert(bf, (uint8_t*)segment, prefix + 1);
185185
--prefix;
186186
}
187-
}
188187
}
189188
free(segment);
190189
return ret;

0 commit comments

Comments
 (0)