All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DARTTypes.hh
Go to the documentation of this file.
1 /*
2  * Copyright 2014 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 _GAZEBO_DARTTYPES_HH_
19 #define _GAZEBO_DARTTYPES_HH_
20 
21 #include <boost/shared_ptr.hpp>
22 #include "gazebo/math/Pose.hh"
24 
29 namespace gazebo
30 {
31  namespace physics
32  {
33  class DARTPhysics;
34  class DARTModel;
35  class DARTLink;
36  class DARTJoint;
37  class DARTCollision;
38  class DARTRayShape;
39 
40  typedef boost::shared_ptr<DARTPhysics> DARTPhysicsPtr;
41  typedef boost::shared_ptr<DARTModel> DARTModelPtr;
42  typedef boost::shared_ptr<DARTLink> DARTLinkPtr;
43  typedef boost::shared_ptr<DARTJoint> DARTJointPtr;
44  typedef boost::shared_ptr<DARTCollision> DARTCollisionPtr;
45  typedef boost::shared_ptr<DARTRayShape> DARTRayShapePtr;
46 
49 
53  class DARTTypes
54  {
56  public: static Eigen::Vector3d ConvVec3(const math::Vector3 &_vec3)
57  {
58  return Eigen::Vector3d(_vec3.x, _vec3.y, _vec3.z);
59  }
60 
62  public: static math::Vector3 ConvVec3(const Eigen::Vector3d &_vec3)
63  {
64  return math::Vector3(_vec3.x(), _vec3.y(), _vec3.z());
65  }
66 
68  public: static Eigen::Quaterniond ConvQuat(const math::Quaternion &_quat)
69  {
70  return Eigen::Quaterniond(_quat.w, _quat.x, _quat.y, _quat.z);
71  }
72 
74  public: static math::Quaternion ConvQuat(const Eigen::Quaterniond &_quat)
75  {
76  return math::Quaternion(_quat.w(), _quat.x(), _quat.y(), _quat.z());
77  }
78 
80  public: static Eigen::Isometry3d ConvPose(const math::Pose &_pose)
81  {
82  // Below line doesn't work with 'libeigen3-dev is 3.0.5-1'
83  // return Eigen::Translation3d(ConvVec3(_pose.pos)) *
84  // ConvQuat(_pose.rot);
85 
86  Eigen::Isometry3d res;
87 
88  res.translation() = ConvVec3(_pose.pos);
89  res.linear() = Eigen::Matrix3d(ConvQuat(_pose.rot));
90 
91  return res;
92  }
93 
95  public: static math::Pose ConvPose(const Eigen::Isometry3d &_T)
96  {
97  math::Pose pose;
98  pose.pos = ConvVec3(_T.translation());
99  pose.rot = ConvQuat(Eigen::Quaterniond(_T.linear()));
100  return pose;
101  }
102  };
103  }
104 }
105 
106 #endif