Using rosbridge protocol to talk with MATLAB
Hello everybody,
I'm working on a project in which I have to communicate between MATLAB and ROS. To do this, I found rosbridge protocol easiest. The rosbridge server opens a socket on port 8080 (using customized launchfile) ( or 9090 by default).
To talk with it through MATLAB, I think it would be good to use tcpip library and send JSON string message. https://github.com/RobotWebTools/rosbridge_suite/blob/hydro-devel/ROSBRIDGE_PROTOCOL.md is the link I'm following to learn about rosbridge protocol.
But I don't know that it would work. (doesn't work for me so far) Does rosbridge protocol parses the string JSON that I sent from MATLAB and advertise/publish/subscribe topics automatically? I've greated a simple /chatter in order to test my hypothesis but I can't get it working. Anyway, I need some help figuring out rosbridge protocol and solving the problems that I've mentioned.
The procedure that I've followed is like this:
(http://wiki.ros.org/rosbridge_suite/Tutorials/RunningRosbridge)
I've installed the rosbridge using this:
sudo apt-get install ros-groovy-rosbridge-server
Then, I've launched the server:
roslaunch rosbridge_server rosbridge_websocket.launch
On the client side, I've used the tcpip MATLAB library
(http://www.mathworks.com/help/instrument/tcpip.html)
Start a TCP/IP echo server and create a TCPIP object.
echotcpip('on',8080)
t = tcpip('localhost',8080);
fopen(t)
JSON_MSG = '';
fwrite(t,JSON_MSG)
fclose(t)
echotcpip('off')
I've entered something on JSON_MSG part but I couldnt receive any data on server side (simply using rostopic echo). Can anybody please give me some ideas on how to use this json message or whether this procedure would work or not? Note that I use ROS groovy with Ubuntu 12.04. Any help will be greatly appreciated. Thank you.
UPDATE: I've tried the following JSON message, but something is wrong. No data is being received from the server side.
{ "op": "publish",
"topic": "/gz/cmd_vel",
"msg":"{ "linear": "{x : 0.8, y:0.2, z:0.3}",
"angular": "{x : 0, y:0, z:0}" }"
}
UPDATE2: I've installed rosbridge_tcp, and run it. Now, when I try to send data from MATLAB, I get the following error on the server side. Although, it does seem OK, when there's no data sent.
[ERROR] [WallTime: 1386952042.195641] [122.162000] Unable to accept incoming connection. Reason: __init__() got an unexpected keyword argument 'parameters'
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 45997)
Traceback (most recent call last):
File "/usr/lib/python2.7/SocketServer.py", line 582, in process_request_thread
self.finish_request(request, client_address)
File "/usr/lib/python2.7/SocketServer.py", line 323, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "/usr/lib/python2.7/SocketServer.py", line 640, in __init__
self.finish()
File "./rosbridge_tcp", line 100, in finish
self.protocol.finish()
AttributeError: RosbridgeTcpSocket instance has no attribute 'protocol'
----------------------------------------