Hej again Stefan,
I checked that post to install RTDE and even it shows that it is installed and set up VCode, and stuff, I started encountering the same issues as you. I thought that this RTDE package was based on the same RTDE that is given by UR on the link that @emil.madsen has posted here (the one that I use as well), but it turns out this is some SDU stuff that it might be incompatible.
So, anyway, I came back to this original post, see what you are aiming to do, and found a way:
- Leave that ur_rtde post, it’s been dead 8 months already.
- Go to the RTDE link given by @emil.madsen , scroll all the way to the bottom, and download the attached files.
- Unzip the rtde-2.6.0 folder. In my case, I did this whole thing in a Ubuntu 20 VM.
- Create a new file within the example folder and copy-paste the content from record.py. This is how my workspace looks like (
00_tcp_example.py
is the new file):
- Modify the new file to get only the info that you need. In this case, I removed the whole printing and just kept the tcp-pose and the timestamp.
#!/usr/bin/env python
import argparse
import logging
import sys
sys.path.append('..')
import rtde.rtde as rtde
import rtde.rtde_config as rtde_config
import time
# parameters
parser = argparse.ArgumentParser()
parser.add_argument('--host', default='localhost',help='name of host to connect to (localhost)')
parser.add_argument('--port', type=int, default=30004, help='port number (30004)')
parser.add_argument('--samples', type=int, default=0,help='number of samples to record')
parser.add_argument('--frequency', type=int, default=125, help='the sampling frequency in Herz')
parser.add_argument('--config', default='record_configuration.xml', help='data configuration file to use (record_configuration.xml)')
parser.add_argument("--verbose", help="increase output verbosity", action="store_true")
parser.add_argument("--buffered", help="Use buffered receive which doesn't skip data", action="store_true")
parser.add_argument("--binary", help="save the data in binary format", action="store_true")
args = parser.parse_args()
if args.verbose:
logging.basicConfig(level=logging.INFO)
conf = rtde_config.ConfigFile(args.config)
output_names, output_types = conf.get_recipe('out')
con = rtde.RTDE(args.host, args.port)
con.connect()
# settings
con.get_controller_version()
con.send_output_setup(output_names, output_types, frequency=args.frequency)
con.send_start()
# initialize variables
X = 0
Y = 0
Z = 0
RX = 0
RY = 0
RZ = 0
# main loop
i = 1
for i in range(3):
if args.samples > 0 and i >= args.samples:
keep_running = False
try:
if args.buffered:
state = con.receive_buffered(args.binary)
else:
state = con.receive(args.binary)
if state is not None:
X,Y,Z,RX,RY,RZ = state.actual_TCP_pose
date_and_time = state.timestamp
i += 1
print(str(date_and_time)+" TCP: pos ["+str(X)+", "+str(Y)+", "+str(Z)+"] m, rot ["+str(RX)+", "+str(RY)+", "+str(RZ)+"] rad")
time.sleep(0.1)
except KeyboardInterrupt:
break
except rtde.RTDEException:
break
con.send_pause()
con.disconnect()
This is the output:
About the Ubuntu 20 VM, you can also use the Ubuntu 16 VM given on the start package from the UR+ page, because the one given with URSim and Polyscope from the main UR page comes with Lubuntu and very basic tools, which makes the Python and pip install harder.