I have a simple ROS 2 node written in C++ that interacts with the user using the cin
command. The node expects a basic string input like "yes" or "no" from the user:
string answer;
getline(cin, answer);
When I run the node using:
ros2 run package_name executable_name
I can easily interact with the node via stdin and stdout.
However, when I run my node from a launch file (which also performs several other tasks), two issues arise:
- The stdin interaction doesn't work.
- Any stdout output doesn't appear in the launch file terminal.
After searching online, I discovered that there are challenges with handling stdin and stdout from launch file.
I’m considering switching to expecting a service call, and interacting through the rqt Service Caller GUI.
Does this approach seem like the right direction?
Answer: I chose to use a service because it's easy to work with through the rqt app