Go to the documentation of this file.
26 maxTimeInterpolation = -1.0;
38 m_path[
t] =
p.asTPose();
66 p1.second = p2.second = p3.second = p4.second = out_interp;
71 out_valid_interp =
false;
77 bool interp_method_requires_4pts;
83 interp_method_requires_4pts =
false;
86 interp_method_requires_4pts =
true;
95 if( it_ge1 != m_path.end() && it_ge1->first ==
t )
97 out_interp = it_ge1->second;
98 out_valid_interp =
true;
103 if( it_ge1 == m_path.end() || it_ge1 == m_path.begin() )
105 out_valid_interp =
false;
111 if(it_ge2 == m_path.end() )
113 if (interp_method_requires_4pts) {
114 out_valid_interp =
false;
124 if( it_ge1 == m_path.begin() )
126 if (interp_method_requires_4pts) {
127 out_valid_interp =
false;
136 const double dt12 = interp_method_requires_4pts ? (p2.first - p1.first) / 1e7 : .0;
137 const double dt23 = (p3.first - p2.first) / 1e7;
138 const double dt34 = interp_method_requires_4pts ? (p4.first - p3.first) / 1e7 : .0;
140 if( maxTimeInterpolation > 0 &&
141 (dt12 > maxTimeInterpolation ||
142 dt23 > maxTimeInterpolation ||
143 dt34 > maxTimeInterpolation ))
145 out_valid_interp =
false;
164 impl_interpolation(ts,p1,p2,p3,p4, m_method,td,out_interp);
166 out_valid_interp =
true;
175 bool ret = getPreviousPoseWithMinDistance(
t,
distance,
p);
183 if( m_path.size() == 0 ||
distance <=0 )
190 if( it != m_path.end() && it != m_path.begin() )
200 }
while( d <
distance && it != m_path.begin() );
204 out_pose = it->second;
215 maxTimeInterpolation = time;
221 return maxTimeInterpolation;
231 if (!f.is_open())
return false;
236 const auto &
p = i->second;
239 for (
unsigned int k=0;k<
p.size();k++)
261 if (!f.is_open())
return false;
262 if (m_path.empty())
return true;
266 const TTimeStamp t_ini = m_path.begin()->first;
267 const TTimeStamp t_end = m_path.rbegin()->first;
276 if (!valid)
continue;
279 for (
unsigned int k=0;k<
p.size();k++)
302 M.loadFromTextFile(
s);
304 catch(std::exception &)
310 if (M.rows()==0)
return false;
314 const size_t N = M.cols();
316 for (
size_t i=0;i<N;i++) {
333 Min[k] = std::numeric_limits<double>::max();
334 Max[k] =-std::numeric_limits<double>::max();
368 size_t nitems =
size();
371 ant = (
unsigned int)(
samples/2);
377 for( it1 = m_path.begin(); it1 != m_path.end(); ++it1, ++k )
379 it2 = m_path.begin();
381 advance( it2, k-ant );
383 if( k+post < (
int)nitems )
385 it3 = m_path.begin();
386 advance( it3, k+post+1 );
393 unsigned int nsamples =
distance(it2,it3);
395 for(
unsigned int i = 0; it2 != it3; ++it2, ++i )
401 case 0: particles.
m_particles[i].d.x= it2->second[0];
break;
402 case 1: particles.
m_particles[i].d.y=it2->second[1];
break;
403 case 2: particles.
m_particles[i].d.z=it2->second[2];
break;
404 case 3: particles.
m_particles[i].d.yaw = it2->second[3];
break;
408 case 5: particles.
m_particles[i].d.roll= it2->second[5];
break;
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.
mrpt::system::TTimeStamp secondsToTimestamp(const double nSeconds)
Transform a time interval (in seconds) into TTimeStamp (e.g.
void clear()
Clear the contents of this container.
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...
Base class for SE(2)/SE(3) interpolators.
typename mrpt::poses::SE_traits< DIM >::point_t point_t
TPoint2D or TPoint3D.
#define INVALID_TIMESTAMP
Represents an invalid timestamp, where applicable.
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...
typename mrpt::poses::SE_traits< DIM >::lightweight_pose_t pose_t
TPose2D or TPose3D.
CPoseInterpolatorBase()
Default ctor: empty sequence of poses.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
double distance(const TPoint2D &p1, const TPoint2D &p2)
Gets the distance between two points in a 2D space.
typename TPath::iterator iterator
typename mrpt::poses::SE_traits< DIM >::pose_t cpose_t
CPose2D or CPose3D.
#define ASSERT_(f)
Defines an assertion mechanism.
void saveToTextFile(const std::string &file, mrpt::math::TMatrixTextFileFormat fileFormat=mrpt::math::MATRIX_FORMAT_ENG, bool appendMRPTHeader=false, const std::string &userHeader=std::string()) const
Save matrix to a text file, compatible with MATLAB text format (see also the methods of matrix classe...
uint64_t TTimeStamp
A system independent time type, it holds the the number of 100-nanosecond intervals since January 1,...
iterator find(const mrpt::system::TTimeStamp &t)
CONTAINER::Scalar norm(const CONTAINER &v)
TInterpolatorMethod
Type to select the interpolation method in CPoseInterpolatorBase derived classes.
std::map< mrpt::system::TTimeStamp, pose_t > TPath
std::pair< mrpt::system::TTimeStamp, pose_t > TTimePosePair
std::string format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
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.
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
mrpt::math::TPose3D asTPose() const
double timestampTotime_t(const mrpt::system::TTimeStamp t)
Transform from TTimeStamp to standard "time_t" (actually a double number, it can contain fractions of...
typename TPath::const_iterator const_iterator
CArrayNumeric is an array for numeric types supporting several mathematical operations (actually,...
Declares a class that represents a Probability Density function (PDF) of a 3D pose.
CParticleList m_particles
The array of particles.
void loadFromTextFile(const std::string &file)
Load matrix from a text file, compatible with MATLAB text format.
void getMean(CPose3D &mean_pose) const override
Returns an estimate of the pose, (the mean, or mathematical expectation of the PDF),...
This class is a "CSerializable" wrapper for "CMatrixTemplateNumeric<double>".
GLsizei const GLchar ** string
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 | |