MRPT  1.9.9
CPose3DInterpolator_unittest.cpp
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | https://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2019, Individual contributors, see AUTHORS file |
6  | See: https://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See: https://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 
10 #include <CTraitsTest.h>
11 #include <gtest/gtest.h>
12 #include <mrpt/poses/CPose3D.h>
14 #include <mrpt/system/datetime.h>
15 #include <Eigen/Dense>
16 
17 template class mrpt::CTraitsTest<mrpt::poses::CPose3DInterpolator>;
18 
19 TEST(CPose3DInterpolator, interp)
20 {
21  using namespace mrpt::poses;
22  using mrpt::DEG2RAD;
24  using mrpt::math::TPose3D;
25 
26  auto t0 = mrpt::Clock::now();
27  mrpt::Clock::duration dt(std::chrono::milliseconds(100));
28 
29  CPose3DInterpolator pose_path;
30 
31  pose_path.insert(
32  t0, TPose3D(1., 2., 3., DEG2RAD(30.0), DEG2RAD(.0), DEG2RAD(.0)));
33  pose_path.insert(
34  t0 + 2 * dt, TPose3D(
35  1. + 3., 2. + 4., 3. + 5., DEG2RAD(30.0 + 20.0),
36  DEG2RAD(.0), DEG2RAD(.0)));
37 
38  TPose3D interp;
39  bool valid;
40  pose_path.interpolate(t0 + dt, interp, valid);
41 
42  EXPECT_TRUE(valid);
43  const TPose3D interp_good(
44  1. + 1.5, 2. + 2.0, 3. + 2.5, DEG2RAD(30.0 + 10.0), DEG2RAD(.0),
45  DEG2RAD(.0));
46  EXPECT_NEAR(
47  .0,
48  (CPose3D(interp_good).getHomogeneousMatrixVal<CMatrixDouble44>() -
49  CPose3D(interp).getHomogeneousMatrixVal<CMatrixDouble44>())
50  .array()
51  .abs()
52  .sum(),
53  2e-4);
54 }
std::chrono::duration< rep, period > duration
Definition: Clock.h:25
double DEG2RAD(const double x)
Degrees to radians.
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:84
Lightweight 3D pose (three spatial coordinates, plus three angular coordinates).
Definition: TPose3D.h:23
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:7247
CMatrixFixed< double, 4, 4 > CMatrixDouble44
Definition: CMatrixFixed.h:353



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 8fe78517f Sun Jul 14 19:43:28 2019 +0200 at lun oct 28 02:10:00 CET 2019