public void setSphero(float heading, float speed, int milliSeconds) { final float direction = heading; final int time = milliSeconds; final float velocity = speed; mRobot.drive(direction, velocity); try { Thread.sleep(time); } catch (InterruptedException e) { e.printStackTrace(); // handle the exception... // For example consider calling Thread.currentThread().interrupt(); here. } }