class mrpt::obs::CActionCollection

Declares a class for storing a collection of robot actions.

It is used in mrpt::obs::CRawlog, for logs storage and particle filter based simulations.

See also:

CAction, CRawlog

#include <mrpt/obs/CActionCollection.h>

class CActionCollection: public mrpt::serialization::CSerializable
{
public:
    // typedefs

    typedef std::deque<mrpt::containers::deepcopy_poly_ptr<CAction::Ptr>>::iterator iterator;
    typedef std::deque<mrpt::containers::deepcopy_poly_ptr<CAction::Ptr>>::const_iterator const_iterator;

    // construction

    CActionCollection();
    CActionCollection(CAction& a);

    //
methods

    const_iterator begin() const;
    iterator begin();
    const_iterator end() const;
    iterator end();
    iterator erase(const iterator& it);
    void clear();
    CAction::Ptr get(size_t index);
    const CAction& get(size_t index) const;

    template <typename T>
    T::Ptr getActionByClass(size_t ith = 0) const;

    void insert(const CAction& action);
    void insertPtr(const CAction::Ptr& action);
    size_t size() const;
    CActionRobotMovement2D::Ptr getBestMovementEstimation() const;
    CActionRobotMovement2D::Ptr getMovementEstimationByType(CActionRobotMovement2D::TEstimationMethod method);
    bool getFirstMovementEstimationMean(mrpt::poses::CPose3D& out_pose_increment) const;
    bool getFirstMovementEstimation(mrpt::poses::CPose3DPDFGaussian& out_pose_increment) const;
    void eraseByIndex(size_t index);
};

Typedefs

typedef std::deque<mrpt::containers::deepcopy_poly_ptr<CAction::Ptr>>::iterator iterator

You can use CActionCollection::begin to get a iterator to the first element.

typedef 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.

Construction

CActionCollection()

ctor

CActionCollection(CAction& a)

Constructor from a single action.

Methods

const_iterator begin() const

Returns a iterator to the first action: this is an example of usage:

CActionCollection  acts;
...
for (CActionCollection::iterator it=acts.begin();it!=acts.end();++it)
 {
   (*it)->... // (*it) is a "CAction::Ptr"
}
iterator begin()

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

const_iterator end() const

Returns a iterator pointing to the end of the list: this is an example of usage:

CActionCollection  acts;
...
for (CActionCollection::iterator it=acts.begin();it!=acts.end();++it)
   {
   (*it)->... // (*it) is a "CAction::Ptr"
}
iterator end()

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

iterator erase(const iterator& it)

Removes the given action in the list, and return an iterator to the next element (or this-> end() if it was the last one).

void clear()

Erase all actions from the list.

CAction::Ptr get(size_t index)

Access the i’th action.DO NOT MODIFY the returned object, make a copy of ir with “CSerializable::duplicate” if desired.

First element is 0.

Parameters:

std::exception

On index out of bounds.

template <typename T>
T::Ptr getActionByClass(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 class in the list.

Example:

     CActionRobotMovement2D::Ptr obs =
acts->getActionByClass<CActionRobotMovement2D>();

By default (ith=0), the first one is returned.

void insert(const CAction& action)

Add a new object to the list, making a deep copy.

void insertPtr(const CAction::Ptr& action)

Add a new object to the list (no deep copy).

(New in MRPT 2.3.1)

size_t size() const

Returns the actions count in the collection.

CActionRobotMovement2D::Ptr getBestMovementEstimation() const

Returns the best pose increment estimator in the collection, based on the determinant of its pose change covariance matrix.

Returns:

The estimation, or nullptr if none is available.

CActionRobotMovement2D::Ptr getMovementEstimationByType(CActionRobotMovement2D::TEstimationMethod method)

Returns the pose increment estimator in the collection having the specified type.

Returns:

The estimation, or nullptr if none is available.

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” increment of the robot according to it.

Returns:

true on success,false on no odometry found.

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” increment of the robot and its covariance according to it.

Returns:

true on success,false on no odometry found.

void eraseByIndex(size_t index)

Remove an action from the list by its index.

Parameters:

std::exception

On index out of bounds.