cisst-saw
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
osaTrajectory.h
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* ex: set filetype=cpp softtabstop=4 shiftwidth=4 tabstop=4 cindent expandtab: */
3 
4 /*
5  $Id: osaTrajectory.h 4202 2013-05-17 15:39:06Z adeguet1 $
6 
7  Author(s): Simon Leonard
8  Created on: 2012
9 
10  (C) Copyright 2012-2014 Johns Hopkins University (JHU), All Rights
11  Reserved.
12 
13 --- begin cisst license - do not edit ---
14 
15 This software is provided "as is" under an open source license, with
16 no warranty. The complete license can be found in license.txt and
17 http://www.cisst.org/cisst/license.txt.
18 
19 --- end cisst license ---
20 */
21 
22 
23 #ifndef _osaTrajectory_h
24 #define _osaTrajectory_h
25 
26 #include <cisstRobot/robFunction.h>
30 #include <list>
31 
33 
35 
36 public:
37 
38  enum Errno
39  {
46  EINVALID
47  };
48 
49 private:
50 
51  double currenttime;
53  robFunction* function;
54 
55  enum Space{ R3, RN, SO3, SE3 };
56 
57  // segment base class
58  class Segment{
59 
60  private:
61 
62  osaTrajectory::Space inspace;
63  osaTrajectory::Space outspace;
64 
65  protected:
66 
67  double duration;
68 
69  public:
70 
71  Segment( osaTrajectory::Space is, osaTrajectory::Space os ) :
72  inspace( is ),
73  outspace( os ),
74  duration( -1.0 ){}
75 
76  virtual ~Segment() {}
77 
78  virtual osaTrajectory::Space InputSpace() const { return inspace; }
79  virtual osaTrajectory::Space OutputSpace() const { return outspace; }
80 
81  };
82 
83 
84  std::list< osaTrajectory::Segment* > segments;
85  osaTrajectory::Errno LoadNextSegment();
86 
87 
88  // Inverse kinematics segment
89  class IKSegment : public Segment {
90 
91  private:
92 
93  vctFrame4x4<double> Rtstart;
94  vctFrame4x4<double> Rtfinal;
96  double v;
97  double w;
99  public:
100 
101  IKSegment( const vctFrame4x4<double>& Rts,
102  const vctFrame4x4<double>& Rtf,
103  double v, double w);
104 
106  vctFrame4x4<double> StateStart() const { return Rtstart; }
108  vctFrame4x4<double> StateFinal() const { return Rtfinal; }
109 
111  double VelocityLinear() const { return v; }
113  double VelocityAngular() const { return w; }
114 
115  }; // IK segment
116 
117 
118  // ZC: NOT USED ?
119  // Forward kinematics segment
120  class FKSegment : public Segment {
121 
122  private:
123 
126 
127  public:
128 
129  FKSegment( const vctDynamicVector<double>& qs,
130  const vctDynamicVector<double>& qf,
131  double ) :
132  Segment( osaTrajectory::SE3, osaTrajectory::RN ),
133  qstart( qs ),
134  qfinal( qf ){}
135 
137  vctDynamicVector<double> StateStart() const { return qstart; }
139  vctDynamicVector<double> StateFinal() const { return qfinal; }
140 
141  }; // FK segment
142 
143 
144  // Joint segment
145  class RnSegment : public Segment {
146 
147  private:
148 
149  vctDynamicVector<double> qstart;
150  vctDynamicVector<double> qfinal;
152  vctDoubleVec vel;
154  public:
155 
156  RnSegment( const vctDynamicVector<double>& qs,
157  const vctDynamicVector<double>& qf,
158  double );
159 
161  vctDynamicVector<double> StateStart() const { return qstart; }
163  vctDynamicVector<double> StateFinal() const { return qfinal; }
164 
166  vctDoubleVec VelocityJoint() const { return vel; }
167 
168  }; // Joint segment
169 
170 
171  double GetTime() const { return currenttime; }
172  void SetTime( double t ){ currenttime = t; }
173 
174  osaTrajectory::Errno PostProcess();
175 
176 public:
177 
178  osaTrajectory( const std::string& robotfilename,
179  const vctFrame4x4<double>& Rtw0,
180  const vctDynamicVector<double>& qinit );
181 
190  osaTrajectory::Errno InsertIK( const vctFrame4x4<double>& Rt2,
191  double vmax,
192  double wmax );
193 
194  osaTrajectory::Errno Insert( const vctFrame4x4<double>& Rt2, double dt );
195 
196  osaTrajectory::Errno Evaluate( double t,
199 
200  friend std::ostream& operator<<( std::ostream& os,
201  const osaTrajectory::Errno& e ){
202  switch( e ){
203  case osaTrajectory::ESUCCESS: os << "SUCCESS"; break;
204  case osaTrajectory::EPENDING: os << "EPENDING"; break;
205  case osaTrajectory::EEXPIRED: os << "EEXPIRED"; break;
206  case osaTrajectory::EEMPTY: os << "EEMPTY"; break;
207  case osaTrajectory::EUNSUPPORTED: os << "EUNSUPPORTED"; break;
208  case osaTrajectory::ETRANSITION: os << "ETRANSITION"; break;
209  case osaTrajectory::EINVALID: os << "EINVALID"; break;
210  }
211  return os;
212  }
213 
214 };
215 
216 #endif // _osaTrajectory_h
#define CISST_EXPORT
Definition: cmnExportMacros.h:50
Definition: robManipulator.h:34
Typedef for dynamic vectors.
Definition: osaTrajectory.h:45
Base class for robot function.
Definition: robFunction.h:31
Definition: osaTrajectory.h:40
Definition: osaTrajectory.h:41
Errno
Definition: osaTrajectory.h:38
Definition: osaTrajectory.h:34
Errno
Definition: robManipulator.h:43
friend std::ostream & operator<<(std::ostream &os, const osaTrajectory::Errno &e)
Definition: osaTrajectory.h:200
Definition: osaTrajectory.h:43
Declaration of vctFrame4x4.
Definition: osaTrajectory.h:46
Definition: osaTrajectory.h:44
Definition: osaTrajectory.h:42