Gazebo Physics

API Reference

5.3.2
gz/physics/Geometry.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2018 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 GZ_PHYSICS_GEOMETRY_HH_
19 #define GZ_PHYSICS_GEOMETRY_HH_
20 
21 #include <Eigen/Geometry>
22 
23 #define DETAIL_IGN_PHYSICS_MAKE_BOTH_PRECISIONS(Type, Dim) \
24  using Type ## Dim ## d = Type<double, Dim>; \
25  using Type ## Dim ## f = Type<float, Dim>;
26 
32 #define IGN_PHYSICS_MAKE_ALL_TYPE_COMBOS(Type) \
33  DETAIL_IGN_PHYSICS_MAKE_BOTH_PRECISIONS(Type, 2) \
34  DETAIL_IGN_PHYSICS_MAKE_BOTH_PRECISIONS(Type, 3)
35 
36 namespace ignition
37 {
38  namespace physics
39  {
43  template <typename Scalar, std::size_t Dim>
44  using Pose = Eigen::Transform<Scalar, Dim, Eigen::Isometry>;
46 
47  template <typename Scalar, std::size_t Dim>
48  using Vector = Eigen::Matrix<Scalar, Dim, 1>;
50 
51  template <typename Scalar, std::size_t Dim>
54 
55  template <typename Scalar, std::size_t Dim>
56  using AngularVector = Vector<Scalar, (Dim*(Dim-1))/2>;
58 
59  template <typename Scalar, std::size_t Dim>
60  struct Wrench
61  {
64  };
66 
67  template <typename Scalar, std::size_t Dim>
68  using AlignedBox = Eigen::AlignedBox<Scalar, Dim>;
70 
71 
72  template <typename PolicyT>
77  struct FromPolicy
78  {
79  using Scalar = typename PolicyT::Scalar;
80  enum { Dim = PolicyT::Dim };
81 
82  template<template <typename, std::size_t> class Type>
83  using Use = Type<Scalar, Dim>;
84  };
85 
86  template<typename Scalar>
87  Eigen::Rotation2D<Scalar> Rotate(
88  const Scalar &_angle,
89  const AngularVector<Scalar, 2> &_axis)
90  {
91  return Eigen::Rotation2D<Scalar>(_angle*_axis[0]);
92  }
93 
94  template <typename Scalar>
95  Eigen::AngleAxis<Scalar> Rotate(
96  const Scalar &_angle,
97  const AngularVector<Scalar, 3> &_axis)
98  {
99  return Eigen::AngleAxis<Scalar>(_angle, _axis);
100  }
101  }
102 }
103 
104 #endif
This struct is used to conveniently convert from a policy to a geometric type. Example usage:
Definition: gz/physics/Geometry.hh:77
Eigen::AlignedBox< Scalar, Dim > AlignedBox
Definition: gz/physics/Geometry.hh:68
typename PolicyT::Scalar Scalar
Definition: gz/physics/Geometry.hh:79
Eigen::Matrix< Scalar, Dim, 1 > Vector
Definition: gz/physics/Geometry.hh:48
@ Dim
Definition: gz/physics/Geometry.hh:80
Type< Scalar, Dim > Use
Definition: gz/physics/Geometry.hh:83
AngularVector< Scalar, Dim > torque
Definition: gz/physics/Geometry.hh:62
Vector< Scalar, Dim > LinearVector
Definition: gz/physics/Geometry.hh:52
Eigen::Transform< Scalar, Dim, Eigen::Isometry > Pose
This is used by ignition-physics to represent rigid body transforms in 2D or 3D simulations....
Definition: gz/physics/Geometry.hh:44
Eigen::Rotation2D< Scalar > Rotate(const Scalar &_angle, const AngularVector< Scalar, 2 > &_axis)
Definition: gz/physics/Geometry.hh:87
LinearVector< Scalar, Dim > force
Definition: gz/physics/Geometry.hh:63
IGN_PHYSICS_MAKE_ALL_TYPE_COMBOS(FrameData) template< typename Scalar
Definition: gz/physics/Geometry.hh:60
Vector< Scalar,(Dim *(Dim-1))/2 > AngularVector
Definition: gz/physics/Geometry.hh:56