重要提示
提问前必看的发帖注意事项—— 提问前必看!不符合要求的问题拒绝回答!!
社区使用指南—如何添加标签修改密码
未解决 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.
-
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. -
@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的环境混了
-
@小鱼 source /opt/ros/foxy/setup.bash我现在环境只有这个emm把ros1的以经去掉了