I cannot see in the manual anything about a function inversely similar to socket_read_ascii_float, which is a nice work around string parsing functions, but what about the contrary, sending ascii floats in a similar format?
Do you see any way around this? I’d like to read the actual pose of the robot, then send its coordinates to a system through TCP/IP. The system can only read/parse ascii characters, and the ideal I believe would have been to convert the whole coordinates into a string to send…
Sending a floating point number over TCP socket is not supported by URScript.
The simplest solution is to multiply the floating point number with e.g. 10000, thus omitting insignificant digits,a nd sending it as an integer.
In example, you could use a URScript function like:
def getPose(): p = get_actual_tcp_pose() socket_open("127.0.0.1",33000,"ms") socket_set_var("myX",p*100000,"ms") socket_set_var("myY",p*100000,"ms") socket_set_var("myZ",p*100000,"ms") socket_close("ms") end
This program would open a socket to
localhoston port 33000 and send the X, Y and Z data.
The server would read:
SET myX 12345 SET myY 23456 SET myZ 34567
All would be ASCII chars.
(Valid for URSW 220.127.116.11)
Specifically for reading the robot TCP position, consider the RTDE or client interfaces if you have the possibility.