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/util/system.hh"
25 
30 namespace gazebo
31 {
32  namespace physics
33  {
34  class BulletCollision;
35  class BulletLink;
36  class BulletMotionState;
37  class BulletPhysics;
38  class BulletRayShape;
40 
41  typedef boost::shared_ptr<BulletCollision> BulletCollisionPtr;
42  typedef boost::shared_ptr<BulletLink> BulletLinkPtr;
43  typedef boost::shared_ptr<BulletMotionState> BulletMotionStatePtr;
44  typedef boost::shared_ptr<BulletPhysics> BulletPhysicsPtr;
45  typedef boost::shared_ptr<BulletRayShape> BulletRayShapePtr;
46  typedef boost::shared_ptr<BulletSurfaceParams> BulletSurfaceParamsPtr;
47 
50 
54  class GZ_PHYSICS_VISIBLE BulletTypes {
58  public: static ignition::math::Vector3d ConvertVector3Ign(
59  const btVector3 &_bt)
60  {
61  return ignition::math::Vector3d(
62  _bt.getX(), _bt.getY(), _bt.getZ());
63  }
64 
68  public: static btVector3 ConvertVector3(
69  const ignition::math::Vector3d &_vec)
70  {
71  return btVector3(_vec.X(), _vec.Y(), _vec.Z());
72  }
73 
77  public: static ignition::math::Vector4d ConvertVector4dIgn(
78  const btVector4 &_bt)
79  {
80  return ignition::math::Vector4d(_bt.getX(), _bt.getY(),
81  _bt.getZ(), _bt.getW());
82  }
83 
87  public: static btVector4 ConvertVector4dIgn(
88  const ignition::math::Vector4d &_vec)
89  {
90  return btVector4(_vec.X(), _vec.Y(), _vec.Z(), _vec.W());
91  }
92 
96  public: static ignition::math::Pose3d ConvertPoseIgn(
97  const btTransform &_bt)
98  {
99  ignition::math::Pose3d pose;
100  pose.Pos() = ConvertVector3Ign(_bt.getOrigin());
101  pose.Rot().W() = _bt.getRotation().getW();
102  pose.Rot().X() = _bt.getRotation().getX();
103  pose.Rot().Y() = _bt.getRotation().getY();
104  pose.Rot().Z() = _bt.getRotation().getZ();
105  return pose;
106  }
107 
111  public: static btTransform ConvertPose(
112  const ignition::math::Pose3d &_pose)
113  {
114  btTransform trans;
115 
116  trans.setOrigin(ConvertVector3(_pose.Pos()));
117  trans.setRotation(btQuaternion(_pose.Rot().X(), _pose.Rot().Y(),
118  _pose.Rot().Z(), _pose.Rot().W()));
119  return trans;
120  }
121  };
123  }
124 }
125 #endif
boost::shared_ptr< BulletSurfaceParams > BulletSurfaceParamsPtr
Definition: BulletTypes.hh:46
static btTransform ConvertPose(const ignition::math::Pose3d &_pose)
Convert an ignition math pose to a bullet transform.
Definition: BulletTypes.hh:111
boost::shared_ptr< BulletMotionState > BulletMotionStatePtr
Definition: BulletTypes.hh:43
static btVector4 ConvertVector4dIgn(const ignition::math::Vector4d &_vec)
Convert an ignition math Vector4d to a bullet btVector4.
Definition: BulletTypes.hh:87
Bullet surface parameters.
Definition: BulletSurfaceParams.hh:35
boost::shared_ptr< BulletCollision > BulletCollisionPtr
Definition: BulletTypes.hh:39
static ignition::math::Pose3d ConvertPoseIgn(const btTransform &_bt)
Convert a bullet transform to an ignition math pose.
Definition: BulletTypes.hh:96
boost::shared_ptr< BulletPhysics > BulletPhysicsPtr
Definition: BulletTypes.hh:44
static ignition::math::Vector3d ConvertVector3Ign(const btVector3 &_bt)
Convert a bullet btVector3 to an ignition Vector3d.
Definition: BulletTypes.hh:58
static ignition::math::Vector4d ConvertVector4dIgn(const btVector4 &_bt)
Convert a bullet btVector4 to an ignition math Vector4d.
Definition: BulletTypes.hh:77
boost::shared_ptr< BulletLink > BulletLinkPtr
Definition: BulletTypes.hh:42
A set of functions for converting between the math types used by gazebo and bullet.
Definition: BulletTypes.hh:54
static btVector3 ConvertVector3(const ignition::math::Vector3d &_vec)
Convert an ignition Vector3d to a bullet btVector3.
Definition: BulletTypes.hh:68
boost::shared_ptr< BulletRayShape > BulletRayShapePtr
Definition: BulletTypes.hh:45