Global Keyboard Panic button implementation
Hi,
I am working in a project with several robots including one quadcopter.
When I am designing new control codes for the quadcopter, some times I make mistakes and end up with a high speed uncontrollable quadcopter flying in my lab. When this happens I go very fast to the terminal in which I launched the controller and kill the process. I always run a reliable code in parallel which sends stable commands to the quadcopter which I switch to when this happens. This process takes time (seconds) and it usually results on quadcopter crash with a wall or something.
I would like to program a node with a sort of Panic Button on the keyboard that doesn't require having focus on the terminal to run so in case of a controller fault I can override the bad controller. I don't want to have focus on the terminal because I generally have a LOT of terminals working simultaneously and I don't want to waste some seconds finding the right terminal.
Any ideas on the best way of implementing this? I think ROS should provide this kind of safety mechanisms for moving robots, maybe I haven't looked in the right places.
I am programming on Ubuntu 14.04 with ROS Indigo.
Bests,
Asked by raultron on 2015-07-31 03:26:02 UTC
Answers
On Ubuntu 14.04 this works for me:
sudo apt-get install python-xlib
from Xlib import X, display
while True:
d = display.Display().screen().root.query_pointer()._data
if d["mask"] == 28:
print "Triggered"
break
(http://ubuntuforums.org/showthread.php?t=1073760)
mask of 28 is (at least for my keyboard) triggered from ctrl+alt. This could be a starting point. And please publish your findings here :)
Asked by NEngelhard on 2015-07-31 06:06:59 UTC
Comments
You essentially need to write keylogger, right?
Asked by NEngelhard on 2015-07-31 04:57:23 UTC
As an idea, if you have a joystick or some other device, you could use it without focusing the terminal.
Asked by Javier V. Gómez on 2015-07-31 05:05:59 UTC