机器人遥操作处理管线的构建与适配方法

介绍如何用三段式处理管线把手机等遥操作设备与机器人、数据集连接起来,通过适配器统一动作与观测空间的转换,并用特征契约声明每一步修改的数据字段,从而减少重复的胶水代码。

# 机器人和电信操作器处理器 本指南展示了如何构建和修改连接远程操作器(如电话)到机器人和数据集的处理管道. 管道将不同动作/观测空间之间的转换标准化,这样就可以不用重写胶体代码而互换远程操作器和机器人. 我们用电话SO‑100后继者的例子用于具体化,但相同的模式适用于其他机器人. **你会学到什么** - 绝对对相对的 EE 控制 : 每个都意味着什么, 权衡, 以及如何选择您的任务 。 - 三管模式:如何映射Teleop动作 → 数据集动作 → 机器人指令,和机器人观测 → 数据集观测. - 适配器( U)`to_transition` / `to_output`:这些如何将原始文件转换为 `EnvTransition` 并返回来减少锅炉板。 - 数据集特征合同: 步骤如何通过 `transform_features(...)`,以及如何将其聚合/聚合以进行记录。 - 选择一个代表:何时存储关节,绝对的EE会提出,或者相对的EE deltas——以及这如何影响训练. - 管道定制指导:如何安全地交换机器人/URDF以及调制界限,步码大小,以及IK初始化等选项. ### 绝对对相对的 EE 控制 本指南中的例子使用绝对端效应器(EE),因为它们容易解释,在实践中,相对的EE deltas或联合位置常被选为学习特征. 使用处理器,您可以选择您想要用于策略的学习特性。这可能是关节位置/速度,绝对的EE,或者相对的EE位置。您也可以选择存储其他特性,例如关节扭矩,运动电流等. ## 三条管道 我们经常组成三个管道,根据你的设置,如果动作和观察空间已经匹配的话,一些管道就可能空了. 每个管道处理不同动作空间和观测空间之间的不同转换。下面是每个管道的快速解释。 1. 管道 1:Teleop动作空间 → 数据集动作空间(手机姿态 → EE目标) 2. 管道 2:数据集动作空间 → 机器人指令空间(EE目标 → 关节) 3. 管道 3:机器人观测空间 → 数据集观测空间(联动 → EE 姿势) 下面是三条输油管的例子 我们在电话里用到SO-100后继示例 : ```python phone_to_robot_ee_pose_processor = RobotProcessorPipeline[tuple[RobotAction, RobotObservation], RobotAction]( # teleop -> dataset action steps=[ MapPhoneActionToRobotAction(platform=teleop_config.phone_os), EEReferenceAndDelta( kinematics=kinematics_solver, end_effector_step_sizes={"x": 0.5, "y": 0.5, "z": 0.5}, motor_names=list(robot.bus.motors.keys()), ), EEBoundsAndSafety( end_effector_bounds={"min": [-1.0, -1.0, -1.0], "max": [1.0, 1.0, 1.0]}, max_ee_step_m=0.20, ), GripperVelocityToJoint(), ], to_transition=robot_action_observation_to_transition, to_output=transition_to_robot_action, ) robot_ee_to_joints_processor = RobotProcessorPipeline[tuple[RobotAction, RobotObservation], RobotAction]( # dataset action -> robot steps=[ InverseKinematicsEEToJoints( kinematics=kinematics_solver, motor_names=list(robot.bus.motors.keys()), initial_guess_current_joints=True, ), ], to_transition=robot_action_observation_to_transition, to_output=transition_to_robot_action, ) robot_joints_to_ee_pose = RobotProcessorPipeline[RobotObservation, RobotObservation]( # robot obs -> dataset obs steps=[ ForwardKinematicsJointsToEE(kinematics=kinematics_solver, motor_names=list(robot.bus.motors.keys())) ], to_transition=observation_to_transition, to_output=transition_to_observation, ) ``` ## 为什么to_transition / to_output 要从机器人/电信机转换为管道和回路,我们使用 `to_transition` 财务报告和财务报告 `to_output` 管道适配器。 他们将转换标准化 以减少锅炉板代码, 并形成桥梁 机器人和电动操作器 原始字典和管道 `EnvTransition` 格式。 在给SO-100的手机中,我们使用下列适配器: . - `robot_action_observation_to_transition`: 变换一个 `(action, robot observation)` 配对到一个管道过渡(EE和IK步骤需要机器人目前的联合位置). - `transition_to_robot_action`:将输油管转换为机器人动作指令. - `observation_to_transition`: 将机器人观测转换为管道过渡. - `transition_to_observation`:将输油管转换为观察命令。 检查出来 [src/lerobot/processor/converters.py](https://github.com/huggingface/lerobot/blob/main/src/lerobot/processor/converters.py) 更多细节。 ## 数据集特征合同 数据集特性由数据集中保存的密钥决定。每个步骤都可以声明它修改的特性在一个名为“合同”的合同中 `transform_features(...)`。一旦您创建了处理器,处理器就可以将所有这些特性与 `aggregate_pipeline_dataset_features()` 并合并多个特性 dicts 与 `combine_feature_dicts(...)`. 下面是一个例子,说明我们如何与 `transform_features` 手机中的方法到 SO-100 后续实例 : ```python def transform_features( self, features: dict[PipelineFeatureType, dict[str, PolicyFeature]] ) -> dict[PipelineFeatureType, dict[str, PolicyFeature]]: # We only use the ee pose in the dataset, so we don't need the joint positions for n in self.motor_names: features[PipelineFeatureType.ACTION].pop(f"{n}.pos", None) # We specify the dataset features of this step that we want to be stored in the dataset for k in ["x", "y", "z", "wx", "wy", "wz", "gripper_pos"]: features[PipelineFeatureType.ACTION][f"ee.{k}"] = PolicyFeature( type=FeatureType.STATE, shape=(1,) ) return features ``` 在这里,我们声明我们在此步骤中修改的 PolicyFeatures , 这样我们就可以知道我们在运行处理器时可以预期什么样的特性。 这些特性可以被聚合并用来创建数据集特性 。 以下是我们如何将手机中的特性汇总和合并到SO-100记录的例子: ```python features=combine_feature_dicts( # Run the feature contract of the pipelines # This tells you how the features would look like after the pipeline steps aggregate_pipeline_dataset_features( pipeline=phone_to_robot_ee_pose_processor, initial_features=create_initial_features(action=phone.action_features), # <- Action features we can expect, these come from our teleop device (phone) and action processor use_videos=True, ), aggregate_pipeline_dataset_features( pipeline=robot_joints_to_ee_pose, initial_features=create_initial_features(observation=robot.observation_features), # <- Observation features we can expect, these come from our robot and observation processor use_videos=True, patterns=["observation.state.ee"], # <- Here you could optionally filter the features we want to store in the dataset, with a specific pattern ), ), ``` 如何运作: - `aggregate_pipeline_dataset_features(...)`: 应用 `transform_features` 横跨管道和过滤器,按模式排列(图像包括何时) `use_videos=True`,并包含状态特性 `patterns` (请指明)。 - `combine_feature_dicts(...)`: 结合多个特征dicts. - 记录方式 `record_loop(...)` 用途 `build_dataset_frame(...)` 以构建符合 `dataset.features` 之前,我们叫 `add_frame(...)` 将框架添加到数据集中。 ## 定制机器人管道时的指导 您可以将以下任何特性存储为您的动作/观测空间 : - 共同立场 - 绝对的 EE 外观 - 相对的 EE 三角洲 - 其他特征:联合速度,扭矩等. 选择您想要用于您的政策行动和观测空间, 并相应配置/修改管道和步骤 。 ### 不同的机器人 - 例如,你可以很容易地再利用管道, 使用另一个带电话的机器人, 修改示例, 并交换机器人 `RobotKinematics` (URDF)和 (中文(简体) ). `motor_names` 使用自己的机器人与 Phone Teleop。此外,你应确保 `target_frame_name` 指向你的握手手手脚。 ### 安全第一 安全第一 安全第一 安全第一 - 在改变管道时,从紧限开始,在与真正的机器人合作时执行安全步骤. - 它建议首先从模拟开始,然后转移到真正的机器人. 就是这样,我们希望这个指南能帮助你开始定制你的机器人管道, 如果你在任何时刻遇到任何问题,跳进我们 [Discord 社区](https://discord.com/invite/s3KuuzsPFb) 以获得支持。

查看原始来源