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