se2ez
frame.h
Go to the documentation of this file.
1 /* Author: Zachary Kingston */
2 
3 #ifndef SE2EZ_CORE_FRAME_
4 #define SE2EZ_CORE_FRAME_
5 
6 #include <vector>
7 
8 #include <Eigen/Core>
9 #include <Eigen/Geometry>
10 
11 #include <kdl/frames.hpp>
12 #include <kdl/segment.hpp>
13 
15 #include <se2ez/core/math.h>
16 #include <se2ez/core/joint.h>
17 
18 namespace se2ez
19 {
20  /** \cond IGNORE */
21  SE2EZ_CLASS_FORWARD(Geometry)
22  /** \endcond */
23 
24  /** \cond IGNORE */
25  SE2EZ_CLASS_FORWARD(Frame)
26  /** \endcond */
27 
28  /** \class se2ez::FramePtr
29  \brief A shared pointer wrapper for se2ez::Frame. */
30 
31  /** \class se2ez::FrameConstPtr
32  \brief A const shared pointer wrapper for se2ez::Frame. */
33 
34  /** \brief Representation of a single frame (possibly with a joint) in a kinematic tree.
35  */
36  class Frame
37  {
38  public:
40 
41  static FramePtr getRoot();
42 
43  /** \name Constructors
44  \{ */
45 
46  /** \brief Constuctor. Builds a fixed frame at the desired location.
47  * \param[in] name Name of frame.
48  * \param[in] tip Transform to apply after joint transform to reach the tip of the frame.
49  * \param[in] geometry All attached geometry to this frame.
50  */
51  Frame(const std::string &name, const Eigen::Isometry2d &tip,
52  const std::vector<GeometryPtr> &geometry = {});
53 
54  /** \brief Constuctor. Builds a fixed frame at the desired location.
55  * \param[in] name Name of frame.
56  * \param[in] tip Transform to apply after joint transform to reach the tip of the frame.
57  * \param[in] geometry All attached geometry to this frame.
58  */
59  Frame(const std::string &name, const Eigen::Vector3d &tip, const std::vector<GeometryPtr> &geometry);
60 
61  /** \brief Constuctor. Builds the segments that compose a frame along with its internal joints.
62  * \param[in] name Name of frame.
63  * \param[in] tip Transform to apply after joint transform to reach the tip of the frame.
64  * \param[in] type Joint type of frame.
65  * \param[in] upper Upper limits of frame joint.
66  * \param[in] lower Lower limits of frame joint.
67  * \param[in] geometry All attached geometry to this frame.
68  */
69  Frame(const std::string &name, const Eigen::Isometry2d &tip, const Joint::Type &type,
70  const Eigen::VectorXd &lower = {}, const Eigen::VectorXd &upper = {},
71  const std::vector<GeometryPtr> &geometry = {});
72 
73  /** \brief Constuctor. Builds the segments that compose a frame along with its internal joints.
74  * \param[in] name Name of frame.
75  * \param[in] tip Transform to apply after joint transform to reach the tip of the frame.
76  * \param[in] type Joint type of frame.
77  * \param[in] lower Lower limits of frame joint.
78  * \param[in] upper Upper limits of frame joint.
79  * \param[in] geometry All attached geometry to this frame.
80  */
81  Frame(const std::string &name, const Eigen::Vector3d &tip, const Joint::Type &type,
82  const Eigen::VectorXd &lower = {}, const Eigen::VectorXd &upper = {},
83  const std::vector<GeometryPtr> &geometry = {});
84 
85  /** \brief Constuctor. Builds the segments that compose a frame along with its internal joints.
86  * \param[in] name Name of frame.
87  * \param[in] tip Transform to apply after joint transform to reach the tip of the frame.
88  * \param[in] type Joint type of frame.
89  * \param[in] lower Lower limits of frame joint.
90  * \param[in] upper Upper limits of frame joint.
91  * \param[in] geometry All attached geometry to this frame.
92  */
93  Frame(const std::string &name, const Eigen::Isometry2d &tip, const Joint::Type &type,
94  const double lower, const double upper, const std::vector<GeometryPtr> &geometry = {});
95 
96  /** \brief Constuctor. Builds the segments that compose a frame along with its internal joints.
97  * \param[in] name Name of frame.
98  * \param[in] tip Transform to apply after joint transform to reach the tip of the frame.
99  * \param[in] type Joint type of frame.
100  * \param[in] lower Lower limits of frame joint.
101  * \param[in] upper Upper limits of frame joint.
102  * \param[in] geometry All attached geometry to this frame.
103  */
104  Frame(const std::string &name, const Eigen::Vector3d &tip, const Joint::Type &type,
105  const double lower, const double upper, const std::vector<GeometryPtr> &geometry = {});
106 
107  // non-copyable
108  Frame(const Frame &) = delete;
109  Frame(Frame &&) = delete;
110 
111  /** \} */
112 
113  /** \name Getters and Setters
114  \{ */
115 
116  /** \brief Get the name of this frame.
117  * \return The name of the frame.
118  */
119  const std::string &getName() const;
120 
121  /** \brief Get the segments that compose this frame.
122  * \return A vector of the underlying segments.
123  */
124  const std::vector<KDL::Segment> &getSegments() const;
125 
126  /** \brief Get the geometries attached to this frame.
127  * \return A vector of the attached geometries.
128  */
129  const std::vector<GeometryPtr> &getGeometry() const;
130 
131  /** \brief Get the joint within this frame.
132  * \return The joint within the frame.
133  */
134  const Joint &getJoint() const;
135 
136  /** \brief Get the tip of this frame.
137  * \return The tip of this frame.
138  */
139  const Eigen::Isometry2d &getTip() const;
140 
141  /** \} */
142 
143  /** \name Geometric and Configuration Operations
144  \{ */
145 
146  /** \brief Gets the pose of this frame (respect to the root) given a configuration q (for
147  * this frame only, e.g., for the floating joint a three dimensional vector)
148  * \param[in] q The configuration for this frame. \return The pose of this frame.
149  */
150  Eigen::Isometry2d getPose(const Eigen::Ref<const Eigen::VectorXd> &q) const;
151 
152  /** \brief Get the poses of each of the attached geometry frames (in order).
153  * \param[in] pose The pose of the frame.
154  * \param[out] poses Geometry poses.
155  */
156  void getGeometryPoses(const Eigen::Isometry2d &pose, tf::EigenVector<Eigen::Isometry2d> &poses) const;
157 
158  /** \} */
159 
160  /** \name Informative
161  \{ */
162 
163  /** \brief Print debug information about this frame.
164  * \return A string of information about the frame.
165  */
166  std::string printDebug() const;
167 
168  /** \} */
169 
170  private:
171  /** \name Frame Properties
172  \{ */
173 
174  const std::string name_; ///< Name of the frame.
175  const Eigen::Isometry2d tip_; ///< The transform after joint transformation to the tip of the frame.
176  const Joint joint_; ///< The joint associated with the frame.
177 
178  const std::vector<GeometryPtr> geometry_; ///< Geometry attached to this frame (at the tip).
179  const std::vector<KDL::Segment> segments_; ///< Underlying segments that compose this frame.
180 
181  /* \} */
182  };
183 } // namespace se2ez
184 
185 #endif
const std::vector< GeometryPtr > geometry_
Geometry attached to this frame (at the tip).
Definition: frame.h:178
Type
Type of joint.
Definition: joint.h:38
const std::vector< KDL::Segment > segments_
Underlying segments that compose this frame.
Definition: frame.h:179
Container class that stores the underlying joint representation. Can represent basic joints within th...
Definition: joint.h:31
A shared pointer wrapper for se2ez::Frame.
const std::string name_
Name of the frame.
Definition: frame.h:174
#define SE2EZ_EIGEN_CLASS
Definition: class_forward.h:14
const Joint joint_
The joint associated with the frame.
Definition: frame.h:176
Representation of a single frame (possibly with a joint) in a kinematic tree.
Definition: frame.h:36
Main namespace.
Definition: collision.h:11
#define SE2EZ_CLASS_FORWARD(C)
Definition: class_forward.h:9
const Eigen::Isometry2d tip_
The transform after joint transformation to the tip of the frame.
Definition: frame.h:175