visualize_poses.py
Go to the documentation of this file.
00001 #!/usr/bin/python
00002 
00003 import sys
00004 import yaml
00005 import numpy as np
00006 
00007 import roslib
00008 roslib.load_manifest("hrl_ellipsoidal_control")
00009 import rospy
00010 from visualization_msgs.msg import Marker, MarkerArray
00011 from geometry_msgs.msg import Vector3, PoseStamped
00012 import rosbag
00013 
00014 from hrl_ellipsoidal_control.ellipsoid_space import EllipsoidSpace
00015 from hrl_geom.pose_converter import PoseConv
00016 from std_msgs.msg import ColorRGBA
00017 
00018 def create_arrow_marker(pose, m_id, color=ColorRGBA(1., 0., 0., 1.)):
00019     m = Marker()
00020     m.header.frame_id = "/base_link"
00021     m.header.stamp = rospy.Time.now()
00022     m.ns = "ell_pose_viz"
00023     m.id = m_id
00024     m.type = Marker.ARROW
00025     m.action = Marker.ADD
00026     m.scale = Vector3(0.19, 0.09, 0.02)
00027     m.color = color
00028     m.pose = PoseConv.to_pose_msg(pose)
00029     return m
00030 
00031 def main():
00032     rospy.init_node("visualize_poses")
00033     pose_file = file(sys.argv[1], 'r')
00034     params = yaml.load(pose_file)
00035     ell_reg_bag = rosbag.Bag(sys.argv[2], 'r')
00036     for topic, ell_reg, ts in ell_reg_bag.read_messages():
00037         pass
00038     ell_space = EllipsoidSpace(E=ell_reg.E)
00039 
00040     pub_head_pose = rospy.Publisher("/head_center_test", PoseStamped)
00041     pub_arrows = rospy.Publisher("visualization_markers_array", MarkerArray)
00042     def create_tool_arrow():
00043         arrows = MarkerArray()
00044         color = ColorRGBA(0., 0., 1., 1.)
00045         for i, param in enumerate(params):
00046             ell_pos, ell_rot = params[param]
00047             _, ell_rot_mat = PoseConv.to_pos_rot([0]*3, ell_rot)
00048             cart_pose = PoseConv.to_homo_mat(ell_space.ellipsoidal_to_pose(*ell_pos))
00049             cart_pose[:3,:3] = cart_pose[:3,:3] * ell_rot_mat
00050             arrow = create_arrow_marker(cart_pose, i, color)
00051             arrow.header.stamp = rospy.Time.now()
00052             arrows.markers.append(arrow)
00053         return arrows
00054     r = rospy.Rate(10)
00055     while not rospy.is_shutdown():
00056         pub_head_pose.publish(PoseConv.to_pose_stamped_msg("/base_link", [0]*3, [0]*3))
00057         arrows = create_tool_arrow()
00058         pub_arrows.publish(arrows)
00059         r.sleep()
00060 
00061 if __name__ == "__main__":
00062     main()


hrl_face_adls
Author(s): Kelsey Hawkins, Advisor: Prof. Charlie Kemp, Lab: Healthcare Robotics Lab
autogenerated on Wed Nov 27 2013 11:47:39