BulletTypes.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012-2016 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_BULLETTYPES_HH_
18 #define _GAZEBO_BULLETTYPES_HH_
19 
20 #include <boost/shared_ptr.hpp>
22 #include "gazebo/math/Vector3.hh"
23 #include "gazebo/math/Vector4.hh"
24 #include "gazebo/math/Pose.hh"
25 #include "gazebo/util/system.hh"
26 
31 namespace gazebo
32 {
33  namespace physics
34  {
35  class BulletCollision;
36  class BulletLink;
37  class BulletMotionState;
38  class BulletPhysics;
39  class BulletRayShape;
41 
42  typedef boost::shared_ptr<BulletCollision> BulletCollisionPtr;
43  typedef boost::shared_ptr<BulletLink> BulletLinkPtr;
44  typedef boost::shared_ptr<BulletMotionState> BulletMotionStatePtr;
45  typedef boost::shared_ptr<BulletPhysics> BulletPhysicsPtr;
46  typedef boost::shared_ptr<BulletRayShape> BulletRayShapePtr;
47  typedef boost::shared_ptr<BulletSurfaceParams> BulletSurfaceParamsPtr;
48 
51 
55  class GZ_PHYSICS_VISIBLE BulletTypes {
59  public: static math::Vector3 ConvertVector3(const btVector3 &_bt)
60  {
61  return math::Vector3(_bt.getX(), _bt.getY(), _bt.getZ());
62  }
63 
67  public: static btVector3 ConvertVector3(const math::Vector3 &_vec)
68  {
69  return btVector3(_vec.x, _vec.y, _vec.z);
70  }
71 
75  public: static math::Vector4 ConvertVector4(const btVector4 &_bt)
76  {
77  return math::Vector4(_bt.getX(), _bt.getY(),
78  _bt.getZ(), _bt.getW());
79  }
80 
84  public: static btVector4 ConvertVector4(const math::Vector4 &_vec)
85  {
86  return btVector4(_vec.x, _vec.y, _vec.z, _vec.w);
87  }
88 
92  public: static math::Pose ConvertPose(const btTransform &_bt)
93  {
94  math::Pose pose;
95  pose.pos = ConvertVector3(_bt.getOrigin());
96  pose.rot.w = _bt.getRotation().getW();
97  pose.rot.x = _bt.getRotation().getX();
98  pose.rot.y = _bt.getRotation().getY();
99  pose.rot.z = _bt.getRotation().getZ();
100  return pose;
101  }
102 
106  public: static btTransform ConvertPose(const math::Pose &_pose)
107  {
108  btTransform trans;
109 
110  trans.setOrigin(ConvertVector3(_pose.pos));
111  trans.setRotation(btQuaternion(_pose.rot.x, _pose.rot.y,
112  _pose.rot.z, _pose.rot.w));
113  return trans;
114  }
115  };
117  }
118 }
119 #endif
double x
X location.
Definition: Vector3.hh:311
Quaternion rot
The rotation.
Definition: Pose.hh:255
boost::shared_ptr< BulletSurfaceParams > BulletSurfaceParamsPtr
Definition: BulletTypes.hh:47
double y
Y location.
Definition: Vector3.hh:314
boost::shared_ptr< BulletMotionState > BulletMotionStatePtr
Definition: BulletTypes.hh:44
Encapsulates a position and rotation in three space.
Definition: Pose.hh:37
The Vector3 class represents the generic vector containing 3 elements.
Definition: Vector3.hh:39
Bullet surface parameters.
Definition: BulletSurfaceParams.hh:36
boost::shared_ptr< BulletCollision > BulletCollisionPtr
Definition: BulletTypes.hh:40
double y
y value of the quaternion
Definition: Quaternion.hh:383
double Generic x, y, z, w vector
Definition: Vector4.hh:39
double z
Z location.
Definition: Vector3.hh:317
boost::shared_ptr< BulletPhysics > BulletPhysicsPtr
Definition: BulletTypes.hh:45
double w
w value of the quaternion
Definition: Quaternion.hh:377
double y
Y value.
Definition: Vector4.hh:191
static btVector3 ConvertVector3(const math::Vector3 &_vec)
Convert a gazebo Vector3 to a bullet btVector3.
Definition: BulletTypes.hh:67
static math::Pose ConvertPose(const btTransform &_bt)
Convert a bullet transform to a gazebo pose.
Definition: BulletTypes.hh:92
boost::shared_ptr< BulletLink > BulletLinkPtr
Definition: BulletTypes.hh:43
static math::Vector4 ConvertVector4(const btVector4 &_bt)
Convert a bullet btVector4 to a gazebo Vector4.
Definition: BulletTypes.hh:75
double z
Z value.
Definition: Vector4.hh:194
A set of functions for converting between the math types used by gazebo and bullet.
Definition: BulletTypes.hh:55
Vector3 pos
The position.
Definition: Pose.hh:252
static btTransform ConvertPose(const math::Pose &_pose)
Convert a gazebo pose to a bullet transform.
Definition: BulletTypes.hh:106
double w
W value.
Definition: Vector4.hh:197
double x
x value of the quaternion
Definition: Quaternion.hh:380
static math::Vector3 ConvertVector3(const btVector3 &_bt)
Convert a bullet btVector3 to a gazebo Vector3.
Definition: BulletTypes.hh:59
static btVector4 ConvertVector4(const math::Vector4 &_vec)
Convert a gazebo Vector4 to a bullet btVector4.
Definition: BulletTypes.hh:84
double z
z value of the quaternion
Definition: Quaternion.hh:386
boost::shared_ptr< BulletRayShape > BulletRayShapePtr
Definition: BulletTypes.hh:46
double x
X value.
Definition: Vector4.hh:188