ROS 小海龟turtle 原地画圈 python实现

小海龟turtle原地转圈 Python实现

/turtle1/cmd_vel
[geometry_msgs/Twist] /
linear.x
angular.z

#!/usr/bin/env python
# coding:utf-8

import 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.5
        msg.angular.z = 0.2

        pub.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

运行结果:
运行结果

原创文章 44 获赞 8 访问量 3884

猜你喜欢

转载自blog.csdn.net/weixin_44692299/article/details/104294755