Skip to content

踩坑Robotics Stack Exchange2023-08-11

ROS 2 Foxy 自定义消息属性无法访问 ​

本文由 AI 根据公开内容整理,可能有误,请以原文为准:ros2 foxy python or interface not seeing full extent of the custom message(Robotics Stack Exchange #25134)

状态:已解决

问题 ​

ROS 2 Foxy 中自定义消息 Logitechjoy 可构建并导入 Python,但只能访问 header、buttons,访问 header.stamp 或 buttons.green 报 AttributeError: 'property' object has no attribute 'stamp'。

环境 ​

ROS 2 Foxy;Python;colcon build;自定义消息包 control_main_msg。

解决办法 ​

  1. 将 Python 代码中的 joy_msg = Logitechjoy 改为 joy_msg = Logitechjoy(),创建消息类实例后再访问 joy_msg.header.stamp 等字段。
  2. 如果类似错误由构建中断引起,可删除 build 目录后重新构建。

原问题作者:Frenki221;采纳答案作者:cst0。原内容依 CC BY-SA 4.0 授权,本页摘要同样依 CC BY-SA 4.0 授权。

来源

本页事实对应的公开页面,以原文为准。

  1. Robotics Stack Exchange #25134:ros2 foxy python or interface not seeing full extent of the custom message访问 2026-10-22