conversions.py
Go to the documentation of this file.
00001 # Copyright (c) 2013, Oregon State University
00002 # All rights reserved.
00003 
00004 # Redistribution and use in source and binary forms, with or without
00005 # modification, are permitted provided that the following conditions are met:
00006 #     * Redistributions of source code must retain the above copyright
00007 #       notice, this list of conditions and the following disclaimer.
00008 #     * Redistributions in binary form must reproduce the above copyright
00009 #       notice, this list of conditions and the following disclaimer in the
00010 #       documentation and/or other materials provided with the distribution.
00011 #     * Neither the name of the Oregon State University nor the
00012 #       names of its contributors may be used to endorse or promote products
00013 #       derived from this software without specific prior written permission.
00014 
00015 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
00016 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00017 # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00018 # DISCLAIMED. IN NO EVENT SHALL OREGON STATE UNIVERSITY BE LIABLE FOR ANY
00019 # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
00020 # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00021 # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
00022 # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00023 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00024 # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00025 
00026 # Author Dan Lazewatsky/lazewatd@engr.orst.edu
00027 
00028 import roslib; roslib.load_manifest('head_pose_estimation')
00029 import rospy
00030 from geometry_msgs.msg import PoseStamped, Pose, Point, Quaternion 
00031 from tf.transformations import euler_from_quaternion, quaternion_from_euler
00032 import numpy as np
00033 
00034 
00035 def pose_quat_to_euler(pose_msg):
00036         return np.concatenate([
00037                 [
00038                         pose_msg.pose.position.x,
00039                         pose_msg.pose.position.y,
00040                         pose_msg.pose.position.z
00041                 ],
00042                 euler_from_quaternion([
00043                         pose_msg.pose.orientation.x,
00044                         pose_msg.pose.orientation.y,
00045                         pose_msg.pose.orientation.z,
00046                         pose_msg.pose.orientation.w
00047             ])])
00048         
00049 def pose_euler_to_quat(pose):
00050         return Pose(
00051                 Point(*pose[:3]),
00052                 Quaternion(*(quaternion_from_euler(*pose[3:])))
00053           )


headmath
Author(s): Daniel Lazewatsky
autogenerated on Mon Oct 6 2014 00:22:40