26 maxTimeInterpolation = -1.0;
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;
234 const auto &
p = i->second;
237 for (
unsigned int k=0;k<
p.size();k++)
241 f.
printf(
"%s",str.c_str());
258 if (m_path.empty())
return true;
262 const TTimeStamp t_ini = m_path.begin()->first;
263 const TTimeStamp t_end = m_path.rbegin()->first;
272 if (!valid)
continue;
275 for (
unsigned int k=0;k<
p.size();k++)
278 f.
printf(
"%s",str.c_str());
298 M.loadFromTextFile(
s);
300 catch(std::exception &)
306 if (M.getRowCount()==0)
return false;
310 const size_t N = M.getColCount();
312 for (
size_t i=0;i<N;i++) {
329 Min[k] = std::numeric_limits<double>::max();
330 Max[k] =-std::numeric_limits<double>::max();
364 size_t nitems =
size();
367 ant = (
unsigned int)(
samples/2);
373 for( it1 = m_path.begin(); it1 != m_path.end(); ++it1, ++k )
375 it2 = m_path.begin();
377 advance( it2, k-ant );
379 if( k+post < (
int)nitems )
381 it3 = m_path.begin();
382 advance( it3, k+post+1 );
389 unsigned int nsamples =
distance(it2,it3);
391 for(
unsigned int i = 0; it2 != it3; ++it2, ++i )
397 case 0: particles.
m_particles[i].d->x(it2->second[0]);
break;
398 case 1: particles.
m_particles[i].d->y(it2->second[1]);
break;
399 case 2: particles.
m_particles[i].d->z(it2->second[2]);
break;
400 case 3: particles.
m_particles[i].d->setYawPitchRoll(it2->second[3],it1->second[4],it1->second[5]);
break;
401 case 4: particles.
m_particles[i].d->setYawPitchRoll(it1->second[3],it2->second[4],it1->second[5]);
break;
402 case 5: particles.
m_particles[i].d->setYawPitchRoll(it1->second[3],it1->second[4],it2->second[5]);
break;
408 aux[it1->first] =
pose_t(auxPose);
uint64_t TTimeStamp
A system independent time type, it holds the the number of 100-nanosecond intervals since January 1...
This class is a "CSerializable" wrapper for "CMatrixTemplateNumeric<double>".
void getMean(CPose3D &mean_pose) const MRPT_OVERRIDE
Returns an estimate of the pose, (the mean, or mathematical expectation of the PDF), computed as a weighted average over all m_particles.
Base class for SE(2)/SE(3) interpolators.
std::map< mrpt::system::TTimeStamp, pose_t > TPath
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 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...
void clear()
Clear the contents of this container.
CParticleList m_particles
The array of particles.
This CStream derived class allow using a file as a write-only, binary stream.
iterator find(const mrpt::system::TTimeStamp &t)
std::string BASE_IMPEXP format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
GLsizei const GLchar ** string
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...
#define INVALID_TIMESTAMP
Represents an invalid timestamp, where applicable.
mrpt::poses::SE_traits< DIM >::lightweight_pose_t pose_t
TPose2D or TPose3D.
std::pair< mrpt::system::TTimeStamp, pose_t > TTimePosePair
void loadFromTextFile(const std::string &file)
Load matrix from a text file, compatible with MATLAB text format.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
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...
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
mrpt::poses::SE_traits< DIM >::point_t point_t
TPoint2D or TPoint3D.
A partial specialization of CArrayNumeric for double numbers.
TPath::const_iterator const_iterator
mrpt::system::TTimeStamp BASE_IMPEXP secondsToTimestamp(const double nSeconds)
Transform a time interval (in seconds) into TTimeStamp (e.g.
mrpt::poses::SE_traits< DIM >::pose_t cpose_t
CPose2D or CPose3D.
CPoseInterpolatorBase()
Default ctor: empty sequence of poses.
mrpt::system::TTimeStamp BASE_IMPEXP time_tToTimestamp(const double t)
Transform from standard "time_t" (actually a double number, it can contain fractions of seconds) to T...
TInterpolatorMethod
Type to select the interpolation method in CPoseInterpolatorBase derived classes. ...
double BASE_IMPEXP distance(const TPoint2D &p1, const TPoint2D &p2)
Gets the distance between two points in a 2D space.
double BASE_IMPEXP timestampTotime_t(const mrpt::system::TTimeStamp t)
Transform from TTimeStamp to standard "time_t" (actually a double number, it can contain fractions of...
virtual int printf(const char *fmt,...) MRPT_printf_format_check(2
Writes a string to the stream in a textual form.
Declares a class that represents a Probability Density function (PDF) of a 3D pose.
CONTAINER::Scalar norm(const CONTAINER &v)