Main MRPT website > C++ reference for MRPT 1.9.9
CPose3DInterpolator_unittest.cpp
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2017, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 
10 #include <mrpt/poses/CPose3D.h>
12 #include <mrpt/system/datetime.h>
13 #include <mrpt/utils/CTraitsTest.h>
14 #include <gtest/gtest.h>
15 
17 
18 TEST(CPose3DInterpolator, interp)
19 {
20  using namespace mrpt::poses;
21  using mrpt::math::TPose3D;
23 
26 
27  CPose3DInterpolator pose_path;
28 
29  pose_path.insert(
30  t0, TPose3D(1., 2., 3., DEG2RAD(30.0), DEG2RAD(.0), DEG2RAD(.0)));
31  pose_path.insert(
32  t0 + 2 * dt, TPose3D(
33  1. + 3., 2. + 4., 3. + 5., DEG2RAD(30.0 + 20.0),
34  DEG2RAD(.0), DEG2RAD(.0)));
35 
36  TPose3D interp;
37  bool valid;
38  pose_path.interpolate(t0 + dt, interp, valid);
39 
40  EXPECT_TRUE(valid);
41  const TPose3D interp_good(
42  1. + 1.5, 2. + 2.0, 3. + 2.5, DEG2RAD(30.0 + 10.0), DEG2RAD(.0),
43  DEG2RAD(.0));
44  EXPECT_NEAR(
45  .0, (CPose3D(interp_good).getHomogeneousMatrixVal() -
46  CPose3D(interp).getHomogeneousMatrixVal())
47  .array()
48  .abs()
49  .sum(),
50  1e-4);
51 }
uint64_t TTimeStamp
A system independent time type, it holds the the number of 100-nanosecond intervals since January 1...
Definition: datetime.h:32
double DEG2RAD(const double x)
Degrees to radians.
mrpt::system::TTimeStamp now()
A shortcut for system::getCurrentTime.
Definition: datetime.h:76
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 insert(mrpt::system::TTimeStamp t, const pose_t &p)
Inserts a new pose in the sequence.
CONTAINER::Scalar sum(const CONTAINER &v)
Computes the sum of all the elements.
TEST(CPose3DInterpolator, interp)
#define DEG2RAD
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
Definition: CPoint.h:17
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:88
Lightweight 3D pose (three spatial coordinates, plus three angular coordinates).
This class stores a time-stamped trajectory in SE(3) (CPose3D poses).
mrpt::system::TTimeStamp secondsToTimestamp(const double nSeconds)
Transform a time interval (in seconds) into TTimeStamp (e.g.
Definition: datetime.cpp:223
GLuint interp
Definition: glext.h:7133



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: ae4571287 Thu Nov 23 00:06:53 2017 +0100 at dom oct 27 23:51:55 CET 2019