ROS Bridge RobotWebTools Keyboard Teleop
Overview
Adapt the RobotWebTools keyboard teleop example to the Floor Huger robot. This example will capture key events when the keyboard teleop page are in focus. The ROS Bridge Simple Keyboard test required that the focus is within the input textbox.
References
Get the keyboard teleop example. It is located in the examples directory.
git clone https://github.com/RobotWebTools/keyboardteleopjs
Setup
Copy ../keyboardteleopjs/examples/keyboardteleop.html to ~eepp/public_html
Make the following edits capture by diff.
13c13 < <script src="http://cdn.robotwebtools.org/keyboardteleopjs/current/keyboardteleop.js"></script> --- > <script src="../build/keyboardteleop.js"></script> 22c22 < url : 'ws://10.0.0.106:9090' --- > url : 'ws://localhost:9090' 26,27d25 < // default topic is topic : '/cmd_vel' < 29a28 > topic : '/base_controller/command' 42c41 < teleop.scale = (ui.value / 20.0); --- > teleop.scale = (ui.value / 100.0); 48c47 < teleop.scale = ($('#speed-slider').slider('value') / 20.0); --- > teleop.scale = ($('#speed-slider').slider('value') / 100.0);
- 13c13: This will get the keyboardteleop library from the RobotWebTools site instead of a local build directory.
- 22c22: This will allow remote control from computers in the local network. The host computer's IP address is required because a local name server is not enabled.
- 26,27d25 and 29a28: Removing the topic : '/base_controller/command' teleop field causes /cml_vel to be the Twist message topic.
- 42c41 and 48c47: The Phidgets twist values range from 0 to roughly 5.
Run
In separate terminals.
roscore rosrun phidgets motor_control_hc roslaunch rosbridge_server rosbridge_websocket.launch
In browser on hosting machine
localhost/~eepp/keyboardtelop.html
or computer in local network
10.0.0.106/~eepp/keyboardtelop.html
control
- Move forward: 'W' or up arrow
- Move reverse: 'S' or down arrow
- Turn left: 'A' or left arrow
- Turn right: 'D' or right arrow
Modify keyboardteleop Library
The forward and reverse commands have a scale factor of 0.5 which is too slow. It is changed to 1.
Copy ../keyboardteleopjs/src directory to ~eepp/libs. This creates the following directory structure.
~eepp\ public_html\ keyboardteleop.html libs\ KeyboardTeleop.js teleop Teleop.js
Modify the Teleop.js library file to change the speed multiplier for forward (keycode 87 and 38) and reverse (keycode 83 and 40).
63c63 < x = 1 * speed; --- > x = 0.5 * speed; 73c73 < x = -1 * speed; --- > x = -0.5 * speed;
Modify the keyboardteleop.html driving page to pick up the local keyboardteleop library.
13c13,16 < <script src="http://cdn.robotwebtools.org/keyboardteleopjs/current/keyboardteleop.js"></script> --- > > <script src="libs/KeyboardTeleop.js"></script> > <script src="libs/teleop/Teleop.js"></script> >