I am running RTDE scripts and communicating with robot as normal. However, I need to compute the “pose_inv” of a certain pose I have and return it. I decided to write a new script to test it out but got nothing. Here’s my code:
import socket
import time
ip = "192.168.X.XXX" # (censored for privacy reasons)
port = 30004
s = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
s.settimeout(2)
s.connect((ip,port))
time.sleep(2)
s.send(("pose_inv(p[0.1104911905226538, -0.34939614486365744, 0.6564523211369121, -0.025329895430537173, 0.029401735236980375, -0.09949301737799898])\n").encode())
time.sleep(5)
message = s.recv(4096)
print(message)
time.sleep(5)
s.send(('pose_inv(p[0.12,0.36,-0.12,0,0,0])\n').encode())
time.sleep(5)
message2 = s.recv(4096)
print(message2)
After running pose_inv, I get an output of simply
b''
Which is my first problem. Where is my pose? If I do the same on the Polyscope, I get the expected pose. My second problem is being able to send a command after that. When sending the second pose_inv (aka message2) I this error:
message2 = s.recv(4096)
^^^^^^^^^^^^
ConnectionAbortedError: [WinError 10053] An established connection was aborted by the software in your host machine
I’m using the third party “ur_rtde” for RTDE communication, which handles recipes on its own. This was just an example code. Thanks for letting me know that RTDE can’t read pose_inv. Are there any other ways to print the pose_inv on my python side? When sending through socket communication, I get literal bytes in response that can’t be decoded by .decode(). I saw the other forum posts regarding functions that can decode them, is this really the only way?
Oh, well the ur_rtde library may have ways to send that script to the robot and get a response using other interfaces. That library was developed by a third-party so you may have better luck asking them:
Natively there are a couple ways you could probably do it. One may be to assign the pose_inv to a variable and send the full script line to the Primary/Secondary interface. From there you could connect to the Dashboard server on port 29999 and call “getVariable xxxxx” to get the variable value back in Python.