How to run a .html file with js including roslibjs
So I am trying to run a .html file which includes the javascript and uses roslibjs. I get the following error in the js console in firefox:
ReferenceError: ROSLIB is not defined math.html:10
Use of getPreventDefault() is deprecated. Use defaultPrevented instead.
I am running the example provided in the roslibjs
repo in github.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<script src="http://cdn.robotwebtools.org/EventEmitter2/current/eventemitter2.min.js"></script>
<script src="../build/roslib.js"></script>
<script>
// Let's start by adding some vectors.
var v1 = new ROSLIB.Vector3({
x : 1,
y : 2,
z : 3
});
var v2 = v1.clone();
v1.add(v2);
console.log(v1);
// Now let's play with some quaternions.
var q1 = new ROSLIB.Quaternion({
x : 0.1,
y : 0.2,
z : 0.3,
w : 0.4
});
var q2 = q1.clone();
q1.multiply(q2);
q1.invert();
console.log(q1);
// Let's copy the results into a pose.
var p = new ROSLIB.Pose({
position : v1,
orientation : q1
});
console.log(p);
// Finally, let's play with some transforms.
var tf = new ROSLIB.Transform({
translation : v2,
rotation : q2
});
p.applyTransform(tf);
console.log(p);
</script>
</head>
<body>
<h1>Simple Math Example</h1>
<p>Check the JavaScript console for the output.</p>
</body>
</html>
Besides that I was trying to learn how to publish the commands or literally any output to a webpage using the roslibjs. I have followed these steps:
1)roscore
2) open a new terminal
3)rostopic pub /listener std_msgs/String "Hello, World" in the new terminal
This is what I see after entering this command:
publishing and latching message. Press ctrl-C to terminate
4) open another terminal:
5) rostopic echo /cmd_vel in the new terminal
6) This is what I see after entering the command:
WARNING: topic [/cmd_vel] does not appear to be published yet
7) browse to localhost:9090 I get this message:
Can "Upgrade" only to "WebSocket".
8) also after running this nothing happens and it just shows no result or warning:
rosrun rospy_tutorials add_two_ints_server
9) eventually when I run this I get the errors:
roslaunch rosbridge_server rosbridge_websocket.launch
... logging to /home/mona/.ros/log/9cc9437a-3a51-11e5-8592-340286a5d052/roslaunch-mona-Latitude-E5550-27665.log
Checking log directory for disk usage. This may take awhile.
Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.
started roslaunch server http://mona-Latitude-E5550:51847/
SUMMARY
========
PARAMETERS
* /rosbridge_websocket/address:
* /rosbridge_websocket/authenticate: False
* /rosbridge_websocket/port: 9090
* /rosdistro: jade
* /rosversion: 1.11.13
NODES
/
rosapi (rosapi/rosapi_node)
rosbridge_websocket (rosbridge_server/rosbridge_websocket)
ROS_MASTER_URI=http://localhost:11311
core service [/rosout] found
process[rosbridge_websocket-1]: started with pid [27687]
process[rosapi-2]: started with pid [27688]
registered capabilities (classes):
- rosbridge_library.capabilities.call_service.CallService
- rosbridge_library.capabilities.advertise.Advertise
- rosbridge_library.capabilities.publish.Publish
- rosbridge_library.capabilities.subscribe.Subscribe
- <class 'rosbridge_library.capabilities.defragmentation.Defragment'>
- rosbridge_library.capabilities.advertise_service.AdvertiseService
- rosbridge_library.capabilities.service_response.ServiceResponse
- rosbridge_library.capabilities.unadvertise_service.UnadvertiseService
Traceback (most recent call last):
File "/opt/ros/jade/lib/rosbridge_server/rosbridge_websocket", line 135, in <module>
application.listen(port, address)
File "/opt/ros/jade/lib/python2.7/dist-packages/tornado/web.py", line 1691, in listen
server ...