Main MRPT website > C++ reference for MRPT 1.9.9
CActionCollection.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-2017, 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 #ifndef CActionCollection_H
10 #define CActionCollection_H
11 
12 #include <mrpt/obs/CAction.h>
17 
18 namespace mrpt
19 {
20 namespace obs
21 {
22 /** Declares a class for storing a collection of robot actions. It is used in
23  * mrpt::obs::CRawlog,
24  * for logs storage and particle filter based simulations.
25  *
26  * \sa CAction, CRawlog
27  * \ingroup mrpt_obs_grp
28  */
30 {
32 
33  protected:
34  /** The robot "actionss" */
35  std::deque<mrpt::utils::poly_ptr_ptr<CAction::Ptr>> m_actions;
36 
37  public:
38  /** ctor */
40  /** Constructor from a single action. */
42 
43  /** You can use CActionCollection::begin to get a iterator to the first
44  * element.
45  */
46  typedef std::deque<mrpt::utils::poly_ptr_ptr<CAction::Ptr>>::iterator
48 
49  /** You can use CActionCollection::begin to get a iterator to the first
50  * element.
51  */
52  typedef std::deque<mrpt::utils::poly_ptr_ptr<CAction::Ptr>>::const_iterator
54 
55  /** Returns a iterator to the first action: this is an example of usage:
56  * \code
57  * CActionCollection acts;
58  * ...
59  * for (CActionCollection::iterator it=acts.begin();it!=acts.end();++it)
60  * {
61  * (*it)->... // (*it) is a "CAction::Ptr"
62  * }
63  *
64  * \endcode
65  */
66  const_iterator begin() const { return m_actions.begin(); }
67  /** Returns a iterator to the first action: this is an example of usage:
68  * \code
69  * CActionCollection acts;
70  * ...
71  * for (CActionCollection::iterator it=acts.begin();it!=acts.end();++it)
72  * {
73  * (*it)->... // (*it) is a "CAction::Ptr"
74  * }
75  *
76  * \endcode
77  */
78  iterator begin() { return m_actions.begin(); }
79  /** Returns a iterator pointing to the end of the list: this is an example
80  *of usage:
81  * \code
82  * CActionCollection acts;
83  * ...
84  * for (CActionCollection::iterator it=acts.begin();it!=acts.end();++it)
85  * {
86  * (*it)->... // (*it) is a "CAction::Ptr"
87  * }
88  *
89  * \endcode
90  */
91  const_iterator end() const { return m_actions.end(); }
92  /** Returns a iterator pointing to the end of the list: this is an example
93  *of usage:
94  * \code
95  * CActionCollection acts;
96  * ...
97  * for (CActionCollection::iterator it=acts.begin();it!=acts.end();++it)
98  * {
99  * (*it)->... // (*it) is a "CAction::Ptr"
100  * }
101  *
102  * \endcode
103  */
104  iterator end() { return m_actions.end(); }
105  /** Removes the given action in the list, and return an iterator to the next
106  * element (or this->end() if it was the last one).
107  */
108  iterator erase(const iterator& it);
109 
110  /** Erase all actions from the list.
111  */
112  void clear();
113 
114  /** Access the i'th action.DO NOT MODIFY the returned object, make a copy of
115  * ir with "CSerializable::duplicate" if desired.
116  * First element is 0.
117  * \exception std::exception On index out of bounds.
118  */
119  CAction::Ptr get(size_t index);
120  const CAction& get(size_t index) const;
121 
122  /** Access to the i'th action of a given class, or a nullptr smart pointer
123  if there is no action of that class in the list.
124  * Example:
125  * \code
126  CActionRobotMovement2D::Ptr obs =
127  acts->getActionByClass<CActionRobotMovement2D>();
128  * \endcode
129  * By default (ith=0), the first one is returned.
130  */
131  template <typename T>
132  typename T::Ptr getActionByClass(const size_t& ith = 0) const
133  {
134  MRPT_START
135  size_t foundCount = 0;
136  const mrpt::utils::TRuntimeClassId* class_ID = &T::GetRuntimeClassIdStatic();
137  for (const_iterator it = begin(); it != end(); ++it)
138  if ((*it)->GetRuntimeClass()->derivedFrom(class_ID))
139  if (foundCount++ == ith)
140  return std::dynamic_pointer_cast<T>(it->get_ptr());
141  return typename T::Ptr(); // Not found: return empty smart pointer
142  MRPT_END
143  }
144 
145  /** Add a new object to the list.
146  */
147  void insert(CAction& action);
148 
149  /** Returns the actions count in the collection.
150  */
151  size_t size();
152 
153  /** Returns the best pose increment estimator in the collection, based on
154  * the determinant of its pose change covariance matrix.
155  * \return The estimation, or nullptr if none is available.
156  */
158 
159  /** Returns the pose increment estimator in the collection having the
160  * specified type.
161  * \return The estimation, or nullptr if none is available.
162  */
165 
166  /** Look for the first 2D or 3D "odometry" found in this collection of
167  * actions, and return the "mean" increment of the robot according to it.
168  * \return true on success,false on no odometry found.
169  */
171  mrpt::poses::CPose3D& out_pose_increment) const;
172 
173  /** Look for the first 2D or 3D "odometry" found in this collection of
174  * actions, and return the "mean" increment of the robot and its covariance
175  * according to it.
176  * \return true on success,false on no odometry found.
177  */
179  mrpt::poses::CPose3DPDFGaussian& out_pose_increment) const;
180 
181  /** Remove an action from the list by its index.
182  * \exception std::exception On index out of bounds.
183  */
184  void eraseByIndex(const size_t& index);
185 
186 }; // End of class def.
187 
188 } // End of namespace
189 } // End of namespace
190 
191 #endif
iterator begin()
Returns a iterator to the first action: this is an example of usage:
bool getFirstMovementEstimationMean(mrpt::poses::CPose3D &out_pose_increment) const
Look for the first 2D or 3D "odometry" found in this collection of actions, and return the "mean" inc...
The virtual base class which provides a unified interface for all persistent objects in MRPT...
Definition: CSerializable.h:44
const_iterator end() const
Returns a iterator pointing to the end of the list: this is an example of usage:
Scalar * iterator
Definition: eigen_plugins.h:26
std::deque< mrpt::utils::poly_ptr_ptr< CAction::Ptr > > m_actions
The robot "actionss".
CActionRobotMovement2D::Ptr getMovementEstimationByType(CActionRobotMovement2D::TEstimationMethod method)
Returns the pose increment estimator in the collection having the specified type. ...
Declares a class for storing a collection of robot actions.
#define MRPT_END
std::shared_ptr< CActionRobotMovement2D > Ptr
CActionRobotMovement2D::Ptr getBestMovementEstimation() const
Returns the best pose increment estimator in the collection, based on the determinant of its pose cha...
GLuint index
Definition: glext.h:4054
std::shared_ptr< CAction > Ptr
Definition: CAction.h:30
void clear()
Erase all actions from the list.
std::deque< mrpt::utils::poly_ptr_ptr< CAction::Ptr > >::iterator iterator
You can use CActionCollection::begin to get a iterator to the first element.
TEstimationMethod
A list of posible ways for estimating the content of a CActionRobotMovement2D object.
iterator erase(const iterator &it)
Removes the given action in the list, and return an iterator to the next element (or this->end() if i...
Declares a class for storing a robot action.
Definition: CAction.h:28
#define MRPT_START
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
#define DEFINE_SERIALIZABLE(class_name)
This declaration must be inserted in all CSerializable classes definition, within the class declarati...
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:88
iterator end()
Returns a iterator pointing to the end of the list: this is an example of usage:
Declares a class that represents a Probability Density function (PDF) of a 3D pose ...
size_t size()
Returns the actions count in the collection.
std::deque< mrpt::utils::poly_ptr_ptr< CAction::Ptr > >::const_iterator const_iterator
You can use CActionCollection::begin to get a iterator to the first element.
T::Ptr getActionByClass(const size_t &ith=0) const
Access to the i&#39;th action of a given class, or a nullptr smart pointer if there is no action of that ...
A structure that holds runtime class type information.
Definition: CObject.h:31
void eraseByIndex(const size_t &index)
Remove an action from the list by its index.
GLubyte GLubyte GLubyte a
Definition: glext.h:6279
const_iterator begin() const
Returns a iterator to the first action: this is an example of usage:
bool getFirstMovementEstimation(mrpt::poses::CPose3DPDFGaussian &out_pose_increment) const
Look for the first 2D or 3D "odometry" found in this collection of actions, and return the "mean" inc...
void insert(CAction &action)
Add a new object to the list.



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: ae4571287 Thu Nov 23 00:06:53 2017 +0100 at dom oct 27 23:51:55 CET 2019