鱼香ROS社区
    • 版块
    • 最新
    • 未解决
    • 已解决
    • 群组
    • 注册
    • 登录
    紧急通知:禁止一切关于政治&VPN翻墙等话题,发现相关帖子会立马删除封号
    提问前必看的发帖注意事项: 社区问答规则(小鱼个人)更新 | 高质量帖子发布指南

    type object 'type' has no attribute '_TYPE_SUPPORT' This might be a ROS 1 message type but it should be a ROS 2 message type. Make sure to source your ROS 2 workspace after your ROS 1 workspace.

    已定时 已固定 已锁定 已移动 未解决
    综合问题
    报错 ros2 python
    2
    3
    789
    正在加载更多帖子
    • 从旧到新
    • 从新到旧
    • 最多赞同
    回复
    • 在新帖中回复
    登录后回复
    此主题已被删除。只有拥有主题管理权限的用户可以查看。
    • 24491549692
      纯纯牛马小卢
      最后由 编辑

      py编译时遇到的问题,请教一下该怎么解决没找到解决办法

      import rclpy
      from rclpy.node import Node
      from std_msgs.msg import String
      
      
      class Writenode(Node):
          def __init__(self,name):
              super().__init__(name)
              self.get_logger().info("大家好我是作家%s."%name)
              #发布者
              self.pub_thing = self.create_publisher(String,"yellow",10)
              # self.pub_thing.publish()发布函数
              #prama1: 周期 
              self.count = 0
              self.timer_period=5
              self.timer = self.create_timer(self.timers_period,self.time_cailback)
      
          def time_cailback(self):
              msg = String()
              msg.data="黄色小说嘿嘿,第%d"%self.count
              self.pub_thing.publish(msg)
              self.get_logger().info("内容为%s"%msg.data)
              self.count+=1
      
              
      
      def main(args = None):
          rclpy.init(args = args)
      
          lu_node = Writenode("lu")
          
          rclpy.spin(lu_node)
          rclpy.shutdown()        
      

      报的错误
      Traceback (most recent call last):
      File "/home/niumaxiaolu/lushuo/install/village_lu/lib/village_lu/lu_node", line 11, in <module>
      load_entry_point('village-lu==0.0.0', 'console_scripts', 'lu_node')()
      File "/home/niumaxiaolu/lushuo/install/village_lu/lib/python3.8/site-packages/village_lu/lu_oop.py", line 30, in main
      lu_node = Writenode("lu")
      File "/home/niumaxiaolu/lushuo/install/village_lu/lib/python3.8/site-packages/village_lu/lu_oop.py", line 11, in init
      self.pub_thing = self.create_publisher(String,"yellow",10)
      File "/opt/ros/foxy/lib/python3.8/site-packages/rclpy/node.py", line 1144, in create_publisher
      check_for_type_support(msg_type)
      File "/opt/ros/foxy/lib/python3.8/site-packages/rclpy/type_support.py", line 20, in check_for_type_support
      ts = msg_type.class._TYPE_SUPPORT
      AttributeError: type object 'type' has no attribute '_TYPE_SUPPORT' This might be a ROS 1 message type but it should be a ROS 2 message type. Make sure to source your ROS 2 workspace after your ROS 1 workspace.

      小鱼小 1 条回复 最后回复 回复 引用 0
      • 小鱼小
        小鱼 技术大佬 @2449154969
        最后由 编辑

        @2449154969 在 type object 'type' has no attribute '_TYPE_SUPPORT' This might be a ROS 1 message type but it should be a ROS 2 message type. Make sure to source your ROS 2 workspace after your ROS 1 workspace. 中说:

        AttributeError: type object 'type' has no attribute '_TYPE_SUPPORT' This might be a ROS 1 message type but it should be a ROS 2 message type. Make sure to source your ROS 2 workspace after your ROS 1 workspace.

        看提示是你ROS1的环境和ROS2的环境混了

        新书配套视频:https://www.bilibili.com/video/BV1GW42197Ck/

        24491549692 1 条回复 最后回复 回复 引用 0
        • 24491549692
          纯纯牛马小卢 @小鱼
          最后由 编辑

          @小鱼 source /opt/ros/foxy/setup.bash我现在环境只有这个emm把ros1的以经去掉了😢

          1 条回复 最后回复 回复 引用 0
          • 第一个帖子
            最后一个帖子
          皖ICP备16016415号-7
          Powered by NodeBB | 鱼香ROS