segment.cpp 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /** \file itasc/kdl/segment.cpp
  2. * \ingroup itasc
  3. */
  4. // Version: 1.0
  5. // Author: Ruben Smits <ruben dot smits at mech dot kuleuven dot be>
  6. // Maintainer: Ruben Smits <ruben dot smits at mech dot kuleuven dot be>
  7. // URL: http://www.orocos.org/kdl
  8. // This library is free software; you can redistribute it and/or
  9. // modify it under the terms of the GNU Lesser General Public
  10. // License as published by the Free Software Foundation; either
  11. // version 2.1 of the License, or (at your option) any later version.
  12. // This library is distributed in the hope that it will be useful,
  13. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. // Lesser General Public License for more details.
  16. // You should have received a copy of the GNU Lesser General Public
  17. // License along with this library; if not, write to the Free Software
  18. // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  19. #include "segment.hpp"
  20. namespace KDL {
  21. Segment::Segment(const Joint& _joint, const Frame& _f_tip, const Inertia& _M):
  22. M(_M),joint(_joint),
  23. f_tip(_f_tip)
  24. {
  25. }
  26. Segment::Segment(const Segment& in):
  27. M(in.M),joint(in.joint),
  28. f_tip(in.f_tip)
  29. {
  30. }
  31. Segment& Segment::operator=(const Segment& arg)
  32. {
  33. joint=arg.joint;
  34. M=arg.M;
  35. f_tip=arg.f_tip;
  36. return *this;
  37. }
  38. Segment::~Segment()
  39. {
  40. }
  41. Frame Segment::pose(const double* q)const
  42. {
  43. return joint.pose(q)*f_tip;
  44. }
  45. Twist Segment::twist(const double* q, const double& qdot, int dof)const
  46. {
  47. return joint.twist(qdot, dof).RefPoint(pose(q).p);
  48. }
  49. Twist Segment::twist(const Vector& p, const double& qdot, int dof)const
  50. {
  51. return joint.twist(qdot, dof).RefPoint(p);
  52. }
  53. Twist Segment::twist(const Frame& f, const double& qdot, int dof)const
  54. {
  55. return (f.M*joint.twist(qdot, dof)).RefPoint(f.p);
  56. }
  57. }//end of namespace KDL