ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Global Keyboard Panic button implementation

asked 2015-07-31 03:26:02 -0600

raultron gravatar image


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.


edit retag flag offensive close merge delete


You essentially need to write keylogger, right?

NEngelhard gravatar image NEngelhard  ( 2015-07-31 04:57:23 -0600 )edit

As an idea, if you have a joystick or some other device, you could use it without focusing the terminal.

Javier V. Gómez gravatar image Javier V. Gómez  ( 2015-07-31 05:05:59 -0600 )edit

1 Answer

Sort by » oldest newest most voted

answered 2015-07-31 06:06:59 -0600

NEngelhard gravatar image

updated 2015-07-31 06:07:58 -0600

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"

( )

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 :)

edit flag offensive delete link more

Question Tools


Asked: 2015-07-31 03:26:02 -0600

Seen: 297 times

Last updated: Jul 31 '15