LeRobot 在 macOS 上检测 RealSense 摄像头报 failed to set power state 怎么解决【免费下载链接】lerobot LeRobot: Making AI for Robotics more accessible with end-to-end learning项目地址: https://gitcode.com/GitHub_Trending/le/lerobot在 macOS 上使用 LeRobot 检测 Intel RealSense 摄像头时运行设备发现命令lerobot-find-cameras realsense可能会得到这条报错Error finding RealSense cameras: failed to set power state这意味着 LeRobot 无法列出已连接的 RealSense 设备后续的摄像头配置例如录制数据集或遥操作时指定serial_number_or_name也就无从谈起。根据 docs/source/cameras.mdx 的说明该问题在 macOS 上可以用提权方式重跑同一条命令来解决下面给出完整的操作路径和验证方式。先确认你遇到的是这个报错LeRobot 通过lerobot-find-cameras命令做摄像头自动发现RealSenseCamera支持按类型筛选lerobot-find-cameras realsense在 macOS 上执行该命令时如果终端输出中出现了Error finding RealSense cameras: failed to set power state说明命中了本文针对的问题。文档指出该报错对应 Intel RealSense 官方仓库中的一个已知问题在 macOS 上尤为常见。注意区分另一种完全不同的现象如果输出的是Skipping RealSense camera search: pyrealsense2 library not found or not importable.这样的警告见 lerobot_find_cameras.py那是pyrealsense2库未安装或不可导入与failed to set power state不是同一问题本文的 sudo 方案对前者无效。macOSdarwin平台下 LeRobot 期望的库名是pyrealsense2-macosx这一点见 camera_realsense.py 中的平台判断。用 sudo 权限重跑同一条检测命令文档给出的解决办法是用sudo权限运行同一条命令sudo lerobot-find-cameras realsense说明一下副作用sudo会让这条命令以管理员权限执行。它只是重新执行一次只读的摄像头枚举与取图流程不删除文件、不修改系统环境系统可能会要求输入当前用户密码。这是针对 macOS 上 RealSense 设备无法设置电源状态这一报错的官方文档建议做法。验证检测是否成功命令执行后如果检测成功终端会输出--- Detected Cameras ---列表。文档中给出的示例输出如下文档示例具体数值取决于你的设备--- Detected Cameras --- Camera #0: Name: OpenCV Camera 0 Type: OpenCV Id: 0 Backend api: AVFOUNDATION Default stream profile: Format: 16.0 Width: 1920 Height: 1080 Fps: 15.0 -------------------- (more cameras ...)对 RealSense 设备列表中的Id即摄像头的序列号serial number后续在代码或配置中通过serial_number_or_name指定摄像头时使用它。如果命令执行后日志显示No realsense cameras were detected.说明设备未被枚举需先检查 RealSense 是否已插好连接。限制与后续使用文档对 macOS 上 RealSense 摄像头有两条明确的边界说明需要保留在预期里macOS 上 RealSense 摄像头的使用不稳定Note that using RealSense cameras in macOS is unstable。sudo解决的是发现阶段的电源状态报错不保证后续使用同样稳定。设备标识符可能在重启电脑或重新插拔摄像头后变化取决于操作系统。也就是说检测到的Id不是永久固定的重新检测后配置可能需要更新。拿到可用的序列号后下一步就是在代码或录制配置中实例化摄像头。docs/source/cameras.mdx 给出的 RealSense 用法示例from lerobot.cameras.realsense import RealSenseCamera, RealSenseCameraConfig from lerobot.cameras import ColorMode, Cv2Rotation # Create a RealSenseCameraConfig specifying your camera’s serial number and enabling depth. config RealSenseCameraConfig( serial_number_or_name233522074606, # 替换为 lerobot-find-cameras 检测到的序列号 fps15, width640, height480, color_modeColorMode.RGB, use_depthTrue, rotationCv2Rotation.NO_ROTATION, ) camera RealSenseCamera(config) camera.connect() try: color_frame camera.read() depth_map camera.read_depth() print(Color frame shape:, color_frame.shape) print(Depth map shape:, depth_map.shape) finally: camera.disconnect()示例中的序列号233522074606是文档示例值需替换为你自己检测到的Idexposure、gain、white_balance等手动色彩控制参数是可选的省略即保持传感器当前设置且这些参数要求use_rgbTrue无独立 RGB 模块的机型如 RealSense D405在连接时会直接报错。相关文档docs/source/cameras.mdx摄像头类型、自动发现命令、macOS 报错说明与使用示例docs/source/api/cameras.mdx摄像头 API 参考src/lerobot/scripts/lerobot_find_cameras.pylerobot-find-cameras命令实现【免费下载链接】lerobot LeRobot: Making AI for Robotics more accessible with end-to-end learning项目地址: https://gitcode.com/GitHub_Trending/le/lerobot创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考