29 : maxTimeInterpolation(
std::chrono::seconds(-1))
44 m_path[
t] =
p.asTPose();
60 bool& out_valid_interp)
const 72 bool& out_valid_interp)
const 75 for (
size_t k = 0; k < pose_t::static_size; k++)
80 p1.second = p2.second = p3.second = p4.second = out_interp;
85 bool interp_method_requires_4pts;
91 interp_method_requires_4pts =
false;
94 interp_method_requires_4pts =
true;
99 auto it_ge1 = m_path.lower_bound(
t);
102 if (it_ge1 != m_path.end() && it_ge1->first ==
t)
104 out_interp = it_ge1->second;
105 out_valid_interp =
true;
110 if (it_ge1 == m_path.end() || it_ge1 == m_path.begin())
112 out_valid_interp =
false;
117 auto it_ge2 = it_ge1;
119 if (it_ge2 == m_path.end())
121 if (interp_method_requires_4pts)
123 out_valid_interp =
false;
134 if (it_ge1 == m_path.begin())
136 if (interp_method_requires_4pts)
138 out_valid_interp =
false;
150 ? (p2.first - p1.first)
154 ? (p4.first - p3.first)
157 if (maxTimeInterpolation.count() > 0 &&
158 (dt12 > maxTimeInterpolation || dt23 > maxTimeInterpolation ||
159 dt34 > maxTimeInterpolation))
161 out_valid_interp =
false;
173 impl_interpolation(p1, p2, p3, p4, m_method,
t, out_interp);
175 out_valid_interp =
true;
185 bool ret = getPreviousPoseWithMinDistance(
t,
distance,
p);
194 if (m_path.size() == 0 ||
distance <= 0)
return false;
199 auto it = m_path.
find(
t);
200 if (it != m_path.end() && it != m_path.begin())
210 }
while (d <
distance && it != m_path.begin());
214 out_pose = it->second;
226 maxTimeInterpolation = time;
232 return maxTimeInterpolation;
242 if (!f.is_open())
return false;
244 for (
auto i = m_path.begin(); i != m_path.end(); ++i)
247 const auto&
p = i->second;
250 for (
unsigned int k = 0; k <
p.size(); k++)
273 if (!f.is_open())
return false;
274 if (m_path.empty())
return true;
286 if (!valid)
continue;
289 for (
unsigned int k = 0; k <
p.size(); k++)
314 catch (std::exception&)
320 if (M.
rows() == 0)
return false;
324 const size_t N = M.
rows();
326 for (
size_t i = 0; i < N; i++)
328 for (
unsigned int k = 0; k < pose_t::static_size; k++)
343 for (
unsigned int k = 0; k < point_t::static_size; k++)
345 Min[k] = std::numeric_limits<double>::max();
346 Max[k] = -std::numeric_limits<double>::max();
349 for (
auto p = m_path.begin();
p != m_path.end(); ++
p)
351 for (
unsigned int k = 0; k < point_t::static_size; k++)
375 unsigned int component,
unsigned int samples)
377 if (m_path.empty())
return;
382 size_t nitems =
size();
385 ant = (
unsigned int)(
samples / 2);
391 for (it1 = m_path.begin(); it1 != m_path.end(); ++it1, ++k)
393 it2 = m_path.begin();
394 if (k - ant > 0) advance(it2, k - ant);
396 if (k + post < (
int)nitems)
398 it3 = m_path.begin();
399 advance(it3, k + post + 1);
406 unsigned int nsamples =
distance(it2, it3);
408 for (
unsigned int i = 0; it2 != it3; ++it2, ++i)
mrpt::math::TPose3D asTPose() const
Clock that is compatible with MRPT TTimeStamp representation.
std::chrono::duration< rep, period > duration
This class is a "CSerializable" wrapper for "CMatrixDynamic<double>".
Base class for SE(2)/SE(3) interpolators.
std::chrono::time_point< Clock > time_point
typename Lie::Euclidean< DIM >::light_type point_t
TPoint2D or TPoint3D.
CParticleList m_particles
The array of particles.
std::pair< mrpt::Clock::time_point, pose_t > TTimePosePair
T interpolate(const T &x, const VECTOR &ys, const T &x0, const T &x1)
Interpolate a data sequence "ys" ranging from "x0" to "x1" (equally spaced), to obtain the approximat...
void keep_min(T &var, const K test_val)
If the second argument is below the first one, set the first argument to this lower value...
#define ASSERT_(f)
Defines an assertion mechanism.
void getMean(CPose3D &mean_pose) const override
Returns an estimate of the pose, (the mean, or mathematical expectation of the PDF), computed as a weighted average over all m_particles.
void keep_max(T &var, const K test_val)
If the second argument is above the first one, set the first argument to this higher value...
typename Lie::SE< DIM >::light_type pose_t
TPose2D or TPose3D.
typename Lie::SE< DIM >::type cpose_t
CPose2D or CPose3D.
double timestampTotime_t(const mrpt::system::TTimeStamp t) noexcept
Transform from TTimeStamp to standard "time_t" (actually a double number, it can contain fractions of...
std::map< mrpt::Clock::time_point, pose_t > TPath
GLsizei const GLchar ** string
size_type rows() const
Number of rows in the matrix.
size_type cols() const
Number of columns in the matrix.
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
typename TPath::iterator iterator
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
std::string format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
iterator find(const mrpt::Clock::time_point &t)
CPoseInterpolatorBase()
Default ctor: empty sequence of poses.
mrpt::system::TTimeStamp time_tToTimestamp(const double t)
Transform from standard "time_t" (actually a double number, it can contain fractions of seconds) to T...
void clear()
Clear the contents of this container.
TInterpolatorMethod
Type to select the interpolation method in CPoseInterpolatorBase derived classes. ...
double distance(const TPoint2D &p1, const TPoint2D &p2)
Gets the distance between two points in a 2D space.
Declares a class that represents a Probability Density function (PDF) of a 3D pose.
CONTAINER::Scalar norm(const CONTAINER &v)
void loadFromTextFile(std::istream &f)
Loads a vector/matrix from a text file, compatible with MATLAB text format.