Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 import rospy
00020 from visualization_msgs.msg import Marker
00021 from naoqi_bridge_msgs.msg import PoseWithConfidenceStamped
00022
00023
00024 from naoqi_driver.naoqi_node import NaoqiNode
00025 import almath
00026
00027
00028 class PodPublisher(NaoqiNode):
00029
00030 def __init__(self):
00031 NaoqiNode.__init__(self, 'naoqi_pod_node')
00032
00033 self.markerpublisher = rospy.Publisher('naoqi_pod_publisher', PoseWithConfidenceStamped, queue_size=5)
00034 self.rate = rospy.Rate(2)
00035 self.init = False
00036 self.connectNaoQi()
00037
00038
00039 def connectNaoQi(self):
00040 rospy.loginfo("Connecting to NaoQi at %s:%d", self.pip, self.pport)
00041 self.rechargeProxy = self.get_proxy("ALRecharge")
00042 if self.rechargeProxy is not None:
00043 self.init = True
00044
00045
00046 def run(self):
00047 while self.is_looping():
00048 if not self.init:
00049 break
00050 if self.markerpublisher.get_num_connections() > 0:
00051 worldToPod = almath.Pose2D(self.rechargeProxy.getStationPosition())
00052 confidence = self.rechargeProxy._getConfidenceIndex()
00053 self.marker = PoseWithConfidenceStamped()
00054 self.marker.header.stamp = rospy.Time.now()
00055 self.marker.header.frame_id = "/odom"
00056 self.marker.pose.orientation = almath.Quaternion_fromAngleAndAxisRotation(worldToPod.theta, 0, 0, 1)
00057 self.marker.pose.position.x = worldToPod.x
00058 self.marker.pose.position.y = worldToPod.y
00059 self.marker.pose.position.z = 0.0
00060 self.marker.confidence_index = confidence
00061 self.markerpublisher.publish(self.marker)
00062 self.rate.sleep()
00063
00064 if __name__ == '__main__':
00065 publisher = PodPublisher()
00066 publisher.start()
00067 rospy.spin()
00068 exit(0)