template class mrpt::poses::CPoseInterpolatorBase
Overview
Base class for SE(2)/SE(3) interpolators.
See docs for derived classes.
#include <mrpt/poses/CPoseInterpolatorBase.h> template <size_t DIM> class CPoseInterpolatorBase { public: // typedefs typedef typename Lie::SE<DIM>::light_type pose_t; typedef typename Lie::SE<DIM>::type cpose_t; typedef typename Lie::Euclidean<DIM>::light_type point_t; typedef std::pair<mrpt::Clock::time_point, pose_t> TTimePosePair; typedef std::map<mrpt::Clock::time_point, pose_t> TPath; typedef typename TPath::iterator iterator; typedef typename TPath::const_iterator const_iterator; typedef typename TPath::reverse_iterator reverse_iterator; typedef typename TPath::const_reverse_iterator const_reverse_iterator; // construction CPoseInterpolatorBase(); // methods iterator begin(); const_iterator begin() const; const_iterator cbegin() const; iterator end(); const_iterator end() const; const_iterator cend() const; reverse_iterator rbegin(); const_reverse_iterator rbegin() const; reverse_iterator rend(); const_reverse_iterator rend() const; iterator lower_bound(const mrpt::Clock::time_point& t); const_iterator lower_bound(const mrpt::Clock::time_point& t) const; iterator upper_bound(const mrpt::Clock::time_point& t); const_iterator upper_bound(const mrpt::Clock::time_point& t) const; iterator erase(iterator element_to_erase); size_t size() const; bool empty() const; iterator find(const mrpt::Clock::time_point& t); const_iterator find(const mrpt::Clock::time_point& t) const; pose_t& at(const mrpt::Clock::time_point& t); const pose_t& at(const mrpt::Clock::time_point& t) const; void insert(const mrpt::Clock::time_point& t, const pose_t& p); void insert(const mrpt::Clock::time_point& t, const cpose_t& p); pose_t& interpolate(const mrpt::Clock::time_point& t, pose_t& out_interp, bool& out_valid_interp) const; cpose_t& interpolate( const mrpt::Clock::time_point& t, cpose_t& out_interp, bool& out_valid_interp ) const; void clear(); void setMaxTimeInterpolation(const mrpt::Clock::duration& time); mrpt::Clock::duration getMaxTimeInterpolation(); bool getPreviousPoseWithMinDistance(const mrpt::Clock::time_point& t, double distance, pose_t& out_pose); bool getPreviousPoseWithMinDistance( const mrpt::Clock::time_point& t, double distance, cpose_t& out_pose ); bool saveToTextFile(const std::string& s) const; bool saveToTextFile_TUM(const std::string& s) const; bool saveInterpolatedToTextFile(const std::string& s, const mrpt::Clock::duration& period) const; bool loadFromTextFile(const std::string& s); bool loadFromTextFile_TUM(const std::string& s); void getBoundingBox(point_t& minCorner, point_t& maxCorner) const; void setInterpolationMethod(TInterpolatorMethod method); TInterpolatorMethod getInterpolationMethod() const; void filter(unsigned int component, unsigned int samples); }; // direct descendants class CPose2DInterpolator; class CPose3DInterpolator;
Typedefs
typedef typename Lie::SE<DIM>::light_type pose_t
TPose2D or TPose3D.
typedef typename Lie::SE<DIM>::type cpose_t
typedef typename Lie::Euclidean<DIM>::light_type point_t
TPoint2D or TPoint3D.
Construction
CPoseInterpolatorBase()
Default ctor: empty sequence of poses.
Methods
void insert(const mrpt::Clock::time_point& t, const pose_t& p)
Inserts a new pose in the sequence.
It overwrites any previously existing pose at exactly the same time.
void insert(const mrpt::Clock::time_point& t, const cpose_t& p)
Overload (slower)
pose_t& interpolate(const mrpt::Clock::time_point& t, pose_t& out_interp, bool& out_valid_interp) const
Returns the pose at a given time, or interpolates using splines if there is not an exact match.
Parameters:
t |
The time of the point to interpolate. |
out_interp |
The output interpolated pose. |
out_valid_interp |
Whether there was information enough to compute the interpolation. |
Returns:
A reference to out_interp
void clear()
Clears the current sequence of poses.
void setMaxTimeInterpolation(const mrpt::Clock::duration& time)
Set value of the maximum time to consider interpolation.
If set to a negative value, the check is disabled (default behavior).
mrpt::Clock::duration getMaxTimeInterpolation()
Set value of the maximum time to consider interpolation.
bool getPreviousPoseWithMinDistance(const mrpt::Clock::time_point& t, double distance, pose_t& out_pose)
Get the previous CPose3D in the map with a minimum defined distance.
Returns:
true if pose was found, false otherwise
bool saveToTextFile(const std::string& s) const
Saves the points in the interpolator to a text file, with this format: Each row contains these elements separated by spaces:
Timestamp: As a “double time_t”
x y z: The 3D position in meters.
yaw pitch roll: The angles, in radians
Returns:
true on success, false on any error.
See also:
bool saveToTextFile_TUM(const std::string& s) const
Saves the points in the interpolator to a text file in the “TUM” dataset format: each row contains these elements separated by spaces:
Timestamp: As a “double time_t”
x y z: The 3D position in meters.
q_x q_y q_z q_w: Quaternion
Returns:
true on success, false on any error.
See also:
loadFromTextFile, saveTextFile_TUM
bool saveInterpolatedToTextFile(const std::string& s, const mrpt::Clock::duration& period) const
Saves the points in the interpolator to a text file, with the same format that saveToTextFile, but interpolating the path with the given period in seconds.
Returns:
true on success, false on any error.
See also:
bool loadFromTextFile(const std::string& s)
Loads from a text file, in the format described by saveToTextFile.
Parameters:
std::exception |
On invalid file format |
Returns:
true on success, false on any error.
bool loadFromTextFile_TUM(const std::string& s)
Loads from a text file, in the “TUM” dataset format.
Parameters:
std::exception |
On invalid file format |
Returns:
true on success, false on any error.
void getBoundingBox(point_t& minCorner, point_t& maxCorner) const
Computes the bounding box in all Euclidean coordinates of the whole path.
Parameters:
std::exception |
On empty path |
void setInterpolationMethod(TInterpolatorMethod method)
Change the method used to interpolate the robot path.
The default method at construction is “imSpline”.
See also:
TInterpolatorMethod getInterpolationMethod() const
Returns the currently set interpolation method.
See also:
void filter(unsigned int component, unsigned int samples)
Filters by averaging one of the components of the pose data within the interpolator.
The width of the filter is set by the number of samples.
Parameters:
component |
[IN] The index of the component to filter: 0 (x), 1 (y), 2 (z), 3 (yaw), 4 (pitch) or 5 (roll) |
samples |
[IN] The width of the average filter. |