Main MRPT website > C++ reference
MRPT logo
TMotions.h
Go to the documentation of this file.
1 /* +---------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2015, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +---------------------------------------------------------------------------+ */
9 
10 #pragma once
11 
13 
14 namespace mrpt
15 {
16  namespace nav
17  {
18  /** This class contains motions and motions tree structures for the hybrid navigation algorithm
19  *
20  * <b>Usage:</b><br>
21  * \note: this class inheredit mrpt::graphs::CDirectedTree, please refer to inheritance for detail about generic tree methods
22  *
23  * - initialize a motions tree using .initializeMoveTree()
24  * - addEdge (from, to)
25  * - add here more instructions
26  *
27  * <b>About the algorithm:</b><br>
28  *
29  *
30  * <b>Changes history</b>
31  * - 06/MAR/2014: Creation (MB)
32  * \ingroup mrpt_nav_grp
33  */
34 
35  template<class MOVE_TYPE>
36  class TMoveTree : public mrpt::graphs::CDirectedTree<MOVE_TYPE>
37  {
38  public:
39 
40  // This is how to insert an edge from ROOT to CHILDREN:
41  const static mrpt::utils::TNodeID id_root = 0; //!< set ID of the root node always 0
42  mrpt::utils::TNodeID id_child; //!< child id will change according to the parent level
43  bool reverse_; //!< flag for forward of backward tree exploration - default = false i.e. forward
44  bool treeInitialized; //!< flag for checking if the tree is correctly initialized
45  typename TMoveTree::TListEdges my_list_of_edges; //!< structure for the list of edges
46 
47  //methods we need here are:
48 
49  /** Initialize variables and the list of edges for the tree*/
51  {
52  my_list_of_edges = this->edges_to_children[0]; //0 is id_root but it
53  /**DOESN'T COMPILE with [id_root], why? */
54  // the error during test.cpp linking after compilation is:
55  // undefined reference to `mrpt::nav::TMoveTree<mrpt::nav::TMoveSE2>::id_root'
56 
57  id_child = 1; //!< just initialize the id_child as the first after the root
58  reverse_ = false;
59 
60  treeInitialized = true;
61  //if something wrong treeInitialized = false; //TODO
62  return treeInitialized;
63  }
64 
65  /** this allow the user to set the reverse mode in the tree - false as default*/
66  inline void setReverse (bool _reverse) { reverse_=_reverse; }
67 
68  //----> VERIFY THIS !!!!!!!!
69  //I want to hide the tree structure to the user that only should add the node by a addNode function, so i defined:
70  /** addEdge (from, to) have to be implemented in the following way:
71  * IN-> from MOVE_TYPE parent_ to MOVE_TYPE new_motion
72  *
73  * inside this method a search method have to be called to find the TNodeID of parent_ (tree_depth_level)
74  * then new_motion will be added at the next level of parent_
75  *
76  * \note please call initializeMoveTree first
77  */
78  void addEdge ( const MOVE_TYPE &parent_, const MOVE_TYPE &new_motion )
79  {
80  ASSERTMSG_(treeInitialized == true, "The tree is not initialized!")
81 
82  id_child = searchIDinTree(parent_);
83  typename TMoveTree::TEdgeInfo my_edge (id_child, reverse_, new_motion );
84  my_list_of_edges.push_back(my_edge);
85  // something is still missing with id_child I can know what level in the tree
86  // but maybe more edges at the same level exist and they may came from different directions
87  // I still have doubts about how adjiacencies are implemented
88  }
89 
90  /** return the Node_ID of a specific motion.
91  * \note: Node_ID corresponds to the depth of the tree for a specific edge
92  */
93  TNodeID searchIDinTree (const MOVE_TYPE & mov) //TMove_ is parent
94  {
95  id_child = 1; // This have to be always >=1
96  // it will calculated by a search function
97  //write me!!
98  MRPT_TODO ("WRITE searchIDinTree function, here of in CDirectedTree.h?")
99  return id_child;
100  }
101 
102  /** return the TEdgeInfo of the nearest neighbor to a specific motion.
103  * \note: is this better to go into CDirectedTree.h ?
104  */
105  TNodeID getNearestMove(const MOVE_TYPE &TMove_) //think about what to return here
106  {
107  //write me !!!
108  MRPT_TODO ("WRITE getNearestMove function, here of in CDirectedTree.h?")
109  return 0;
110  }
111 
112  };
113 
114  /** @name TMoveSE2 class for planning in SE2 */
115  class TMoveSE2
116  {
117  public:
118  TMoveSE2 ( mrpt::poses::TPose2D POSE_) :
119  state( POSE_ ), //!< should the state be initialized as NULL or something else?
120  cost( 0.0 )
121  {}
122  mrpt::poses::TPose2D state; //!< state in SE2 as 2D pose (x, y, phi) - \note: it is not possible to initialize a motion without a state
123  double cost; //!< cost associated to each motion, this should be defined by the user according to a spefic cost function
124  };
125 
126  /** @name TMoveSE3 class for planning in SE3 */
127  class TMoveSE3
128  {
129  public:
130  TMoveSE3( mrpt::poses::TPose3D POSE_ ) :
131  state( POSE_ ),
132  cost( 0.0 )
133  {}
134  mrpt::poses::TPose3D state; //!< state in SE3 as 3D pose (x, y, z, yaw, pitch, roll) - \note: it is not possible to initialize a motion without a state
135  double cost; //!< cost associated to each motion, this should be defined by the user according to a spefic cost function
136  };
137 
138  /** @name TMoveSE2_TP class for planning in SE2 and TP-space */
140  {
141  public:
142  TMoveSE2_TP ( mrpt::poses::TPose2D POSE_ ) :
143  state( POSE_ ),
144  cost( 0.0 ),
145  ptg_index ( 0 ), ptg_K ( 0 ), ptg_dist ( 0.0 ) //these are all PTGs parameters, do we need more?
146  {}
147  mrpt::poses::TPose2D state; //!< state in SE2 as 2D pose (x, y, phi) - \note: it is not possible to initialize a motion without a state
148  double cost; //!< cost associated to each motion, this should be defined by the user according to a spefic cost function
149  int ptg_index; //!< indicate the type of trajectory used for this motion
150  int ptg_K; //!< identify the trajectory number K of the type ptg_index
151  double ptg_dist; //!< identify the lenght of the trajectory for this motion
152  };
153 
154 
155  typedef TMoveTree<TMoveSE2> TMoveTreeSE2; //!< tree datastructure for planning RRT in SE2
156  typedef TMoveTree<TMoveSE3> TMoveTreeSE3; //!< tree datastructure for planning RRT in SE3
157  typedef TMoveTree<TMoveSE2_TP> TMoveTreeSE2_TP; //!< tree datastructure for planning RRT in SE2 with TP-space
158 
159  }
160 }
bool initializeMoveTree()
Initialize variables and the list of edges for the tree.
Definition: TMotions.h:50
mrpt::poses::TPose2D state
state in SE2 as 2D pose (x, y, phi) -
Definition: TMotions.h:122
TMapNode2ListEdges edges_to_children
The edges of each node.
Definition: CDirectedTree.h:69
mrpt::poses::TPose2D state
state in SE2 as 2D pose (x, y, phi) -
Definition: TMotions.h:147
< Make available this typedef in this namespace too
Definition: CDirectedTree.h:50
void addEdge(const MOVE_TYPE &parent_, const MOVE_TYPE &new_motion)
addEdge (from, to) have to be implemented in the following way: IN-> from MOVE_TYPE parent_ to MOVE_T...
Definition: TMotions.h:78
mrpt::utils::TNodeID id_child
child id will change according to the parent level
Definition: TMotions.h:42
TNodeID searchIDinTree(const MOVE_TYPE &mov)
return the Node_ID of a specific motion.
Definition: TMotions.h:93
uint64_t TNodeID
The type for node IDs in graphs of different types.
Definition: types_simple.h:39
TMoveTree< TMoveSE2_TP > TMoveTreeSE2_TP
tree datastructure for planning RRT in SE2 with TP-space
Definition: TMotions.h:157
TMoveSE2_TP(mrpt::poses::TPose2D POSE_)
Definition: TMotions.h:142
#define MRPT_TODO(x)
TMoveTree< TMoveSE3 > TMoveTreeSE3
tree datastructure for planning RRT in SE3
Definition: TMotions.h:156
This class contains motions and motions tree structures for the hybrid navigation algorithm...
Definition: TMotions.h:36
double ptg_dist
identify the lenght of the trajectory for this motion
Definition: TMotions.h:151
int ptg_index
indicate the type of trajectory used for this motion
Definition: TMotions.h:149
mrpt::poses::TPose3D state
state in SE3 as 3D pose (x, y, z, yaw, pitch, roll) -
Definition: TMotions.h:134
TMoveSE2(mrpt::poses::TPose2D POSE_)
Definition: TMotions.h:118
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
static const mrpt::utils::TNodeID id_root
set ID of the root node always 0
Definition: TMotions.h:41
uint64_t TNodeID
The type for node IDs in graphs of different types.
TMoveSE3(mrpt::poses::TPose3D POSE_)
Definition: TMotions.h:130
double cost
cost associated to each motion, this should be defined by the user according to a spefic cost functio...
Definition: TMotions.h:135
void setReverse(bool _reverse)
this allow the user to set the reverse mode in the tree - false as default
Definition: TMotions.h:66
int ptg_K
identify the trajectory number K of the type ptg_index
Definition: TMotions.h:150
TMoveTree< TMoveSE2 > TMoveTreeSE2
tree datastructure for planning RRT in SE2
Definition: TMotions.h:155
TNodeID getNearestMove(const MOVE_TYPE &TMove_)
return the TEdgeInfo of the nearest neighbor to a specific motion.
Definition: TMotions.h:105
bool reverse_
flag for forward of backward tree exploration - default = false i.e. forward
Definition: TMotions.h:43
double cost
cost associated to each motion, this should be defined by the user according to a spefic cost functio...
Definition: TMotions.h:123
#define ASSERTMSG_(f, __ERROR_MSG)
TMoveTree::TListEdges my_list_of_edges
structure for the list of edges
Definition: TMotions.h:45
double cost
cost associated to each motion, this should be defined by the user according to a spefic cost functio...
Definition: TMotions.h:148
bool treeInitialized
flag for checking if the tree is correctly initialized
Definition: TMotions.h:44



Page generated by Doxygen 1.8.9.1 for MRPT 1.3.0 SVN: at Sun Sep 13 03:55:12 UTC 2015