ROS Bridge RobotWebTools Keyboard Teleop

From wikidb
Jump to: navigation, search

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.

Code Base

Get the keyboard teleop example. It is located in the examples directory.

 git clone https://github.com/RobotWebTools/keyboardteleopjs

or

 git clone https://github.com/GT-RAIL/keyboardteleopjs

Setup

Copy ../keyboardteleopjs/examples/keyboardteleop.html to ~eepp/public_html

Make the following edits captured 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 enables the default Twist message topic, which is /cml_vel.
  • 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/keyboardteleop.html

or computer in local network

 10.0.0.106/~eepp/keyboardteleop.html

or the following as modified in the following section

 10.0.0.106/~eepp/keyboardteleop_local_lib.htm

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

roslaunch Script

 roslaunch floor_hugger teleop_bridge.launch

TODO - remove the following absolute path. Figure out what group does and if it has any meaning below.

 cat teleop_bridge.launch
     <launch>
         <group name="teleop">
             <node name="motor_node" pkg="phidgets" type="motor_control_hc" 
                 output="screen" 
             />
 
             <include file="/opt/ros/indigo/share/rosbridge_server/launch/rosbridge_websocket.launch"
             />
          </group>
     </launch>

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.

 \home\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). Furthermore, rotate (z) twisted the wrong way.

 58c58
 <         z = -1 * speed;
 ---
 >         z = 1 * speed;
 63c63
 <         x = 1 * speed;
 ---
 >         x = 0.5 * speed;
 68c68
 <         z = 1 * speed;
 ---
 >         z = -1 * speed;
 73c73
 <         x = -1 * speed;
 ---
 >         x = -0.5 * speed;

Copy keyboardteleop.html to keyboardteleop_local_lib.html and modify it 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>
 >

Browse to

 10.0.0.106/~eepp/keyboardteleop_local_lib.html