DARTTypes.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 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 #ifndef GAZEBO_PHYSICS_DART_DARTTYPES_HH_
18 #define GAZEBO_PHYSICS_DART_DARTTYPES_HH_
19 
20 #include <boost/shared_ptr.hpp>
21 #include <ignition/math/Pose3.hh>
22 #include <ignition/math/Quaternion.hh>
23 #include <ignition/math/Vector3.hh>
24 
25 #include "gazebo/common/Assert.hh"
27 #include "gazebo/util/system.hh"
28 
33 namespace gazebo
34 {
35  namespace physics
36  {
37  class DARTPhysics;
38  class DARTModel;
39  class DARTLink;
40  class DARTJoint;
41  class DARTCollision;
42  class DARTRayShape;
44 
45  typedef boost::shared_ptr<DARTPhysics> DARTPhysicsPtr;
46  typedef boost::shared_ptr<DARTModel> DARTModelPtr;
47  typedef boost::shared_ptr<DARTLink> DARTLinkPtr;
48  typedef boost::shared_ptr<DARTJoint> DARTJointPtr;
49  typedef boost::shared_ptr<DARTCollision> DARTCollisionPtr;
50  typedef boost::shared_ptr<DARTRayShape> DARTRayShapePtr;
51  typedef boost::shared_ptr<DARTSurfaceParams> DARTSurfaceParamsPtr;
52 
53  using DARTBodyNodePropPtr =
54  std::shared_ptr<dart::dynamics::BodyNode::Properties>;
55  using DARTJointPropPtr =
56  std::shared_ptr<dart::dynamics::Joint::Properties>;
57 
60 
64  class GZ_PHYSICS_VISIBLE DARTTypes
65  {
69  public: static Eigen::Vector3d ConvVec3(
70  const ignition::math::Vector3d &_vec3)
71  {
72  return Eigen::Vector3d(_vec3.X(), _vec3.Y(), _vec3.Z());
73  }
74 
78  public: static ignition::math::Vector3d ConvVec3Ign(
79  const Eigen::Vector3d &_vec3)
80  {
81  return ignition::math::Vector3d(_vec3.x(), _vec3.y(), _vec3.z());
82  }
83 
87  public: static Eigen::Quaterniond ConvQuat(
88  const ignition::math::Quaterniond &_quat)
89  {
90  return Eigen::Quaterniond(_quat.W(), _quat.X(), _quat.Y(), _quat.Z());
91  }
92 
96  public: static ignition::math::Quaterniond ConvQuatIgn(
97  const Eigen::Quaterniond &_quat)
98  {
99  return ignition::math::Quaterniond(
100  _quat.w(), _quat.x(), _quat.y(), _quat.z());
101  }
102 
104  public: static Eigen::Isometry3d ConvPose(
105  const ignition::math::Pose3d &_pose)
106  {
107  // Below line doesn't work with 'libeigen3-dev is 3.0.5-1'
108  // return Eigen::Translation3d(ConvVec3(_pose.pos)) *
109  // ConvQuat(_pose.rot);
110 
111  Eigen::Isometry3d res = Eigen::Isometry3d::Identity();
112 
113  res.translation() = ConvVec3(_pose.Pos());
114  res.linear() = Eigen::Matrix3d(ConvQuat(_pose.Rot()));
115 
116  return res;
117  }
118 
122  public: static ignition::math::Pose3d ConvPoseIgn(
123  const Eigen::Isometry3d &_T)
124  {
125  ignition::math::Pose3d pose;
126  pose.Pos() = ConvVec3Ign(_T.translation());
127  pose.Rot() = ConvQuatIgn(Eigen::Quaterniond(_T.linear()));
128  return pose;
129  }
130 
137  public: static double InvertThreadPitch(double _pitch)
138  {
139  GZ_ASSERT(std::abs(_pitch) > 0.0,
140  "Zero thread pitch is not allowed.\n");
141 
142  return -2.0 * M_PI / _pitch;
143  }
144  };
145  }
146 }
147 
148 #endif
boost::shared_ptr< DARTJoint > DARTJointPtr
Definition: DARTTypes.hh:48
static ignition::math::Quaterniond ConvQuatIgn(const Eigen::Quaterniond &_quat)
Convert eigen quaternion to ignition quaternion.
Definition: DARTTypes.hh:96
#define GZ_ASSERT(_expr, _msg)
This macro define the standard way of launching an exception inside gazebo.
Definition: Assert.hh:24
static Eigen::Quaterniond ConvQuat(const ignition::math::Quaterniond &_quat)
Convert ignition quaternion to eigen quaternion.
Definition: DARTTypes.hh:87
Forward declarations for the common classes.
Definition: Animation.hh:26
static Eigen::Isometry3d ConvPose(const ignition::math::Pose3d &_pose)
Definition: DARTTypes.hh:104
boost::shared_ptr< DARTModel > DARTModelPtr
Definition: DARTTypes.hh:46
static double InvertThreadPitch(double _pitch)
Invert thread pitch to match the different definitions of thread pitch in Gazebo and DART...
Definition: DARTTypes.hh:137
static ignition::math::Vector3d ConvVec3Ign(const Eigen::Vector3d &_vec3)
Convert eigen vector3d to ignition math vector3d.
Definition: DARTTypes.hh:78
DART surface parameters.
Definition: DARTSurfaceParams.hh:38
boost::shared_ptr< DARTLink > DARTLinkPtr
Definition: DARTTypes.hh:47
static Eigen::Vector3d ConvVec3(const ignition::math::Vector3d &_vec3)
Convert ignition math vector3d to eigen vector3d.
Definition: DARTTypes.hh:69
boost::shared_ptr< DARTRayShape > DARTRayShapePtr
Definition: DARTTypes.hh:50
boost::shared_ptr< DARTPhysics > DARTPhysicsPtr
Definition: DARTTypes.hh:43
std::shared_ptr< dart::dynamics::BodyNode::Properties > DARTBodyNodePropPtr
Definition: DARTTypes.hh:54
std::shared_ptr< dart::dynamics::Joint::Properties > DARTJointPropPtr
Definition: DARTTypes.hh:56
boost::shared_ptr< DARTCollision > DARTCollisionPtr
Definition: DARTTypes.hh:49
boost::shared_ptr< DARTSurfaceParams > DARTSurfaceParamsPtr
Definition: DARTTypes.hh:51
static ignition::math::Pose3d ConvPoseIgn(const Eigen::Isometry3d &_T)
Convert eigen iosmetry3d to ignition math pose3d.
Definition: DARTTypes.hh:122
A set of functions for converting between the math types used by gazebo and dart. ...
Definition: DARTTypes.hh:64