In general, all you need is a node publishing a geometry_msgs/Twist
message on the correct topic (likely turtle1/cmd_vel
). There are many keyboard-based teleop nodes that could be used instead of the turtle_teleop_key
. For example teleop_twist_keyboard or key_teleop. Running one of these nodes with the right remapping would allow you to control the turtlesim using whatever the keybindings of that node are. For example after running your turtlesim_node
you could run
rosrun teleop_twist_keyboard teleop_twist_keyboard.py cmd_vel:=turtle1/cmd_vel
And then you'd be using the keys described on the teleop_twist_keyboard page.
If you really want to change the keys used in the turtle_teleop_key
node from the tutorial, then the only way to do that would be to have a copy of the source code for the turtlesim package in your workspace, edit the source code, and then recompile. The keys used for driving the turtle are defined here, and they are processed in this case statement. If you wanted to use "wsad", you could change the top defines to be:
#define KEYCODE_R 0x64
#define KEYCODE_L 0x61
#define KEYCODE_U 0x77
#define KEYCODE_D 0x73
#define KEYCODE_Q 0x71
To read more about why, in the original code, the arrow keys are the specific values they are (e.g. Right=0x43), you could read the following: