1 #define BOOST_TEST_MODULE ArmarX::RobotTrajectoryDesigner::SplineInterpolation
2 #define ARMARX_BOOST_TEST
5 #include <RobotComponents/Test.h>
8 #include "../exceptions/NoInterpolationPossibleException.h"
10 #include "../../Interpolation/SplineInterpolation.h"
11 #include "../../Util/OrientationConversion.h"
18 Vector3BasePtr pos1 =
new Vector3(2, 4, 6);
20 PoseBasePtr pose1 =
new Pose(pos1, ori1);
22 Vector3BasePtr pos2 =
new Vector3(0, 1, 2);
24 PoseBasePtr pose2 =
new Pose(pos2, ori2);
27 Vector3BasePtr pos3 =
new Vector3(0, -5, -2);
29 PoseBasePtr pose3 =
new Pose(pos3, ori3);
31 std::vector<PoseBasePtr> cp = {pose1, pose2, pose3};
34 BOOST_CHECK_EQUAL(ip->getNumberOfControlPoints(), 3);
36 BOOST_CHECK_EQUAL(ip->getPoseAt(0)->position->x, 2);
37 BOOST_CHECK_EQUAL(ip->getPoseAt(0)->position->y, 4);
38 BOOST_CHECK_EQUAL(ip->getPoseAt(0)->position->z, 6);
39 BOOST_CHECK_EQUAL(ip->getPoseAt(0.5)->position->x, 0);
40 BOOST_CHECK_EQUAL(ip->getPoseAt(0.5)->position->y, 1);
41 BOOST_CHECK_EQUAL(ip->getPoseAt(0.5)->position->z, 2);
42 BOOST_CHECK_EQUAL(ip->getPoseAt(1)->position->x, 0);
43 BOOST_CHECK_EQUAL(ip->getPoseAt(1)->position->y, -5);
44 BOOST_CHECK_EQUAL(ip->getPoseAt(1)->position->z, -2);
55 Vector3BasePtr pos1 =
new Vector3(2, 4, 6);
57 PoseBasePtr pose1 =
new Pose(pos1, ori1);
59 Vector3BasePtr pos2 =
new Vector3(2, 4, 6);
61 PoseBasePtr pose2 =
new Pose(pos2, ori2);
63 Vector3BasePtr pos3 =
new Vector3(2, 4, 6);
65 PoseBasePtr pose3 =
new Pose(pos3, ori3);
67 Vector3BasePtr pos4 =
new Vector3(2, 4, 6);
69 PoseBasePtr pose4 =
new Pose(pos4, ori4);
71 std::vector<PoseBasePtr> cp = {pose1, pose2, pose3, pose4};
79 BOOST_CHECK_EQUAL(ip->getPoseAt(0)->orientation->qw, q1->qw);
80 BOOST_CHECK_EQUAL(ip->getPoseAt(0)->orientation->qx, q1->qx);
81 BOOST_CHECK_EQUAL(ip->getPoseAt(0)->orientation->qy, q1->qy);
82 BOOST_CHECK_EQUAL(ip->getPoseAt(0)->orientation->qz, q1->qz);
84 BOOST_CHECK_CLOSE(ip->getPoseAt(0.333)->orientation->qw, q2->qw, 1);
85 BOOST_CHECK_CLOSE(ip->getPoseAt(0.333)->orientation->qx, q2->qx, 1);
86 BOOST_CHECK_CLOSE(ip->getPoseAt(0.333)->orientation->qy, q2->qy, 1);
87 BOOST_CHECK_CLOSE(ip->getPoseAt(0.333)->orientation->qz, q2->qz, 1);
89 BOOST_CHECK_CLOSE(ip->getPoseAt(0.666)->orientation->qw, q3->qw, 1);
90 BOOST_CHECK_CLOSE(ip->getPoseAt(0.666)->orientation->qx, q3->qx, 1);
91 BOOST_CHECK_CLOSE(ip->getPoseAt(0.666)->orientation->qy, q3->qy, 1);
92 BOOST_CHECK_CLOSE(ip->getPoseAt(0.666)->orientation->qz, q3->qz, 1);
94 BOOST_CHECK_EQUAL(ip->getPoseAt(1)->orientation->qw, q4->qw);
95 BOOST_CHECK_EQUAL(ip->getPoseAt(1)->orientation->qx, q4->qx);
96 BOOST_CHECK_EQUAL(ip->getPoseAt(1)->orientation->qy, q4->qy);
97 BOOST_CHECK_EQUAL(ip->getPoseAt(1)->orientation->qz, q4->qz);
105 Vector3BasePtr pos1 =
new Vector3(2, 4, 6);
107 PoseBasePtr pose1 =
new Pose(pos1, ori1);
109 Vector3BasePtr pos2 =
new Vector3(0, -2, -8);
111 PoseBasePtr pose2 =
new Pose(pos2, ori2);
113 Vector3BasePtr pos3 =
new Vector3(2, 4, 6);
115 PoseBasePtr pose3 =
new Pose(pos3, ori3);
117 std::vector<PoseBasePtr> cp = {pose1, pose2, pose3};
120 BOOST_CHECK_EQUAL(ip->getPoseAt(0)->position->x, 2);
121 BOOST_CHECK_EQUAL(ip->getPoseAt(0)->position->y, 4);
122 BOOST_CHECK_EQUAL(ip->getPoseAt(0)->position->z, 6);
123 BOOST_CHECK_EQUAL(ip->getPoseAt(1)->position->x, 2);
124 BOOST_CHECK_EQUAL(ip->getPoseAt(1)->position->y, 4);
125 BOOST_CHECK_EQUAL(ip->getPoseAt(1)->position->z, 6);
126 BOOST_CHECK_EQUAL(ip->getPoseAt(0.5)->position->x, 0);
127 BOOST_CHECK_EQUAL(ip->getPoseAt(0.5)->position->y, -2);
128 BOOST_CHECK_EQUAL(ip->getPoseAt(0.5)->position->z, -8);
133 Vector3BasePtr pos1 =
new Vector3(2, 4, 6);
135 PoseBasePtr pose1 =
new Pose(pos1, ori1);
137 Vector3BasePtr pos2 =
new Vector3(0, -2, -8);
139 PoseBasePtr pose2 =
new Pose(pos2, ori2);
141 Vector3BasePtr pos3 =
new Vector3(5, 8, 7);
143 PoseBasePtr pose3 =
new Pose(pos3, ori3);
145 Vector3BasePtr pos4 =
new Vector3(4, 23, 1);
147 PoseBasePtr pose4 =
new Pose(pos4, ori4);
149 Vector3BasePtr pos5 =
new Vector3(7, 12, 4);
151 PoseBasePtr pose5 =
new Pose(pos5, ori5);
153 Vector3BasePtr pos6 =
new Vector3(7, 44, -3);
155 PoseBasePtr pose6 =
new Pose(pos6, ori6);
157 Vector3BasePtr pos7 =
new Vector3(5, 4, -8);
159 PoseBasePtr pose7 =
new Pose(pos7, ori7);
161 Vector3BasePtr pos8 =
new Vector3(5, -4, -8);
163 PoseBasePtr pose8 =
new Pose(pos8, ori8);
165 Vector3BasePtr pos9 =
new Vector3(0, 0, 4);
167 PoseBasePtr pose9 =
new Pose(pos9, ori9);
169 Vector3BasePtr pos10 =
new Vector3(0, 1, 2);
171 PoseBasePtr pose10 =
new Pose(pos10, ori10);
173 Vector3BasePtr pos11 =
new Vector3(0, 0, 0);
175 PoseBasePtr pose11 =
new Pose(pos11, ori11);
177 std::vector<PoseBasePtr> cp = {pose1, pose2, pose3, pose4, pose5, pose6, pose7, pose8, pose9, pose10, pose11};
180 BOOST_CHECK_EQUAL(ip->getPoseAt(0)->position->x, 2);
181 BOOST_CHECK_EQUAL(ip->getPoseAt(0)->position->y, 4);
182 BOOST_CHECK_EQUAL(ip->getPoseAt(0)->position->z, 6);
183 BOOST_CHECK_EQUAL(ip->getPoseAt(0.1)->position->x, 0);
184 BOOST_CHECK_EQUAL(ip->getPoseAt(0.1)->position->y, -2);
185 BOOST_CHECK_EQUAL(ip->getPoseAt(0.1)->position->z, -8);
186 BOOST_CHECK_EQUAL(ip->getPoseAt(0.2)->position->x, 5);
187 BOOST_CHECK_EQUAL(ip->getPoseAt(0.2)->position->y, 8);
188 BOOST_CHECK_EQUAL(ip->getPoseAt(0.2)->position->z, 7);
189 BOOST_CHECK_EQUAL(ip->getPoseAt(0.3)->position->x, 4);
190 BOOST_CHECK_EQUAL(ip->getPoseAt(0.3)->position->y, 23);
191 BOOST_CHECK_EQUAL(ip->getPoseAt(0.3)->position->z, 1);
192 BOOST_CHECK_EQUAL(ip->getPoseAt(0.4)->position->x, 7);
193 BOOST_CHECK_EQUAL(ip->getPoseAt(0.4)->position->y, 12);
194 BOOST_CHECK_EQUAL(ip->getPoseAt(0.4)->position->z, 4);
195 BOOST_CHECK_EQUAL(ip->getPoseAt(0.5)->position->x, 7);
196 BOOST_CHECK_EQUAL(ip->getPoseAt(0.5)->position->y, 44);
197 BOOST_CHECK_EQUAL(ip->getPoseAt(0.5)->position->z, -3);
198 BOOST_CHECK_EQUAL(ip->getPoseAt(0.6)->position->x, 5);
199 BOOST_CHECK_EQUAL(ip->getPoseAt(0.6)->position->y, 4);
200 BOOST_CHECK_EQUAL(ip->getPoseAt(0.6)->position->z, -8);
201 BOOST_CHECK_EQUAL(ip->getPoseAt(0.7)->position->x, 5);
202 BOOST_CHECK_EQUAL(ip->getPoseAt(0.7)->position->y, -4);
203 BOOST_CHECK_EQUAL(ip->getPoseAt(0.7)->position->z, -8);
204 BOOST_CHECK_EQUAL(ip->getPoseAt(0.8)->position->x, 0);
206 BOOST_CHECK_EQUAL(ip->getPoseAt(0.8)->position->z, 4);
208 BOOST_CHECK_EQUAL(ip->getPoseAt(0.9)->position->y, 1);
209 BOOST_CHECK_EQUAL(ip->getPoseAt(0.9)->position->z, 2);
210 BOOST_CHECK_EQUAL(ip->getPoseAt(1)->position->x, 0);
211 BOOST_CHECK_EQUAL(ip->getPoseAt(1)->position->y, 0);
212 BOOST_CHECK_EQUAL(ip->getPoseAt(1)->position->z, 0);