@Override public void run() { while (true) { try { MILLISECONDS.sleep(100); // set speed int speed = 0; if (isUpPressed) speed = speedConfig; else if (isDownPressed) speed = -1 * speedConfig; // set direction int direction = 0; if (isLeftPressed) direction = -turnspeedConfig; else if (isRightPressed) direction = turnspeedConfig; if (speed != 0 || direction != 0) droneController.pcmd(speed, direction); } catch (Exception e1) { e1.printStackTrace(); } } }