ISeeML  1.0
All Classes Namespaces Files Functions Variables Enumerations Enumerator Friends Modules Pages
CompoundPath.hpp
1 //
2 // Definition of iSeeML::rob::CompoundPath, superclass of every
3 // other ISeeML compound/complex/composed robotic paths' class.
4 //
5 
6 // To only include this definition once
7 #ifndef ISEEML_COMP_PATH_HH
8 #define ISEEML_COMP_PATH_HH
9 
10 
11 // This class needs the definition of iSeeML::rob::CurvConfig.
12 #include <iSeeML/rob/CurvConfig.hpp>
13 // This class needs the definition of iSeeML::rob::BasicPath.
14 #include <iSeeML/rob/BasicPath.hpp>
15 
29  // === Object's Fields ==========================================
30 
31  // The set of basic paths is defined in sub-class, and is
32  // manipulated through piece and replace virtual methods, as well
33  // as through copy operator.
34 
39  static const string ClassName;
40 
41 
42  // === Constructors and Destructors =============================
43 
44  // None, this is an abstract class with no object's fields.
45 
46 public:
47  // === Description Methods ======================================
48 
54 #define ISEEML_ROB_COMPATH_forall_pieces(i) \
55  int i; for(i = 1; i <= nbPieces(); i++)
56 
67  void writeTo(ostream& O) const {
68  O << '{'; ISEEML_ROB_COMPATH_forall_pieces(i)
69  O << piece(i) << (i == nbPieces() ? "}" : ", "); }
70 
71 
79  const iSeeML::rob::OrPtConfig& start() const { return piece(1).start(); }
80 
88  const iSeeML::rob::OrPtConfig& end() const
89  { return piece( nbPieces() ).end(); }
90 
91 
114  const iSeeML::rob::BasicPath& piece(const int index) const {
115  // cout << this << "->CP::piece(" << index << ") const" << endl;
116  return getPiece(index); }
117 
118 
126  double length() const {
127  double res = 0;
128  ISEEML_ROB_COMPATH_forall_pieces(i)
129  res += piece(i).length();
130  return res;
131  }
132 
140  double deflection() const {
141  double res = 0;
142  ISEEML_ROB_COMPATH_forall_pieces(i)
143  res += piece(i).deflection();
144  return res;
145  }
146 
151  virtual int nbPieces() const = 0;
152 
153  // === Modification Methods =====================================
154 
172  iSeeML::rob::BasicPath& piece(const int index) {
173  // cout << this << "->CP::piece(" << index << ")" << endl;
174  return getPiece(index); }
175 
176 
177  // === Operators ================================================
178 
197  iSeeML::rob::CurvConfig operator[](const double& s) const {
198  int pieceNb = 1; // Start from the first piece
199  double arcLength = s, l = piece(pieceNb).length();
200 #ifdef ISEEML_CHECK_COMP_PATH_PRECOND
201  if (s < 0) cerr << ClassName << "::operator[]:"
202  << " negative arc length " << s << endl;
203 #endif
204  // Search the piece corresponding to the arc length
205  while (arcLength > l)
206 #ifdef ISEEML_CHECK_COMP_PATH_PRECOND
207  if ( pieceNb == nbPieces() )
208  cerr << ClassName << "::operator[]:"
209  << " arc length " << s << endl
210  << " bigger than length " << length() << endl;
211  else
212 #endif
213  { arcLength -= l;
214 #ifdef ISEEML_CHECK_ARRAY_ELEMT
215  if ( pieceNb == nbPieces() ) l = arcLength; // stop
216  else
217 #endif
218  l = piece(++pieceNb).length(); }
219  // Return the configuration in the selected piece
220  return( piece(pieceNb)[arcLength] ); } // end of operator[]
221 
222 protected:
223  // === Various Methods ==========================================
224 
243  iSeeML::rob::BasicPath& getPiece(const int index) const {
244  // cout << this << "->CP::getPiece(" << index << ")" << endl;
245 #ifdef ISEEML_CHECK_COMP_PATH_PRECOND
246  if ( !nbPieces() )
247  cerr << ClassName << "::piece: no pieces!!!" << endl;
248  else if ( (index < 1) || ( index > nbPieces() ) )
249  cerr << ClassName << "::piece: abnormal index "
250  << index << ", not in 1.." << nbPieces() << endl;
251 #endif
252  const int nb =
253 #ifdef ISEEML_CHECK_ARRAY_ELEMT
254  index < 2 ? 1 : index >= nbPieces() ? nbPieces() :
255 #endif
256  index; return _piece(nb); }
257 
269  virtual iSeeML::rob::BasicPath& _piece(const int index) const = 0;
270 
271 }; // end of class iSeeML::rob::CompoundPath
272 
273 #endif // end of definition
274 
iSeeML::rob::Path
This class is the base class of all robotic paths in ISeeML.
Definition: Path.hpp:51
iSeeML::rob::CompoundPath::length
double length() const
Description method, giving the path's length (sum of the pieces' length).
Definition: CompoundPath.hpp:126
iSeeML::rob::CompoundPath::piece
const iSeeML::rob::BasicPath & piece(const int index) const
Description method, returning the (constant) basic path of given index in the list of which this comp...
Definition: CompoundPath.hpp:114
iSeeML::rob::CompoundPath::writeTo
void writeTo(ostream &O) const
Description method, writing a description of the path in a given output stream (the array of pieces i...
Definition: CompoundPath.hpp:67
iSeeML::rob::CurvConfig
This class defines a more precise configuration than classical ones for mobile robots.
Definition: CurvConfig.hpp:30
iSeeML::rob::CompoundPath::operator[]
iSeeML::rob::CurvConfig operator[](const double &s) const
Description method, giving a configuration at a given arc length along the path.
Definition: CompoundPath.hpp:197
iSeeML::rob::Path::deflection
virtual double deflection() const =0
Description method, giving the path's deflection (change of orientation).
iSeeML::rob::OrPtConfig
This class defines a standard robotic configuration, containing the position of a reference point and...
Definition: OrPtConfig.hpp:45
iSeeML::rob::Path::length
virtual double length() const =0
Description method, giving the path's length.
iSeeML::rob::CompoundPath::piece
iSeeML::rob::BasicPath & piece(const int index)
Modification method, returning (for modification) the basic path of given index in the list of which ...
Definition: CompoundPath.hpp:172
iSeeML::rob::CompoundPath::deflection
double deflection() const
Description method, giving the path's deflection (sum of the pieces' deflection).
Definition: CompoundPath.hpp:140
iSeeML::rob::Path::start
virtual const iSeeML::rob::OrPtConfig & start() const =0
Description method, giving the path's starting configuration.
iSeeML::rob::CompoundPath::start
const iSeeML::rob::OrPtConfig & start() const
Description method, giving the path's starting configuration (first piece's starting configuration).
Definition: CompoundPath.hpp:79
iSeeML::rob::CompoundPath::_piece
virtual iSeeML::rob::BasicPath & _piece(const int index) const =0
Virtual method returning the basic path of given index in the list of which this compound path is mad...
iSeeML::rob::Path::end
virtual const iSeeML::rob::OrPtConfig & end() const =0
Description method, giving the path's final configuration.
iSeeML::rob::BasicPath
This class defines superclass of basic paths, from which compound paths can be built.
Definition: BasicPath.hpp:21
iSeeML::rob::CompoundPath::nbPieces
virtual int nbPieces() const =0
Description method, giving the number of pieces of the path.
iSeeML::rob::CompoundPath::end
const iSeeML::rob::OrPtConfig & end() const
Description method, giving the path's final configuration (last piece's starting configuration).
Definition: CompoundPath.hpp:88
iSeeML::rob::CompoundPath::getPiece
iSeeML::rob::BasicPath & getPiece(const int index) const
Method returning the basic path of given index in the list of which this compound path is made.
Definition: CompoundPath.hpp:243
iSeeML::rob::CompoundPath
This class defines compound (or complex, or composed) paths, which are made of a set of basic paths.
Definition: CompoundPath.hpp:28