python ros 订阅robot_pose获取机器人位置,,#!/usr/bin
python ros 订阅robot_pose获取机器人位置,,#!/usr/bin
#!/usr/bin/env pythonimport rospyimport tffrom tf.transformations import *from std_msgs.msg import Stringfrom geometry_msgs.msg import Posefrom geometry_msgs.msg import Quaterniondef 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()
python ros 订阅robot_pose获取机器人位置
相关内容
- Python pip源使用国内镜像,,常用镜像源豆瓣 ht
- python-閫氳繃openpy鎿嶄綔excel,,鏍囩锛?a hre
- python基础汇总,,变量的命名规则:1、
- python 之 数据库(多表查询之连接查询、子查询、pymy
- python basemap readshapefile二三事,,今天要用到basem
- python从入门到掉坑,,python 从起步
- Python3绘图之Matplotlib(03),,饼图 = pie散点
- python/django-上传excel文件并用pandas处理,,html文件<fo
- 学习python的第五天,,1、学习使人秃头2、
- Python-递归函数,,阅读目录: 1、函
评论关闭