moveit2
The MoveIt Motion Planning Framework for ROS 2.
Loading...
Searching...
No Matches
unittest_joint_limits_validator.cpp
Go to the documentation of this file.
1/*********************************************************************
2 * Software License Agreement (BSD License)
3 *
4 * Copyright (c) 2018 Pilz GmbH & Co. KG
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 *
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above
14 * copyright notice, this list of conditions and the following
15 * disclaimer in the documentation and/or other materials provided
16 * with the distribution.
17 * * Neither the name of Pilz GmbH & Co. KG nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 * POSSIBILITY OF SUCH DAMAGE.
33 *********************************************************************/
34
35#include <gtest/gtest.h>
36
38
40
41using namespace pilz_industrial_motion_planner;
42
43class JointLimitsValidatorTest : public ::testing::Test
44{
45};
46
50TEST_F(JointLimitsValidatorTest, CheckPositionEquality)
51{
52 JointLimitsContainer container;
53
55 lim1.has_position_limits = true;
56 lim1.min_position = -1;
57 lim1.max_position = 1;
58
59 container.addLimit("joint1", lim1);
60 container.addLimit("joint2", lim1);
61
66}
67
71TEST_F(JointLimitsValidatorTest, CheckPositionInEqualityMinPosition)
72{
73 JointLimitsContainer container;
74
76 lim1.has_position_limits = true;
77 lim1.min_position = -1;
78 lim1.max_position = 1;
79
81 lim2.has_position_limits = true;
82 lim2.min_position = -2;
83 lim2.max_position = 1;
84
85 container.addLimit("joint1", lim1);
86 container.addLimit("joint2", lim2);
87
92}
93
97TEST_F(JointLimitsValidatorTest, CheckPositionInEqualityMaxPosition1)
98{
99 JointLimitsContainer container;
100
102 lim1.has_position_limits = true;
103 lim1.min_position = -1;
104 lim1.max_position = 2;
105
107 lim2.has_position_limits = true;
108 lim2.min_position = -1;
109 lim2.max_position = 1;
110
111 container.addLimit("joint1", lim1);
112 container.addLimit("joint2", lim2);
113
114 EXPECT_EQ(false, JointLimitsValidator::validateAllPositionLimitsEqual(container));
118}
119
123TEST_F(JointLimitsValidatorTest, CheckPositionInEqualityMaxPosition2)
124{
125 JointLimitsContainer container;
126
128 lim1.has_position_limits = true;
129 lim1.min_position = -1;
130 lim1.max_position = 2;
131
133 lim2.has_position_limits = true;
134 lim2.min_position = -1;
135 lim2.max_position = 1;
136
138 lim3.has_position_limits = true;
139 lim3.min_position = -1;
140 lim3.max_position = 1;
141
142 container.addLimit("joint1", lim1);
143 container.addLimit("joint2", lim2);
144 container.addLimit("joint3", lim3);
145
146 EXPECT_EQ(false, JointLimitsValidator::validateAllPositionLimitsEqual(container));
150}
151
155TEST_F(JointLimitsValidatorTest, CheckPositionInEqualityHasPositionLimits)
156{
157 JointLimitsContainer container;
158
160 lim1.has_position_limits = true;
161 lim1.min_position = -1;
162 lim1.max_position = 1;
163
165 lim2.has_position_limits = false;
166 lim2.min_position = -1;
167 lim2.max_position = 1;
168
169 container.addLimit("joint1", lim1);
170 container.addLimit("joint2", lim2);
171
172 EXPECT_EQ(false, JointLimitsValidator::validateAllPositionLimitsEqual(container));
176}
177
178//----------------------------------------------------------------------------------
179//----------------------------------------------------------------------------------
180// VELOCITY
181//----------------------------------------------------------------------------------
182//----------------------------------------------------------------------------------
183
187TEST_F(JointLimitsValidatorTest, CheckVelocityEquality)
188{
189 JointLimitsContainer container;
190
192 lim1.has_velocity_limits = true;
193 lim1.max_velocity = 1;
194
195 container.addLimit("joint1", lim1);
196 container.addLimit("joint2", lim1);
197
202}
203
207TEST_F(JointLimitsValidatorTest, CheckPositionInEqualityMaxVelocity1)
208{
209 JointLimitsContainer container;
210
212 lim1.has_velocity_limits = true;
213 lim1.max_velocity = 1;
214
216 lim2.has_velocity_limits = true;
217 lim2.max_velocity = 2;
218
219 container.addLimit("joint1", lim1);
220 container.addLimit("joint2", lim2);
221
223 EXPECT_EQ(false, JointLimitsValidator::validateAllVelocityLimitsEqual(container));
226}
227
231TEST_F(JointLimitsValidatorTest, CheckPositionInEqualityMaxVelocity2)
232{
233 JointLimitsContainer container;
234
236 lim1.has_velocity_limits = true;
237 lim1.max_velocity = 1;
238
240 lim2.has_velocity_limits = true;
241 lim2.max_velocity = 2;
242
244 lim3.has_velocity_limits = true;
245 lim3.max_velocity = 2;
246
247 container.addLimit("joint1", lim1);
248 container.addLimit("joint2", lim2);
249 container.addLimit("joint3", lim3);
250
252 EXPECT_EQ(false, JointLimitsValidator::validateAllVelocityLimitsEqual(container));
255}
256
260TEST_F(JointLimitsValidatorTest, CheckPositionInEqualityHasVelocityLimits)
261{
262 JointLimitsContainer container;
263
265 lim1.has_velocity_limits = true;
266
268 lim2.has_velocity_limits = false;
269
270 container.addLimit("joint1", lim1);
271 container.addLimit("joint2", lim2);
272
274 EXPECT_EQ(false, JointLimitsValidator::validateAllVelocityLimitsEqual(container));
277}
278
279//----------------------------------------------------------------------------------
280//----------------------------------------------------------------------------------
281// ACCELERATION
282//----------------------------------------------------------------------------------
283//----------------------------------------------------------------------------------
284
288TEST_F(JointLimitsValidatorTest, CheckAccelerationEquality)
289{
290 JointLimitsContainer container;
291
293 lim1.has_acceleration_limits = true;
294 lim1.max_acceleration = 1;
295
296 container.addLimit("joint1", lim1);
297 container.addLimit("joint2", lim1);
298
303}
304
308TEST_F(JointLimitsValidatorTest, CheckPositionInEqualityMaxAcceleration1)
309{
310 JointLimitsContainer container;
311
313 lim1.has_acceleration_limits = true;
314 lim1.max_acceleration = 1;
315
317 lim2.has_acceleration_limits = true;
318 lim2.max_acceleration = 2;
319
320 container.addLimit("joint1", lim1);
321 container.addLimit("joint2", lim2);
322
327}
328
332TEST_F(JointLimitsValidatorTest, CheckPositionInEqualityMaxAcceleration2)
333{
334 JointLimitsContainer container;
335
337 lim1.has_acceleration_limits = true;
338 lim1.max_acceleration = 1;
339
341 lim2.has_acceleration_limits = true;
342 lim2.max_acceleration = 2;
343
345 lim3.has_acceleration_limits = true;
346 lim3.max_acceleration = 2;
347
348 container.addLimit("joint1", lim1);
349 container.addLimit("joint2", lim2);
350 container.addLimit("joint3", lim3);
351
356}
357
362TEST_F(JointLimitsValidatorTest, CheckPositionInEqualityHasAccelerationLimits)
363{
364 JointLimitsContainer container;
365
367 lim1.has_acceleration_limits = true;
368
370 lim2.has_acceleration_limits = false;
371
372 container.addLimit("joint1", lim1);
373 container.addLimit("joint2", lim2);
374
379}
380
381//----------------------------------------------------------------------------------
382//----------------------------------------------------------------------------------
383// DECELERATION
384//----------------------------------------------------------------------------------
385//----------------------------------------------------------------------------------
386
390TEST_F(JointLimitsValidatorTest, CheckDecelerationEquality)
391{
392 JointLimitsContainer container;
393
395 lim1.has_deceleration_limits = true;
396 lim1.max_deceleration = 1;
397
398 container.addLimit("joint1", lim1);
399 container.addLimit("joint2", lim1);
400
405}
406
410TEST_F(JointLimitsValidatorTest, CheckInEqualityMaxDeceleration1)
411{
412 JointLimitsContainer container;
413
415 lim1.has_deceleration_limits = true;
416 lim1.max_deceleration = -1;
417
419 lim2.has_deceleration_limits = true;
420 lim2.max_deceleration = -2;
421
422 container.addLimit("joint1", lim1);
423 container.addLimit("joint2", lim2);
424
429}
430
434TEST_F(JointLimitsValidatorTest, CheckInEqualityMaxDeceleration2)
435{
436 JointLimitsContainer container;
437
439 lim1.has_deceleration_limits = true;
440 lim1.max_deceleration = -1;
441
443 lim2.has_deceleration_limits = true;
444 lim2.max_deceleration = -2;
445
447 lim3.has_deceleration_limits = true;
448 lim3.max_deceleration = -2;
449
450 container.addLimit("joint1", lim1);
451 container.addLimit("joint2", lim2);
452 container.addLimit("joint3", lim3);
453
458}
459
464TEST_F(JointLimitsValidatorTest, CheckInEqualityHasDecelerationLimits)
465{
466 JointLimitsContainer container;
467
469 lim1.has_deceleration_limits = true;
470 lim1.max_deceleration = -1;
471
473 lim2.has_deceleration_limits = false;
474
475 container.addLimit("joint1", lim1);
476 container.addLimit("joint2", lim2);
477
478 ASSERT_EQ(2u, container.getCount());
479
484}
485
486int main(int argc, char** argv)
487{
488 testing::InitGoogleTest(&argc, argv);
489 return RUN_ALL_TESTS();
490}
Container for JointLimits, essentially a map with convenience functions. Adds the ability to as for l...
bool addLimit(const std::string &joint_name, JointLimit joint_limit)
Add a limit.
size_t getCount() const
Get Number of limits in the container.
static bool validateAllPositionLimitsEqual(const pilz_industrial_motion_planner::JointLimitsContainer &joint_limits)
Validates that the position limits of all limits are equal.
static bool validateAllDecelerationLimitsEqual(const pilz_industrial_motion_planner::JointLimitsContainer &joint_limits)
Validates that the deceleration of all limits is equal.
static bool validateAllVelocityLimitsEqual(const pilz_industrial_motion_planner::JointLimitsContainer &joint_limits)
Validates that the velocity of all limits is equal.
static bool validateAllAccelerationLimitsEqual(const pilz_industrial_motion_planner::JointLimitsContainer &joint_limits)
Validates that the acceleration of all limits is equal.
TEST_F(GetSolverTipFrameIntegrationTest, TestHasSolverManipulator)
Check if hasSolver() can be called successfully for the manipulator group.
Extends joint_limits_interface::JointLimits with a deceleration parameter.
int main(int argc, char **argv)