test.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 
00003 import roslib; roslib.load_manifest('door_perception')
00004 import rospy
00005 import numpy
00006 import tf
00007 
00008 from articulation_msgs.msg import *
00009 from articulation_msgs.srv import *
00010 from geometry_msgs.msg import Pose, PoseStamped, Point, Quaternion
00011 from sensor_msgs.msg import ChannelFloat32
00012 
00013 #Storage
00014 global_track_msg = TrackMsg()
00015 global_track_msg.header.stamp = rospy.get_rostime()
00016 global_track_msg.header.frame_id = "/"
00017 global_track_msg.id = 1
00018 
00019 def pose_callback(pose_stamped):
00020     rospy.loginfo(rospy.get_name()+" heard a pose in frame %s",pose_stamped.header.frame_id)
00021     request = TrackModelSrvRequest()
00022     global_track_msg.pose.append( pose_stamped.pose )
00023     global_track_msg.pose_headers.append( pose_stamped.header )
00024     request.model.track = global_track_msg
00025 
00026     try:      
00027         response = model_select(request)
00028         print "selected model: '%s' (n = %d, log LH = %f)" % (
00029             response.model.name,
00030             len(response.model.track.pose),
00031             [entry.value for entry in response.model.params if entry.name=='loglikelihood'][0]
00032         )
00033         model_pub.publish(response.model)
00034     except rospy.ServiceException: 
00035         print "model selection failed"
00036         pass
00037 
00038 def main():
00039     rospy.init_node('door_fitting')
00040     listener = tf.TransformListener()
00041     rospy.Subscriber("/camera/pose0", PoseStamped, pose_callback)
00042 
00043     rospy.wait_for_service('model_select')
00044     model_select = rospy.ServiceProxy('model_select', TrackModelSrv)
00045     model_pub = rospy.Publisher('model', ModelMsg)
00046  
00047     rospy.spin()
00048 
00049 
00050 if __name__ == '__main__':
00051   main()
00052 
00053 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Properties Friends


door_perception_old
Author(s): Felix Endres
autogenerated on Wed Dec 26 2012 15:56:10