Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

key_timeout too high and not properly adjustable #29

Open
StefanT83 opened this issue Feb 18, 2022 · 1 comment
Open

key_timeout too high and not properly adjustable #29

StefanT83 opened this issue Feb 18, 2022 · 1 comment

Comments

@StefanT83
Copy link

StefanT83 commented Feb 18, 2022

Hi,

I would like to be able to teleoperate a robot similar to a joystick: when I release the joystick, the robot would just stop. Instead, when I run this command

$rosrun teleop_twist_keyboard teleop_twist_keyboard.py _key_timeout:=0.5

the robot continues to move for another 0.5 seconds, somethimes hitting an obstacle or wall. After 0.5 seconds, the robot stops.

I tried to lower the 0.5 value, say to 0.4, but then I get into another issue. When I start the robot from standstill and press the "I" key on the keyboard (meaning requesting to go forward) and check

$rosrun echo /cmd_vel

it shows that the teleop_twist_keyboard node publishes alternatively the desired value (corresponding to pressing the "I" key on the keyboard) but alternating this with publishing zeros for some mysterious reason. As a consequence the robot starts "shaking" as a consequence of the inputs requesting advancing, then stopping, then advancing etc. In other words the behavior I get is that the robot is not moving forward by just accelerating (as desired).

How can I lower that key_timeout value from 0.5 to, say 0.05 or even arbitrarily close to zero?
(My feeling is that the answer has something to do with this info copy-pasted from the readme.md: "It is recommended that you set key_timeout higher than the initial key repeat delay on your system (This delay is 0.5 seconds by default on Ubuntu, but can be adjusted)."

Thank you.

@trainman419
Copy link
Contributor

Yes. The trouble here is that the key_timeout expires before your OS generates a repeated key press.

So, teleop_twist_keyboard gets a keypress, generates a movement command, times out and generates the stop command, all before it gets the repeated key press from the OS to reset the key timer. This causes jerky movement and it's why the recommendation that you've quoted exists:

It is recommended that you set key_timeout higher than the initial key repeat delay on your system

To fix this, you need to adjust the key repeat rate within your operating system.
Here's docs on how to adjust the key repeat rate in Ubuntu: https://help.ubuntu.com/stable/ubuntu-help/keyboard-repeat-keys.html.en

Hope that helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants