Sending floats from the robot controller through TCP/IP?

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[0]*100000,"ms")
	socket_set_var("myY",p[1]*100000,"ms")
	socket_set_var("myZ",p[2]*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 3.3.0.145)

Note:
Specifically for reading the robot TCP position, consider the RTDE or client interfaces if you have the possibility.

3 Likes