打开终端,一键安装!
pip install --upgrade ur-rtde$ pip install --upgrade ur-rtde Defaulting to user installation because normal site-packages is not writeable Requirement already satisfied: ur-rtde in /home/robot/.local/lib/python3.10/site-packages (1.6.2)关系图如下:
官网链接如下:
https://sdurobotics.gitlab.io/ur_rtde/examples/examples.htmlhttps://sdurobotics.gitlab.io/ur_rtde/examples/examples.html
https://docs.universal-robots.com/tutorials/index.htmlhttps://docs.universal-robots.com/tutorials/index.html
测试里面有啥东西!
import rtde_control import rtde_receive import inspect import sys # -------------------------- 工具函数:打印模块/类的详细信息 -------------------------- def print_module_info(module, module_name): """打印模块的核心信息:所有属性、类、函数""" print("="*80) print(f"【模块 {module_name}】 完整内容探索") print("="*80) # 1. 获取模块所有属性名(过滤内置私有属性,如__name__、__doc__) all_attributes = [attr for attr in dir(module) if not attr.startswith("__")] print(f"\n1. 模块所有公开属性/类/函数列表:") print(f" {', '.join(all_attributes)}\n") # 2. 分离模块中的 类、函数、普通属性 classes = [] functions = [] others = [] for attr_name in all_attributes: attr = getattr(module, attr_name) if inspect.isclass(attr): classes.append((attr_name, attr)) elif inspect.isfunction(attr) or inspect.ismethod(attr): functions.append((attr_name, attr)) else: others.append((attr_name, attr)) # 3. 打印模块中的类(核心重点) if classes: print(f"2. 模块中的类(共{len(classes)}个):") for cls_name, cls in classes: print(f"\n ▶ 类名:{cls_name}") # 打印类的父类 print(f" 父类:{[base.__name__ for base in cls.__bases__]}") # 打印类的文档字符串(说明) doc = cls.__doc__ if doc: print(f" 说明:{doc[:100]}..." if len(doc) > 100 else f" 说明:{doc}") # 打印类的所有方法(过滤内置方法) cls_methods = [m for m in dir(cls) if not m.startswith("__") and callable(getattr(cls, m))] print(f" 方法列表:{cls_methods}") # 4. 打印模块中的独立函数 if functions: print(f"\n3. 模块中的独立函数(共{len(functions)}个):") for func_name, func in functions: print(f" ▶ 函数名:{func_name}") # 打印函数参数 sig = inspect.signature(func) print(f" 参数:{sig}") # 打印函数说明 doc = func.__doc__ if doc: print(f" 说明:{doc[:80]}..." if len(doc) > 80 else f" 说明:{doc}") # 5. 打印模块中的普通属性(非类/非函数) if others: print(f"\n4. 模块中的普通属性(共{len(others)}个):") for attr_name, attr in others: print(f" ▶ {attr_name} = {attr}") # -------------------------- 核心:探索 rtde_control 和 rtde_receive -------------------------- if __name__ == "__main__": # 防止中文乱码 sys.stdout.reconfigure(encoding='utf-8') # 1. 探索 rtde_control 模块 print_module_info(rtde_control, "rtde_control") # 2. 探索 rtde_receive 模块 print_module_info(rtde_receive, "rtde_receive") # -------------------------- 额外:交互式查看(可选) -------------------------- print("\n" + "="*80) print("【额外提示】交互式查看更详细信息的方法:") print("="*80) print("1. 查看某个类的详细帮助(如 RTDEControlInterface):") print(" help(rtde_control.RTDEControlInterface)") print("\n2. 查看某个方法的具体用法(如 moveJ):") print(" help(rtde_control.RTDEControlInterface.moveJ)") print("\n3. 仅查看模块的属性列表:") print(" print(dir(rtde_control)) # rtde_control 所有属性") print(" print(dir(rtde_receive)) # rtde_receive 所有属性")结果如下:
================================================================================ 【模块 rtde_control】 完整内容探索 ================================================================================ 1. 模块所有公开属性/类/函数列表: AsyncOperationStatus, Path, PathEntry, RTDEControlInterface 2. 模块中的类(共4个): ▶ 类名:AsyncOperationStatus 父类:['pybind11_object'] 方法列表:['changeCount', 'equals', 'isAsyncOperationRunning', 'operationId', 'progress', 'value'] ▶ 类名:Path 父类:['pybind11_object'] 方法列表:['addEntry', 'appendMovejPath', 'appendMovelPath', 'clear', 'size', 'toScriptCode', 'waypoints'] ▶ 类名:PathEntry 父类:['pybind11_object'] 方法列表:['eMoveType', 'ePositionType', 'toScriptCode'] ▶ 类名:RTDEControlInterface 父类:['pybind11_object'] 方法列表:['Feature', 'Flags', 'directTorque', 'disconnect', 'enableExternalFtSensor', 'endFreedriveMode', 'endTeachMode', 'forceMode', 'forceModeSetDamping', 'forceModeSetGainScaling', 'forceModeStop', 'freedriveMode', 'ftRtdeInputEnable', 'getActualJointPositionsHistory', 'getActualToolFlangePose', 'getAsyncOperationProgress', 'getAsyncOperationProgressEx', 'getCoriolisAndCentrifugalTorques', 'getForwardKinematics', 'getFreedriveStatus', 'getInverseKinematics', 'getInverseKinematicsHasSolution', 'getJacobian', 'getJacobianTimeDerivative', 'getJointTorques', 'getMassMatrix', 'getRobotStatus', 'getStepTime', 'getTCPOffset', 'getTargetJointAccelerations', 'getTargetWaypoint', 'initPeriod', 'isConnected', 'isJointsWithinSafetyLimits', 'isPoseWithinSafetyLimits', 'isProgramRunning', 'isSteady', 'jogStart', 'jogStop', 'kickWatchdog', 'moveJ', 'moveJ_IK', 'moveL', 'moveL_FK', 'movePath', 'moveUntilContact', 'poseTrans', 'readContactDetection', 'reconnect', 'reuploadScript', 'sendCustomScript', 'sendCustomScriptFile', 'sendCustomScriptFunction', 'servoC', 'servoJ', 'servoL', 'servoStop', 'setCustomScriptFile', 'setExternalForceTorque', 'setGravity', 'setPayload', 'setTargetPayload', 'setTcp', 'setWatchdog', 'speedJ', 'speedL', 'speedStop', 'startContactDetection', 'stopContactDetection', 'stopJ', 'stopL', 'stopScript', 'teachMode', 'toolContact', 'triggerProtectiveStop', 'waitPeriod', 'zeroFtSensor'] ================================================================================ 【模块 rtde_receive】 完整内容探索 ================================================================================ 1. 模块所有公开属性/类/函数列表: RTDEReceiveInterface 2. 模块中的类(共1个): ▶ 类名:RTDEReceiveInterface 父类:['pybind11_object'] 方法列表:['disconnect', 'getActualCurrent', 'getActualDigitalInputBits', 'getActualDigitalOutputBits', 'getActualExecutionTime', 'getActualJointVoltage', 'getActualMainVoltage', 'getActualMomentum', 'getActualQ', 'getActualQd', 'getActualRobotCurrent', 'getActualRobotVoltage', 'getActualTCPForce', 'getActualTCPPose', 'getActualTCPSpeed', 'getActualToolAccelerometer', 'getDigitalInState', 'getDigitalOutState', 'getFtRawWrench', 'getJointControlOutput', 'getJointMode', 'getJointTemperatures', 'getOutputDoubleRegister', 'getOutputIntRegister', 'getPayload', 'getPayloadCog', 'getPayloadInertia', 'getRobotMode', 'getRobotStatus', 'getRuntimeState', 'getSafetyMode', 'getSafetyStatusBits', 'getSpeedScaling', 'getSpeedScalingCombined', 'getStandardAnalogInput0', 'getStandardAnalogInput1', 'getStandardAnalogOutput0', 'getStandardAnalogOutput1', 'getTargetCurrent', 'getTargetMoment', 'getTargetQ', 'getTargetQd', 'getTargetQdd', 'getTargetSpeedFraction', 'getTargetTCPPose', 'getTargetTCPSpeed', 'getTimestamp', 'initPeriod', 'isConnected', 'isEmergencyStopped', 'isProtectiveStopped', 'reconnect', 'startFileRecording', 'stopFileRecording', 'waitPeriod'] ================================================================================ 【额外提示】交互式查看更详细信息的方法: ================================================================================ 1. 查看某个类的详细帮助(如 RTDEControlInterface): help(rtde_control.RTDEControlInterface) 2. 查看某个方法的具体用法(如 moveJ): help(rtde_control.RTDEControlInterface.moveJ) 3. 仅查看模块的属性列表: print(dir(rtde_control)) # rtde_control 所有属性 print(dir(rtde_receive)) # rtde_receive 所有属性进一步详细测试,激发ur-rtde里面所有的功能!