pod.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 # Copyright (C) 2014 Aldebaran Robotics
4 #
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8 #
9 # http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16 #
17 
18 #import ROS dependencies
19 import rospy
20 from visualization_msgs.msg import Marker
21 from naoqi_bridge_msgs.msg import PoseWithConfidenceStamped
22 
23 #import NAO dependencies
24 from naoqi_driver.naoqi_node import NaoqiNode
25 import almath
26 
27 
29 
30  def __init__(self):
31  NaoqiNode.__init__(self, 'naoqi_pod_node')
32 
33  self.markerpublisher = rospy.Publisher('naoqi_pod_publisher', PoseWithConfidenceStamped, queue_size=5)
34  self.rate = rospy.Rate(2)
35  self.init = False
36  self.connectNaoQi()
37 
38  # (re-) connect to NaoQI:
39  def connectNaoQi(self):
40  rospy.loginfo("Connecting to NaoQi at %s:%d", self.pip, self.pport)
41  self.rechargeProxy = self.get_proxy("ALRecharge")
42  if self.rechargeProxy is not None:
43  self.init = True
44 
45  # do it!
46  def run(self):
47  while self.is_looping():
48  if not self.init:
49  break
50  if self.markerpublisher.get_num_connections() > 0:
51  worldToPod = almath.Pose2D(self.rechargeProxy.getStationPosition())
52  confidence = self.rechargeProxy._getConfidenceIndex()
53  self.marker = PoseWithConfidenceStamped()
54  self.marker.header.stamp = rospy.Time.now()
55  self.marker.header.frame_id = "/odom"
56  self.marker.pose.orientation = almath.Quaternion_fromAngleAndAxisRotation(worldToPod.theta, 0, 0, 1)
57  self.marker.pose.position.x = worldToPod.x
58  self.marker.pose.position.y = worldToPod.y
59  self.marker.pose.position.z = 0.0
60  self.marker.confidence_index = confidence
61  self.markerpublisher.publish(self.marker)
62  self.rate.sleep()
63 
64 if __name__ == '__main__':
65  publisher = PodPublisher()
66  publisher.start()
67  rospy.spin()
68  exit(0)
def connectNaoQi(self)
Definition: pod.py:39
def run(self)
Definition: pod.py:46
def __init__(self)
Definition: pod.py:30
def get_proxy(self, name, warn=True)


python
Author(s):
autogenerated on Thu Jul 16 2020 03:18:36