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



Page generated by Doxygen 1.9.6 for MRPT 1.4.0 SVN: at Wed Mar 22 04:35:51 UTC 2023