11from pathlib import Path
2+ from typing import NewType
23import rtde .rtde as rtde
34import rtde .rtde_config as rtde_config
45
6+ UINT32 = NewType ("UINT32" , int )
7+
58
69class RTDE :
710 def __init__ (self , ip : str ):
@@ -27,3 +30,49 @@ def joint_angles(self) -> list[float]:
2730 def tcp_pose (self ) -> list [float ]:
2831 """Return TCP pose [x, y, z, rx, ry, rz]."""
2932 return list (self ._get_data ().actual_TCP_pose )
33+
34+ def robot_status (self ) -> dict [str , bool ]:
35+ """Return robot status.
36+
37+ Robot status bits (UINT32):
38+ - **`Bit 0`**: Is power on
39+ - **`Bit 1`**: Is program running
40+ - **`Bit 2`**: Is teach button pressed
41+ - **`Bit 3`**: Is power button pressed
42+
43+ Safety status bits (UINT32):
44+ - **`Bit 0`**: Is normal mode
45+ - **`Bit 1`**: Is reduced mode
46+ - **`Bit 2`**: Is protective stop
47+ - **`Bit 3`**: Is recovery mode
48+ - **`Bit 4`**: Is safeguard stopped
49+ - **`Bit 5`**: Is system emergency stopped
50+ - **`Bit 6`**: Is robot emergency stopped
51+ - **`Bit 7`**: Is Emergency Stopped
52+ - **`Bit 8`**: Is violation
53+ - **`Bit 9`**: Is Fault
54+ - **`Bit 10`**: Is stopped due to safety
55+ """
56+ data = self ._get_data ()
57+ rsb : UINT32 = data .robot_status_bits
58+ ssb : UINT32 = data .safety_status_bits
59+
60+ return {
61+ # Robot status bits
62+ "Power On" : bool (rsb & 1 ),
63+ "Program Running" : bool (rsb & 2 ),
64+ "Teach Button" : bool (rsb & 4 ),
65+ "Power Button" : bool (rsb & 8 ),
66+ # Safety status bits
67+ "Normal Mode" : bool (ssb & 1 ),
68+ "Reduced Mode" : bool (ssb & 2 ),
69+ "Protective Stop" : bool (ssb & 4 ),
70+ "Recovery Mode" : bool (ssb & 8 ),
71+ "Safeguard Stopped" : bool (ssb & 16 ),
72+ "System Emergency Stopped" : bool (ssb & 32 ),
73+ "Robot Emergency Stopped" : bool (ssb & 64 ),
74+ "Emergency Stopped" : bool (ssb & 128 ),
75+ "Violation" : bool (ssb & 256 ),
76+ "Fault" : bool (ssb & 512 ),
77+ "Stopped Due to Safety" : bool (ssb & 1024 ),
78+ }
0 commit comments