ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

I was able to get your example to work (using turtlesim) without any problems. Here is what I ran:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<script src="http://cdn.robotwebtools.org/threejs/current/three.min.js"></script>
<script src="http://cdn.robotwebtools.org/ColladaAnimationCompress/0.0.1/ColladaLoader2.min.js"></script>
<script src="http://cdn.robotwebtools.org/EventEmitter2/current/eventemitter2.min.js"></script>
<script src="http://cdn.robotwebtools.org/roslibjs/current/roslib.js"></script>
<script src="http://cdn.robotwebtools.org/ros3djs/current/ros3d.js"></script>

<script>
  function init() {
    var ros = new ROSLIB.Ros({
      url : 'ws://localhost:9090'
    });

     var viewer3D = new ROS3D.Viewer({
      divID      : 'threed-map',
      width      : 560,
      height     : 420,
      antialias  : true,
      background : '#111111'
    });

    // Create a TF client that subscribes to the fixed frame.
    var tfClient = new ROSLIB.TFClient({
      ros          : ros,
      angularThres : 0.01,
      transThres   : 0.01,
      rate         : 10.0,
      fixedFrame   : '/world'
    });

    var arrowNode = new ROS3D.SceneNode({
      tfClient : tfClient,
      frameID  : '/turtle1',
      object   : new ROS3D.Arrow(),        
    });

    viewer3D.scene.add(arrowNode);
  }
</script>
</head>

<body onload="init()">
  <div id="threed-map"></div>
</body>
</html>

After this, I ran the following commands:

roslaunch turtle_tf turtle_tf_demo.launch
rosrun tf2_web_republisher tf2_web_republisher
roslaunch rosbridge_server rosbridge_websocket.launch

Use your arrow keys on your keyboard to move the turtle (you must have turtle_tf_demo.launch terminal focused).

Make sure tf2_web_republisher is up and running before your connect. Also, check to see if results are being sent back to the client:

rostopic echo /tf2_web_republisher/result

I was able to get your example to work (using turtlesim) without any problems. Here is what I ran:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<script src="http://cdn.robotwebtools.org/threejs/current/three.min.js"></script>
<script src="http://cdn.robotwebtools.org/ColladaAnimationCompress/0.0.1/ColladaLoader2.min.js"></script>
<script src="http://cdn.robotwebtools.org/EventEmitter2/current/eventemitter2.min.js"></script>
<script src="http://cdn.robotwebtools.org/roslibjs/current/roslib.js"></script>
<script src="http://cdn.robotwebtools.org/ros3djs/current/ros3d.js"></script>

<script>
  function init() {
    var ros = new ROSLIB.Ros({
      url : 'ws://localhost:9090'
    });

     var viewer3D = new ROS3D.Viewer({
      divID      : 'threed-map',
      width      : 560,
      height     : 420,
      antialias  : true,
      background : '#111111'
    });

    // Create a TF client that subscribes to the fixed frame.
    var tfClient = new ROSLIB.TFClient({
      ros          : ros,
      angularThres : 0.01,
      transThres   : 0.01,
      rate         : 10.0,
      fixedFrame   : '/world'
    });

    var arrowNode = new ROS3D.SceneNode({
      tfClient : tfClient,
      frameID  : '/turtle1',
      object   : new ROS3D.Arrow(),        
    });

    viewer3D.scene.add(arrowNode);
  }
</script>
</head>

<body onload="init()">
  <div id="threed-map"></div>
</body>
</html>

After this, I ran the following commands:

roslaunch turtle_tf turtle_tf_demo.launch
rosrun tf2_web_republisher tf2_web_republisher
roslaunch rosbridge_server rosbridge_websocket.launch

Use your arrow keys on your keyboard to move the turtle (you must have turtle_tf_demo.launch terminal focused).

Make sure tf2_web_republisher is up and running before your connect. Also, check to see if results are being sent back to the client:

rostopic echo /tf2_web_republisher/result
/tf2_web_republisher/feedback