How can I get the actual tcp pose while the robot is working?

In Python, how can I get current robot pose?
I am trying to automate the movment in z-axis of the robot tcp as it moves in the x and y axes. For this I am using a camera; which measures the distance to the surface. The aim is to remain the camera at the same distance while the surface area varies; when the robot is moving (X and Y).
I am trying to get the robot position using the following script but the result is encoded and as much as I try to decode it, I can’t get it.

import socket
import time

HOST=“192.168.1.12”
PORT=30002

s=socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((HOST,PORT))

s.send(“get_actual_TCP_pose()”.encode())
position=s.recv(1024)
print(position)
print(bytes(position).decode())

How do i take the the Z position in order to compare with the distance which is reading the camera?

Hope someone could help me,

Thanks!

This is the answer that the program gives me once it has been run.