def PoseCallback(posedata):
# PoseWithCovarianceStamped data from amcl_pose
global robot_pose # [time, [x,y,yaw]]
header = posedata.header
pose = posedata.pose
if (not robot_pose[0]) or (header.stamp > robot_pose[0]):
# more recent pose data received
robot_pose[0] = header.stamp
# TODO: maybe add covariance check here?
print('robot position update!')
euler = euler_from_quaternion([pose.pose.orientation.x, pose.pose.orientation.y, pose.pose.orientation.z, pose.pose.orientation.w]) #roll, pitch, yaw
robot_pose[1] = [pose.pose.position.x, pose.pose.position.y, euler[2]] # in radians
return robot_pose
#========================================
评论列表
文章目录