MathTest.cpp
Go to the documentation of this file.
1 
20 #define BOOST_TEST_STATIC_LINK
21 
22 #include <boost/test/included/unit_test.hpp>
24 
25 using namespace next_best_view;
26 using namespace boost::unit_test;
27 
28 class MathTest : public BaseTest {
29 public:
30  MathTest() : BaseTest(false, true) {}
31 
32  virtual ~MathTest() {}
33 
38  ROS_INFO("Running Test for S2C and C2S");
39 
40  // tolerance
41  double tolerance = 2E-7;
42 
43  // Unit Sphere Tests
44  int thetaDivisor = 32;
45  double thetaStepSize = M_PI / (double) thetaDivisor;
46  int phiDivisor = 64;
47  double phiStepSize = M_2_PI / (double) phiDivisor;
48  for (int thetaFac = 0; thetaFac < thetaDivisor; thetaFac++) {
49  double theta = - M_PI_2 + thetaFac * thetaStepSize;
50  for (int phiFac = 0; phiFac < phiDivisor; phiFac++) {
51  double phi = - M_PI + phiFac * phiStepSize;
52 
53  // create coordinates
54  SimpleSphereCoordinates scoords(1, theta, phi);
55  // convert to cartesian
56  SimpleVector3 ccoords = MathHelper::convertS2C(scoords);
57  // convert to sphere again
59  // convert to cartesian again
60  SimpleVector3 reccoords = MathHelper::convertS2C(rescoords);
61 
62  double cerror = (ccoords - reccoords).lpNorm<2>();
63 
64  BOOST_CHECK_MESSAGE(cerror < tolerance, "error has to be minimal.");
65  }
66  }
67  }
68 
69  void iterationTest() {
70  evaluateS2CandC2S();
71  }
72 };
73 
74 test_suite* init_unit_test_suite( int argc, char* argv[] ) {
75  test_suite* evaluation = BOOST_TEST_SUITE("Evaluation NBV");
76 
78 
79  evaluation->add(BOOST_CLASS_TEST_CASE(&MathTest::iterationTest, testPtr));
80 
81  framework::master_test_suite().add(evaluation);
82 
83  return 0;
84 }
void iterationTest()
Definition: MathTest.cpp:69
MathTest()
Definition: MathTest.cpp:30
SimpleVector3 SimpleSphereCoordinates
Definition: typedef.hpp:54
Eigen::Matrix< Precision, 3, 1 > SimpleVector3
Definition: typedef.hpp:53
test_suite * init_unit_test_suite(int argc, char *argv[])
Definition: MathTest.cpp:74
this namespace contains all generally usable classes.
#define ROS_INFO(...)
virtual ~MathTest()
Definition: MathTest.cpp:32
static SimpleSphereCoordinates convertC2S(const SimpleVector3 &cartesian)
converts cartesian coordinates to sphere coordinates
Definition: MathHelper.cpp:29
void evaluateS2CandC2S()
evaluates the correctness of the Sphere To Cartesian and Cartesian To Sphere Methods.
Definition: MathTest.cpp:37
static SimpleVector3 convertS2C(const SimpleSphereCoordinates &sphere)
converts sphere coordinates to cartesian coordinates (lightweight)
Definition: MathHelper.cpp:41


asr_next_best_view
Author(s): Aumann Florian, Borella Jocelyn, Heller Florian, Meißner Pascal, Schleicher Ralf, Stöckle Patrick, Stroh Daniel, Trautmann Jeremias, Walter Milena, Wittenbeck Valerij
autogenerated on Thu Jan 9 2020 07:20:18