当前位置:   article > 正文

ROS 小海龟turtle 订阅者 Python实现_ros turtle python

ros turtle python

小海龟turtle订阅者 Python实现

/turtle1/pose [turtlesim/Pose]

#!/usr/bin/env python
#coding:utf-8
#//   /turtle1/pose [turtlesim/Pose]

import rospy
from turtlesim.msg import Pose

def turtleCallBack(msg):
    rospy.loginfo("turtle pose: x:%06f, y:%0.6f",msg.x , msg.y)

def turtle_subscriber():
    rospy.init_node('turtle_subscriber',anonymous = True)
    rospy.Subscriber("/turtle1/pose",Pose,turtleCallBack)
    rospy.spin()

if __name__ == '__main__':
    turtle_subscriber()
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17

运行结果:
运行结果

声明:本文内容由网友自发贡献,转载请注明出处:【wpsshop】
推荐阅读
相关标签
  

闽ICP备14008679号