news 2026/9/3 7:32:46

ur-rtde详细使用教程

作者头像

张小明

前端开发工程师

1.2k 24
文章封面图
ur-rtde详细使用教程

打开终端,一键安装!

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里面所有的功能!

版权声明: 本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!
网站建设 2026/9/2 13:05:59

EmotiVoice镜像部署指南:Docker一键启动超便捷

EmotiVoice镜像部署指南:Docker一键启动超便捷 在AI语音技术飞速发展的今天,用户早已不满足于“机器朗读”式的冰冷输出。从虚拟偶像到智能助手,从有声书生产到游戏NPC对话,人们期待的是有情绪、有温度、有个性的声音。然而&#…

作者头像 李华
网站建设 2026/9/2 16:15:22

2.6 DeepResearch 深度研究助手的容器化部署与测试

2.6 DeepResearch 深度研究助手的容器化部署与测试 导语:大家好,欢迎来到我们第二周的最后一讲。在过去的几天里,我们成功地从零到一构建了一个强大的多智能体研究系统——DeepResearch。它可以在我们的本地机器上出色地完成任务。但是,如何将这个强大的 AI 应用交付给最终…

作者头像 李华
网站建设 2026/9/2 21:34:03

从疑惑到清晰:Linux与Windows的核心差异

前言 作为计算机学习者或从业者,你是否也曾有过这些困惑: 为什么市面上会同时存在Linux和Windows两大主流操作系统?先有的哪个?既然已经有了第一个,为什么还需要第二个?它们的核心区别到底是什么&#xff0…

作者头像 李华
网站建设 2026/9/3 6:15:19

一篇文章带你了解Redis数据类型

前言 Redis作为高性能键值存储(缓存/数据库),其数据类型设计是“高性能多场景适配”的核心,也是面试高频考点、业务开发必备技能。本文将分「核心数据类型」「拓展数据类型」两大模块,讲透每个类型的特点、常用命令、实…

作者头像 李华
网站建设 2026/9/2 21:34:09

3.6 线上问题排查实战:让你的 AI 服务 7x24 小时稳定运行

3.6 线上问题排查实战:让你的 AI 服务 7x24 小时稳定运行 导语:欢迎来到第三周的终极实战!我们已经成功地将“旅小智”部署到了云端。但是,部署成功只是一个新的开始。在真实的生产环境中,系统会在你意想不到的时间、以你意想不到的方式出现问题。当凌晨三点,告警短信将你…

作者头像 李华