pinocchio  2.7.0
A fast and flexible implementation of Rigid Body Dynamics algorithms and their analytical derivatives
frame.hpp
1 //
2 // Copyright (c) 2016-2021 CNRS INRIA
3 //
4 
5 #ifndef __pinocchio_frame_hpp__
6 #define __pinocchio_frame_hpp__
7 
8 #include "pinocchio/spatial/se3.hpp"
9 #include "pinocchio/spatial/inertia.hpp"
10 #include "pinocchio/multibody/fwd.hpp"
11 
12 #include <string>
13 
14 namespace pinocchio
15 {
28  enum FrameType
29  {
30  OP_FRAME = 0x1 << 0,
31  JOINT = 0x1 << 1,
32  FIXED_JOINT = 0x1 << 2,
33  BODY = 0x1 << 3,
34  SENSOR = 0x1 << 4
35  };
36 
40  template<typename _Scalar, int _Options>
41  struct FrameTpl
42  {
43  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
44  typedef pinocchio::JointIndex JointIndex;
45  enum { Options = _Options };
46  typedef _Scalar Scalar;
49 
54  : name()
55  , parent()
56  , placement()
57  , type()
58  , inertia(Inertia::Zero())
59  {} // needed by std::vector
60 
71  FrameTpl(const std::string & name,
72  const JointIndex parent,
73  const FrameIndex previousFrame,
74  const SE3 & frame_placement,
75  const FrameType type,
76  const Inertia & inertia = Inertia::Zero())
77  : name(name)
78  , parent(parent)
80  , placement(frame_placement)
81  , type(type)
82  , inertia(inertia)
83  {}
84 
92  template<typename S2, int O2>
93  bool operator == (const FrameTpl<S2,O2> & other) const
94  {
95  return name == other.name
96  && parent == other.parent
97  && previousFrame == other.previousFrame
98  && placement == other.placement
99  && type == other.type
100  && inertia == other.inertia;
101  }
102 
106  template<typename S2, int O2>
107  bool operator != (const FrameTpl<S2,O2> & other) const
108  {
109  return !(*this == other);
110  }
111 
113  template<typename NewScalar>
115  {
116  typedef FrameTpl<NewScalar,Options> ReturnType;
117  ReturnType res(name,
118  parent,
120  placement.template cast<NewScalar>(),
121  type,
122  inertia.template cast<NewScalar>());
123  return res;
124  }
125 
126  // data
127 
129  std::string name;
130 
132  JointIndex parent;
133 
135  FrameIndex previousFrame;
136 
139 
142 
147 
148  }; // struct FrameTpl
149 
150  template<typename Scalar, int Options>
151  inline std::ostream & operator << (std::ostream& os,
152  const FrameTpl<Scalar,Options> & f)
153  {
154  os
155  << "Frame name: "
156  << f.name
157  << " paired to (parent joint/ previous frame)"
158  << "(" << f.parent << "/" << f.previousFrame << ")"
159  << std::endl
160  << "with relative placement wrt parent joint:\n"
161  << f.placement
162  << "containing inertia:\n"
163  << f.inertia
164  << std::endl;
165 
166  return os;
167  }
168 
169 } // namespace pinocchio
170 
171 #endif // ifndef __pinocchio_frame_hpp__
pinocchio::FrameTpl::type
FrameType type
Type of the frame.
Definition: frame.hpp:141
pinocchio::JOINT
@ JOINT
joint frame: attached to the child body of a joint (a.k.a. child frame)
Definition: frame.hpp:31
pinocchio::FrameTpl::FrameTpl
FrameTpl()
Default constructor of a frame.
Definition: frame.hpp:53
pinocchio::SE3Tpl< Scalar, Options >
pinocchio::FrameTpl::inertia
Inertia inertia
Inertia information attached to the frame. This inertia will be appended to the inertia supported by ...
Definition: frame.hpp:146
pinocchio::FIXED_JOINT
@ FIXED_JOINT
fixed joint frame: joint frame but for a fixed joint
Definition: frame.hpp:32
pinocchio::BODY
@ BODY
body frame: attached to the collision, inertial or visual properties of a link
Definition: frame.hpp:33
pinocchio::SENSOR
@ SENSOR
sensor frame: defined in a sensor element
Definition: frame.hpp:34
pinocchio::FrameTpl::FrameTpl
FrameTpl(const std::string &name, const JointIndex parent, const FrameIndex previousFrame, const SE3 &frame_placement, const FrameType type, const Inertia &inertia=Inertia::Zero())
Builds a frame defined by its name, its joint parent id, its placement and its type.
Definition: frame.hpp:71
pinocchio::FrameTpl
A Plucker coordinate frame attached to a parent joint inside a kinematic tree.
Definition: frame.hpp:41
pinocchio::OP_FRAME
@ OP_FRAME
operational frame: user-defined frames that are defined at runtime
Definition: frame.hpp:30
pinocchio::FrameTpl::operator==
bool operator==(const FrameTpl< S2, O2 > &other) const
Equality comparison operator.
Definition: frame.hpp:93
pinocchio::FrameTpl::placement
SE3 placement
Placement of the frame wrt the parent joint.
Definition: frame.hpp:138
pinocchio::FrameTpl::parent
JointIndex parent
Index of the parent joint.
Definition: frame.hpp:132
pinocchio::FrameTpl::cast
FrameTpl< NewScalar, Options > cast() const
Definition: frame.hpp:114
pinocchio::FrameTpl::name
std::string name
Name of the frame.
Definition: frame.hpp:129
pinocchio::InertiaTpl< Scalar, Options >
pinocchio::FrameTpl::previousFrame
FrameIndex previousFrame
Index of the previous frame.
Definition: frame.hpp:135
pinocchio::FrameType
FrameType
Enum on the possible types of frames.
Definition: frame.hpp:28
pinocchio::FrameTpl::operator!=
bool operator!=(const FrameTpl< S2, O2 > &other) const
Definition: frame.hpp:107
pinocchio
Main pinocchio namespace.
Definition: treeview.dox:11