segment.hpp 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. // Copyright (C) 2007 Ruben Smits <ruben dot smits at mech dot kuleuven dot be>
  2. // Version: 1.0
  3. // Author: Ruben Smits <ruben dot smits at mech dot kuleuven dot be>
  4. // Maintainer: Ruben Smits <ruben dot smits at mech dot kuleuven dot be>
  5. // URL: http://www.orocos.org/kdl
  6. // This library is free software; you can redistribute it and/or
  7. // modify it under the terms of the GNU Lesser General Public
  8. // License as published by the Free Software Foundation; either
  9. // version 2.1 of the License, or (at your option) any later version.
  10. // This library is distributed in the hope that it will be useful,
  11. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. // Lesser General Public License for more details.
  14. // You should have received a copy of the GNU Lesser General Public
  15. // License along with this library; if not, write to the Free Software
  16. // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  17. #ifndef KDL_SEGMENT_HPP
  18. #define KDL_SEGMENT_HPP
  19. #include "frames.hpp"
  20. #include "inertia.hpp"
  21. #include "joint.hpp"
  22. #include <vector>
  23. namespace KDL {
  24. /**
  25. * \brief This class encapsulates a simple segment, that is a "rigid
  26. * body" (i.e., a frame and an inertia) with a joint and with
  27. * "handles", root and tip to connect to other segments.
  28. *
  29. * A simple segment is described by the following properties :
  30. * - Joint
  31. * - inertia: of the rigid body part of the Segment
  32. * - Offset from the end of the joint to the tip of the segment:
  33. * the joint is located at the root of the segment.
  34. *
  35. * @ingroup KinematicFamily
  36. */
  37. class Segment {
  38. friend class Chain;
  39. private:
  40. Inertia M;
  41. Joint joint;
  42. Frame f_tip;
  43. public:
  44. /**
  45. * Constructor of the segment
  46. *
  47. * @param joint joint of the segment, default:
  48. * Joint(Joint::None)
  49. * @param f_tip frame from the end of the joint to the tip of
  50. * the segment, default: Frame::Identity()
  51. * @param M rigid body inertia of the segment, default: Inertia::Zero()
  52. */
  53. Segment(const Joint& joint=Joint(), const Frame& f_tip=Frame::Identity(),const Inertia& M = Inertia::Zero());
  54. Segment(const Segment& in);
  55. Segment& operator=(const Segment& arg);
  56. virtual ~Segment();
  57. /**
  58. * Request the pose of the segment, given the joint position q.
  59. *
  60. * @param q 1D position of the joint
  61. *
  62. * @return pose from the root to the tip of the segment
  63. */
  64. Frame pose(const double* q)const;
  65. /**
  66. * Request the 6D-velocity of the tip of the segment, given
  67. * the joint position q and the joint velocity qdot.
  68. *
  69. * @param q ND position of the joint
  70. * @param qdot ND velocity of the joint
  71. *
  72. * @return 6D-velocity of the tip of the segment, expressed
  73. *in the base-frame of the segment(root) and with the tip of
  74. *the segment as reference point.
  75. */
  76. Twist twist(const double* q,const double& qdot, int dof=0)const;
  77. /**
  78. * Request the 6D-velocity at a given point p, relative to base frame of the segment
  79. * givven the joint velocity qdot.
  80. *
  81. * @param p reference point
  82. * @param qdot ND velocity of the joint
  83. *
  84. * @return 6D-velocity at a given point p, expressed
  85. * in the base-frame of the segment(root)
  86. */
  87. Twist twist(const Vector& p, const double& qdot, int dof=0)const;
  88. /**
  89. * Request the 6D-velocity at a given frame origin, relative to base frame of the segment
  90. * assuming the frame rotation is the rotation of the joint.
  91. *
  92. * @param f joint pose frame + reference point
  93. * @param qdot ND velocity of the joint
  94. *
  95. * @return 6D-velocity at frame reference point, expressed
  96. * in the base-frame of the segment(root)
  97. */
  98. Twist twist(const Frame& f, const double& qdot, int dof)const;
  99. /**
  100. * Request the joint of the segment
  101. *
  102. *
  103. * @return const reference to the joint of the segment
  104. */
  105. const Joint& getJoint()const
  106. {
  107. return joint;
  108. }
  109. /**
  110. * Request the inertia of the segment
  111. *
  112. *
  113. * @return const reference to the inertia of the segment
  114. */
  115. const Inertia& getInertia()const
  116. {
  117. return M;
  118. }
  119. /**
  120. * Request the pose from the joint end to the tip of the
  121. *segment.
  122. *
  123. * @return const reference to the joint end - segment tip pose.
  124. */
  125. const Frame& getFrameToTip()const
  126. {
  127. return f_tip;
  128. }
  129. };
  130. }//end of namespace KDL
  131. #endif