brendanandrade / web-matlab-bridge Goto Github PK
View Code? Open in Web Editor NEWAccessing ROS via websockets from matlab
Accessing ROS via websockets from matlab
I am using Ubuntu 64 bit , Matlab 2012(a), JAVA 1.7_0.25, MATLAB_JAVA = JAVA 1.7_0.25, used ant to rebuild the src files, added the java_websocket.jar to static class path,
when running example.m, I get the Exception
java.lang.NullPointerException
at com.mathworks.jmi.bean.MatlabBeanInterface.addCallback(MatlabBeanInterface.java:765)
at com.mathworks.jmi.bean.MatlabCallbackInterface.addCallback(MatlabCallbackInterface.java:130)
It is occuring at the line where publisher is initialzed
Main problem --> subscriber.data is empty ... it is not returning any data
The Java WebSocket version you are using is writing all the headers of the request in lower case. This is not how the protocol is specified and causes troubles with some servers. Here is the bug and fix:
It seems like ros_websocket.m can not load the Java object. Do I have to do anything special to let Matlab know where is the java_websocket located?
Thanks!
The full error output:
??? Undefined function or method 'ROSBridgeClient' for input arguments of type 'java.net.URI'.
Error in ==> ros_websocket>ros_websocket.ros_websocket at 82
obj.client = ROSBridgeClient(obj.MASTER_URI);
Error in ==> example at 37
ws = ros_websocket(master_uri);
If a PoseArray or similar Array message is send from matlab of length one, the json message lacks the [] brackets to indicating an error.
Ex: '{"op": "publish", "topic": "cmd_vel_array", "msg":{
"twists": {
"linear": {
"x": 0.5,
"y": 0,
"z": 0
},
"angular": {
"x": 0,
"y": 0,
"z": 2,
"w": 0
}
}
}}'
It should be: '{"op": "publish", "topic": "cmd_vel_array", "msg":{
"twists": [{
"linear": {
"x": 0.5,
"y": 0,
"z": 0
},
"angular": {
"x": 0,
"y": 0,
"z": 2,
"w": 0
}
}]
}}'
This arises from the behavior of "savejson" function used in the publish method in the Publisher class.
When I attempt to run the first two lines of example.m
master_uri = 'ws://localhost:9090';
ws = ros_websocket(master_uri);
A java applet appears saying the Java Websocket is open and allowing me to manually close the Websocket, but when it tries to connect the following error occurs
Error using ros_websocket (line 87)
Java exception occurred:
java.lang.IllegalStateException: WebSocketClient objects are not reuseable
at org.java_websocket.client.WebSocketClient.connect(WebSocketClient.java:153)
java.net.ConnectException: Connection refused: connect
at sun.nio.ch.Net.connect(Native Method)
at sun.nio.ch.SocketChannelImpl.connect(Unknown Source)
at org.java_websocket.client.WebSocketClient.tryToConnect(WebSocketClient.java:201)
at org.java_websocket.client.WebSocketClient.interruptableRun(WebSocketClient.java:219)
at org.java_websocket.client.WebSocketClient.run(WebSocketClient.java:209)
at java.lang.Thread.run(Unknown Source)
Exception in thread "Thread-59" java.lang.NullPointerException
at org.java_websocket.WebSocketImpl.closeConnection(WebSocketImpl.java:446)
at org.java_websocket.WebSocketImpl.closeConnection(WebSocketImpl.java:475)
at org.java_websocket.client.WebSocketClient.interruptableRun(WebSocketClient.java:232)
at org.java_websocket.client.WebSocketClient.run(WebSocketClient.java:209)
at java.lang.Thread.run(Unknown Source)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.