Go to the documentation of this file.00001
00004
00005
00006
00007
00008 #include <Eigen/Geometry>
00009 #include "../../include/sophus_ros_conversions/eigen.hpp"
00010 #include "../../include/sophus_ros_conversions/geometry.hpp"
00011
00012
00013
00014
00015
00016 namespace sophus_ros_conversions {
00017
00018
00019
00020
00021
00022 void poseMsgToSophus(const geometry_msgs::Pose &pose, Sophus::SE3f &se3)
00023 {
00024 Eigen::Quaternion<Sophus::SE3f::Scalar> orientation;
00025 Sophus::SE3f::Point translation;
00026 pointMsgToEigen(pose.position, translation);
00027 quaternionMsgToEigen(pose.orientation, orientation);
00028 se3 = Sophus::SE3f(orientation, translation);
00029 }
00030
00031 geometry_msgs::Pose sophusToPoseMsg(const Sophus::SE3f& s) {
00032 geometry_msgs::Pose pose;
00033 Eigen::Vector3f translation = s.translation();
00034 pose.position = eigenToPointMsg(translation);
00035 Eigen::Quaternionf quaternion = s.unit_quaternion();
00036 pose.orientation = eigenToQuaternionMsg(quaternion);
00037 return pose;
00038 }
00039
00040
00041 void vector3MsgToSophus(const geometry_msgs::Vector3 &v, Sophus::SE3f::Point &translation)
00042 {
00043 translation << v.x, v.y, v.z;
00044 }
00045
00046
00047 void transformMsgToSophus(const geometry_msgs::Transform &transform, Sophus::SE3f &se3)
00048 {
00049 Sophus::SE3f::Point translation;
00050 Eigen::Quaternion<Sophus::SE3f::Scalar> orientation;
00051 vector3MsgToSophus(transform.translation, translation);
00052 quaternionMsgToEigen(transform.rotation, orientation);
00053 se3 = Sophus::SE3f(orientation, translation);
00054 }
00055
00056 Sophus::SE3f transformMsgToSophus(const geometry_msgs::Transform &transform)
00057 {
00058 Sophus::SE3f T;
00059 transformMsgToSophus(transform, T);
00060 return T;
00061 }
00062
00063 geometry_msgs::Transform sophusToTransformMsg(const Sophus::SE3f& se3) {
00064 geometry_msgs::Transform msg;
00065 msg.translation.x = se3.translation().x();
00066 msg.translation.y = se3.translation().y();
00067 msg.translation.z = se3.translation().z();
00068 msg.rotation.x = se3.unit_quaternion().x();
00069 msg.rotation.y = se3.unit_quaternion().y();
00070 msg.rotation.z = se3.unit_quaternion().z();
00071 msg.rotation.w = se3.unit_quaternion().w();
00072 return msg;
00073 }
00074
00075
00076
00077
00078
00079 }