Skip to content
This repository was archived by the owner on May 31, 2025. It is now read-only.
This repository was archived by the owner on May 31, 2025. It is now read-only.

Give the total number of subscribers when a publisher advertises #21

@blaroche

Description

@blaroche

This is an enhancement issue based on the discussions about this question: http://answers.ros.org/question/11167/how-do-i-publish-exactly-one-message

The problem that my colleague and I experienced is that the first (few) messages published were "lost". In our case, we wanted to publish exactly one message and not more. The problem with ROS is that the publisher starts sending its messages as soon as it exists, without waiting for the subscribers to establish a connection. This is acceptable in some cases, but not in many others.

Here is my suggestion:

Calling NodeHandle::advertise eventually gets to line 403 of topic_manager.cpp: master::execute("registerPublisher", args, result, payload, true); Currently, the variable result is ignored, but it should contain the total number of subscribers for the given topic. I would also add an optional parameter in advertise() that would be a duration. Then, we a publisher would be created, it would wait for the subscribers to connect, up to the given duration. Any call to Publisher::publish before that would queue the message.

This solution is not fail-proof, but at least with a timeout option, it would increase the reliability when required and still allow not to wait (or not to wait too long) for other cases (by giving zero as a timeout duration).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions