ros2 / demos

Apache License 2.0
502 stars 330 forks source link

Cleanup the interactive quality of service demos. #637

Closed clalancette closed 1 year ago

clalancette commented 1 year ago

The interactive demos are supposed to listen for commands on stdin and do particular actions. And for the most part they do that, except for 'x'. That command is supposed to quit the program, but doesn't currently do so.

What we do here is to revamp the keyboard handling so that it works in all situations. This involves taking the executor and putting it into a thread, and then having the main thread do stdin handling. We also install a signal handler.

With all of that in place, then, we can either catch the signal from a Ctrl-C or type 'x' to have things quit. This then quits the keyboard handling loop, which then goes on to cancel the executor, join the thread, and shutdown rclcpp.

This fixes #633.

clalancette commented 1 year ago

All right, I've finally been able to test this out on Windows. That involved actually a rewrite of the implementation, but I think it is a lot nicer now; all of the details are hidden in utils.cpp. I'm going to mark this as ready for review and run CI on it.

clalancette commented 1 year ago

CI: