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

how to subscribe with rosbridge

asked 2015-05-03 22:28:54 -0500

minerva gravatar image

updated 2015-05-03 22:29:26 -0500

hello guys, i'm new at ros. i want to subscribe a topic to a webpage. i tried to do the following tutorial but subscribe part doesnt work. Should i add a label or something to view the subscription to the html file? here is the tutorial: http://wiki.ros.org/roslibjs/Tutorial...

edit retag flag offensive close merge delete

Comments

what do you see in the browser console?

corb gravatar image corb  ( 2015-05-03 22:40:27 -0500 )edit

what do you mean by browser console? i just open html file.

minerva gravatar image minerva  ( 2015-05-04 16:15:10 -0500 )edit

You need to save the html code to a file, like "ros_test.html". Then open that file in your browser. You should see "Simple roslib Example. Check your Web Console for output". To see the console (in the Chrome browser): menu/more tools/javascript console. Other browsers will be similar.

corb gravatar image corb  ( 2015-05-04 16:42:52 -0500 )edit

oh "Received message on /listener: Hello wold" is written there thank you :) so the code is ok but how can i write it to a label?

minerva gravatar image minerva  ( 2015-05-05 05:27:43 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2015-05-05 06:44:25 -0500

corb gravatar image

You need to save the html code to a file, like ros_test.html. Then open that file in your browser. You should see Simple roslib Example. Check your Web Console for output. To see the console (in the Chrome browser): menu, more tools, javascript console. Other browsers will have something similar.

To have the HTML update: In the body section, add something with an Id:

  <body>
  <h1>Simple roslib Example</h1>
  <p id="abc">Test</p>
</body>

In listener.subscribe(function(message), add

document.getElementById("abc").innerHTML = message.data;
edit flag offensive delete link more

Comments

it helped thank you! :)

minerva gravatar image minerva  ( 2015-05-05 07:13:47 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2015-05-03 22:28:54 -0500

Seen: 981 times

Last updated: May 05 '15