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-2018, 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 #pragma once
10 
11 #include <mrpt/obs/CAction.h>
16 
17 namespace mrpt
18 {
19 namespace obs
20 {
21 /** Declares a class for storing a collection of robot actions. It is used in
22  * mrpt::obs::CRawlog,
23  * for logs storage and particle filter based simulations.
24  *
25  * \sa CAction, CRawlog
26  * \ingroup mrpt_obs_grp
27  */
29 {
31 
32  protected:
33  /** The robot "actionss" */
34  std::deque<mrpt::containers::deepcopy_poly_ptr<CAction::Ptr>> m_actions;
35 
36  public:
37  /** ctor */
38  CActionCollection() = default;
39  /** Constructor from a single action. */
41 
42  /** You can use CActionCollection::begin to get a iterator to the first
43  * element.
44  */
45  using iterator =
46  std::deque<mrpt::containers::deepcopy_poly_ptr<CAction::Ptr>>::iterator;
47 
48  /** You can use CActionCollection::begin to get a iterator to the first
49  * element.
50  */
51  using const_iterator = std::deque<
53 
54  /** Returns a iterator to the first action: this is an example of usage:
55  * \code
56  * CActionCollection acts;
57  * ...
58  * for (CActionCollection::iterator it=acts.begin();it!=acts.end();++it)
59  * {
60  * (*it)->... // (*it) is a "CAction::Ptr"
61  * }
62  *
63  * \endcode
64  */
65  const_iterator begin() const { return m_actions.begin(); }
66  /** Returns a iterator to the first action: this is an example of usage:
67  * \code
68  * CActionCollection acts;
69  * ...
70  * for (CActionCollection::iterator it=acts.begin();it!=acts.end();++it)
71  * {
72  * (*it)->... // (*it) is a "CAction::Ptr"
73  * }
74  *
75  * \endcode
76  */
77  iterator begin() { return m_actions.begin(); }
78  /** Returns a iterator pointing to the end of the list: this is an example
79  *of usage:
80  * \code
81  * CActionCollection acts;
82  * ...
83  * for (CActionCollection::iterator it=acts.begin();it!=acts.end();++it)
84  * {
85  * (*it)->... // (*it) is a "CAction::Ptr"
86  * }
87  *
88  * \endcode
89  */
90  const_iterator end() const { return m_actions.end(); }
91  /** Returns a iterator pointing to the end of the list: this is an example
92  *of usage:
93  * \code
94  * CActionCollection acts;
95  * ...
96  * for (CActionCollection::iterator it=acts.begin();it!=acts.end();++it)
97  * {
98  * (*it)->... // (*it) is a "CAction::Ptr"
99  * }
100  *
101  * \endcode
102  */
103  iterator end() { return m_actions.end(); }
104  /** Removes the given action in the list, and return an iterator to the next
105  * element (or this->end() if it was the last one).
106  */
107  iterator erase(const iterator& it);
108 
109  /** Erase all actions from the list.
110  */
111  void clear();
112 
113  /** Access the i'th action.DO NOT MODIFY the returned object, make a copy of
114  * ir with "CSerializable::duplicate" if desired.
115  * First element is 0.
116  * \exception std::exception On index out of bounds.
117  */
118  CAction::Ptr get(size_t index);
119  const CAction& get(size_t index) const;
120 
121  /** Access to the i'th action of a given class, or a nullptr smart pointer
122  if there is no action of that class in the list.
123  * Example:
124  * \code
125  CActionRobotMovement2D::Ptr obs =
126  acts->getActionByClass<CActionRobotMovement2D>();
127  * \endcode
128  * By default (ith=0), the first one is returned.
129  */
130  template <typename T>
131  typename T::Ptr getActionByClass(const size_t& ith = 0) const
132  {
133  MRPT_START
134  size_t foundCount = 0;
135  const mrpt::rtti::TRuntimeClassId* class_ID =
136  &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 } // namespace obs
189 } // namespace mrpt
mrpt::poses::CPose3DPDFGaussian
Declares a class that represents a Probability Density function (PDF) of a 3D pose .
Definition: CPose3DPDFGaussian.h:40
mrpt::rtti::TRuntimeClassId
A structure that holds runtime class type information.
Definition: CObject.h:30
mrpt::obs::CActionCollection::getActionByClass
T::Ptr getActionByClass(const size_t &ith=0) const
Access to the i'th action of a given class, or a nullptr smart pointer if there is no action of that ...
Definition: CActionCollection.h:131
mrpt::obs::CActionCollection::getFirstMovementEstimation
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...
Definition: CActionCollection.cpp:206
mrpt::obs::CActionCollection::eraseByIndex
void eraseByIndex(const size_t &index)
Remove an action from the list by its index.
Definition: CActionCollection.cpp:131
mrpt::obs::CActionCollection::begin
iterator begin()
Returns a iterator to the first action: this is an example of usage:
Definition: CActionCollection.h:77
CPose3DPDFGaussian.h
mrpt::obs::CActionCollection
Declares a class for storing a collection of robot actions.
Definition: CActionCollection.h:28
mrpt
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Definition: CKalmanFilterCapable.h:30
mrpt::obs::CActionRobotMovement2D::Ptr
std::shared_ptr< CActionRobotMovement2D > Ptr
Definition: CActionRobotMovement2D.h:34
mrpt::obs::CActionCollection::iterator
std::deque< mrpt::containers::deepcopy_poly_ptr< CAction::Ptr > >::iterator iterator
You can use CActionCollection::begin to get a iterator to the first element.
Definition: CActionCollection.h:46
mrpt::obs::CActionCollection::getMovementEstimationByType
CActionRobotMovement2D::Ptr getMovementEstimationByType(CActionRobotMovement2D::TEstimationMethod method)
Returns the pose increment estimator in the collection having the specified type.
Definition: CActionCollection.cpp:142
CActionRobotMovement2D.h
mrpt::obs::CActionCollection::begin
const_iterator begin() const
Returns a iterator to the first action: this is an example of usage:
Definition: CActionCollection.h:65
mrpt::obs::CActionCollection::get
CAction::Ptr get(size_t index)
Access the i'th action.DO NOT MODIFY the returned object, make a copy of ir with "CSerializable::dupl...
Definition: CActionCollection.cpp:64
mrpt::obs::CActionCollection::end
const_iterator end() const
Returns a iterator pointing to the end of the list: this is an example of usage:
Definition: CActionCollection.h:90
MRPT_START
#define MRPT_START
Definition: exceptions.h:262
mrpt::poses::CPose3D
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:88
index
GLuint index
Definition: glext.h:4054
mrpt::obs::CActionCollection::m_actions
std::deque< mrpt::containers::deepcopy_poly_ptr< CAction::Ptr > > m_actions
The robot "actionss".
Definition: CActionCollection.h:34
mrpt::serialization::CSerializable
The virtual base class which provides a unified interface for all persistent objects in MRPT.
Definition: CSerializable.h:32
mrpt::containers::deepcopy_poly_ptr< CAction::Ptr >
mrpt::obs::CActionCollection::CActionCollection
CActionCollection()=default
ctor
mrpt::obs::CActionCollection::getBestMovementEstimation
CActionRobotMovement2D::Ptr getBestMovementEstimation() const
Returns the best pose increment estimator in the collection, based on the determinant of its pose cha...
Definition: CActionCollection.cpp:93
mrpt::obs::CActionCollection::const_iterator
std::deque< mrpt::containers::deepcopy_poly_ptr< CAction::Ptr > >::const_iterator const_iterator
You can use CActionCollection::begin to get a iterator to the first element.
Definition: CActionCollection.h:52
CAction.h
mrpt::obs::CActionCollection::end
iterator end()
Returns a iterator pointing to the end of the list: this is an example of usage:
Definition: CActionCollection.h:103
DEFINE_SERIALIZABLE
#define DEFINE_SERIALIZABLE(class_name)
This declaration must be inserted in all CSerializable classes definition, within the class declarati...
Definition: CSerializable.h:102
mrpt::obs::CActionCollection::getFirstMovementEstimationMean
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...
Definition: CActionCollection.cpp:183
MRPT_END
#define MRPT_END
Definition: exceptions.h:266
mrpt::obs::CActionCollection::insert
void insert(CAction &action)
Add a new object to the list.
Definition: CActionCollection.cpp:85
mrpt::obs::CActionCollection::erase
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...
Definition: CActionCollection.cpp:171
mrpt::obs::CAction::Ptr
std::shared_ptr< CAction > Ptr
Definition: CAction.h:29
deepcopy_poly_ptr.h
mrpt::obs::CAction
Declares a class for storing a robot action.
Definition: CAction.h:27
iterator
Scalar * iterator
Definition: eigen_plugins.h:26
CSerializable.h
mrpt::obs::CActionCollection::clear
void clear()
Erase all actions from the list.
Definition: CActionCollection.cpp:60
mrpt::obs::CActionCollection::size
size_t size()
Returns the actions count in the collection.
Definition: CActionCollection.cpp:81
mrpt::obs::CActionRobotMovement2D::TEstimationMethod
TEstimationMethod
A list of posible ways for estimating the content of a CActionRobotMovement2D object.
Definition: CActionRobotMovement2D.h:40
a
GLubyte GLubyte GLubyte a
Definition: glext.h:6279



Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST