ROBOOP, A Robotics Object Oriented Package in C++
trajectory.h
Go to the documentation of this file.
1 /*
2 Copyright (C) 2002-2004 Etienne Lachance
3 
4 This library is free software; you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8 
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13 
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 
18 
19 Report problems and direct all questions to:
20 
21 email: etienne.lachance@polymtl.ca or richard.gourdeau@polymtl.ca
22 
23 Reference:
24 
25 [1] J. Angeles, Fundamentals of Robotic Mechanical Systems: Theory, Methods and Algorithms,
26  Springer-Verlag, Mechanical Engineering Series, 1997, ISBN: 0-387-94540-7.
27 
28 [2] E.B. Dam, M. Koch and M. Lillholm, "Quaternions, Interpolation and Animation",
29  tech report of University of Copenhagen, number: DIKU-TR-98/5, 1998.
30 
31 -------------------------------------------------------------------------------
32 Revision_history:
33 
34 2004/05/22: Etienne Lachance
35  -Added class Trajectory_Select.
36 
37 2004/07/01: Etienne Lachance
38  -Added doxygen documentation.
39 
40 2004/07/01: Ethan Tira-Thompson
41  -Added support for newmat's use_namespace #define, using ROBOOP namespace
42 
43 2005/11/06: Etienne Lachance
44  - No need to provide a copy constructor and the assignment operator
45  (operator=) for Spl_Quaternion, Spl_Cubic and Spl_path classes. Instead we
46  use the one provide by the compiler.
47 -------------------------------------------------------------------------------
48 */
49 
50 
51 #ifndef TRAJECTORY_H
52 #define TRAJECTORY_H
53 
59 #ifdef _MSC_VER // Microsoft
60 //#include <string.h>
61 //#include <iostream.h>
62 #pragma warning (disable:4786) /* Disable decorated name truncation warnings */
63 #endif
64 //#include <string>
65 //#include <iostream>
66 
67 //#include <fstream>
68 #include <sstream>
69 #include <map>
70 #include "quaternion.h"
71 #include "utils.h"
72 
73 #ifdef use_namespace
74 namespace ROBOOP {
75  using namespace NEWMAT;
76 #endif
77 
78 #define K_ZER0 1
79 #define BAD_DATA -1
80 #define EXTRAPOLLATION -2
81 #define NOT_IN_RANGE -3
82 
87 class Spl_cubic
88 {
89 public:
90  Spl_cubic(){};
91  Spl_cubic(const Matrix & pts);
92  short interpolating(const Real t, ColumnVector & s);
93  short first_derivative(const Real t, ColumnVector & ds);
94  short second_derivative(const Real t, ColumnVector & dds);
95 private:
96  int nb_path;
97  Matrix
98  Ak, Bk, Ck, Dk;
99  RowVector tk;
100  bool bad_data;
101 };
102 
103 
104 #define NONE 0
105 #define JOINT_SPACE 1
106 #define CARTESIAN_SPACE 2
107 
109 typedef std::map< Real, ColumnVector, less< Real > > point_map;
110 
111 
116 class Spl_path : public Spl_cubic
117 {
118 public:
119  Spl_path():Spl_cubic(){};
120  Spl_path(const std::string & filename);
121  Spl_path(const Matrix & x);
122  short p(const Real time, ColumnVector & p);
123  short p_pdot(const Real time, ColumnVector & p, ColumnVector & pdot);
124  short p_pdot_pddot(const Real time, ColumnVector & p, ColumnVector & pdot,
125  ColumnVector & pdotdot);
126  short get_type(){ return type; }
127  double get_final_time(){ return final_time; }
128 
129 private:
130  short type;
131  double final_time;
132 };
133 
134 
136 typedef std::map< Real, Quaternion, less< Real > > quat_map;
137 
138 
144 {
145 public:
146  Spl_Quaternion(){}
147  Spl_Quaternion(const std::string & filename);
148  Spl_Quaternion(const quat_map & quat);
149  short quat(const Real t, Quaternion & s);
150  short quat_w(const Real t, Quaternion & s, ColumnVector & w);
151 private:
153 };
154 
155 
161 {
162 public:
164  Trajectory_Select(const std::string & filename);
165  Trajectory_Select & operator=(const Trajectory_Select & x);
166 
167  void set_trajectory(const std::string & filename);
168 
169  short type;
172 private:
174 };
175 
176 #ifdef use_namespace
177 }
178 #endif
179 
180 #endif