1 #define BOOST_TEST_MODULE ArmarX::RobotTrajectoryDesigner::InterpolationSegmentFactory
2 #define ARMARX_BOOST_TEST
4 #include <RobotComponents/Test.h>
6 #include "../InterpolationType.h"
7 #include "../InterpolationSegmentFactory.h"
8 #include "../exceptions/NoInterpolationPossibleException.h"
9 #include "../exceptions/InterpolationNotDefinedException.h"
11 #include <boost/test/unit_test.hpp>
13 #include "../../Interpolation/LinearInterpolation.h"
14 #include "../../Util/OrientationConversion.h"
20 Vector3BasePtr pos1 =
new Vector3(2, 4, 6);
22 PoseBasePtr pose1 =
new Pose(pos1, ori1);
24 Vector3BasePtr pos2 =
new Vector3(0, -2, -8);
26 PoseBasePtr pose2 =
new Pose(pos2, ori2);
28 Vector3BasePtr pos3 =
new Vector3(5, 8, 7);
30 PoseBasePtr pose3 =
new Pose(pos3, ori3);
32 Vector3BasePtr pos4 =
new Vector3(4, 23, 1);
34 PoseBasePtr pose4 =
new Pose(pos4, ori4);
36 Vector3BasePtr pos5 =
new Vector3(7, 12, 4);
38 PoseBasePtr pose5 =
new Pose(pos5, ori5);
40 Vector3BasePtr pos6 =
new Vector3(7, 44, -3);
42 PoseBasePtr pose6 =
new Pose(pos6, ori6);
44 Vector3BasePtr pos7 =
new Vector3(5, 4, -8);
46 PoseBasePtr pose7 =
new Pose(pos7, ori7);
48 Vector3BasePtr pos8 =
new Vector3(5, -4, -8);
50 PoseBasePtr pose8 =
new Pose(pos8, ori8);
52 Vector3BasePtr pos9 =
new Vector3(0, 0, 4);
54 PoseBasePtr pose9 =
new Pose(pos9, ori9);
56 Vector3BasePtr pos10 =
new Vector3(0, 1, 2);
58 PoseBasePtr pose10 =
new Pose(pos10, ori10);
60 Vector3BasePtr pos11 =
new Vector3(0, 0, 0);
62 PoseBasePtr pose11 =
new Pose(pos11, ori11);
64 std::vector<PoseBasePtr> cp = {pose1, pose2, pose3, pose4, pose5, pose6, pose7, pose8, pose9, pose10, pose11};
91 BOOST_CHECK_EQUAL(ips1->getPoseAt(0)->position->x, 2);
92 BOOST_CHECK_EQUAL(ips1->getPoseAt(0)->position->y, 4);
93 BOOST_CHECK_EQUAL(ips1->getPoseAt(0)->position->z, 6);
94 BOOST_CHECK_EQUAL(ips1->getPoseAt(1)->position->x, 0);
95 BOOST_CHECK_EQUAL(ips1->getPoseAt(1)->position->y, -2);
96 BOOST_CHECK_EQUAL(ips1->getPoseAt(1)->position->z, -8);
98 BOOST_CHECK_EQUAL(ips2->getPoseAt(0)->position->x, 0);
99 BOOST_CHECK_EQUAL(ips2->getPoseAt(0)->position->y, -2);
100 BOOST_CHECK_EQUAL(ips2->getPoseAt(0)->position->z, -8);
101 BOOST_CHECK_EQUAL(ips2->getPoseAt(1)->position->x, 5);
102 BOOST_CHECK_EQUAL(ips2->getPoseAt(1)->position->y, 8);
103 BOOST_CHECK_EQUAL(ips2->getPoseAt(1)->position->z, 7);
105 BOOST_CHECK_EQUAL(ips3->getPoseAt(0)->position->x, 5);
106 BOOST_CHECK_EQUAL(ips3->getPoseAt(0)->position->y, 8);
107 BOOST_CHECK_EQUAL(ips3->getPoseAt(0)->position->z, 7);
108 BOOST_CHECK_EQUAL(ips3->getPoseAt(1)->position->x, 4);
109 BOOST_CHECK_EQUAL(ips3->getPoseAt(1)->position->y, 23);
110 BOOST_CHECK_EQUAL(ips3->getPoseAt(1)->position->z, 1);
112 BOOST_CHECK_EQUAL(ips4->getPoseAt(0)->position->x, 4);
113 BOOST_CHECK_EQUAL(ips4->getPoseAt(0)->position->y, 23);
114 BOOST_CHECK_EQUAL(ips4->getPoseAt(0)->position->z, 1);
115 BOOST_CHECK_EQUAL(ips4->getPoseAt(1)->position->x, 7);
116 BOOST_CHECK_EQUAL(ips4->getPoseAt(1)->position->y, 12);
117 BOOST_CHECK_EQUAL(ips4->getPoseAt(1)->position->z, 4);
119 BOOST_CHECK_EQUAL(ips5->getPoseAt(0)->position->x, 7);
120 BOOST_CHECK_EQUAL(ips5->getPoseAt(0)->position->y, 12);
121 BOOST_CHECK_EQUAL(ips5->getPoseAt(0)->position->z, 4);
122 BOOST_CHECK_EQUAL(ips5->getPoseAt(1)->position->x, 7);
123 BOOST_CHECK_EQUAL(ips5->getPoseAt(1)->position->y, 44);
124 BOOST_CHECK_EQUAL(ips5->getPoseAt(1)->position->z, -3);
126 BOOST_CHECK_EQUAL(ips6->getPoseAt(0)->position->x, 7);
127 BOOST_CHECK_EQUAL(ips6->getPoseAt(0)->position->y, 44);
128 BOOST_CHECK_EQUAL(ips6->getPoseAt(0)->position->z, -3);
129 BOOST_CHECK_EQUAL(ips6->getPoseAt(1)->position->x, 5);
130 BOOST_CHECK_EQUAL(ips6->getPoseAt(1)->position->y, 4);
131 BOOST_CHECK_EQUAL(ips6->getPoseAt(1)->position->z, -8);
133 BOOST_CHECK_EQUAL(ips7->getPoseAt(0)->position->x, 5);
134 BOOST_CHECK_EQUAL(ips7->getPoseAt(0)->position->y, 4);
135 BOOST_CHECK_EQUAL(ips7->getPoseAt(0)->position->z, -8);
136 BOOST_CHECK_EQUAL(ips7->getPoseAt(1)->position->x, 5);
137 BOOST_CHECK_EQUAL(ips7->getPoseAt(1)->position->y, -4);
138 BOOST_CHECK_EQUAL(ips7->getPoseAt(1)->position->z, -8);
140 BOOST_CHECK_EQUAL(ips8->getPoseAt(0)->position->x, 5);
141 BOOST_CHECK_EQUAL(ips8->getPoseAt(0)->position->y, -4);
142 BOOST_CHECK_EQUAL(ips8->getPoseAt(0)->position->z, -8);
143 BOOST_CHECK_EQUAL(ips8->getPoseAt(1)->position->x, 0);
144 BOOST_CHECK_EQUAL(ips8->getPoseAt(1)->position->y, 0);
145 BOOST_CHECK_EQUAL(ips8->getPoseAt(1)->position->z, 4);
147 BOOST_CHECK_EQUAL(ips9->getPoseAt(0)->position->x, 0);
148 BOOST_CHECK_EQUAL(ips9->getPoseAt(0)->position->y, 0);
149 BOOST_CHECK_EQUAL(ips9->getPoseAt(0)->position->z, 4);
150 BOOST_CHECK_EQUAL(ips9->getPoseAt(1)->position->x, 0);
151 BOOST_CHECK_EQUAL(ips9->getPoseAt(1)->position->y, 1);
152 BOOST_CHECK_EQUAL(ips9->getPoseAt(1)->position->z, 2);
154 BOOST_CHECK_EQUAL(ips10->getPoseAt(0)->position->x, 0);
155 BOOST_CHECK_EQUAL(ips10->getPoseAt(0)->position->y, 1);
156 BOOST_CHECK_EQUAL(ips10->getPoseAt(0)->position->z, 2);
157 BOOST_CHECK_EQUAL(ips10->getPoseAt(1)->position->x, 0);
158 BOOST_CHECK_EQUAL(ips10->getPoseAt(1)->position->y, 0);
159 BOOST_CHECK_EQUAL(ips10->getPoseAt(1)->position->z, 0);
178 Vector3BasePtr pos1 =
new Vector3(2, 4, 6);
180 PoseBasePtr pose1 =
new Pose(pos1, ori1);
182 Vector3BasePtr pos2 =
new Vector3(0, -2, -8);
184 PoseBasePtr pose2 =
new Pose(pos2, ori2);
186 Vector3BasePtr pos3 =
new Vector3(5, 8, 7);
188 PoseBasePtr pose3 =
new Pose(pos3, ori3);
190 Vector3BasePtr pos4 =
new Vector3(4, 23, 1);
192 PoseBasePtr pose4 =
new Pose(pos4, ori4);
194 Vector3BasePtr pos5 =
new Vector3(7, 12, 4);
196 PoseBasePtr pose5 =
new Pose(pos5, ori5);
198 Vector3BasePtr pos6 =
new Vector3(7, 44, -3);
200 PoseBasePtr pose6 =
new Pose(pos6, ori6);
202 Vector3BasePtr pos7 =
new Vector3(5, 4, -8);
204 PoseBasePtr pose7 =
new Pose(pos7, ori7);
206 Vector3BasePtr pos8 =
new Vector3(5, -4, -8);
208 PoseBasePtr pose8 =
new Pose(pos8, ori8);
210 Vector3BasePtr pos9 =
new Vector3(0, 0, 4);
212 PoseBasePtr pose9 =
new Pose(pos9, ori9);
214 Vector3BasePtr pos10 =
new Vector3(0, 1, 2);
216 PoseBasePtr pose10 =
new Pose(pos10, ori10);
218 Vector3BasePtr pos11 =
new Vector3(0, 0, 0);
220 PoseBasePtr pose11 =
new Pose(pos11, ori11);
222 std::vector<PoseBasePtr> cp = {pose1, pose2, pose3, pose4, pose5, pose6, pose7, pose8, pose9, pose10, pose11};
265 Vector3BasePtr pos1 =
new Vector3(2, 4, 6);
267 PoseBasePtr pose1 =
new Pose(pos1, ori1);
269 std::vector<PoseBasePtr> poses = std::vector<PoseBasePtr>();
270 for (
int i = 0; i < 10; i++)
272 poses.push_back(pose1);
274 std::vector<VirtualRobot::IKSolver::CartesianSelection> selections = std::vector<VirtualRobot::IKSolver::CartesianSelection>();
275 selections.push_back(VirtualRobot::IKSolver::CartesianSelection::All);
278 selections.push_back(VirtualRobot::IKSolver::CartesianSelection::All);
281 selections.push_back(VirtualRobot::IKSolver::CartesianSelection::All);
282 selections.push_back(VirtualRobot::IKSolver::CartesianSelection::All);
284 selections.push_back(VirtualRobot::IKSolver::CartesianSelection::All);
288 BOOST_CHECK_EQUAL(selections[0], VirtualRobot::IKSolver::CartesianSelection::All);
289 BOOST_CHECK_EQUAL(selections[1], VirtualRobot::IKSolver::CartesianSelection::All);
290 BOOST_CHECK_EQUAL(selections[2], VirtualRobot::IKSolver::CartesianSelection::All);
291 BOOST_CHECK_EQUAL(selections[3], VirtualRobot::IKSolver::CartesianSelection::All);
292 BOOST_CHECK_EQUAL(selections[4], VirtualRobot::IKSolver::CartesianSelection::All);
293 BOOST_CHECK_EQUAL(selections[5], VirtualRobot::IKSolver::CartesianSelection::All);
294 BOOST_CHECK_EQUAL(selections[6], VirtualRobot::IKSolver::CartesianSelection::All);
295 BOOST_CHECK_EQUAL(selections[7], VirtualRobot::IKSolver::CartesianSelection::All);
296 BOOST_CHECK_EQUAL(selections[8], VirtualRobot::IKSolver::CartesianSelection::All);
297 BOOST_CHECK_EQUAL(selections[9], VirtualRobot::IKSolver::CartesianSelection::All);
304 Vector3BasePtr pos1 =
new Vector3(2, 4, 6);
306 PoseBasePtr pose1 =
new Pose(pos1, ori1);
308 std::vector<PoseBasePtr> poses = std::vector<PoseBasePtr>();
309 for (
int i = 0; i < 11; i++)
311 poses.push_back(pose1);
313 std::vector<VirtualRobot::IKSolver::CartesianSelection> selections = std::vector<VirtualRobot::IKSolver::CartesianSelection>();
314 selections.push_back(VirtualRobot::IKSolver::CartesianSelection::All);
316 selections.push_back(VirtualRobot::IKSolver::CartesianSelection::All);
317 selections.push_back(VirtualRobot::IKSolver::CartesianSelection::X);
318 selections.push_back(VirtualRobot::IKSolver::CartesianSelection::Y);
321 selections.push_back(VirtualRobot::IKSolver::CartesianSelection::Y);
323 selections.push_back(VirtualRobot::IKSolver::CartesianSelection::Z);
324 selections.push_back(VirtualRobot::IKSolver::CartesianSelection::Z);
329 BOOST_CHECK_EQUAL(selections[0], VirtualRobot::IKSolver::CartesianSelection::All);
330 BOOST_CHECK_EQUAL(selections[1], VirtualRobot::IKSolver::CartesianSelection::All);
331 BOOST_CHECK_EQUAL(selections[2], VirtualRobot::IKSolver::CartesianSelection::All);
338 BOOST_CHECK_EQUAL(selections[9], VirtualRobot::IKSolver::CartesianSelection::Z);
339 selections.push_back(VirtualRobot::IKSolver::CartesianSelection::Z);
344 Vector3BasePtr pos1 =
new Vector3(2, 4, 6);
346 PoseBasePtr pose1 =
new Pose(pos1, ori1);
348 std::vector<PoseBasePtr> poses = std::vector<PoseBasePtr>();
349 for (
int i = 0; i < 20; i++)
351 poses.push_back(pose1);
353 std::vector<VirtualRobot::IKSolver::CartesianSelection> selections = std::vector<VirtualRobot::IKSolver::CartesianSelection>();
354 selections.push_back(VirtualRobot::IKSolver::CartesianSelection::X);
358 selections.push_back(VirtualRobot::IKSolver::CartesianSelection::X);
360 selections.push_back(VirtualRobot::IKSolver::CartesianSelection::X);
361 selections.push_back(VirtualRobot::IKSolver::CartesianSelection::Y);
363 selections.push_back(VirtualRobot::IKSolver::CartesianSelection::X);
364 selections.push_back(VirtualRobot::IKSolver::CartesianSelection::Y);
365 selections.push_back(VirtualRobot::IKSolver::CartesianSelection::Z);
366 selections.push_back(VirtualRobot::IKSolver::CartesianSelection::Z);
369 selections.push_back(VirtualRobot::IKSolver::CartesianSelection::Y);
370 selections.push_back(VirtualRobot::IKSolver::CartesianSelection::Z);
371 selections.push_back(VirtualRobot::IKSolver::CartesianSelection::Y);
372 selections.push_back(VirtualRobot::IKSolver::CartesianSelection::X);
373 selections.push_back(VirtualRobot::IKSolver::CartesianSelection::X);
377 BOOST_CHECK_EQUAL(selections[0], VirtualRobot::IKSolver::CartesianSelection::All);
378 BOOST_CHECK_EQUAL(selections[1], VirtualRobot::IKSolver::CartesianSelection::All);
379 BOOST_CHECK_EQUAL(selections[2], VirtualRobot::IKSolver::CartesianSelection::All);
380 BOOST_CHECK_EQUAL(selections[3], VirtualRobot::IKSolver::CartesianSelection::All);
381 BOOST_CHECK_EQUAL(selections[4], VirtualRobot::IKSolver::CartesianSelection::All);
382 BOOST_CHECK_EQUAL(selections[5], VirtualRobot::IKSolver::CartesianSelection::All);
383 BOOST_CHECK_EQUAL(selections[6], VirtualRobot::IKSolver::CartesianSelection::All);
384 BOOST_CHECK_EQUAL(selections[7], VirtualRobot::IKSolver::CartesianSelection::All);
385 BOOST_CHECK_EQUAL(selections[8], VirtualRobot::IKSolver::CartesianSelection::All);
396 BOOST_CHECK_EQUAL(selections[19], VirtualRobot::IKSolver::CartesianSelection::X);