chain.hpp 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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_CHAIN_HPP
  18. #define KDL_CHAIN_HPP
  19. #include "segment.hpp"
  20. #include <string>
  21. #include <Eigen/StdVector>
  22. namespace KDL {
  23. /**
  24. * \brief This class encapsulates a <strong>serial</strong> kinematic
  25. * interconnection structure. It is build out of segments.
  26. *
  27. * @ingroup KinematicFamily
  28. */
  29. class Chain {
  30. private:
  31. // Eigen allocator is needed for alignment of Eigen data types
  32. std::vector<Segment, Eigen::aligned_allocator<Segment> > segments;
  33. unsigned int nrOfJoints;
  34. unsigned int nrOfSegments;
  35. public:
  36. /**
  37. * The constructor of a chain, a new chain is always empty.
  38. *
  39. */
  40. Chain();
  41. Chain(const Chain& in);
  42. Chain& operator = (const Chain& arg);
  43. /**
  44. * Adds a new segment to the <strong>end</strong> of the chain.
  45. *
  46. * @param segment The segment to add
  47. */
  48. void addSegment(const Segment& segment);
  49. /**
  50. * Adds a complete chain to the <strong>end</strong> of the chain
  51. * The added chain is copied.
  52. *
  53. * @param chain The chain to add
  54. */
  55. void addChain(const Chain& chain);
  56. /**
  57. * Request the total number of joints in the chain.\n
  58. * <strong> Important:</strong> It is not the
  59. * same as the total number of segments since a segment does not
  60. * need to have a joint. This function is important when
  61. * creating a KDL::JntArray to use with this chain.
  62. * @return total nr of joints
  63. */
  64. unsigned int getNrOfJoints()const {return nrOfJoints;};
  65. /**
  66. * Request the total number of segments in the chain.
  67. * @return total number of segments
  68. */
  69. unsigned int getNrOfSegments()const {return nrOfSegments;};
  70. /**
  71. * Request the nr'd segment of the chain. There is no boundary
  72. * checking.
  73. *
  74. * @param nr the nr of the segment starting from 0
  75. *
  76. * @return a constant reference to the nr'd segment
  77. */
  78. const Segment& getSegment(unsigned int nr)const;
  79. virtual ~Chain();
  80. };
  81. }//end of namespace KDL
  82. #endif