This node uses the SDL library to grab keypresses. To do so, it opens a window where input is received. This window needs to becurrently focused, otherwise this node will not receive any key presses.
- Create a new workspace.
$ cd /path/to/your_ws/src- Clone this repository
- (ssh)
$ git clone git@github.com:cmower/ros2-keyboard.git - (https)
$ git clone https://github.com/cmower/ros2-keyboard.git
- Install SDL 1.2 with the command
sudo apt install libsdl1.2-dev. $ cd /path/to/your_ws$ colcon build
Publishes keyboard events when the window is focused.
- Published topics:
keydownandkeyup(keyboard_msgs/Key) - Parameters
allow_repeat(bool): Enables or disables the keyboard repeat rate. Default isfalse.repeat_delay(int): How long the key must be pressed before it begins repeating. Default isSDL_DEFAULT_REPEAT_DELAY.repeat_interval(int): Key replay speed. Default isSDL_DEFAULT_REPEAT_INTERVAL.
Converts keyboard events to a joy message.
- Published topic:
joy(sensor_msgs/Joy) - Subscribed topics:
keydownandkeyup(keyboard_msgs/Key) - Parameters
config_file_name(str): File name for the configuration file. See here for an example.sampling_frequency(int): Rate (Hz) at whichjoymessages are published. Default is50.
In one terminal, start the keyboard node.
ros2 run keyboard keyboardIn a second terminal, start the keyboard_to_joy.py node.
ros2 run keyboard keyboard_to_joy.py --ros-args \
-p config_file_name:=`ros2 pkg prefix keyboard`/share/keyboard/config/example_config.yaml