tf2_geometry_msgs.h
Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2008, Willow Garage, Inc.
00003  * All rights reserved.
00004  *
00005  * Redistribution and use in source and binary forms, with or without
00006  * modification, are permitted provided that the following conditions are met:
00007  *
00008  *     * Redistributions of source code must retain the above copyright
00009  *       notice, this list of conditions and the following disclaimer.
00010  *     * Redistributions in binary form must reproduce the above copyright
00011  *       notice, this list of conditions and the following disclaimer in the
00012  *       documentation and/or other materials provided with the distribution.
00013  *     * Neither the name of the Willow Garage, Inc. nor the names of its
00014  *       contributors may be used to endorse or promote products derived from
00015  *       this software without specific prior written permission.
00016  *
00017  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00018  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00019  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00020  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
00021  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00022  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00023  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00024  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00025  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00026  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00027  * POSSIBILITY OF SUCH DAMAGE.
00028  */
00029 
00032 #ifndef TF2_GEOMETRY_MSGS_H
00033 #define TF2_GEOMETRY_MSGS_H
00034 
00035 #include <boost/array.hpp>
00036 
00037 #include <tf2/convert.h>
00038 #include <tf2/LinearMath/Quaternion.h>
00039 #include <tf2/LinearMath/Transform.h>
00040 #include <geometry_msgs/PointStamped.h>
00041 #include <geometry_msgs/QuaternionStamped.h>
00042 #include <geometry_msgs/TransformStamped.h>
00043 #include <geometry_msgs/Vector3Stamped.h>
00044 #include <geometry_msgs/Pose.h>
00045 #include <geometry_msgs/PoseStamped.h>
00046 #include <geometry_msgs/PoseWithCovarianceStamped.h>
00047 #include <geometry_msgs/Wrench.h>
00048 #include <geometry_msgs/WrenchStamped.h>
00049 #include <kdl/frames.hpp>
00050 
00051 namespace tf2
00052 {
00053 
00059 inline
00060 KDL::Frame gmTransformToKDL(const geometry_msgs::TransformStamped& t) __attribute__ ((deprecated));
00061 inline
00062 KDL::Frame gmTransformToKDL(const geometry_msgs::TransformStamped& t)
00063   {
00064     return KDL::Frame(KDL::Rotation::Quaternion(t.transform.rotation.x, t.transform.rotation.y, 
00065                                                 t.transform.rotation.z, t.transform.rotation.w),
00066                       KDL::Vector(t.transform.translation.x, t.transform.translation.y, t.transform.translation.z));
00067   }
00068 
00069 
00070 /*************/
00072 /*************/
00073 
00079 inline
00080 geometry_msgs::Vector3 toMsg(const tf2::Vector3& in)
00081 {
00082   geometry_msgs::Vector3 out;
00083   out.x = in.getX();
00084   out.y = in.getY();
00085   out.z = in.getZ();
00086   return out;
00087 }
00088 
00094 inline
00095 void fromMsg(const geometry_msgs::Vector3& in, tf2::Vector3& out)
00096 {
00097   out = tf2::Vector3(in.x, in.y, in.z);
00098 }
00099 
00100 
00101 /********************/
00103 /********************/
00104 
00111 template <>
00112 inline
00113   const ros::Time& getTimestamp(const geometry_msgs::Vector3Stamped& t) {return t.header.stamp;}
00114 
00121 template <>
00122 inline
00123   const std::string& getFrameId(const geometry_msgs::Vector3Stamped& t) {return t.header.frame_id;}
00124 
00125 
00131 inline
00132 geometry_msgs::Vector3Stamped toMsg(const geometry_msgs::Vector3Stamped& in)
00133 {
00134   return in;
00135 }
00136 
00142 inline
00143 void fromMsg(const geometry_msgs::Vector3Stamped& msg, geometry_msgs::Vector3Stamped& out)
00144 {
00145   out = msg;
00146 }
00147 
00153 inline
00154 geometry_msgs::Vector3Stamped toMsg(const tf2::Stamped<tf2::Vector3>& in)
00155 {
00156   geometry_msgs::Vector3Stamped out;
00157   out.header.stamp = in.stamp_;
00158   out.header.frame_id = in.frame_id_;
00159   out.vector.x = in.getX();
00160   out.vector.y = in.getY();
00161   out.vector.z = in.getZ();
00162   return out;
00163 }
00164 
00170 inline
00171 void fromMsg(const geometry_msgs::Vector3Stamped& msg, tf2::Stamped<tf2::Vector3>& out)
00172 {
00173   out.stamp_ = msg.header.stamp;
00174   out.frame_id_ = msg.header.frame_id;
00175   out.setData(tf2::Vector3(msg.vector.x, msg.vector.y, msg.vector.z));
00176 }
00177 
00178 
00179 /***********/
00181 /***********/
00182 
00188 inline
00189 geometry_msgs::Point& toMsg(const tf2::Vector3& in, geometry_msgs::Point& out)
00190 {
00191   out.x = in.getX();
00192   out.y = in.getY();
00193   out.z = in.getZ();
00194   return out;
00195 }
00196 
00202 inline
00203 void fromMsg(const geometry_msgs::Point& in, tf2::Vector3& out)
00204 {
00205   out = tf2::Vector3(in.x, in.y, in.z);
00206 }
00207 
00208 
00209 /******************/
00211 /******************/
00212 
00219 template <>
00220 inline
00221   const ros::Time& getTimestamp(const geometry_msgs::PointStamped& t)  {return t.header.stamp;}
00222 
00229 template <>
00230 inline
00231   const std::string& getFrameId(const geometry_msgs::PointStamped& t)  {return t.header.frame_id;}
00232 
00238 inline
00239 geometry_msgs::PointStamped toMsg(const geometry_msgs::PointStamped& in)
00240 {
00241   return in;
00242 }
00243 
00249 inline
00250 void fromMsg(const geometry_msgs::PointStamped& msg, geometry_msgs::PointStamped& out)
00251 {
00252   out = msg;
00253 }
00254 
00260 inline
00261 geometry_msgs::PointStamped toMsg(const tf2::Stamped<tf2::Vector3>& in, geometry_msgs::PointStamped & out)
00262 {
00263   out.header.stamp = in.stamp_;
00264   out.header.frame_id = in.frame_id_;
00265   out.point.x = in.getX();
00266   out.point.y = in.getY();
00267   out.point.z = in.getZ();
00268   return out;
00269 }
00270 
00276 inline
00277 void fromMsg(const geometry_msgs::PointStamped& msg, tf2::Stamped<tf2::Vector3>& out)
00278 {
00279   out.stamp_ = msg.header.stamp;
00280   out.frame_id_ = msg.header.frame_id;
00281   out.setData(tf2::Vector3(msg.point.x, msg.point.y, msg.point.z));
00282 }
00283 
00284 
00285 /****************/
00287 /****************/
00288 
00294 inline
00295 geometry_msgs::Quaternion toMsg(const tf2::Quaternion& in)
00296 {
00297   geometry_msgs::Quaternion out;
00298   out.w = in.getW();
00299   out.x = in.getX();
00300   out.y = in.getY();
00301   out.z = in.getZ();
00302   return out;
00303 }
00304 
00310 inline
00311 void fromMsg(const geometry_msgs::Quaternion& in, tf2::Quaternion& out)
00312 {
00313   // w at the end in the constructor
00314   out = tf2::Quaternion(in.x, in.y, in.z, in.w);
00315 }
00316 
00317 
00318 /***********************/
00320 /***********************/
00321 
00328 template <>
00329 inline
00330 const ros::Time& getTimestamp(const geometry_msgs::QuaternionStamped& t)  {return t.header.stamp;}
00331 
00338 template <>
00339 inline
00340 const std::string& getFrameId(const geometry_msgs::QuaternionStamped& t)  {return t.header.frame_id;}
00341 
00347 inline
00348 geometry_msgs::QuaternionStamped toMsg(const geometry_msgs::QuaternionStamped& in)
00349 {
00350   return in;
00351 }
00352 
00358 inline
00359 void fromMsg(const geometry_msgs::QuaternionStamped& msg, geometry_msgs::QuaternionStamped& out)
00360 {
00361   out = msg;
00362 }
00363 
00369 inline
00370 geometry_msgs::QuaternionStamped toMsg(const tf2::Stamped<tf2::Quaternion>& in)
00371 {
00372   geometry_msgs::QuaternionStamped out;
00373   out.header.stamp = in.stamp_;
00374   out.header.frame_id = in.frame_id_;
00375   out.quaternion.w = in.getW();
00376   out.quaternion.x = in.getX();
00377   out.quaternion.y = in.getY();
00378   out.quaternion.z = in.getZ();
00379   return out;
00380 }
00381 
00382 template <>
00383 inline
00384 geometry_msgs::QuaternionStamped toMsg(const tf2::Stamped<tf2::Quaternion>& in)  __attribute__ ((deprecated));
00385 
00386 
00387 //Backwards compatibility remove when forked for Lunar or newer
00388 template <>
00389 inline
00390 geometry_msgs::QuaternionStamped toMsg(const tf2::Stamped<tf2::Quaternion>& in)
00391 {
00392   return toMsg(in);
00393 }
00394 
00400 inline
00401 void fromMsg(const geometry_msgs::QuaternionStamped& in, tf2::Stamped<tf2::Quaternion>& out)
00402 {
00403   out.stamp_ = in.header.stamp;
00404   out.frame_id_ = in.header.frame_id;
00405   tf2::Quaternion tmp;
00406   fromMsg(in.quaternion, tmp);
00407   out.setData(tmp);
00408 }
00409 
00410 template<>
00411 inline
00412 void fromMsg(const geometry_msgs::QuaternionStamped& in, tf2::Stamped<tf2::Quaternion>& out) __attribute__ ((deprecated));
00413 
00414 //Backwards compatibility remove when forked for Lunar or newer
00415 template<>
00416 inline
00417 void fromMsg(const geometry_msgs::QuaternionStamped& in, tf2::Stamped<tf2::Quaternion>& out)
00418 {
00419     fromMsg(in, out);
00420 }
00421 
00422 /**********/
00424 /**********/
00425 
00430 inline
00431 geometry_msgs::Pose& toMsg(const tf2::Transform& in, geometry_msgs::Pose& out)
00432 {
00433   toMsg(in.getOrigin(), out.position);
00434   out.orientation = toMsg(in.getRotation());
00435   return out;
00436 }
00437 
00442 inline
00443 void fromMsg(const geometry_msgs::Pose& in, tf2::Transform& out)
00444 {
00445   out.setOrigin(tf2::Vector3(in.position.x, in.position.y, in.position.z));
00446   // w at the end in the constructor
00447   out.setRotation(tf2::Quaternion(in.orientation.x, in.orientation.y, in.orientation.z, in.orientation.w));
00448 }
00449 
00450 
00451 
00452 /*****************/
00454 /*****************/
00455 
00461 template <>
00462 inline
00463   const ros::Time& getTimestamp(const geometry_msgs::PoseStamped& t)  {return t.header.stamp;}
00464 
00470 template <>
00471 inline
00472   const std::string& getFrameId(const geometry_msgs::PoseStamped& t)  {return t.header.frame_id;}
00473 
00479 inline
00480 geometry_msgs::PoseStamped toMsg(const geometry_msgs::PoseStamped& in)
00481 {
00482   return in;
00483 }
00484 
00490 inline
00491 void fromMsg(const geometry_msgs::PoseStamped& msg, geometry_msgs::PoseStamped& out)
00492 {
00493   out = msg;
00494 }
00495 
00501 inline
00502 geometry_msgs::PoseStamped toMsg(const tf2::Stamped<tf2::Transform>& in, geometry_msgs::PoseStamped & out)
00503 {
00504   out.header.stamp = in.stamp_;
00505   out.header.frame_id = in.frame_id_;
00506   toMsg(in.getOrigin(), out.pose.position);
00507   out.pose.orientation = toMsg(in.getRotation());
00508   return out;
00509 }
00510 
00516 inline
00517 void fromMsg(const geometry_msgs::PoseStamped& msg, tf2::Stamped<tf2::Transform>& out)
00518 {
00519   out.stamp_ = msg.header.stamp;
00520   out.frame_id_ = msg.header.frame_id;
00521   tf2::Transform tmp;
00522   fromMsg(msg.pose, tmp);
00523   out.setData(tmp);
00524 }
00525 
00526 /*******************************/
00528 /*******************************/
00529 
00535 template <>
00536 inline
00537   const ros::Time& getTimestamp(const geometry_msgs::PoseWithCovarianceStamped& t)  {return t.header.stamp;}
00538 
00544 template <>
00545 inline
00546   const std::string& getFrameId(const geometry_msgs::PoseWithCovarianceStamped& t)  {return t.header.frame_id;}
00547 
00553 inline
00554 geometry_msgs::PoseWithCovarianceStamped toMsg(const geometry_msgs::PoseWithCovarianceStamped& in)
00555 {
00556   return in;
00557 }
00558 
00564 inline
00565 void fromMsg(const geometry_msgs::PoseWithCovarianceStamped& msg, geometry_msgs::PoseWithCovarianceStamped& out)
00566 {
00567   out = msg;
00568 }
00569 
00575 inline
00576 geometry_msgs::PoseWithCovarianceStamped toMsg(const tf2::Stamped<tf2::Transform>& in, geometry_msgs::PoseWithCovarianceStamped & out)
00577 {
00578   out.header.stamp = in.stamp_;
00579   out.header.frame_id = in.frame_id_;
00580   toMsg(in.getOrigin(), out.pose.pose.position);
00581   out.pose.pose.orientation = toMsg(in.getRotation());
00582   return out;
00583 }
00584 
00590 inline
00591 void fromMsg(const geometry_msgs::PoseWithCovarianceStamped& msg, tf2::Stamped<tf2::Transform>& out)
00592 {
00593   out.stamp_ = msg.header.stamp;
00594   out.frame_id_ = msg.header.frame_id;
00595   tf2::Transform tmp;
00596   fromMsg(msg.pose, tmp);
00597   out.setData(tmp);
00598 }
00599 
00600 /***************/
00602 /***************/
00603 
00609 inline
00610 geometry_msgs::Transform toMsg(const tf2::Transform& in)
00611 {
00612   geometry_msgs::Transform out;
00613   out.translation = toMsg(in.getOrigin());
00614   out.rotation = toMsg(in.getRotation());
00615   return out;
00616 }
00617 
00623 inline
00624 void fromMsg(const geometry_msgs::Transform& in, tf2::Transform& out)
00625 {
00626   tf2::Vector3 v;
00627   fromMsg(in.translation, v);
00628   out.setOrigin(v);
00629   // w at the end in the constructor
00630   tf2::Quaternion q;
00631   fromMsg(in.rotation, q);
00632   out.setRotation(q);
00633 }
00634 
00635 
00636 /**********************/
00638 /**********************/
00639 
00645 template <>
00646 inline
00647 const ros::Time& getTimestamp(const geometry_msgs::TransformStamped& t)  {return t.header.stamp;}
00648 
00654 template <>
00655 inline
00656 const std::string& getFrameId(const geometry_msgs::TransformStamped& t)  {return t.header.frame_id;}
00657 
00663 inline
00664 geometry_msgs::TransformStamped toMsg(const geometry_msgs::TransformStamped& in)
00665 {
00666   return in;
00667 }
00668 
00674 inline
00675 void fromMsg(const geometry_msgs::TransformStamped& msg, geometry_msgs::TransformStamped& out)
00676 {
00677   out = msg;
00678 }
00679 
00685 inline
00686 geometry_msgs::TransformStamped toMsg(const tf2::Stamped<tf2::Transform>& in)
00687 {
00688   geometry_msgs::TransformStamped out;
00689   out.header.stamp = in.stamp_;
00690   out.header.frame_id = in.frame_id_;
00691   out.transform.translation = toMsg(in.getOrigin());
00692   out.transform.rotation = toMsg(in.getRotation());
00693   return out;
00694 }
00695 
00696 
00702 inline
00703 void fromMsg(const geometry_msgs::TransformStamped& msg, tf2::Stamped<tf2::Transform>& out)
00704 {
00705   out.stamp_ = msg.header.stamp;
00706   out.frame_id_ = msg.header.frame_id;
00707   tf2::Transform tmp;
00708   fromMsg(msg.transform, tmp);
00709   out.setData(tmp);
00710 }
00711 
00718 template <>
00719 inline
00720   void doTransform(const geometry_msgs::Point& t_in, geometry_msgs::Point& t_out, const geometry_msgs::TransformStamped& transform)
00721   {
00722     tf2::Transform t;
00723     fromMsg(transform.transform, t);
00724     tf2::Vector3 v_in;
00725     fromMsg(t_in, v_in);
00726     tf2::Vector3 v_out = t * v_in;
00727     toMsg(v_out, t_out);
00728   }
00729 
00736 template <>
00737 inline
00738   void doTransform(const geometry_msgs::PointStamped& t_in, geometry_msgs::PointStamped& t_out, const geometry_msgs::TransformStamped& transform)
00739   {
00740     doTransform(t_in.point, t_out.point, transform);
00741     t_out.header.stamp = transform.header.stamp;
00742     t_out.header.frame_id = transform.header.frame_id;
00743   }
00744 
00751 template <>
00752 inline
00753 void doTransform(const geometry_msgs::Quaternion& t_in, geometry_msgs::Quaternion& t_out, const geometry_msgs::TransformStamped& transform)
00754 {
00755   tf2::Quaternion t, q_in;
00756   fromMsg(transform.transform.rotation, t);
00757   fromMsg(t_in, q_in);
00758 
00759   tf2::Quaternion q_out = t * q_in;
00760   t_out = toMsg(q_out);
00761 }
00762 
00769 template <>
00770 inline
00771 void doTransform(const geometry_msgs::QuaternionStamped& t_in, geometry_msgs::QuaternionStamped& t_out, const geometry_msgs::TransformStamped& transform)
00772 {
00773   doTransform(t_in.quaternion, t_out.quaternion, transform);
00774   t_out.header.stamp = transform.header.stamp;
00775   t_out.header.frame_id = transform.header.frame_id;
00776 }
00777 
00778 
00785 template <>
00786 inline
00787 void doTransform(const geometry_msgs::Pose& t_in, geometry_msgs::Pose& t_out, const geometry_msgs::TransformStamped& transform)
00788 {
00789   tf2::Vector3 v;
00790   fromMsg(t_in.position, v);
00791   tf2::Quaternion r;
00792   fromMsg(t_in.orientation, r);
00793 
00794   tf2::Transform t;
00795   fromMsg(transform.transform, t);
00796   tf2::Transform v_out = t * tf2::Transform(r, v);
00797   toMsg(v_out, t_out);
00798 }
00799 
00806 template <>
00807 inline
00808 void doTransform(const geometry_msgs::PoseStamped& t_in, geometry_msgs::PoseStamped& t_out, const geometry_msgs::TransformStamped& transform)
00809 {
00810   doTransform(t_in.pose, t_out.pose, transform);
00811   t_out.header.stamp = transform.header.stamp;
00812   t_out.header.frame_id = transform.header.frame_id;
00813 }
00814 
00820 inline
00821 geometry_msgs::PoseWithCovariance::_covariance_type transformCovariance(const geometry_msgs::PoseWithCovariance::_covariance_type& cov_in, const tf2::Transform& transform)
00822 {
00835   // get rotation matrix transpose  
00836   const tf2::Matrix3x3  R_transpose = transform.getBasis().transpose();
00837   
00838   // convert the covariance matrix into four 3x3 blocks
00839   const tf2::Matrix3x3 cov_11(cov_in[0], cov_in[1], cov_in[2],
00840                               cov_in[6], cov_in[7], cov_in[8],
00841                               cov_in[12], cov_in[13], cov_in[14]);
00842   const tf2::Matrix3x3 cov_12(cov_in[3], cov_in[4], cov_in[5],
00843                               cov_in[9], cov_in[10], cov_in[11],
00844                               cov_in[15], cov_in[16], cov_in[17]);
00845   const tf2::Matrix3x3 cov_21(cov_in[18], cov_in[19], cov_in[20],
00846                               cov_in[24], cov_in[25], cov_in[26],
00847                               cov_in[30], cov_in[31], cov_in[32]);
00848   const tf2::Matrix3x3 cov_22(cov_in[21], cov_in[22], cov_in[23],
00849                               cov_in[27], cov_in[28], cov_in[29],
00850                               cov_in[33], cov_in[34], cov_in[35]);
00851   
00852   // perform blockwise matrix multiplication
00853   const tf2::Matrix3x3 result_11 = transform.getBasis()*cov_11*R_transpose;
00854   const tf2::Matrix3x3 result_12 = transform.getBasis()*cov_12*R_transpose;
00855   const tf2::Matrix3x3 result_21 = transform.getBasis()*cov_21*R_transpose;
00856   const tf2::Matrix3x3 result_22 = transform.getBasis()*cov_22*R_transpose;
00857   
00858   // form the output
00859   geometry_msgs::PoseWithCovariance::_covariance_type output;
00860   output[0] = result_11[0][0];
00861   output[1] = result_11[0][1];
00862   output[2] = result_11[0][2];
00863   output[6] = result_11[1][0];
00864   output[7] = result_11[1][1];
00865   output[8] = result_11[1][2];
00866   output[12] = result_11[2][0];
00867   output[13] = result_11[2][1];
00868   output[14] = result_11[2][2];
00869   
00870   output[3] = result_12[0][0];
00871   output[4] = result_12[0][1];
00872   output[5] = result_12[0][2];
00873   output[9] = result_12[1][0];
00874   output[10] = result_12[1][1];
00875   output[11] = result_12[1][2];
00876   output[15] = result_12[2][0];
00877   output[16] = result_12[2][1];
00878   output[17] = result_12[2][2];
00879   
00880   output[18] = result_21[0][0];
00881   output[19] = result_21[0][1];
00882   output[20] = result_21[0][2];
00883   output[24] = result_21[1][0];
00884   output[25] = result_21[1][1];
00885   output[26] = result_21[1][2];
00886   output[30] = result_21[2][0];
00887   output[31] = result_21[2][1];
00888   output[32] = result_21[2][2];
00889   
00890   output[21] = result_22[0][0];
00891   output[22] = result_22[0][1];
00892   output[23] = result_22[0][2];
00893   output[27] = result_22[1][0];
00894   output[28] = result_22[1][1];
00895   output[29] = result_22[1][2];
00896   output[33] = result_22[2][0];
00897   output[34] = result_22[2][1];
00898   output[35] = result_22[2][2];
00899   
00900   return output;
00901 }
00902 
00909 template <>
00910 inline
00911 void doTransform(const geometry_msgs::PoseWithCovarianceStamped& t_in, geometry_msgs::PoseWithCovarianceStamped& t_out, const geometry_msgs::TransformStamped& transform)
00912 {
00913   tf2::Vector3 v;
00914   fromMsg(t_in.pose.pose.position, v);
00915   tf2::Quaternion r;
00916   fromMsg(t_in.pose.pose.orientation, r);
00917 
00918   tf2::Transform t;
00919   fromMsg(transform.transform, t);
00920   tf2::Transform v_out = t * tf2::Transform(r, v);
00921   toMsg(v_out, t_out.pose.pose);
00922   t_out.header.stamp = transform.header.stamp;
00923   t_out.header.frame_id = transform.header.frame_id;
00924 
00925   t_out.pose.covariance = transformCovariance(t_in.pose.covariance, t);
00926 }
00927 
00934 template <>
00935 inline
00936 void doTransform(const geometry_msgs::TransformStamped& t_in, geometry_msgs::TransformStamped& t_out, const geometry_msgs::TransformStamped& transform)
00937   {
00938     tf2::Transform input;
00939     fromMsg(t_in.transform, input);
00940 
00941     tf2::Transform t;
00942     fromMsg(transform.transform, t);
00943     tf2::Transform v_out = t * input;
00944 
00945     t_out.transform = toMsg(v_out);
00946     t_out.header.stamp = transform.header.stamp;
00947     t_out.header.frame_id = transform.header.frame_id;
00948   }
00949 
00956 template <>
00957 inline
00958   void doTransform(const geometry_msgs::Vector3& t_in, geometry_msgs::Vector3& t_out, const geometry_msgs::TransformStamped& transform)
00959   {
00960     tf2::Transform t;
00961     fromMsg(transform.transform, t);
00962     tf2::Vector3 v_out = t.getBasis() * tf2::Vector3(t_in.x, t_in.y, t_in.z);
00963     t_out.x = v_out[0];
00964     t_out.y = v_out[1];
00965     t_out.z = v_out[2];
00966   }
00967 
00974 template <>
00975 inline
00976   void doTransform(const geometry_msgs::Vector3Stamped& t_in, geometry_msgs::Vector3Stamped& t_out, const geometry_msgs::TransformStamped& transform)
00977   {
00978     doTransform(t_in.vector, t_out.vector, transform);
00979     t_out.header.stamp = transform.header.stamp;
00980     t_out.header.frame_id = transform.header.frame_id;
00981   }
00982 
00983 
00984 /**********************/
00985 /*** WrenchStamped ****/
00986 /**********************/
00987 template <>
00988 inline
00989 const ros::Time& getTimestamp(const geometry_msgs::WrenchStamped& t) {return t.header.stamp;}
00990 
00991 
00992 template <>
00993 inline
00994 const std::string& getFrameId(const geometry_msgs::WrenchStamped& t) {return t.header.frame_id;}
00995 
00996 
00997 inline
00998 geometry_msgs::WrenchStamped toMsg(const geometry_msgs::WrenchStamped& in)
00999 {
01000   return in;
01001 }
01002 
01003 inline
01004 void fromMsg(const geometry_msgs::WrenchStamped& msg, geometry_msgs::WrenchStamped& out)
01005 {
01006   out = msg;
01007 }
01008 
01009 
01010 inline
01011 geometry_msgs::WrenchStamped toMsg(const tf2::Stamped< boost::array<tf2::Vector3, 2> >& in, geometry_msgs::WrenchStamped& out)
01012 {
01013   out.header.stamp = in.stamp_;
01014   out.header.frame_id = in.frame_id_;
01015   out.wrench.force = toMsg(in[0]);
01016   out.wrench.torque = toMsg(in[1]);
01017   return out;
01018 }
01019 
01020 
01021 inline
01022 void fromMsg(const geometry_msgs::WrenchStamped& msg, tf2::Stamped< boost::array<tf2::Vector3, 2> >& out)
01023 {
01024   out.stamp_ = msg.header.stamp;
01025   out.frame_id_ = msg.header.frame_id;
01026   tf2::Vector3 tmp;
01027   fromMsg(msg.wrench.force, tmp);
01028   tf2::Vector3 tmp1;
01029   fromMsg(msg.wrench.torque, tmp1);
01030   boost::array<tf2::Vector3, 2> tmp_array;
01031   tmp_array[0] = tmp;
01032   tmp_array[1] = tmp1;
01033   out.setData(tmp_array);
01034 }
01035 
01036 template<>
01037 inline
01038 void doTransform(const geometry_msgs::Wrench& t_in, geometry_msgs::Wrench& t_out, const geometry_msgs::TransformStamped& transform)
01039 {
01040   doTransform(t_in.force, t_out.force, transform);
01041   doTransform(t_in.torque, t_out.torque, transform);
01042 }
01043 
01044 
01045 template<>
01046 inline
01047 void doTransform(const geometry_msgs::WrenchStamped& t_in, geometry_msgs::WrenchStamped& t_out, const geometry_msgs::TransformStamped& transform)
01048 {
01049   doTransform(t_in.wrench, t_out.wrench, transform);
01050   t_out.header.stamp = transform.header.stamp;
01051   t_out.header.frame_id = transform.header.frame_id;
01052 }
01053 
01054 } // namespace
01055 
01056 #endif // TF2_GEOMETRY_MSGS_H


tf2_geometry_msgs
Author(s): Wim Meeussen
autogenerated on Thu Jun 6 2019 20:23:07