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

Suggestions to read Keyboard inputs and publish to a topic. (For ex: publish 'w' when the key 'w' is pressed and so on) [closed]

asked 2019-05-24 09:51:51 -0500

Jayadev gravatar image

Hi, I'm working on a project where I need to send certain data to a programmed embedded system connected through rosserial, which will accordingly execute a function. So, I need to read and publish the keyboard inputs, which will then be subscribed by the embedded system. Please suggest me a solution. Thank you in advance.

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by Jayadev
close date 2019-06-22 07:31:40.357391


Can you tell us what you've found yourself? We're all here to help, but to avoid suggesting things you've already tried, it would be good to know what didn't work for you.

gvdhoorn gravatar image gvdhoorn  ( 2019-05-24 10:05:57 -0500 )edit

I've tried certain packages like ros-keyboard ( ), keyboard_reader ( ) from Github. ros-keyboard requires you to keep the popped up window highlighted for it to work, which is not ideal for my case and the keyboard_reader said it couldn't grab my keyboard. I have also tried working with the ROS's own teleop_twist to make it fit my requirement but it seemed to not work as it required a very deep knowledge of the python functions to read inputs (like getch(), msvcrt(), sys(), etc). Finally, I tried a funtion called getchar() to fail and come here for suggestions.

Jayadev gravatar image Jayadev  ( 2019-05-25 08:45:47 -0500 )edit

Does it have to be a keyboard? If you have an xbox controller or other joystick or gamepad, the ros-joy packages have worked great for me.

ChuiV gravatar image ChuiV  ( 2019-06-10 09:13:08 -0500 )edit

Yes. It had to be the keyboard to give the inputs. I have it linked in the answer.

Jayadev gravatar image Jayadev  ( 2019-06-22 07:26:14 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2019-06-22 07:30:54 -0500

Jayadev gravatar image

I dug and found some repositories to work on. And here is the keyboard publisher that publishes the ASCII values of the keyboard events. Repository:

edit flag offensive delete link more

Question Tools



Asked: 2019-05-24 09:51:51 -0500

Seen: 1,553 times

Last updated: Jun 22 '19