Created
August 27, 2019 12:09
-
-
Save lucascoelhof/b40c3f56080d789bf0623843af10f752 to your computer and use it in GitHub Desktop.
Transform a ROS Pose msg with another pose
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
geometry_msgs::Pose transformPose(geometry_msgs::Pose& _origin_to_frame, geometry_msgs::Pose& _frame_to_target) | |
{ | |
geometry_msgs::Pose result; | |
tf::Transform origin_to_frame_transform; | |
origin_to_frame_transform.setOrigin(tf::Vector3(_origin_to_frame.position.x, _origin_to_frame.position.y, _origin_to_frame.position.z)); | |
origin_to_frame_transform.setRotation(tf::Quaternion(_origin_to_frame.orientation.x, _origin_to_frame.orientation.y, | |
_origin_to_frame.orientation.z, _origin_to_frame.orientation.w)); | |
tf::Transform frame_to_target_transform; | |
frame_to_target_transform.setOrigin(tf::Vector3(_frame_to_target.position.x, _frame_to_target.position.y, _frame_to_target.position.z)); | |
frame_to_target_transform.setRotation(tf::Quaternion(_frame_to_target.orientation.x, _frame_to_target.orientation.y, | |
_frame_to_target.orientation.z, _frame_to_target.orientation.w)); | |
tf::Transform origin_to_target; | |
origin_to_target = origin_to_frame_transform * frame_to_target_transform; | |
tf::poseTFToMsg(origin_to_target, result); | |
return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment