133 auto nbr_ex = std::make_shared<NegativeBlendRadiusException>(
"");
134 EXPECT_EQ(nbr_ex->getErrorCode(), moveit_msgs::msg::MoveItErrorCodes::INVALID_MOTION_PLAN);
136 auto lbrnz_ex = std::make_shared<LastBlendRadiusNotZeroException>(
"");
137 EXPECT_EQ(lbrnz_ex->getErrorCode(), moveit_msgs::msg::MoveItErrorCodes::INVALID_MOTION_PLAN);
139 auto sss_ex = std::make_shared<StartStateSetException>(
"");
140 EXPECT_EQ(sss_ex->getErrorCode(), moveit_msgs::msg::MoveItErrorCodes::INVALID_ROBOT_STATE);
142 auto obr_ex = std::make_shared<OverlappingBlendRadiiException>(
"");
143 EXPECT_EQ(obr_ex->getErrorCode(), moveit_msgs::msg::MoveItErrorCodes::INVALID_MOTION_PLAN);
145 auto pp_ex = std::make_shared<PlanningPipelineException>(
"");
146 EXPECT_EQ(pp_ex->getErrorCode(), moveit_msgs::msg::MoveItErrorCodes::FAILURE);
171 Sequence seq{ data_loader_->getSequence(
"ComplexSequence") };
172 ASSERT_GE(seq.size(), 3u);
173 seq.erase(3, seq.size());
174 seq.setAllBlendRadiiToZero();
176 RobotTrajCont res123_vec{ manager_->solve(scene_, pipeline_, seq.toRequest()) };
177 EXPECT_EQ(res123_vec.size(), 1u);
178 EXPECT_GT(res123_vec.front()->getWayPointCount(), 0u);
179 EXPECT_TRUE(hasStrictlyIncreasingTime(res123_vec.front())) <<
"Time steps not strictly positively increasing";
181 ROS_INFO(
"step 2: only first segment");
182 moveit_msgs::msg::MotionSequenceRequest req_1;
183 req_1.items.resize(1);
184 req_1.items.at(0).req = seq.getCmd(0).toRequest();
185 req_1.items.at(0).blend_radius = 0.;
186 RobotTrajCont res1_vec{ manager_->solve(scene_, pipeline_, req_1) };
187 EXPECT_EQ(res1_vec.size(), 1u);
188 EXPECT_GT(res1_vec.front()->getWayPointCount(), 0u);
189 EXPECT_EQ(res1_vec.front()->getFirstWayPoint().getVariableCount(),
190 req_1.items.at(0).req.start_state.joint_state.name.size());
192 ROS_INFO(
"step 3: only second segment");
193 moveit_msgs::msg::MotionSequenceRequest req_2;
194 req_2.items.resize(1);
195 req_2.items.at(0).req = seq.getCmd(1).toRequest();
196 req_2.items.at(0).blend_radius = 0.;
197 RobotTrajCont res2_vec{ manager_->solve(scene_, pipeline_, req_2) };
198 EXPECT_EQ(res2_vec.size(), 1u);
199 EXPECT_GT(res2_vec.front()->getWayPointCount(), 0u);
200 EXPECT_EQ(res2_vec.front()->getFirstWayPoint().getVariableCount(),
201 req_2.items.at(0).req.start_state.joint_state.name.size());
203 ROS_INFO(
"step 4: only third segment");
204 moveit_msgs::msg::MotionSequenceRequest req_3;
205 req_3.items.resize(1);
206 req_3.items.at(0).req = seq.getCmd(2).toRequest();
207 req_3.items.at(0).blend_radius = 0.;
208 RobotTrajCont res3_vec{ manager_->solve(scene_, pipeline_, req_3) };
209 EXPECT_EQ(res3_vec.size(), 1u);
210 EXPECT_GT(res3_vec.front()->getWayPointCount(), 0u);
211 EXPECT_EQ(res3_vec.front()->getFirstWayPoint().getVariableCount(),
212 req_3.items.at(0).req.start_state.joint_state.name.size());
215 auto t1_2_3 = res123_vec.front()->getWayPointDurationFromStart(res123_vec.front()->getWayPointCount() - 1);
216 auto t1 = res1_vec.front()->getWayPointDurationFromStart(res123_vec.front()->getWayPointCount() - 1);
217 auto t2 = res2_vec.front()->getWayPointDurationFromStart(res123_vec.front()->getWayPointCount() - 1);
218 auto t3 = res3_vec.front()->getWayPointDurationFromStart(res123_vec.front()->getWayPointCount() - 1);
219 ROS_DEBUG_STREAM(
"total time: " << t1_2_3 <<
" t1:" << t1 <<
" t2:" << t2 <<
" t3:" << t3);
220 EXPECT_LT(fabs((t1_2_3 - t1 - t2 - t3)), 0.4);
240 Sequence seq{ data_loader_->getSequence(
"ComplexSequence") };
241 ASSERT_GE(seq.size(), 3u);
242 seq.erase(3, seq.size());
243 seq.setAllBlendRadiiToZero();
244 seq.setBlendRadius(0, 0.1);
245 RobotTrajCont res1{ manager_->solve(scene_, pipeline_, seq.toRequest()) };
246 EXPECT_EQ(res1.size(), 1u);
247 EXPECT_GT(res1.front()->getWayPointCount(), 0u);
248 EXPECT_TRUE(hasStrictlyIncreasingTime(res1.front())) <<
"Time steps not strictly positively increasing";
250 seq.setAllBlendRadiiToZero();
251 seq.setBlendRadius(1, 0.1);
252 RobotTrajCont res2{ manager_->solve(scene_, pipeline_, seq.toRequest()) };
253 EXPECT_EQ(res2.size(), 1u);
254 EXPECT_GT(res2.front()->getWayPointCount(), 0u);
255 EXPECT_TRUE(hasStrictlyIncreasingTime(res2.front())) <<
"Time steps not strictly positively increasing";
270 Sequence seq{ data_loader_->getSequence(
"PtpPtpSequence") };
271 ASSERT_GE(seq.size(), 2u);
272 seq.setAllBlendRadiiToZero();
274 RobotTrajCont res_vec{ manager_->solve(scene_, pipeline_, seq.toRequest()) };
275 EXPECT_EQ(res_vec.size(), 1u);
276 EXPECT_GT(res_vec.front()->getWayPointCount(), 0u);
277 EXPECT_TRUE(hasStrictlyIncreasingTime(res_vec.front()));
292 Sequence seq{ data_loader_->getSequence(
"PtpLinSequence") };
293 ASSERT_GE(seq.size(), 2u);
294 seq.setAllBlendRadiiToZero();
296 RobotTrajCont res_vec{ manager_->solve(scene_, pipeline_, seq.toRequest()) };
297 EXPECT_EQ(res_vec.size(), 1u);
298 EXPECT_GT(res_vec.front()->getWayPointCount(), 0u);
299 EXPECT_TRUE(hasStrictlyIncreasingTime(res_vec.front()));
314 Sequence seq{ data_loader_->getSequence(
"LinPtpSequence") };
315 ASSERT_GE(seq.size(), 2u);
316 seq.setAllBlendRadiiToZero();
318 RobotTrajCont res_vec{ manager_->solve(scene_, pipeline_, seq.toRequest()) };
319 EXPECT_EQ(res_vec.size(), 1u);
320 EXPECT_GT(res_vec.front()->getWayPointCount(), 0u);
321 EXPECT_TRUE(hasStrictlyIncreasingTime(res_vec.front()));
335 Sequence seq{ data_loader_->getSequence(
"SimpleSequence") };
336 ASSERT_EQ(seq.size(), 2u);
337 moveit_msgs::msg::MotionSequenceRequest req{ seq.toRequest() };
338 RobotTrajCont res_vec{ manager_->solve(scene_, pipeline_, req) };
339 EXPECT_EQ(res_vec.size(), 1u);
340 EXPECT_GT(res_vec.front()->getWayPointCount(), 0u);
341 EXPECT_EQ(res_vec.front()->getFirstWayPoint().getVariableCount(),
342 req.items.at(0).req.start_state.joint_state.name.size());
345 ros::Publisher pub = nh.advertise<moveit_msgs::msg::DisplayTrajectory>(
"my_planned_path", 1);
346 ros::Duration duration(1.0);
349 moveit_msgs::msg::DisplayTrajectory display_trajectory;
350 moveit_msgs::msg::RobotTrajectory rob_traj_msg;
351 res_vec.front()->getRobotTrajectoryMsg(rob_traj_msg);
352 display_trajectory.trajectory.push_back(rob_traj_msg);
353 pub.publish(display_trajectory);
405 Sequence seq{ data_loader_->getSequence(
"SimpleSequence") };
406 ASSERT_GE(seq.size(), 2u);
408 moveit_msgs::msg::MotionSequenceRequest req{ seq.
toRequest() };
409 req.items.at(1).req.start_state = lin.getGoalConfiguration().toMoveitMsgsRobotState();
410 EXPECT_THROW(manager_->solve(scene_, pipeline_, req), StartStateSetException);
482 Sequence seq{ data_loader_->getSequence(
"ComplexSequence") };
483 ASSERT_GE(seq.size(), 3u);
484 seq.erase(3, seq.size());
486 RobotTrajCont res_valid_vec{ manager_->solve(scene_, pipeline_, seq.toRequest()) };
487 EXPECT_EQ(res_valid_vec.size(), 1u);
488 EXPECT_GT(res_valid_vec.front()->getWayPointCount(), 0u);
493 Eigen::Isometry3d p1, p2;
494 tf2::fromMsg(ptp.getGoalConfiguration().getPose(), p1);
495 tf2::fromMsg(circ.getGoalConfiguration().getPose(), p2);
496 auto distance = (p2.translation() - p1.translation()).norm();
498 seq.setBlendRadius(1, (distance - seq.getBlendRadius(0) + 0.01));
499 EXPECT_THROW(manager_->solve(scene_, pipeline_, seq.toRequest()), OverlappingBlendRadiiException);
518 Sequence seq{ data_loader_->getSequence(
"ComplexSequence") };
519 ASSERT_GE(seq.size(), 2u);
520 RobotTrajCont res_single_vec{ manager_->solve(scene_, pipeline_, seq.toRequest()) };
521 EXPECT_EQ(res_single_vec.size(), 1u);
522 EXPECT_GT(res_single_vec.front()->getWayPointCount(), 0u);
524 moveit_msgs::msg::MotionSequenceRequest req{ seq.toRequest() };
527 const size_t n{ req.items.size() };
528 for (
size_t i = 0; i < n; ++i)
530 moveit_msgs::msg::MotionSequenceItem item{ req.items.at(i) };
535 item.req.start_state = moveit_msgs::msg::RobotState();
537 req.items.push_back(item);
540 RobotTrajCont res_n_vec{ manager_->solve(scene_, pipeline_, req) };
541 EXPECT_EQ(res_n_vec.size(), 1u);
542 EXPECT_GT(res_n_vec.front()->getWayPointCount(), 0u);
544 const double trajectory_time_1 =
545 res_single_vec.front()->getWayPointDurationFromStart(res_single_vec.front()->getWayPointCount() - 1);
546 const double trajectory_time_n =
547 res_n_vec.front()->getWayPointDurationFromStart(res_n_vec.front()->getWayPointCount() - 1);
548 double multiplicator = req.items.size() / n;
549 EXPECT_LE(trajectory_time_n, trajectory_time_1 * multiplicator);
550 EXPECT_GE(trajectory_time_n, trajectory_time_1 * multiplicator * 0.5);
564 Sequence seq{ data_loader_->getSequence(
"ComplexSequenceWithGripper") };
565 ASSERT_GE(seq.size(), 1u);
567 unsigned int num_groups{ 1 };
568 std::string last_group_name{ seq.getCmd(0).getPlanningGroup() };
569 for (
size_t i = 1; i < seq.size(); ++i)
571 if (seq.getCmd(i).getPlanningGroup() != last_group_name)
574 last_group_name = seq.getCmd(i).getPlanningGroup();
578 RobotTrajCont res_single_vec{ manager_->solve(scene_, pipeline_, seq.toRequest()) };
579 EXPECT_EQ(res_single_vec.size(), num_groups);
581 for (
const auto& res : res_single_vec)
583 EXPECT_GT(res->getWayPointCount(), 0u);
594 Sequence seq{ data_loader_->getSequence(
"PureGripperSequence") };
595 ASSERT_GE(seq.size(), 2u);
596 ASSERT_TRUE(seq.cmdIsOfType<
Gripper>(0));
597 ASSERT_TRUE(seq.cmdIsOfType<
Gripper>(1));
600 seq.setBlendRadius(0, 1.0);
601 RobotTrajCont res_vec{ manager_->solve(scene_, pipeline_, seq.toRequest()) };
602 EXPECT_EQ(res_vec.size(), 1u);
620 using std::placeholders::_1;
622 Sequence seq{ data_loader_->getSequence(
"ComplexSequenceWithGripper") };
623 ASSERT_GE(seq.size(), 4u);
624 seq.erase(4, seq.size());
627 gripper.
getStartConfiguration().setCreateJointNameFunc([](
size_t n) {
return createGripperJointName(n); });
630 gripper.getStartConfiguration().clearModel();
633 ptp.
getStartConfiguration().setCreateJointNameFunc([](
size_t n) {
return createManipulatorJointName(n); });
636 ptp.getStartConfiguration().clearModel();
638 RobotTrajCont res_vec{ manager_->solve(scene_, pipeline_, seq.toRequest()) };
639 EXPECT_GE(res_vec.size(), 1u);
640 EXPECT_GT(res_vec.front()->getWayPointCount(), 0u);