orocos_kdl
velocityprofile_dirac.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  tag: Peter Soetens Mon May 10 19:10:36 CEST 2004 velocityprofile_dirac.cxx
3 
4  velocityprofile_dirac.cxx - description
5  -------------------
6  begin : Mon May 10 2004
7  copyright : (C) 2004 Peter Soetens
8  email : peter.soetens@mech.kuleuven.ac.be
9 
10  ***************************************************************************
11  * This library is free software; you can redistribute it and/or *
12  * modify it under the terms of the GNU Lesser General Public *
13  * License as published by the Free Software Foundation; either *
14  * version 2.1 of the License, or (at your option) any later version. *
15  * *
16  * This library is distributed in the hope that it will be useful, *
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
19  * Lesser General Public License for more details. *
20  * *
21  * You should have received a copy of the GNU Lesser General Public *
22  * License along with this library; if not, write to the Free Software *
23  * Foundation, Inc., 59 Temple Place, *
24  * Suite 330, Boston, MA 02111-1307 USA *
25  * *
26  ***************************************************************************/
27 
28 #include "utilities/error.h"
30 
31 namespace KDL {
32 
33 
35  double pos1,
36  double pos2
37  )
38  {
39  p1 = pos1;
40  p2 = pos2;
41  t = 0;
42  }
43 
45  SetProfileDuration(double pos1,double pos2,double duration)
46  {
47  SetProfile(pos1,pos2);
48  t = duration;
49  }
50 
51  double VelocityProfile_Dirac::Duration() const {
52  return t;
53  }
54 
55  double VelocityProfile_Dirac::Pos(double time) const {
56  if ( t == 0 ) {
57  return time <= 0 ? p1 : p2;
58  } else if (time < 0) {
59  return p1;
60  } else if (time <= t) {
61  return p1 + (( p2 - p1)/t)*time;
62  } else {
63  return p2;
64  }
65  }
66 
67  double VelocityProfile_Dirac::Vel(double time) const {
68  if ( t == 0 )
69  {
71  }
72  else
73  if ( 0 < time && time < t )
74  return (p2-p1) / t;
75  return 0;
76  }
77 
78  double VelocityProfile_Dirac::Acc(double time) const {
80  return 0;
81  }
82 
83 
85  os << "DIRACVEL[ ]";
86  }
87 
88 
89 
90 }
91 
KDL::VelocityProfile_Dirac::Duration
virtual double Duration() const
Definition: velocityprofile_dirac.cpp:76
velocityprofile_dirac.hpp
KDL::VelocityProfile_Dirac::Write
virtual void Write(std::ostream &os) const
Definition: velocityprofile_dirac.cpp:109
KDL
Definition: kukaLWR_DHnew.cpp:25
std::ostream
KDL::VelocityProfile_Dirac::Acc
virtual double Acc(double time) const
Definition: velocityprofile_dirac.cpp:103
KDL::VelocityProfile_Dirac::p2
double p2
Definition: velocityprofile_dirac.hpp:100
KDL::VelocityProfile_Dirac::SetProfileDuration
virtual void SetProfileDuration(double pos1, double pos2, double duration)
Definition: velocityprofile_dirac.cpp:70
error.h
KDL::VelocityProfile_Dirac::t
double t
Definition: velocityprofile_dirac.hpp:100
KDL::VelocityProfile_Dirac::Pos
virtual double Pos(double time) const
Definition: velocityprofile_dirac.cpp:80
KDL::Error_MotionPlanning_Incompatible
Definition: error.h:216
KDL::VelocityProfile_Dirac::Vel
virtual double Vel(double time) const
Definition: velocityprofile_dirac.cpp:92
KDL::VelocityProfile_Dirac::SetProfile
void SetProfile(double pos1, double pos2)
Definition: velocityprofile_dirac.cpp:59
std::time
T time(T... args)
KDL::VelocityProfile_Dirac::p1
double p1
Definition: velocityprofile_dirac.hpp:100