1 #define BOOST_TEST_MODULE ArmarX::RobotTrajectoryDesigner::LinearInterpolation
2 #define ARMARX_BOOST_TEST
5 #include <RobotComponents/Test.h>
7 #include "../../Interpolation/LinearInterpolation.h"
8 #include "../../Util/OrientationConversion.h"
17 Vector3BasePtr pos1 =
new Vector3(2, 4, 6);
19 PoseBasePtr pose1 =
new Pose(pos1, ori1);
21 Vector3BasePtr pos2 =
new Vector3(0, 1, 2);
23 PoseBasePtr pose2 =
new Pose(pos2, ori2);
25 std::vector<PoseBasePtr> cp = *
new std::vector<PoseBasePtr>();
30 BOOST_CHECK_EQUAL(ip->getNumberOfControlPoints(), 2);
32 BOOST_CHECK_EQUAL(ip->getPoseAt(0)->position->x, 2);
33 BOOST_CHECK_EQUAL(ip->getPoseAt(0)->position->y, 4);
34 BOOST_CHECK_EQUAL(ip->getPoseAt(0)->position->z, 6);
35 BOOST_CHECK_EQUAL(ip->getPoseAt(1)->position->x, 0);
36 BOOST_CHECK_EQUAL(ip->getPoseAt(1)->position->y, 1);
37 BOOST_CHECK_EQUAL(ip->getPoseAt(1)->position->z, 2);
38 BOOST_CHECK_EQUAL(ip->getPoseAt(0.5)->position->x, 1);
39 BOOST_CHECK_EQUAL(ip->getPoseAt(0.5)->position->y, 2.5);
40 BOOST_CHECK_EQUAL(ip->getPoseAt(0.5)->position->z, 4);
45 Vector3BasePtr pos1 =
new Vector3(2, 4, 6);
47 PoseBasePtr pose1 =
new Pose(pos1, ori1);
49 Vector3BasePtr pos2 =
new Vector3(0, 1, 2);
51 PoseBasePtr pose2 =
new Pose(pos2, ori2);
54 Vector3BasePtr pos3 =
new Vector3(0, -5, -2);
56 PoseBasePtr pose3 =
new Pose(pos3, ori3);
58 std::vector<PoseBasePtr> cp = {pose1, pose2, pose3};
61 BOOST_CHECK_EQUAL(ip->getNumberOfControlPoints(), 3);
63 BOOST_CHECK_EQUAL(ip->getPoseAt(0)->position->x, 2);
64 BOOST_CHECK_EQUAL(ip->getPoseAt(0)->position->y, 4);
65 BOOST_CHECK_EQUAL(ip->getPoseAt(0)->position->z, 6);
66 BOOST_CHECK_EQUAL(ip->getPoseAt(0.5)->position->x, 0);
67 BOOST_CHECK_EQUAL(ip->getPoseAt(0.5)->position->y, 1);
68 BOOST_CHECK_EQUAL(ip->getPoseAt(0.5)->position->z, 2);
69 BOOST_CHECK_EQUAL(ip->getPoseAt(1)->position->x, 0);
70 BOOST_CHECK_EQUAL(ip->getPoseAt(1)->position->y, -5);
71 BOOST_CHECK_EQUAL(ip->getPoseAt(1)->position->z, -2);
76 Vector3BasePtr pos1 =
new Vector3(2, 4, 6);
78 PoseBasePtr pose1 =
new Pose(pos1, ori1);
80 Vector3BasePtr pos2 =
new Vector3(2, 4, 6);
82 PoseBasePtr pose2 =
new Pose(pos2, ori2);
84 std::vector<PoseBasePtr> cp = {pose1, pose2};
87 BOOST_CHECK_EQUAL(ip->getNumberOfControlPoints(), 2);
89 BOOST_CHECK_EQUAL(ip->getPoseAt(0)->position->x, 2);
90 BOOST_CHECK_EQUAL(ip->getPoseAt(0)->position->y, 4);
91 BOOST_CHECK_EQUAL(ip->getPoseAt(0)->position->z, 6);
92 BOOST_CHECK_EQUAL(ip->getPoseAt(1)->position->x, 2);
93 BOOST_CHECK_EQUAL(ip->getPoseAt(1)->position->y, 4);
94 BOOST_CHECK_EQUAL(ip->getPoseAt(1)->position->z, 6);
95 BOOST_CHECK_EQUAL(ip->getPoseAt(0.5)->position->x, 2);
96 BOOST_CHECK_EQUAL(ip->getPoseAt(0.5)->position->y, 4);
97 BOOST_CHECK_EQUAL(ip->getPoseAt(0.5)->position->z, 6);
98 BOOST_CHECK_EQUAL(ip->getPoseAt(0.154645)->position->x, 2);
99 BOOST_CHECK_EQUAL(ip->getPoseAt(0.154645)->position->y, 4);
100 BOOST_CHECK_EQUAL(ip->getPoseAt(0.154645)->position->z, 6);
101 BOOST_CHECK_EQUAL(ip->getPoseAt(0.8997)->position->x, 2);
102 BOOST_CHECK_EQUAL(ip->getPoseAt(0.8997)->position->y, 4);
103 BOOST_CHECK_EQUAL(ip->getPoseAt(0.8997)->position->z, 6);
110 Vector3BasePtr pos1 =
new Vector3(2, 4, 6);
112 PoseBasePtr pose1 =
new Pose(pos1, ori1);
114 Vector3BasePtr pos2 =
new Vector3(2, 4, 6);
116 PoseBasePtr pose2 =
new Pose(pos2, ori2);
118 Vector3BasePtr pos3 =
new Vector3(2, 4, 6);
120 PoseBasePtr pose3 =
new Pose(pos3, ori3);
122 Vector3BasePtr pos4 =
new Vector3(2, 4, 6);
124 PoseBasePtr pose4 =
new Pose(pos4, ori4);
126 std::vector<PoseBasePtr> cp = {pose1, pose2, pose3, pose4};
134 BOOST_CHECK_EQUAL(ip->getPoseAt(0)->orientation->qw, q1->qw);
135 BOOST_CHECK_EQUAL(ip->getPoseAt(0)->orientation->qx, q1->qx);
136 BOOST_CHECK_EQUAL(ip->getPoseAt(0)->orientation->qy, q1->qy);
137 BOOST_CHECK_EQUAL(ip->getPoseAt(0)->orientation->qz, q1->qz);
139 BOOST_CHECK_CLOSE(ip->getPoseAt(0.333)->orientation->qw, q2->qw, 1);
140 BOOST_CHECK_CLOSE(ip->getPoseAt(0.333)->orientation->qx, q2->qx, 1);
141 BOOST_CHECK_CLOSE(ip->getPoseAt(0.333)->orientation->qy, q2->qy, 1);
142 BOOST_CHECK_CLOSE(ip->getPoseAt(0.333)->orientation->qz, q2->qz, 1);
144 BOOST_CHECK_CLOSE(ip->getPoseAt(0.666)->orientation->qw, q3->qw, 1);
145 BOOST_CHECK_CLOSE(ip->getPoseAt(0.666)->orientation->qx, q3->qx, 1);
146 BOOST_CHECK_CLOSE(ip->getPoseAt(0.666)->orientation->qy, q3->qy, 1);
147 BOOST_CHECK_CLOSE(ip->getPoseAt(0.666)->orientation->qz, q3->qz, 1);
149 BOOST_CHECK_EQUAL(ip->getPoseAt(1)->orientation->qw, q4->qw);
150 BOOST_CHECK_EQUAL(ip->getPoseAt(1)->orientation->qx, q4->qx);
151 BOOST_CHECK_EQUAL(ip->getPoseAt(1)->orientation->qy, q4->qy);
152 BOOST_CHECK_EQUAL(ip->getPoseAt(1)->orientation->qz, q4->qz);
159 Vector3BasePtr pos1 =
new Vector3(2, 4, 6);
161 PoseBasePtr pose1 =
new Pose(pos1, ori1);
163 Vector3BasePtr pos2 =
new Vector3(0, -2, -8);
165 PoseBasePtr pose2 =
new Pose(pos2, ori2);
167 Vector3BasePtr pos3 =
new Vector3(2, 4, 6);
169 PoseBasePtr pose3 =
new Pose(pos3, ori3);
171 std::vector<PoseBasePtr> cp = {pose1, pose2, pose3};
174 BOOST_CHECK_EQUAL(ip->getPoseAt(0)->position->x, 2);
175 BOOST_CHECK_EQUAL(ip->getPoseAt(0)->position->y, 4);
176 BOOST_CHECK_EQUAL(ip->getPoseAt(0)->position->z, 6);
177 BOOST_CHECK_EQUAL(ip->getPoseAt(1)->position->x, 2);
178 BOOST_CHECK_EQUAL(ip->getPoseAt(1)->position->y, 4);
179 BOOST_CHECK_EQUAL(ip->getPoseAt(1)->position->z, 6);
180 BOOST_CHECK_EQUAL(ip->getPoseAt(0.5)->position->x, 0);
181 BOOST_CHECK_EQUAL(ip->getPoseAt(0.5)->position->y, -2);
182 BOOST_CHECK_EQUAL(ip->getPoseAt(0.5)->position->z, -8);
183 BOOST_CHECK_EQUAL(ip->getPoseAt(0.25)->position->x, 1);
184 BOOST_CHECK_EQUAL(ip->getPoseAt(0.25)->position->y, 1);
185 BOOST_CHECK_EQUAL(ip->getPoseAt(0.25)->position->z, -1);
186 BOOST_CHECK_EQUAL(ip->getPoseAt(0.75)->position->x, 1);
187 BOOST_CHECK_EQUAL(ip->getPoseAt(0.75)->position->y, 1);
188 BOOST_CHECK_EQUAL(ip->getPoseAt(0.75)->position->z, -1);
195 Vector3BasePtr pos1 =
new Vector3(2, 4, 6);
197 PoseBasePtr pose1 =
new Pose(pos1, ori1);
199 Vector3BasePtr pos2 =
new Vector3(0, -2, -8);
201 PoseBasePtr pose2 =
new Pose(pos2, ori2);
203 Vector3BasePtr pos3 =
new Vector3(5, 8, 7);
205 PoseBasePtr pose3 =
new Pose(pos3, ori3);
207 Vector3BasePtr pos4 =
new Vector3(4, 23, 1);
209 PoseBasePtr pose4 =
new Pose(pos4, ori4);
211 Vector3BasePtr pos5 =
new Vector3(7, 12, 4);
213 PoseBasePtr pose5 =
new Pose(pos5, ori5);
215 Vector3BasePtr pos6 =
new Vector3(7, 44, -3);
217 PoseBasePtr pose6 =
new Pose(pos6, ori6);
219 Vector3BasePtr pos7 =
new Vector3(5, 4, -8);
221 PoseBasePtr pose7 =
new Pose(pos7, ori7);
223 Vector3BasePtr pos8 =
new Vector3(5, -4, -8);
225 PoseBasePtr pose8 =
new Pose(pos8, ori8);
227 Vector3BasePtr pos9 =
new Vector3(0, 0, 4);
229 PoseBasePtr pose9 =
new Pose(pos9, ori9);
231 Vector3BasePtr pos10 =
new Vector3(0, 1, 2);
233 PoseBasePtr pose10 =
new Pose(pos10, ori10);
235 Vector3BasePtr pos11 =
new Vector3(0, 0, 0);
237 PoseBasePtr pose11 =
new Pose(pos11, ori11);
258 std::vector<PoseBasePtr> cp = {pose1, pose2, pose3, pose4, pose5, pose6, pose7, pose8, pose9, pose10, pose11};
261 BOOST_CHECK_EQUAL(ip->getPoseAt(0)->position->x, 2);
262 BOOST_CHECK_EQUAL(ip->getPoseAt(0)->position->y, 4);
263 BOOST_CHECK_EQUAL(ip->getPoseAt(0)->position->z, 6);
264 BOOST_CHECK_EQUAL(ip->getPoseAt(0.1)->position->x, 0);
265 BOOST_CHECK_EQUAL(ip->getPoseAt(0.1)->position->y, -2);
266 BOOST_CHECK_EQUAL(ip->getPoseAt(0.1)->position->z, -8);
267 BOOST_CHECK_EQUAL(ip->getPoseAt(0.2)->position->x, 5);
268 BOOST_CHECK_EQUAL(ip->getPoseAt(0.2)->position->y, 8);
269 BOOST_CHECK_EQUAL(ip->getPoseAt(0.2)->position->z, 7);
270 BOOST_CHECK_EQUAL(ip->getPoseAt(0.3)->position->x, 4);
271 BOOST_CHECK_EQUAL(ip->getPoseAt(0.3)->position->y, 23);
272 BOOST_CHECK_EQUAL(ip->getPoseAt(0.3)->position->z, 1);
273 BOOST_CHECK_EQUAL(ip->getPoseAt(0.4)->position->x, 7);
274 BOOST_CHECK_EQUAL(ip->getPoseAt(0.4)->position->y, 12);
275 BOOST_CHECK_EQUAL(ip->getPoseAt(0.4)->position->z, 4);
276 BOOST_CHECK_EQUAL(ip->getPoseAt(0.5)->position->x, 7);
277 BOOST_CHECK_EQUAL(ip->getPoseAt(0.5)->position->y, 44);
278 BOOST_CHECK_EQUAL(ip->getPoseAt(0.5)->position->z, -3);
279 BOOST_CHECK_EQUAL(ip->getPoseAt(0.6)->position->x, 5);
280 BOOST_CHECK_EQUAL(ip->getPoseAt(0.6)->position->y, 4);
281 BOOST_CHECK_EQUAL(ip->getPoseAt(0.6)->position->z, -8);
282 BOOST_CHECK_EQUAL(ip->getPoseAt(0.7)->position->x, 5);
283 BOOST_CHECK_EQUAL(ip->getPoseAt(0.7)->position->y, -4);
284 BOOST_CHECK_EQUAL(ip->getPoseAt(0.7)->position->z, -8);
285 BOOST_CHECK_EQUAL(ip->getPoseAt(0.8)->position->x, 0);
286 BOOST_CHECK_EQUAL(ip->getPoseAt(0.8)->position->y, 0);
287 BOOST_CHECK_EQUAL(ip->getPoseAt(0.8)->position->z, 4);
288 BOOST_CHECK_EQUAL(ip->getPoseAt(0.9)->position->x, 0);
289 BOOST_CHECK_EQUAL(ip->getPoseAt(0.9)->position->y, 1);
290 BOOST_CHECK_EQUAL(ip->getPoseAt(0.9)->position->z, 2);
291 BOOST_CHECK_EQUAL(ip->getPoseAt(1)->position->x, 0);
292 BOOST_CHECK_EQUAL(ip->getPoseAt(1)->position->y, 0);
293 BOOST_CHECK_EQUAL(ip->getPoseAt(1)->position->z, 0);