BulletTypes.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012-2015 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 
18 #ifndef _BULLETTYPES_HH
19 #define _BULLETTYPES_HH
20 
21 #include <boost/shared_ptr.hpp>
23 #include "gazebo/math/Vector3.hh"
24 #include "gazebo/math/Vector4.hh"
25 #include "gazebo/math/Pose.hh"
26 #include "gazebo/util/system.hh"
27 
32 namespace gazebo
33 {
34  namespace physics
35  {
36  class BulletCollision;
37  class BulletLink;
38  class BulletMotionState;
39  class BulletPhysics;
40  class BulletRayShape;
42 
43  typedef boost::shared_ptr<BulletCollision> BulletCollisionPtr;
44  typedef boost::shared_ptr<BulletLink> BulletLinkPtr;
45  typedef boost::shared_ptr<BulletMotionState> BulletMotionStatePtr;
46  typedef boost::shared_ptr<BulletPhysics> BulletPhysicsPtr;
47  typedef boost::shared_ptr<BulletRayShape> BulletRayShapePtr;
48  typedef boost::shared_ptr<BulletSurfaceParams> BulletSurfaceParamsPtr;
49 
52 
60  public: static math::Vector3 ConvertVector3(const btVector3 &_bt)
61  {
62  return math::Vector3(_bt.getX(), _bt.getY(), _bt.getZ());
63  }
64 
68  public: static btVector3 ConvertVector3(const math::Vector3 &_vec)
69  {
70  return btVector3(_vec.x, _vec.y, _vec.z);
71  }
72 
76  public: static math::Vector4 ConvertVector4(const btVector4 &_bt)
77  {
78  return math::Vector4(_bt.getX(), _bt.getY(),
79  _bt.getZ(), _bt.getW());
80  }
81 
85  public: static btVector4 ConvertVector4(const math::Vector4 &_vec)
86  {
87  return btVector4(_vec.x, _vec.y, _vec.z, _vec.w);
88  }
89 
93  public: static math::Pose ConvertPose(const btTransform &_bt)
94  {
95  math::Pose pose;
96  pose.pos = ConvertVector3(_bt.getOrigin());
97  pose.rot.w = _bt.getRotation().getW();
98  pose.rot.x = _bt.getRotation().getX();
99  pose.rot.y = _bt.getRotation().getY();
100  pose.rot.z = _bt.getRotation().getZ();
101  return pose;
102  }
103 
107  public: static btTransform ConvertPose(const math::Pose &_pose)
108  {
109  btTransform trans;
110 
111  trans.setOrigin(ConvertVector3(_pose.pos));
112  trans.setRotation(btQuaternion(_pose.rot.x, _pose.rot.y,
113  _pose.rot.z, _pose.rot.w));
114  return trans;
115  }
116  };
118  }
119 }
120 #endif // #ifndef _BULLETTYPES_HH
boost::shared_ptr< BulletRayShape > BulletRayShapePtr
Definition: BulletTypes.hh:47
double z
Attributes of the quaternion.
Definition: Quaternion.hh:364
boost::shared_ptr< BulletLink > BulletLinkPtr
Definition: BulletTypes.hh:44
Encapsulates a position and rotation in three space.
Definition: Pose.hh:40
The Vector3 class represents the generic vector containing 3 elements.
Definition: Vector3.hh:43
boost::shared_ptr< BulletMotionState > BulletMotionStatePtr
Definition: BulletTypes.hh:45
Bullet surface parameters.
Definition: BulletSurfaceParams.hh:36
static math::Vector4 ConvertVector4(const btVector4 &_bt)
Convert a bullet btVector4 to a gazebo Vector4.
Definition: BulletTypes.hh:76
static math::Vector3 ConvertVector3(const btVector3 &_bt)
Convert a bullet btVector3 to a gazebo Vector3.
Definition: BulletTypes.hh:60
double x
X location.
Definition: Vector3.hh:302
static btTransform ConvertPose(const math::Pose &_pose)
Convert a gazebo pose to a bullet transform.
Definition: BulletTypes.hh:107
double z
Z location.
Definition: Vector3.hh:308
double Generic x, y, z, w vector
Definition: Vector4.hh:39
static btVector4 ConvertVector4(const math::Vector4 &_vec)
Convert a gazebo Vector4 to a bullet btVector4.
Definition: BulletTypes.hh:85
double x
X value.
Definition: Vector4.hh:188
boost::shared_ptr< BulletSurfaceParams > BulletSurfaceParamsPtr
Definition: BulletTypes.hh:48
double w
W value.
Definition: Vector4.hh:197
double w
Attributes of the quaternion.
Definition: Quaternion.hh:355
double y
Y value.
Definition: Vector4.hh:191
static math::Pose ConvertPose(const btTransform &_bt)
Convert a bullet transform to a gazebo pose.
Definition: BulletTypes.hh:93
Vector3 pos
The position.
Definition: Pose.hh:243
A set of functions for converting between the math types used by gazebo and bullet.
Definition: BulletTypes.hh:56
double z
Z value.
Definition: Vector4.hh:194
Quaternion rot
The rotation.
Definition: Pose.hh:246
double y
Attributes of the quaternion.
Definition: Quaternion.hh:361
static btVector3 ConvertVector3(const math::Vector3 &_vec)
Convert a gazebo Vector3 to a bullet btVector3.
Definition: BulletTypes.hh:68
boost::shared_ptr< BulletPhysics > BulletPhysicsPtr
Definition: BulletTypes.hh:46
boost::shared_ptr< BulletCollision > BulletCollisionPtr
Definition: BulletTypes.hh:41
double x
Attributes of the quaternion.
Definition: Quaternion.hh:358
#define GAZEBO_VISIBLE
Use to represent "symbol visible" if supported.
Definition: system.hh:48
double y
Y location.
Definition: Vector3.hh:305