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-2018, 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 <CTraitsTest.h>
14 #include <gtest/gtest.h>
15 
16 template class mrpt::CTraitsTest<mrpt::poses::CPose3DInterpolator>;
17 
18 TEST(CPose3DInterpolator, interp)
19 {
20  using namespace mrpt::poses;
21  using mrpt::math::TPose3D;
23  using mrpt::DEG2RAD;
24 
25  auto t0 = mrpt::Clock::now();
26  mrpt::Clock::duration dt(std::chrono::milliseconds(100));
27 
28  CPose3DInterpolator pose_path;
29 
30  pose_path.insert(
31  t0, TPose3D(1., 2., 3., DEG2RAD(30.0), DEG2RAD(.0), DEG2RAD(.0)));
32  pose_path.insert(
33  t0 + 2 * dt, TPose3D(1. + 3., 2. + 4., 3. + 5.,
34  DEG2RAD(30.0 + 20.0), 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<CMatrixDouble44>() -
46  CPose3D(interp).getHomogeneousMatrixVal<CMatrixDouble44>())
47  .array()
48  .abs()
49  .sum(),
50  1e-4);
51 }
std::chrono::duration< rep, period > duration
Definition: Clock.h:25
double DEG2RAD(const double x)
Degrees to radians.
CMatrixFixedNumeric< double, 4, 4 > CMatrixDouble44
Definition: eigen_frwds.h:58
static time_point now() noexcept
Returns the current time, with the highest resolution available.
Definition: Clock.cpp:46
CONTAINER::Scalar sum(const CONTAINER &v)
Computes the sum of all the elements.
TEST(CPose3DInterpolator, interp)
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
pose_t & interpolate(const mrpt::Clock::time_point &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...
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:86
Lightweight 3D pose (three spatial coordinates, plus three angular coordinates).
This class stores a time-stamped trajectory in SE(3) (CPose3D poses).
void insert(const mrpt::Clock::time_point &t, const pose_t &p)
Inserts a new pose in the sequence.
GLuint interp
Definition: glext.h:7133



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 7d5e6d718 Fri Aug 24 01:51:28 2018 +0200 at lun nov 2 08:35:50 CET 2020