本文主要是介绍ROS 小海龟turtle 原地画圈 python实现,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
小海龟turtle原地转圈 Python实现
/turtle1/cmd_vel
[geometry_msgs/Twist] /
linear.x
angular.z
#!/usr/bin/env python
# coding:utf-8import rospy
from geometry_msgs.msg import Twist
def turtle_publisher():rospy.init_node('turtle_publisher', anonymous = True)pub = rospy.Publisher('/turtle1/cmd_vel', Twist, queue_size=10)rate = rospy.Rate(1)while not rospy.is_shutdown():msg = Twist()msg.linear.x = 0.5msg.angular.z = 0.2pub.publish(msg)rospy.loginfo('publish turtle message command [%0.2f m/s, %0.2f rad/s]', msg.linear.x , msg.angular.z )rate.sleep()
if __name__ == '__main__':try:turtle_publisher()except rospy.ROSInterruptException:pass
运行结果:
这篇关于ROS 小海龟turtle 原地画圈 python实现的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!