test_laser_icp.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 import roslib; roslib.load_manifest('iri_laser_icp')
00003 import rospy
00004 import os
00005 import sys
00006 from iri_laser_icp.srv import *
00007 from sensor_msgs.msg import LaserScan
00008 from geometry_msgs.msg import PoseWithCovarianceStamped
00009 
00010 
00011 class test_laser_icp:
00012 
00013   def __init__(self):
00014     rospy.loginfo("initiating node...")
00015     rospy.init_node('test_laser_icp', anonymous=True)
00016     self.scan_subs = rospy.Subscriber("scan", LaserScan, self.callback)
00017     self.first = True
00018     self.pose = PoseWithCovarianceStamped()
00019     self.scan1 = LaserScan()
00020     self.scan2 = LaserScan()
00021 
00022   def get_pose_client(self):
00023       rospy.loginfo("waiting to get service...")
00024       rospy.wait_for_service('test_icp_server/get_relative_pose')
00025       try:
00026           get_pose = rospy.ServiceProxy('test_icp_server/get_relative_pose', GetRelativePose)
00027           respose = get_pose(self.scan1, self.scan2)
00028           self.pose = respose.pose_rel
00029       except rospy.ServiceException, e:
00030           print "Service call failed: %s"%e
00031 
00032   def callback(self, laserscan):
00033       rospy.loginfo("le callback")
00034       if(self.first):
00035         self.scan1 = laserscan
00036         self.first = False
00037       else:
00038         self.scan2 = laserscan
00039         self.get_pose_client()
00040         rospy.loginfo(" Pose: x,y %f %f ",self.pose.pose.pose.position.x,self.pose.pose.pose.position.y)
00041         self.scan1 = self.scan2
00042     
00043 def main(args):
00044       li = test_laser_icp()
00045       try:
00046         rospy.spin()
00047       except KeyboardInterrupt:
00048         print "Shutting down"
00049 
00050 if __name__ == '__main__':
00051     main(sys.argv)
00052 
00053 # if __name__ == '__main__':
00054 #   rospy.loginfo("test laser icp")
00055 #   while not rospy.is_shutdown():
00056 #     try:
00057 #         compute_icp()
00058 #     except rospy.ROSInterruptException:
00059 #         pass
00060 
00061 
00062 
00063 # class test_vision_node:
00064 
00065 #     def __init__(self):
00066 #         rospy.init_node('test_vision_node')
00067 
00068 #         """ Give the OpenCV display window a name. """
00069 #         self.cv_window_name = "OpenCV Image"
00070 
00071 #         """ Create the window and make it re-sizeable (second parameter = 0) """
00072 #         cv.NamedWindow(self.cv_window_name, 0)
00073 
00074 #         """ Create the cv_bridge object """
00075 #         self.bridge = CvBridge()
00076 
00077 #         """ Subscribe to the raw camera image topic """
00078 #         self.image_sub = rospy.Subscriber("/camera/image_raw", Image, self.callback)
00079 
00080 #     def callback(self, data):
00081 #         try:
00082 #             """ Convert the raw image to OpenCV format """
00083 #             cv_image = self.bridge.imgmsg_to_cv(data, "bgr8")
00084 #         except CvBridgeError, e:
00085 #           print e
00086   
00087         
00088 #         """ Get the width and height of the image """
00089 #         (width, height) = cv.GetSize(cv_image)
00090 
00091 #         """ Overlay some text onto the image display """
00092 #         text_font = cv.InitFont(cv.CV_FONT_HERSHEY_DUPLEX, 2, 2)
00093 #         cv.PutText(cv_image, "OpenCV Image", (50, height / 2), text_font, cv.RGB(255, 255, 0))
00094   
00095 #         """ Refresh the image on the screen """
00096 #         cv.ShowImage(self.cv_window_name, cv_image)
00097 #         cv.WaitKey(3)
00098 
00099 # def main(args):
00100 #       vn = test_vision_node()
00101 #       try:
00102 #         rospy.spin()
00103 #       except KeyboardInterrupt:
00104 #         print "Shutting down vison node."
00105 #       cv.DestroyAllWindows()
00106 
00107 # if __name__ == '__main__':
00108 #     main(sys.argv)
00109 
00110 
00111 
00112     # std_msgs/Header header
00113 #   uint32 seq
00114 #   time stamp
00115 #   string frame_id
00116 # geometry_msgs/PoseWithCovariance pose
00117 #   geometry_msgs/Pose pose
00118 #     geometry_msgs/Point position
00119 #       float64 x
00120 #       float64 y
00121 #       float64 z
00122 #     geometry_msgs/Quaternion orientation
00123 #       float64 x
00124 #       float64 y
00125 #       float64 z
00126 #       float64 w
00127 #   float64[36] covariance


iri_laser_icp
Author(s): Marti
autogenerated on Fri Dec 6 2013 21:20:17