ISeeML  1.0
DubinsLikePath.hpp
1 //
2 // Definition of iSeeML::rob::DubinsLikePath, superclass
3 // of every ISeeML robotic paths similar
4 // to @ref iSeeML::rob::DubinsPath "Dubins paths".
5 //
6 
7 // To only include this definition once
8 #ifndef ISEEML_DUBINS_LIKE_PATH_HH
9 #define ISEEML_DUBINS_LIKE_PATH_HH
10 
11 
12 // This class needs the definition of iSeeML::rob::CompPath.
13 #include <iSeeML/rob/CompoundPath.hpp>
14 // This class needs the definition of iSeeML::rob::LinCurvPath.
15 #include <iSeeML/rob/LinCurvPath.hpp>
16 
17 
34 {
35 
36  // === Inner Type Definitions ===================================
37 public:
47  enum Type {
49  lsl,
51  lsr,
53  rsl,
55  rsr,
57  lrl,
59  rlr };
60 
62  enum {
67 
68 private:
69  // === Object's Fields ==========================================
70 
75  static const string ClassName;
76 
77 
82  int NbPieces;
84  iSeeML::rob::LinCurvPath *LcPieces;
85 
86  Type PathType;
87 
89  double MaximumCurvature;
90 
91 protected:
92  // === Constructors and Destructor ==============================
93 
102  DubinsLikePath(const Type& type, const double& maxCurv) :
103  NbPieces(0), LcPieces(NULL), PathType(type),
104  MaximumCurvature(fabs(maxCurv)) {}
105 
113  NbPieces(0), LcPieces(NULL) { *this = other; }
114 
115 
120  ~DubinsLikePath() { if (LcPieces != NULL) delete[] LcPieces; }
121 
122 
123  // === Description Methods ======================================
124 
145  static int turnSign(const int number, const Type& type) {
146  static int values[3][nbPossiblePaths] =
147  { {1, 1, -1, -1, 1, -1}, {0, 0, 0, 0, -1, 1},
148  {1, -1, 1, -1, 1, -1} };
149 #ifdef ISEEML_CHECK_DLIKE_PATH_PRECOND
150  if ( (number < 1) || (number > 3) )
151  cerr << ClassName << "::turnSign: abnormal number "
152  << number << endl;
153 #endif
154  const int nb =
155 #ifdef ISEEML_CHECK_ARRAY_ELEMT
156  number < 1 ? 0 : (number > 3) ? 2 :
157 #endif
158  number - 1;
159  return(values[nb][(int) type]); } // end of int turnSign(...)
160 
161 
162 public:
163  // cf. CompoundPath
164  int nbPieces() const { return NbPieces; }
165 
171  const Type& type() const { return PathType; }
172 
177  const double& maxCurv() const { return MaximumCurvature; }
178 
179 
194  const iSeeML::rob::LinCurvPath& lcPiece(const int index) const {
195  return( *((LinCurvPath*) &( piece(index) )) ); }
196 
197 
207  virtual double turnRadius() const = 0;
208 
209 
210 protected:
218  virtual int turnNbPieces(const double& length) const = 0;
219 
220 
240  virtual bool getConnection(const double& dist, double& length,
241  double& angle) const = 0;
242 
243 
244  // === Modification Methods =====================================
245 
260  iSeeML::rob::LinCurvPath& lcPiece(const int index) {
261  return( *((LinCurvPath*) &( piece(index) )) ); }
262 
263 private:
283  void reset(const int newNbPieces,
284  const iSeeML::rob::LinCurvPath& stdPath) {
285  // cout << this << "->DLP::reset(" << newNbPieces << ")..." << endl;
286  // free previous LinCurvPath array
287  if (LcPieces != NULL) delete[] LcPieces;
288 #ifdef ISEEML_CHECK_DLIKE_PATH_PRECOND
289  if (newNbPieces < 0)
290  cerr << ClassName << "::reset: negative nb of pieces,"
291  << endl << " considered as zero!" << endl;
292 #endif
293  NbPieces = newNbPieces > 0 ? newNbPieces : 0;
294  if (NbPieces) {
295  LcPieces = new LinCurvPath[NbPieces];
296 #ifdef ISEEML_CHECK_NULL_POINTER
297  if (LcPieces == NULL) {
298  cerr << ClassName << "reset: out of memory!!!" << endl;
299  exit(-1); }
300 #endif
301  ISEEML_ROB_COMPATH_forall_pieces(i) lcPiece(i) = stdPath; }
302  else
303  LcPieces = NULL; }
304 
305 
336  void definePieces(const iSeeML::rob::OrPtConfig& start,
337  const iSeeML::rob::OrPtConfig& goal,
338  const iSeeML::geom::Point
339  centers[nbTurningCircles]);
340 protected:
352  void setNoPiece(const iSeeML::rob::OrPtConfig& start) {
354  (start, 0), 0, 0) ); }
355 
386  void definePieces(const iSeeML::rob::OrPtConfig& start,
387  const double& defl1, const double& lenDefl,
388  const double& defl3);
389 
390 
417  virtual void addTurn(int& index,
418  const iSeeML::rob::OrPtConfig **start,
419  const double& defl) = 0;
420 
437  void addPiece(int& index, const iSeeML::rob::CurvConfig& start,
438  const double& curvDeriv, const double& length) {
439  // add the new piece and change next piece's index
440  lcPiece(++index) = LinCurvPath( start, curvDeriv,
441  fabs(length) ); }
442 
443 public:
454  void connect(const iSeeML::rob::OrPtConfig& start,
455  const iSeeML::rob::OrPtConfig& goal);
456 
457 
458  // === Operators ================================================
459 
472  NbPieces = other.nbPieces(); PathType = other.type();
473  // free previous LinCurvPath array
474  if (LcPieces != NULL) delete[] LcPieces;
475  if (NbPieces) {
476  LcPieces = new LinCurvPath[NbPieces];
477 #ifdef ISEEML_CHECK_NULL_POINTER
478  if (LcPieces == NULL) {
479  cerr << ClassName << "operator=: out of memory!!!"
480  << endl; exit(-1); }
481 #endif
482  ISEEML_ROB_COMPATH_forall_pieces(i)
483  lcPiece(i) = other.lcPiece(i); }
484  else
485  LcPieces = NULL;
486  MaximumCurvature = other.maxCurv(); return *this; }
487 
488 
489  // === Various Methods ==========================================
490 
504  virtual void computeCenters(const iSeeML::rob::OrPtConfig& start,
505  const iSeeML::rob::OrPtConfig& goal,
507  centers[nbTurningCircles]) const
508  = 0;
509 
510 protected:
511  // cf. CompoundPath
512  iSeeML::rob::BasicPath& _piece(const int index) const {
513  // cout << this << "->DLP::_piece(" << index << ")" << endl;
514  return LcPieces[index - 1]; }
515 
516 
523  virtual DubinsLikePath* connectArray() const = 0;
524 
549  virtual DubinsLikePath&
550  getSolution(DubinsLikePath* paths, const int index) const = 0;
551 
552 private:
566  int bestPathIndex(DubinsLikePath* paths) const {
567  // Compare lsl and lsr paths and get the shortest's index
568  bool test =
569  getSolution(paths, lsl) < getSolution(paths, lsr);
570  const int ls = test ? lsl : lsr;
571  // Compare rsl and rsr pathss and get the shortest's index
572  test = getSolution(paths, rsl) < getSolution(paths, rsr);
573  const int rs = test ? rsl : rsr;
574  // Compare lrl and rlr pathss and get the shortest's index
575  test = getSolution(paths, lrl) < getSolution(paths, rlr);
576  const int ccc = test ? lrl : rlr;
577  // Compare ls* and rs* pathss and get the shortest's index
578  test = getSolution(paths, ls) < getSolution(paths, rs);
579  const int csc = test ? ls : rs;
580  // get the index of the shortest between all
581  test = getSolution(paths, csc) < getSolution(paths, ccc);
582  const int best = test ? csc : ccc;
583  return best; } // end of int bestPathIndex(DubinsLikeArray&)
584 
585 }; // end of class iSeeML::rob::DubinsLikePath
586 
587 #endif // end of definition
588 
Type
Dubins-like paths can be of six types: their first and last parts are turns, their middle part is tan...
Definition: DubinsLikePath.hpp:47
This class defines Dubins like paths, which are similar to Dubins paths.
Definition: DubinsLikePath.hpp:33
This class defines compound (or complex, or composed) paths, which are made of a set of basic paths...
Definition: CompoundPath.hpp:28
DubinsLikePath(const DubinsLikePath &other)
The copy constructor (the default one is not correct).
Definition: DubinsLikePath.hpp:112
This class defines superclass of basic paths, from which compound paths can be built.
Definition: BasicPath.hpp:21
const iSeeML::rob::OrPtConfig & start() const
Description method, giving the path&#39;s starting configuration (first piece&#39;s starting configuration)...
Definition: CompoundPath.hpp:79
Path made of a left turn, a straight line and a right turn.
Definition: DubinsLikePath.hpp:51
iSeeML::rob::LinCurvPath & lcPiece(const int index)
Modification method, returning for modification the (linear curvature) piece of the path with a given...
Definition: DubinsLikePath.hpp:260
const iSeeML::rob::LinCurvPath & lcPiece(const int index) const
Description method, returning the (linear curvature) piece of the path with a given index...
Definition: DubinsLikePath.hpp:194
This class defines linear curvature elementary paths, for which the curvature derivative (with respec...
Definition: LinCurvPath.hpp:27
Path made of a right turn, a straight line and a right turn.
Definition: DubinsLikePath.hpp:55
Path made of a left turn, a right turn and a left turn.
Definition: DubinsLikePath.hpp:57
Path made of a right turn, a straight line and a left turn.
Definition: DubinsLikePath.hpp:53
void connect(const iSeeML::rob::OrPtConfig &start, const iSeeML::rob::OrPtConfig &goal)
Modification method, defining type and pieces of a Dubins&#39; like path in order to connect two given co...
virtual double turnRadius() const =0
Description method, giving the radius of the turning circle (the circle of all the configurations whi...
~DubinsLikePath()
The destructor (the default one is not correct).
Definition: DubinsLikePath.hpp:120
This class defines a standard robotic configuration, containing the position of a reference point and...
Definition: OrPtConfig.hpp:45
static int turnSign(const int number, const Type &type)
Description method, giving the sign (1 for left, -1 for right, 0 for a segment) of the turn or segmen...
Definition: DubinsLikePath.hpp:145
virtual void computeCenters(const iSeeML::rob::OrPtConfig &start, const iSeeML::rob::OrPtConfig &goal, iSeeML::geom::Point centers[nbTurningCircles]) const =0
Various method, computing the set of circle centers used to turn from starting configuration of the c...
virtual DubinsLikePath & getSolution(DubinsLikePath *paths, const int index) const =0
Various method, getting in an array of Dubins-like paths the element of given index.
void addPiece(int &index, const iSeeML::rob::CurvConfig &start, const double &curvDeriv, const double &length)
Modification method, adding to the pieces of a path a piece starting at a given configuration (with c...
Definition: DubinsLikePath.hpp:437
virtual DubinsLikePath * connectArray() const =0
Various method, returning an array of nbPossiblePaths Dubins-like paths, initialised as clones of the...
virtual void addTurn(int &index, const iSeeML::rob::OrPtConfig **start, const double &defl)=0
Modification method, adding to the pieces of a path a turn starting at a given configuration, with a given curvature sign and length.
virtual int turnNbPieces(const double &length) const =0
Description method, computing the number of pieces needed for a turn of given length.
Path made of a right turn, a left turn and a right turn.
Definition: DubinsLikePath.hpp:59
Path made of a left turn, a straight line and a left turn.
Definition: DubinsLikePath.hpp:49
double length() const
Description method, giving the path&#39;s length (sum of the pieces&#39; length).
Definition: CompoundPath.hpp:126
This class defines 2D geometric points, defined by their Cartesian coordinates.
Definition: Point.hpp:29
DubinsLikePath(const Type &type, const double &maxCurv)
The structure can be filled using this constructor, which is protected (only defined for sub-classes)...
Definition: DubinsLikePath.hpp:102
iSeeML::rob::BasicPath & _piece(const int index) const
Virtual method returning the basic path of given index in the list of which this compound path is mad...
Definition: DubinsLikePath.hpp:512
the number of possible paths (6).
Definition: DubinsLikePath.hpp:64
virtual bool getConnection(const double &dist, double &length, double &angle) const =0
Description method, trying to compute the length of the line segment connecting the turning circles a...
const double & maxCurv() const
Description method, giving the path&#39;s maximum curvature.
Definition: DubinsLikePath.hpp:177
const Type & type() const
Description method, giving the path&#39;s type (from lsl to rlr).
Definition: DubinsLikePath.hpp:171
int nbPieces() const
Description method, giving the number of pieces of the path.
Definition: DubinsLikePath.hpp:164
This class defines a more precise configuration than classical ones for mobile robots.
Definition: CurvConfig.hpp:30
the number of usefull turning circles (4).
Definition: DubinsLikePath.hpp:66
DubinsLikePath & operator=(const DubinsLikePath &other)
Copy operator (default one is not correct).
Definition: DubinsLikePath.hpp:471
void setNoPiece(const iSeeML::rob::OrPtConfig &start)
Modification method, setting pieces of a non-valid Dubins&#39; like path from a starting configuration (p...
Definition: DubinsLikePath.hpp:352
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