ros2 / demos

Apache License 2.0
493 stars 329 forks source link

Quality of service demo interactive_{publisher,subscriber} doesn't quit properly #633

Closed clalancette closed 1 year ago

clalancette commented 1 year ago

The quality of service interactive publisher and subscriber are run like the following:

ros2 run quality_of_service_demo_cpp interactive_publisher

or

ros2 run quality_of_service_demo_cpp interactive_subscriber

Both demos are interactive in the sense that they listen for keyboard commands to do certain actions. One of those actions is to quit, which is done by hitting the 'x' button.

Unfortunately, this doesn't work and doesn't exit the program for either of them. The basic problem is that the keyboard handling code that is common to both demos is doing the equivalent of a getch with no timeout in a thread. So when the user hits 'x', the executor is shutdown, but nothing makes the getch return and thus lets the thread complete.

I'm not quite sure how to solve it at the moment, but it should be looked into.

This came out of the testing in https://github.com/osrf/ros2_test_cases/issues/783