65 TTimePosePair p1, p2, p3, p4;
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);
176 out_pose = cpose_t(
p);
183 if( m_path.size() == 0 ||
distance <=0 )
190 if( it != m_path.end() && it != m_path.begin() )
199 d = (point_t(myPose) - point_t(it->second)).
norm();
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);
CParticleList m_particles
The array of particles.
A partial specialization of CArrayNumeric for double numbers.
This class is a "CSerializable" wrapper for "CMatrixTemplateNumeric<double>".
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Declares a class that represents a Probability Density function (PDF) of a 3D pose.
void getMean(CPose3D &mean_pose) const MRPT_OVERRIDE
Returns an estimate of the pose, (the mean, or mathematical expectation of the PDF),...
mrpt::poses::SE_traits< DIM >::lightweight_pose_t pose_t
TPose2D or TPose3D.
bool loadFromTextFile(const std::string &s)
Loads from a text file, in the format described by saveToTextFile.
std::map< mrpt::system::TTimeStamp, pose_t > TPath
TPath::const_iterator const_iterator
void setMaxTimeInterpolation(double time)
Set value of the maximum time to consider interpolation.
bool saveToTextFile(const std::string &s) const
Saves the points in the interpolator to a text file, with this format: Each row contains these elemen...
void insert(mrpt::system::TTimeStamp t, const pose_t &p)
Inserts a new pose in the sequence.
TInterpolatorMethod getInterpolationMethod() const
Returns the currently set interpolation method.
bool saveInterpolatedToTextFile(const std::string &s, double period) const
Saves the points in the interpolator to a text file, with the same format that saveToTextFile,...
void getBoundingBox(point_t &minCorner, point_t &maxCorner) const
Computes the bounding box in all Euclidean coordinates of the whole path.
double getMaxTimeInterpolation()
Set value of the maximum time to consider interpolation.
pose_t & interpolate(mrpt::system::TTimeStamp 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.
void clear()
Clears the current sequence of poses.
bool getPreviousPoseWithMinDistance(const mrpt::system::TTimeStamp &t, double distance, pose_t &out_pose)
Get the previous CPose3D in the map with a minimum defined distance.
CPoseInterpolatorBase()
Default ctor: empty sequence of poses.
mrpt::poses::SE_traits< DIM >::pose_t cpose_t
CPose2D or CPose3D.
void filter(unsigned int component, unsigned int samples)
Filters by averaging one of the components of the pose data within the interpolator.
void setInterpolationMethod(TInterpolatorMethod method)
Change the method used to interpolate the robot path. The default method at construction is "imSpline...
mrpt::poses::SE_traits< DIM >::point_t point_t
TPoint2D or TPoint3D.
double maxTimeInterpolation
Maximum time considered to interpolate. If the difference between the desired timestamp where to inte...
This CStream derived class allow using a file as a write-only, binary stream.
virtual int printf(const char *fmt,...) MRPT_printf_format_check(2
Writes a string to the stream in a textual form.
#define INVALID_TIMESTAMP
Represents an invalid timestamp, where applicable.
const Scalar * const_iterator
GLsizei const GLchar ** string
double BASE_IMPEXP distance(const TPoint2D &p1, const TPoint2D &p2)
Gets the distance between two points in a 2D space.
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...
TInterpolatorMethod
Type to select the interpolation method in CPoseInterpolatorBase derived classes.
mrpt::system::TTimeStamp BASE_IMPEXP secondsToTimestamp(const double nSeconds)
Transform a time interval (in seconds) into TTimeStamp (e.g.
uint64_t TTimeStamp
A system independent time type, it holds the the number of 100-nanosecond intervals since January 1,...
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...
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...
CONTAINER::Scalar norm(const CONTAINER &v)
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.
void clear()
Clear the contents of this container.
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.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
std::string BASE_IMPEXP format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.