BulletTypes.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012 Open Source Robotics Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16 */
17 #ifndef GAZEBO_PHYSICS_BULLET_BULLETTYPES_HH_
18 #define GAZEBO_PHYSICS_BULLET_BULLETTYPES_HH_
19 
20 #include <boost/shared_ptr.hpp>
21 #include <ignition/math/Vector4.hh>
22 
24 #include "gazebo/math/Vector3.hh"
25 #include "gazebo/math/Vector4.hh"
26 #include "gazebo/math/Pose.hh"
27 #include "gazebo/util/system.hh"
28 
33 namespace gazebo
34 {
35  namespace physics
36  {
37  class BulletCollision;
38  class BulletLink;
39  class BulletMotionState;
40  class BulletPhysics;
41  class BulletRayShape;
43 
44  typedef boost::shared_ptr<BulletCollision> BulletCollisionPtr;
45  typedef boost::shared_ptr<BulletLink> BulletLinkPtr;
46  typedef boost::shared_ptr<BulletMotionState> BulletMotionStatePtr;
47  typedef boost::shared_ptr<BulletPhysics> BulletPhysicsPtr;
48  typedef boost::shared_ptr<BulletRayShape> BulletRayShapePtr;
49  typedef boost::shared_ptr<BulletSurfaceParams> BulletSurfaceParamsPtr;
50 
53 
57  class GZ_PHYSICS_VISIBLE BulletTypes {
62  public: static math::Vector3 ConvertVector3(const btVector3 &_bt)
64  {
65 #ifndef _WIN32
66  #pragma GCC diagnostic push
67  #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
68 #endif
69  return math::Vector3(_bt.getX(), _bt.getY(), _bt.getZ());
70 #ifndef _WIN32
71  #pragma GCC diagnostic pop
72 #endif
73  }
74 
78  public: static ignition::math::Vector3d ConvertVector3Ign(
79  const btVector3 &_bt)
80  {
81  return ignition::math::Vector3d(
82  _bt.getX(), _bt.getY(), _bt.getZ());
83  }
84 
89  public: static btVector3 ConvertVector3(const math::Vector3 &_vec)
91  {
92 #ifndef _WIN32
93  #pragma GCC diagnostic push
94  #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
95 #endif
96  return btVector3(_vec.x, _vec.y, _vec.z);
97 #ifndef _WIN32
98  #pragma GCC diagnostic pop
99 #endif
100  }
101 
105  public: static btVector3 ConvertVector3(
106  const ignition::math::Vector3d &_vec)
107  {
108  return btVector3(_vec.X(), _vec.Y(), _vec.Z());
109  }
110 
115  public: static math::Vector4 ConvertVector4(const btVector4 &_bt)
116  GAZEBO_DEPRECATED(8.0)
117  {
118 #ifndef _WIN32
119  #pragma GCC diagnostic push
120  #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
121 #endif
122  return ConvertVector4dIgn(_bt);
123 #ifndef _WIN32
124  #pragma GCC diagnostic pop
125 #endif
126  }
127 
131  public: static ignition::math::Vector4d ConvertVector4dIgn(
132  const btVector4 &_bt)
133  {
134  return ignition::math::Vector4d(_bt.getX(), _bt.getY(),
135  _bt.getZ(), _bt.getW());
136  }
137 
142  public: static btVector4 ConvertVector4(const math::Vector4 &_vec)
143  GAZEBO_DEPRECATED(8.0)
144  {
145 #ifndef _WIN32
146  #pragma GCC diagnostic push
147  #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
148 #endif
149  return ConvertVector4dIgn(_vec.Ign());
150 #ifndef _WIN32
151  #pragma GCC diagnostic pop
152 #endif
153  }
154 
158  public: static btVector4 ConvertVector4dIgn(
159  const ignition::math::Vector4d &_vec)
160  {
161  return btVector4(_vec.X(), _vec.Y(), _vec.Z(), _vec.W());
162  }
163 
167  public: static ignition::math::Pose3d ConvertPoseIgn(
168  const btTransform &_bt)
169  {
170  ignition::math::Pose3d pose;
171  pose.Pos() = ConvertVector3Ign(_bt.getOrigin());
172  pose.Rot().W() = _bt.getRotation().getW();
173  pose.Rot().X() = _bt.getRotation().getX();
174  pose.Rot().Y() = _bt.getRotation().getY();
175  pose.Rot().Z() = _bt.getRotation().getZ();
176  return pose;
177  }
178 
183  public: static math::Pose ConvertPose(const btTransform &_bt)
184  GAZEBO_DEPRECATED(8.0)
185  {
186 #ifndef _WIN32
187  #pragma GCC diagnostic push
188  #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
189 #endif
190  return ConvertPoseIgn(_bt);
191 #ifndef _WIN32
192  #pragma GCC diagnostic pop
193 #endif
194  }
195 
200  public: static btTransform ConvertPose(const math::Pose &_pose)
201  GAZEBO_DEPRECATED(8.0)
202  {
203 #ifndef _WIN32
204  #pragma GCC diagnostic push
205  #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
206 #endif
207  return ConvertPose(_pose.Ign());
208 #ifndef _WIN32
209  #pragma GCC diagnostic pop
210 #endif
211  }
212 
216  public: static btTransform ConvertPose(
217  const ignition::math::Pose3d &_pose)
218  {
219  btTransform trans;
220 
221  trans.setOrigin(ConvertVector3(_pose.Pos()));
222  trans.setRotation(btQuaternion(_pose.Rot().X(), _pose.Rot().Y(),
223  _pose.Rot().Z(), _pose.Rot().W()));
224  return trans;
225  }
226  };
228  }
229 }
230 #endif
boost::shared_ptr< BulletSurfaceParams > BulletSurfaceParamsPtr
Definition: BulletTypes.hh:49
static btTransform ConvertPose(const ignition::math::Pose3d &_pose)
Convert an ignition math pose to a bullet transform.
Definition: BulletTypes.hh:216
boost::shared_ptr< BulletMotionState > BulletMotionStatePtr
Definition: BulletTypes.hh:46
static btVector4 ConvertVector4dIgn(const ignition::math::Vector4d &_vec)
Convert an ignition math Vector4d to a bullet btVector4.
Definition: BulletTypes.hh:158
Encapsulates a position and rotation in three space.
Definition: Pose.hh:42
The Vector3 class represents the generic vector containing 3 elements.
Definition: Vector3.hh:44
static btVector4 ConvertVector4(const math::Vector4 &_vec) GAZEBO_DEPRECATED(8.0)
Convert a gazebo Vector4 to a bullet btVector4.
Definition: BulletTypes.hh:142
static math::Vector4 ConvertVector4(const btVector4 &_bt) GAZEBO_DEPRECATED(8.0)
Convert a bullet btVector4 to a gazebo Vector4.
Definition: BulletTypes.hh:115
Bullet surface parameters.
Definition: BulletSurfaceParams.hh:35
boost::shared_ptr< BulletCollision > BulletCollisionPtr
Definition: BulletTypes.hh:42
static math::Vector3 ConvertVector3(const btVector3 &_bt) GAZEBO_DEPRECATED(8.0)
Convert a bullet btVector3 to a gazebo Vector3.
Definition: BulletTypes.hh:62
double Generic x, y, z, w vector
Definition: Vector4.hh:41
static btVector3 ConvertVector3(const math::Vector3 &_vec) GAZEBO_DEPRECATED(8.0)
Convert a gazebo Vector3 to a bullet btVector3.
Definition: BulletTypes.hh:89
static ignition::math::Pose3d ConvertPoseIgn(const btTransform &_bt)
Convert a bullet transform to an ignition math pose.
Definition: BulletTypes.hh:167
boost::shared_ptr< BulletPhysics > BulletPhysicsPtr
Definition: BulletTypes.hh:47
static ignition::math::Vector3d ConvertVector3Ign(const btVector3 &_bt)
Convert a bullet btVector3 to an ignition Vector3d.
Definition: BulletTypes.hh:78
static ignition::math::Vector4d ConvertVector4dIgn(const btVector4 &_bt)
Convert a bullet btVector4 to an ignition math Vector4d.
Definition: BulletTypes.hh:131
static btTransform ConvertPose(const math::Pose &_pose) GAZEBO_DEPRECATED(8.0)
Convert a gazebo pose to a bullet transform.
Definition: BulletTypes.hh:200
boost::shared_ptr< BulletLink > BulletLinkPtr
Definition: BulletTypes.hh:45
A set of functions for converting between the math types used by gazebo and bullet.
Definition: BulletTypes.hh:57
static math::Pose ConvertPose(const btTransform &_bt) GAZEBO_DEPRECATED(8.0)
Convert a bullet transform to a gazebo pose.
Definition: BulletTypes.hh:183
#define GAZEBO_DEPRECATED(version)
Definition: system.hh:302
static btVector3 ConvertVector3(const ignition::math::Vector3d &_vec)
Convert an ignition Vector3d to a bullet btVector3.
Definition: BulletTypes.hh:105
boost::shared_ptr< BulletRayShape > BulletRayShapePtr
Definition: BulletTypes.hh:48