#!/usr/bin/env python
import rospy
import time
def hello_robot_counter():
# 初始化ROS节点
rospy.init_node('hello_robot_counter', anonymous=True)
# 设置初始数字
count = 0
# 设置循环速率
rate = rospy.Rate(1) # 1Hz
while not rospy.is_shutdown():
# 输出信息
print("hellorobot", count)
# 更新数字,每次增加3
count += 3
# 按照设定的速率延迟
rate.sleep()
if __name__ == '__main__':
try:
hello_robot_counter()
except rospy.ROSInterruptException:
pass
Python输出hellorobot
最新推荐文章于 2024-08-08 14:28:23 发布