Basic RTDE + ur_robot_driver (ROS) + Matlab handling

Hi, I want the UR5 (CB3) to follow a specific trajectory with respect to positions, velocities and accelerations in joint space given for every time step. While the robot is driving the trajectory I need to gather measurements (actual positions, velocities and accelerations and the joint torques or the motor currents if joint torques are not available).
1.) Trajectory Following:
I get seemingly good trajectory following by publishing messages to the ‘/scaled_pos_traj_controller/command’-controller of the ROS driver (GitHub - UniversalRobots/Universal_Robots_ROS_Driver: Universal Robots ROS driver supporting CB3 and e-Series) or by sending a chain of ‘speedj’-commands directly without the ROS driver. But actually, I want to design my own controller using the actual joint states. I also experienced weird behaviors if I supply a ‘dense’ trajectory with many waypoints in a fast succession. But fast means here actually <<125Hz. Is there some data about this? How should this be handled?
What might be the best control strategy for this kind of problem for the given ?
2.) Measurements:
I really do not get how to connect to the RTDE interface. The python examples (https://www.universal-robots.com/how-tos-and-faqs/how-to/ur-how-tos/real-time-data-exchange-rtde-guide-22229/) are not useful at all, because of my lacking python skills. I don’t even know how to run the files or how they are meant to be used for further development. I tried to receive messages of the joint states via ROS, but this stops the driving command.
a) How can I use the Python files? (There is no documentation…)
b) How can I use the RTDE interface inside Matlab?
c) How can I use the ROS driver in conjunction with RTDE (the URCap stops when I try to connect to somehow outside of the URCap)?
d) While I need to use RTDE in the future, is there a quicker and easier way to get my measurement?

Thanks a lot in advance! I know it’s a lot…

Hi ulmen,

you could use the socket connection to send your control command, like "s.send ("movej(p[0.00, 0.4, 0.3, 2.22, -2.22, 0.00], a=1.0, v=0.1)\n".encode('utf-8'))".

Several days ago, we met the same questions as you, and we sew the same page about how to control the UR robot using code, without the controller of UR. what’s more, we all want to read the RTDE information to know the motion status of the UR robot. Then, we design the C++ and python code to control and read data from RTDE. I am not sure if it is helpful to you, and as you can see in “readme”, there are still bugs existing in our code, and we have no idea how to fix it! If you have any questions on how to use it, you can contact me (leihui.liAToutlook.com)!!!

there is our code address as following:

1 Like

Hey Leihui,
thanks for the response! Nice code! Yes, I’m able to send movej and speedj commands to the client. I’m also using port 30003 for that like you. The upside of movej is reliablitiy regarding position error, while speedj is way smoother and seems get the intricacies of my trajectory. But there is quiet some position error summing up over the course of the 10 seconds. The ‘/scaled_pos_traj_controller/command’ of the ROS driver gives best results so far in open loop. But all methods could be way better with some feedback in a closed loop. This could also partly solve the ‘density’ problem, because the improved performance per trajectory point will cancel out some drawback of fewer points.
It all comes down to using RTDE, exchanging data back and forth without interrupting the drive commands.
For the first step, I really need to collect the data for some offline evaluation.