104 字
1 分钟
ros2——Topic python代码实现
Topic 示例
#!/usr/bin/env python3
import rclpyfrom rclpy.node import Nodefrom example_interfaces.msg import String
class RosNewsStation(Node):
def __init__(self): super().__init__("ros_news_station") self.publisher_ = self.create_publisher(String,"ros_news",10) self.create_timer(0.5,self.timer_callback) self.get_logger().info("Topic has been created")
def timer_callback(self): msg = String() msg.data = "Hello World" self.publisher_.publish(msg) self.get_logger().info(msg.data)
def main(args=None): rclpy.init() node = RosNewsStation() rclpy.spin(node) rclpy.shutdown()
if __name__ == "__main__": main()ros2——Topic python代码实现
https://blog.wangmasterai.com/posts/ros2系列/话题-topic/client-代码实现/分享文章
生成精美分享图或复制链接,与更多人分享本文。
继续阅读
换条路线
从其他文章中稳定抽取
最后更新于 ,距今已过 33 天
部分内容可能已过时