Hello I’m trying to do a simple socket communication in an URCap but i get this following print when calling
get_actual_joint_positions(), how to encoded it to something readable an example would be highly appreciated which
is something that generally lacks.
Thx my socket code is below:
The data should be coming across as a buffer stream and so you will need to decode that data. I have never tried sending that command directly to the port but we read the stream coming from 30003 and 30001 as well as RTDE and we have to decode the data using unpack. I am not sure how you would do that in JAVA but I know in python and nodejs we use the unpack library and send it the encoding of the data. When it comes to joint position it is usually a list of 6 positions which are all a double. In the RTDE documents, this is referred to as a VECTOR6D.
Here is a link to one library I quickly looked at that might be what you need.
So setup the socket connection, check to make sure the socket is connected, get the output stream from that connection, then write to that connection with string s, and encode with UTF-8. To be honest not sure if the UTF-8 is needed but personally that socket connection is talking to a Raspberry PI.
Now for reading a message back you’ll do something like this
I have a question on the sample codes that you shared for socket communication. In one of the samples, the TimerTask opens up a new socket connection for each iteration.
Instead, can we open the socket connection once in openview() and close it in closeview() method? so that we can avoid multiple TCP/IP handshakes.
Does anyone in this channel know how to clear the socket buffer as an interrupt? I am finding that my error recovery sequence is overloading the controller and I want to be able to clear the input buffer of ASCII messages. Any advice is appreciated!