Skip to content

Multi-threading to handle image pub/sub #67

@lucasw

Description

@lucasw

Publishing and subscribing to large images takes a lot of cpu time ( https://answers.ros.org/question/312964/ros2-megapixel-image-pubsub-cpu-usage-is-very-high/ ), so would like to put those operations in a separate thread and pass images back and forth between them.

One thread for all image publishing and subscribing, or one thread for all publishing and a second for subscribing. Or many threads for all of those?

If the ros executor is to be used this needs to be wrapped in a separate rclcpp::Node, and create a separate thread within the main imgui_ros node thread to run spin() on it. That is a good approach because the nested executor could be swapped for the multi-threaded one if performance turns out to be much better - it could be the cpu usage goes away if every publish and subscribe gets a thread of its own.

Queue objects (deques) with strings for topics and Image messages can be used. If a topic is new create a publisher or subscriber for it. An update function within imgui_ros has a map to all the other objects that need to be updated when a new message arrives.

https://answers.ros.org/question/313838/multithreadedexecutor-thread-affinity-for-certain-callbacks/

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions