#!/usr/bin/env python
import rospy
import tf
from tf.transformations import *
from std_msgs.msg import String
from geometry_msgs.msg import Pose
from geometry_msgs.msg import Quaternion


def get_pos(data):
    (roll, pitch, yaw) = euler_from_quaternion([data.orientation.x, data.orientation.y, data.orientation.z, data.orientation.w])
    rospy.loginfo("current position(x:%f,y:%f,z:%f),theta:%f", data.position.x, data.position.y, data.position.z, yaw)
    #rospy.loginfo("current position(x:%f,y:%f,z:%f)", data.position.x, data.position.y, data.position.z)


def poslistener():
    # In ROS, nodes are uniquely named. If two nodes with the same
    # name are launched, the previous one is kicked off. The
    # anonymous=True flag means that rospy will choose a unique
    # name for our 'listener' node so that multiple listeners can
    # run simultaneously.
    rospy.init_node('poslistener', anonymous=True)

    rospy.Subscriber("robot_pose", Pose, get_pos)

    # spin() simply keeps python from exiting until this node is stopped
    rospy.spin()


if __name__ == '__main__':
    poslistener()

 

相关文章:

  • 2021-11-23
  • 2021-09-08
  • 2021-08-04
  • 2021-08-20
  • 2022-02-15
  • 2022-12-23
猜你喜欢
  • 2021-10-22
  • 2021-09-26
  • 2021-12-17
  • 2021-07-30
  • 2022-12-23
  • 2022-12-23
  • 2021-07-28
相关资源
相似解决方案