Asynchronous I/O (UDP, serial) in component

asked 2020-10-22 11:34:37 -0500

oysstu gravatar image

This question is related to the use of asynchronous I/O, e.g. sockets or serial comms through Boost ASIO, but in a composable node. The use-case is a node which publishes a topic based on a serial/udp/tcp input, where this node can both be used in a single-threaded executor in order to avoid memory copies or in a standalone thread.

Obviously, this can be implemented through polling by creating a timer which checks for incoming data. Is it possible to somehow integrate asynchronous I/O with the ROS2 event loop (thus leveraging epoll for event notifications), though? I've looked into spin_until_future_complete, waitables, and custom executors, as possible solutions, but haven't found a clear solution yet.

edit retag flag offensive close merge delete

Comments

Hi, Have you found a way since your post?

flash_27 gravatar image flash_27  ( 2021-09-30 11:16:32 -0500 )edit

I didn't find a satisfactory solution using custom waitables (could be possible though, it just seemed to me that it would be polling in the ROS event loop). In the end I resorted to running the ASIO context in a different thread, where the callbacks publish messages directly. Data in the opposite direction (ROS -> ASIO) can be passed by posting using io_service::post (threadsafe).

oysstu gravatar image oysstu  ( 2021-10-07 14:37:17 -0500 )edit