Suggestions to read Keyboard inputs and publish to a topic. (For ex: publish 'w' when the key 'w' is pressed and so on) [closed]
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.
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.
I've tried certain packages like
ros-keyboard
( https://github.com/lrse/ros-keyboard ),keyboard_reader
( https://github.com/UTNuclearRoboticsP... ) 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 thekeyboard_reader
said it couldn't grab my keyboard. I have also tried working with the ROS's ownteleop_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 (likegetch()
,msvcrt()
,sys()
, etc). Finally, I tried a funtion calledgetchar()
to fail and come here for suggestions.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.
Yes. It had to be the keyboard to give the inputs. I have it linked in the answer.