tf2_bullet.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2008, Willow Garage, Inc.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * * Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  * * Neither the name of the Willow Garage, Inc. nor the names of its
14  * contributors may be used to endorse or promote products derived from
15  * this software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27  * POSSIBILITY OF SUCH DAMAGE.
28  */
29 
32 #ifndef TF2_BULLET_H
33 #define TF2_BULLET_H
34 
35 #include <tf2/convert.h>
36 #include <LinearMath/btTransform.h>
37 #include <geometry_msgs/PointStamped.h>
38 
39 
40 namespace tf2
41 {
46 inline
47 btTransform transformToBullet(const geometry_msgs::TransformStamped& t)
48  {
49  return btTransform(btQuaternion(t.transform.rotation.x, t.transform.rotation.y,
50  t.transform.rotation.z, t.transform.rotation.w),
51  btVector3(t.transform.translation.x, t.transform.translation.y, t.transform.translation.z));
52  }
53 
54 
61 template <>
62 inline
63  void doTransform(const tf2::Stamped<btVector3>& t_in, tf2::Stamped<btVector3>& t_out, const geometry_msgs::TransformStamped& transform)
64  {
65  t_out = tf2::Stamped<btVector3>(transformToBullet(transform) * t_in, transform.header.stamp, transform.header.frame_id);
66  }
67 
73 inline
74 geometry_msgs::PointStamped toMsg(const tf2::Stamped<btVector3>& in)
75 {
76  geometry_msgs::PointStamped msg;
77  msg.header.stamp = in.stamp_;
78  msg.header.frame_id = in.frame_id_;
79  msg.point.x = in[0];
80  msg.point.y = in[1];
81  msg.point.z = in[2];
82  return msg;
83 }
84 
90 inline
91 void fromMsg(const geometry_msgs::PointStamped& msg, tf2::Stamped<btVector3>& out)
92 {
93  out.stamp_ = msg.header.stamp;
94  out.frame_id_ = msg.header.frame_id;
95  out[0] = msg.point.x;
96  out[1] = msg.point.y;
97  out[2] = msg.point.z;
98 }
99 
100 
107 template <>
108 inline
109  void doTransform(const tf2::Stamped<btTransform>& t_in, tf2::Stamped<btTransform>& t_out, const geometry_msgs::TransformStamped& transform)
110  {
111  t_out = tf2::Stamped<btTransform>(transformToBullet(transform) * t_in, transform.header.stamp, transform.header.frame_id);
112  }
113 
114 
115 } // namespace
116 
117 #endif // TF2_BULLET_H
tf2::fromMsg
void fromMsg(const A &, B &b)
tf2::Stamped
tf2::Stamped::frame_id_
std::string frame_id_
tf2::Stamped::stamp_
ros::Time stamp_
tf2::transformToBullet
btTransform transformToBullet(const geometry_msgs::TransformStamped &t)
Convert a timestamped transform to the equivalent Bullet data type.
Definition: tf2_bullet.h:47
tf2::doTransform
void doTransform(const T &data_in, T &data_out, const geometry_msgs::TransformStamped &transform)
tf2
tf2::toMsg
B toMsg(const A &a)
convert.h


tf2_bullet
Author(s): Wim Meeussen
autogenerated on Sun Feb 4 2024 03:18:13