news 2025/12/27 13:05:05

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进行投诉反馈,一经查实,立即删除!
网站建设 2025/12/23 4:57:00

2.1 Agent 开发新范式!LangGraph 从链式思维到图状态的革命

2.1 Agent 开发新范式!LangGraph 从链式思维到图状态的革命 导语:欢迎进入课程的第二周!在第一周,我们聚焦于构建和强化单个 Agent 的能力。我们学会了如何让它使用工具、拥有记忆、并遵循我们的指令。然而,当我们面对真正复杂的、需要多个角色分工协作才能完成的任务时,…

作者头像 李华
网站建设 2025/12/19 2:14:37

EmotiVoice语音合成噪音抑制后处理:提升最终输出纯净度

EmotiVoice语音合成噪音抑制后处理:提升最终输出纯净度 在智能语音内容爆发式增长的今天,用户早已不满足于“能说话”的AI语音。从虚拟偶像直播到有声书自动播讲,从游戏NPC互动到数字员工客服,人们期待的是像真人一样富有情感、自…

作者头像 李华
网站建设 2025/12/19 2:14:25

9个AI写作工具,专科生轻松搞定论文格式规范!

9个AI写作工具,专科生轻松搞定论文格式规范! AI工具如何让论文写作变得轻松 对于专科生来说,论文写作不仅是学术能力的体现,更是毕业路上的一道重要关卡。而随着AI技术的不断进步,越来越多的AI写作工具应运而生&#x…

作者头像 李华
网站建设 2025/12/19 1:34:36

基于AI的全国蔬菜供应与价格预测PPT自动化生成方案

一、方案概述在农业数字化转型的浪潮中,准确预测蔬菜价格波动和优化供应管理变得愈发重要。为应对这一挑战,本文将系统阐述如何构建一个基于人工智能技术的全国蔬菜供应与价格预测PPT自动化生成方案。该综合解决方案通过整合多源农业数据,运用…

作者头像 李华
网站建设 2025/12/18 20:24:04

【收藏必备】Transformer原理与实现:大模型开发者必学核心知识

简介 Transfromer架构在 2017 年由 Google 提出的一种基于自注意力机制的深度神经网络架构,目前Transformer已经成为了NLP领域的基础架构。基于Transformer架构也衍生出了著名的Transformer模型,例如GPT(The Generative Pretrained Transformer)、BERT(B…

作者头像 李华
网站建设 2025/12/19 4:05:03

45、数据库应用开发:从单机到 Web 的实现与优化

数据库应用开发:从单机到 Web 的实现与优化 1. 项目实现概述 在项目开发中,实现环节至关重要,它涉及到选择合适的编程语言和 API,进行面向对象设计并编写代码。对于本项目,我们需要快速开发出一个多功能的程序,并且要考虑到程序未来的扩展性。 1.1 语言和 API 选择 选…

作者头像 李华