rosbridge JSON format for std_msgs/String error
Hi, I am attempting to use rosbridge to publish a string message to a topic. My code is below, but this is the line that tries to do the publishing.
connection.publish('/recognizer/output', 'std_msgs/String', '{"Hello World"}');
I am able to make my connection to rosbridge and I can even listen to topics, it just appears my formatting for the String message publishing is not correct. This should be easy for anyone to reproduce, just start roscore, start rosbridge, copy my code into an html page (see code below) and open in google chrome.
The error I get is as follows. Any help would be greatly appreciated. It seems to argue that it needs a : delimiter, but I have tried putting one in and it is still not happy either. -Scott
The rosbridge/json format error
GET / HTTP/1.1
Host: 127.0.0.1:9090
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:7.0.1) Gecko/20100101 Firefox/7.0.1
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip, deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Connection: keep-alive, Upgrade
Sec-WebSocket-Version: 8
Sec-WebSocket-Origin: null
Sec-WebSocket-Extensions: deflate-stream
Sec-WebSocket-Key: UzHkStz0wbNSaL5vwnRaoQ==
Pragma: no-cache
Cache-Control: no-cache
Upgrade: websocket
------
draft-ietf-hybi-thewebsocketprotocol-06 (preliminary, _may_ be deprecated)
closed 9
Connection from 127.0.0.1:52592
2 concurrent connections.
------
GET / HTTP/1.1
Upgrade: websocket
Connection: Upgrade
Host: 127.0.0.1:9090
Origin: null
Sec-WebSocket-Key: PGcwCtYx88PudrPTfk4L3g==
Sec-WebSocket-Version: 13
------
draft-ietf-hybi-thewebsocketprotocol-06 (preliminary, _may_ be deprecated)
Problem Problem Problem Problem Problem Problem Problem Problem Problem Problem
Traceback (most recent call last):
File "/home/wilson/ros_packages/rosbridge/bin/rosbridge.py", line 39, in handleFrameHelper
call = json.loads(frame)
File "/usr/lib/python2.7/json/__init__.py", line 326, in loads
return _default_decoder.decode(s)
File "/usr/lib/python2.7/json/decoder.py", line 360, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/lib/python2.7/json/decoder.py", line 376, in raw_decode
obj, end = self.scan_once(s, idx)
ValueError: Expecting : delimiter: line 1 column 53 (char 53)
Problem Problem Problem Problem Problem Problem Problem Problem Problem Problem
Here is my code
<html>
<head>
<script type="text/javascript" src="http://brown-ros-pkg.googlecode.com/svn/tags/brown-ros-pkg/rosbridge/ros.js"></script>
<script type="text/javascript">
function main() {
var connection = new ros.Connection("ws://127.0.0.1:9090");
connection.setOnClose(function (e) {
document.write('connection closed<br/>');
});
connection.setOnError(function (e) {
document.write('error!<br/>');
});
connection.setOnOpen(function (e) {
document.write('connected to ROS<br/>');
document.write('attempting to send message over socket connection.');
connection.publish('/recognizer/output', 'std_msgs/String', '{"Hello World"}');
});
}
</script>
</head>
<body onload="main()">
</body>
</html>