How do I read/write to serial device initialized with termios across multiple nodes/packages

asked 2019-11-20 20:56:20 -0600

sh_ec_ks gravatar image

Attempting to develop my own driver for the IRobot Create 2. Currently, I have a C/C++ code written to initialize the robot and read/write data . I'm beginning to add ROS for handling of the data but am confused how to keep this device in scope across multiple nodes. It seems like I can only read/write to the device from the node that initializes it. Ultimately I'd like to have different nodes for initializing, publishing/subscribing to data, navigation etc.. how do i bridge the gap between my system and ROS for something like this?

edit retag flag offensive close merge delete

Comments

I don't believe what you want to do is possible. Serial ports are devices you open in exclusive mode, they cannot be shared between processes. This is not necessarily something special when using ROS.

Either use a plugin architecture (where the host serialises access to the shared resource) or you could consider using a node that 'shares' your serial port over a topic interface.

gvdhoorn gravatar imagegvdhoorn ( 2019-11-21 09:53:38 -0600 )edit