Skip to content

Extend Node to support subscribing to a topic until a condition is met #591

Open
@iche033

Description

@iche033

Offer the ability to subscribe to a topic until some some conditions are met

One concrete example is that we want to subscribe to the pose topic until x > 0.

The idea is similar to std::condition_variable's wait_until function, where we can pass a predicate (function callback for evaluating conditions) to the function, and returns true when the requirements are met

Implementation suggestion

a) Extend SubscribeOptions to pass a predicate for evaluation conditions. Given that Node::Subscribe is non-blocking, we probably still want one final message callback to indicate that the conditions are met.
b) Alternatively, we could have a new blocking WaitUntil(topic, timeout, predicate) API function for this purpose.

Something to be careful of is that once the condition is met, the node would need to Unsubscribe to the topic. In this case, we should not stop subscription / remove other message handlers.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    Status

    Inbox

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions