OrientationConversionTest.cpp
Go to the documentation of this file.
1 #define BOOST_TEST_MODULE ArmarX::RobotTrajectoryDesigner::OrientationConversionTest
2 #define ARMARX_BOOST_TEST
3 
4 #include "../../../../../build/testing/RobotTrajectoryDesigner/Test.h"
5 
6 #include "RobotTrajectoryDesigner/gui-plugins/RobotTrajectoryDesignerGuiPlugin/Interpolation/LinearInterpolation.h"
7 #include "RobotTrajectoryDesigner/gui-plugins/RobotTrajectoryDesignerGuiPlugin/Util/OrientationConversion.h"
9 
11 using namespace armarx;
12 using namespace boost::test_tools;
13 BOOST_AUTO_TEST_CASE(eulerToQuatTest1)
14 {
15  //Init
16  QuaternionBasePtr ori = OrientationConversion::toQuaternion(1, 0, 0);
17  BOOST_REQUIRE_CLOSE(ori->qw, 0.878, 1);
18  BOOST_REQUIRE_CLOSE(ori->qx, 0.479, 1);
19  BOOST_REQUIRE_CLOSE(ori->qy, -0.0, 1);
20  BOOST_REQUIRE_CLOSE(ori->qz, 0, 1);
21 }
22 
23 BOOST_AUTO_TEST_CASE(eulerToQuatTest2)
24 {
25  //Init
26  QuaternionBasePtr ori = OrientationConversion::toQuaternion(3, 1, -2);
27  BOOST_REQUIRE_CLOSE_FRACTION(ori->qw, -0.369, 1);
28  BOOST_REQUIRE_CLOSE(ori->qx, 0.502, 1);
29  BOOST_REQUIRE_CLOSE(ori->qy, -0.718, 1);
30  BOOST_REQUIRE_CLOSE(ori->qz, -0.311, 1);
31 }
32 BOOST_AUTO_TEST_CASE(eulerToQuatTest3)
33 {
34  //Init
35  QuaternionBasePtr ori = OrientationConversion::toQuaternion(1, -1, 2);
36  BOOST_REQUIRE_CLOSE(ori->qw, 0.223, 1);
37  BOOST_REQUIRE_CLOSE(ori->qx, 0.581, 1);
38  BOOST_REQUIRE_CLOSE(ori->qy, 0.127, 1);
39  BOOST_REQUIRE_CLOSE(ori->qz, 0.772, 1);
40 }
41 
42 
43 
44 
45 BOOST_AUTO_TEST_CASE(quatToEulerTest1)
46 {
47  //Init
48  QuaternionBasePtr ori = *new QuaternionBasePtr(new FramedOrientation());
49  ori->qw = 0.5;
50  ori->qx = 0.5;
51  ori->qy = 0.5;
52  ori->qz = 0.5;
53  std::vector<double> euler = OrientationConversion::toEulerAngle(ori);
54  BOOST_REQUIRE_CLOSE(euler[0], 1.571, 1);
55  BOOST_REQUIRE_CLOSE(euler[1], 0, 1);
56  BOOST_REQUIRE_CLOSE(euler[2], 1.571, 1);
57 }
58 
59 BOOST_AUTO_TEST_CASE(quatToEulerTest2)
60 {
61  //Init
62  QuaternionBasePtr ori = *new QuaternionBasePtr(new FramedOrientation());
63  ori->qw = 0.658;
64  ori->qx = 0.164;
65  ori->qy = -0.329;
66  ori->qz = 0.658;
67  std::vector<double> euler = OrientationConversion::toEulerAngle(ori);
68  BOOST_REQUIRE_CLOSE(euler[0], -0.288, 1);
69  BOOST_REQUIRE_CLOSE(euler[1], -0.706, 1);
70  BOOST_REQUIRE_CLOSE(euler[2], 1.678, 1);
71 }
72 
73 BOOST_AUTO_TEST_CASE(twoConversionsTest)
74 {
75  QuaternionBasePtr ori = OrientationConversion::toQuaternion(0.1, 0.2, 0.3);
76  std::vector<double> euler = OrientationConversion::toEulerAngle(ori);
77  BOOST_REQUIRE_CLOSE(euler[0], 0.1, 1);
78  BOOST_REQUIRE_CLOSE(euler[1], 0.2, 1);
79  BOOST_REQUIRE_CLOSE(euler[2], 0.3, 1);
80 }
81 
82 
armarx::OrientationConversion::toEulerAngle
static std::vector< double > toEulerAngle(QuaternionBasePtr q)
Definition: OrientationConversion.cpp:33
Pose.h
FramedPose.h
armarx::OrientationConversion::toQuaternion
static QuaternionBasePtr toQuaternion(const double roll, const double pitch, const double yaw)
Definition: OrientationConversion.cpp:57
BOOST_AUTO_TEST_CASE
BOOST_AUTO_TEST_CASE(eulerToQuatTest1)
Definition: OrientationConversionTest.cpp:13
armarx::VariantType::FramedOrientation
const VariantTypeId FramedOrientation
Definition: FramedPose.h:40
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28