# Chapter 5: RTDEReceiveInterface ## About This Chapter Whereas `RTDEControlInterface` is the class used to **move the robot**, `RTDEReceiveInterface` is the class used to **retrieve the robot's state**. In practical applications, it is used just as frequently as motion commands for tasks such as: - Retrieving the current position - Determining whether motion has completed - Monitoring errors - Monitoring safety status This chapter describes the main APIs and usage of `RTDEReceiveInterface` in SDU Robotics' `ur_rtde` library. --- # 5.1 What Is the Receive Interface? `RTDEReceiveInterface` is a state-acquisition interface provided by SDU Robotics' `ur_rtde`. It uses the output data of Universal Robots' official RTDE interface to obtain the controller state. ``` UR Controller │ RTDE Output │ RTDEReceiveInterface │ Python ``` It does not provide any motion commands. --- # 5.2 Creating an Instance ```python from rtde_receive import RTDEReceiveInterface ROBOT_IP = "192.168.0.10" rtde_r = RTDEReceiveInterface(ROBOT_IP) ``` Normally, it is instantiated together with `RTDEControlInterface`. ```python rtde_c = RTDEControlInterface(IP) rtde_r = RTDEReceiveInterface(IP) ``` --- # 5.3 Reading Joint Positions This is one of the most frequently used APIs. ```python q = rtde_r.getActualQ() ``` Return value: ``` [ q1, q2, q3, q4, q5, q6 ] ``` Unit: ``` rad ``` The values are not in joint degrees. --- # 5.4 Joint Velocities ```python dq = rtde_r.getActualQd() ``` Unit: ``` rad/s ``` These values can also be used to determine whether the robot has stopped. --- # 5.5 Reading the TCP Pose ```python pose = rtde_r.getActualTCPPose() ``` Return value: ``` [ x, y, z, rx, ry, rz ] ``` Units: ``` m rad ``` The position values are not in millimeters. --- # 5.6 TCP Speed ```python speed = rtde_r.getActualTCPSpeed() ``` Retrieves the TCP velocity vector. It can be used to determine whether the robot has stopped. --- # 5.7 TCP Force On robots equipped with a force sensor, the following API is available: ```python force = rtde_r.getActualTCPForce() ``` Return value: ``` Fx Fy Fz Mx My Mz ``` It is frequently used in Force Mode. --- # 5.8 Robot Mode ```python mode = rtde_r.getRobotMode() ``` Retrieves the state of the robot controller. Representative states include: - Disconnected - Booting - Power Off - Idle - Running This is useful for checking the controller before starting operation. --- # 5.9 Safety Mode ```python mode = rtde_r.getSafetyMode() ``` Retrieves the safety state. Examples include: - Normal - Protective Stop - Recovery - Emergency Stop --- # 5.10 Runtime State ```python state = rtde_r.getRuntimeState() ``` Retrieves the current program state. For example, it can be used to distinguish among: ``` Stopped Running Paused ``` It is often used together with the Dashboard interface. --- # 5.11 Digital Input ```python rtde_r.getDigitalInState(pin) ``` Retrieves the input state. Return value: ``` True False ``` --- # 5.12 Digital Output ```python rtde_r.getDigitalOutState(pin) ``` Retrieves the output state. This can be used to verify whether the output is actually ON. --- # 5.13 Joint Temperatures ```python temp = rtde_r.getJointTemperatures() ``` Retrieves the temperature of each joint. This is useful for monitoring during prolonged operation. --- # 5.14 Determining Motion Completion A motion command alone does not tell you whether the robot has reached its destination. For example: ```python target = [...] while True: q = rtde_r.getActualQ() if max(abs(a-b) for a,b in zip(q,target)) < 1e-3: break time.sleep(0.01) ``` This checks the difference between the current and target positions. --- # 5.15 Detecting a Stop Velocity can also be used to detect a stop. ```python dq = rtde_r.getActualQd() ``` If all joint velocities become sufficiently small, the robot can be considered stopped. --- # 5.16 The Concept Behind wait_move() The `wait_move()` method in `ur_ctrl.py` determines completion internally using logic such as: ``` Current position ↓ Difference from target position ↓ Within tolerance ↓ Complete ``` Alternatively: ``` Velocity ↓ Approximately zero ↓ Complete ``` The return value of `MoveJ` alone is not sufficient. --- # 5.17 Monitoring Loop A typical example: ```python while True: pose = rtde_r.getActualTCPPose() mode = rtde_r.getRobotMode() safety = rtde_r.getSafetyMode() print(pose) if safety != NORMAL: break time.sleep(0.02) ``` A monitoring frequency of approximately 50 Hz is often sufficient. --- # 5.18 Characteristics of RTDEReceive `RTDEReceive` has the following characteristics: - High-speed operation - Read-only access - A wide range of APIs However, it does not provide motion commands. Use `RTDEControl` for motion commands. --- # Summary `RTDEReceiveInterface` is a class dedicated to monitoring robot state. This library uses the following information: - Current position - Velocity - Robot Mode - Safety Mode - Runtime State These are used to implement: - `wait_move()` - Error monitoring - State monitoring The next chapter describes `RTDEIOInterface`.