Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

throttle: multiple input topics through a single terminal command #99

Open
abhishek47kashyap opened this issue Jan 25, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@abhishek47kashyap
Copy link

Description

Currently throttle takes only one input topic (intopic in the readme). Able being to pass in multiple intopic's can be a useful enhancement.

Possible use case: through a single terminal command, throttle RGB and depth data coming in from an RGBD camera.

Related Issues

None.

Completion Criteria

  • Can throttle n input topics in parallel and publish on n output topics.

Implementation Notes / Suggestions

Spinning n threads, one for each intopic-outtopic pair. n should probably have a cap but not entirely sure what's a good way to decide on the number.

Testing Notes / Suggestions

  • Units tests that can verify throttling of n >= 1 topics.
@abhishek47kashyap abhishek47kashyap added the enhancement New feature or request label Jan 25, 2024
@christophebedard
Copy link
Member

christophebedard commented Jan 25, 2024

Since most topic_tools nodes share the same base node class (which has an input topic and output topic) and support providing input/output topic names as parameters through the CLI (e.g., ros2 run topic_tools throttle messages --ros-args -p input_topic:=my_topic -p msgs_per_sec:=2.0), this might be tricky to implement. How would you do it?

@abhishek47kashyap
Copy link
Author

In the readme, I see mux "subscribes to a set of incoming topics".

mux deals with the multiple input topics by having std::vector<std::string> input_topics_ in the derived class MuxNode. Perhaps we could do a similar thing for throttle's input topics in ThrottleNode, and further extend that for output topics?

With multiple intopic-outtopic pairs, some of the member variables of ThrottleNode like period_ and last_time_ would require topic-wise bookkeeping. And it seems ToolBaseNode::make_subscribe_unsubscribe_decisions() would need to be modified too.

What would be your thoughts on how to approach this? Making changes to ToolBaseNode would most likely require changes to the other derived classes as well.

@christophebedard
Copy link
Member

You're right, mux does subscribe to multiple input topics.

Changing ToolBaseNode to support N input topics and M output topics is worth a try. Since ToolBaseNode currently only creates an input topic subscription if a subscription to the output topic exists (if "lazy"), it may need some kind of "N input to 1 output" vs "N-M input-output pairs" flag. Just give it a shot and we'll see!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants