36 #include <gtest/gtest.h>
46 #include <moveit_msgs/Constraints.h>
47 #include <moveit_msgs/GetMotionPlan.h>
48 #include <moveit_msgs/JointConstraint.h>
49 #include <moveit_msgs/MotionPlanResponse.h>
55 #include <moveit_msgs/GetMotionSequence.h>
56 #include <moveit_msgs/MotionSequenceRequest.h>
64 static std::string createJointName(
const size_t& joint_number)
66 return std::string(
"prbt_joint_") + std::to_string(joint_number + 1);
72 void SetUp()
override;
75 ros::NodeHandle ph_{
"~" };
89 robot_model_ = model_loader.
getModel();
91 data_loader_ = std::make_unique<XmlTestdataLoader>(test_data_file_name_, robot_model_);
92 ASSERT_NE(
nullptr, data_loader_) <<
"Failed to load test data by provider.";
94 ASSERT_TRUE(ros::service::waitForService(pilz_industrial_motion_planner::SEQUENCE_SERVICE_NAME, ros::Duration(10)))
95 <<
"Service not available.";
97 client_ = nh.serviceClient<moveit_msgs::GetMotionSequence>(pilz_industrial_motion_planner::SEQUENCE_SERVICE_NAME);
113 moveit_msgs::msg::MotionSequenceRequest empty_list;
115 moveit_msgs::GetMotionSequence srv;
116 srv.request.request = empty_list;
118 ASSERT_TRUE(client_.call(srv));
120 EXPECT_EQ(moveit_msgs::msg::MoveItErrorCodes::SUCCESS, srv.response.response.error_code.val) <<
"Planning failed.";
121 EXPECT_TRUE(srv.response.response.planned_trajectories.empty());
139 Sequence seq{ data_loader_->getSequence(
"ComplexSequence") };
143 moveit_msgs::GetMotionSequence srv;
144 srv.request.request = seq.toRequest();
146 ASSERT_TRUE(client_.call(srv));
148 EXPECT_EQ(moveit_msgs::msg::MoveItErrorCodes::INVALID_GROUP_NAME, srv.response.response.error_code.val)
149 <<
"Planning should have failed but did not.";
150 EXPECT_TRUE(srv.response.response.planned_trajectories.empty());
166 Sequence seq{ data_loader_->getSequence(
"ComplexSequence") };
169 moveit_msgs::GetMotionSequence srv;
170 srv.request.request = seq.toRequest();
172 ASSERT_TRUE(client_.call(srv));
174 EXPECT_EQ(moveit_msgs::msg::MoveItErrorCodes::INVALID_MOTION_PLAN, srv.response.response.error_code.val)
175 <<
"Planning should have failed but did not.";
176 EXPECT_TRUE(srv.response.response.planned_trajectories.empty());
192 Sequence seq{ data_loader_->getSequence(
"ComplexSequence") };
195 moveit_msgs::GetMotionSequence srv;
196 srv.request.request = seq.toRequest();
198 ASSERT_TRUE(client_.call(srv));
200 EXPECT_EQ(moveit_msgs::msg::MoveItErrorCodes::INVALID_MOTION_PLAN, srv.response.response.error_code.val)
201 <<
"Incorrect error code";
202 EXPECT_TRUE(srv.response.response.planned_trajectories.empty());
218 Sequence seq{ data_loader_->getSequence(
"ComplexSequence") };
219 seq.
erase(2, seq.size());
220 seq.setBlendRadius(0, 10 * seq.getBlendRadius(seq.size() - 2));
222 moveit_msgs::GetMotionSequence srv;
223 srv.request.request = seq.toRequest();
225 ASSERT_TRUE(client_.call(srv));
227 EXPECT_EQ(moveit_msgs::msg::MoveItErrorCodes::FAILURE, srv.response.response.error_code.val)
228 <<
"Incorrect error code";
229 EXPECT_TRUE(srv.response.response.planned_trajectories.empty());
247 Sequence seq{ data_loader_->getSequence(
"ComplexSequence") };
248 moveit_msgs::msg::MotionSequenceRequest req_list{ seq.
toRequest() };
251 using std::placeholders::_1;
252 JointConfiguration config{
"MyGroupName", { -1., 2., -3., 4., -5., 0. }, [](
size_t n) {
return createJointName(n); } };
253 req_list.items[1].req.start_state.joint_state = config.toSensorMsg();
255 moveit_msgs::GetMotionSequence srv;
256 srv.request.request = req_list;
258 ASSERT_TRUE(client_.call(srv));
260 EXPECT_EQ(moveit_msgs::msg::MoveItErrorCodes::INVALID_ROBOT_STATE, srv.response.response.error_code.val)
261 <<
"Incorrect error code.";
262 EXPECT_TRUE(srv.response.response.planned_trajectories.empty());
280 Sequence seq{ data_loader_->getSequence(
"ComplexSequence") };
284 moveit_msgs::GetMotionSequence srv;
285 srv.request.request = seq.toRequest();
287 ASSERT_TRUE(client_.call(srv));
289 EXPECT_EQ(moveit_msgs::msg::MoveItErrorCodes::NO_IK_SOLUTION, srv.response.response.error_code.val)
290 <<
"Incorrect error code.";
291 EXPECT_TRUE(srv.response.response.planned_trajectories.empty());
307 Sequence seq{ data_loader_->getSequence(
"ComplexSequence") };
314 moveit_msgs::GetMotionSequence srv;
315 srv.request.request = seq.toRequest();
317 ASSERT_TRUE(client_.call(srv));
319 EXPECT_NE(moveit_msgs::msg::MoveItErrorCodes::SUCCESS, srv.response.response.error_code.val)
320 <<
"Incorrect error code.";
321 EXPECT_TRUE(srv.response.response.planned_trajectories.empty());
337 Sequence seq{ data_loader_->getSequence(
"ComplexSequence") };
338 moveit_msgs::msg::MotionSequenceRequest req{ seq.
toRequest() };
342 size_t n{ req.items.size() };
343 for (
size_t i = 0; i < n; ++i)
345 moveit_msgs::msg::MotionSequenceItem item{ req.items.at(i) };
350 item.req.start_state = moveit_msgs::msg::RobotState();
352 req.items.push_back(item);
355 moveit_msgs::GetMotionSequence srv;
356 srv.request.request = req;
358 ASSERT_TRUE(client_.call(srv));
360 EXPECT_EQ(moveit_msgs::msg::MoveItErrorCodes::SUCCESS, srv.response.response.error_code.val)
361 <<
"Incorrect error code.";
362 EXPECT_EQ(srv.response.response.planned_trajectories.size(), 1u);
363 EXPECT_GT(srv.response.response.planned_trajectories.front().joint_trajectory.points.size(), 0u)
364 <<
"Trajectory should contain points.";
381 Sequence seq{ data_loader_->getSequence(
"ComplexSequence") };
385 moveit_msgs::GetMotionSequence srv;
386 srv.request.request = seq.toRequest();
388 ASSERT_TRUE(client_.call(srv));
390 EXPECT_EQ(moveit_msgs::msg::MoveItErrorCodes::SUCCESS, srv.response.response.error_code.val)
391 <<
"Incorrect error code.";
392 EXPECT_EQ(srv.response.response.planned_trajectories.size(), 1u);
393 EXPECT_GT(srv.response.response.planned_trajectories.front().joint_trajectory.points.size(), 0u)
394 <<
"Trajectory should contain points.";
411 Sequence seq{ data_loader_->getSequence(
"ComplexSequence") };
413 moveit_msgs::GetMotionSequence srv;
416 ASSERT_TRUE(client_.call(srv));
418 EXPECT_EQ(moveit_msgs::msg::MoveItErrorCodes::SUCCESS, srv.response.response.error_code.val)
419 <<
"Incorrect error code.";
420 EXPECT_EQ(srv.response.response.planned_trajectories.size(), 1u);
421 EXPECT_GT(srv.response.response.planned_trajectories.front().joint_trajectory.points.size(), 0u)
422 <<
"Trajectory should contain points.";
425 int main(
int argc,
char** argv)
427 ros::init(argc, argv,
"integrationtest_sequence_service_capability");
429 testing::InitGoogleTest(&argc, argv);
430 return RUN_ALL_TESTS();
ros::ServiceClient client_
std::string test_data_file_name_
TestdataLoaderUPtr data_loader_
robot_model::RobotModelPtr robot_model_
GoalType & getGoalConfiguration()
Data class storing all information regarding a Circ command.
Class to define a robot configuration in space with the help of joint values.
Base class for commands storing all general information of a command.
void setPlanningGroup(const std::string &planning_group)
Data class storing all information regarding a Ptp command.
Data class storing all information regarding a Sequence command.
void setAllBlendRadiiToZero()
void setBlendRadius(const size_t index_cmd, const double blend_radius)
void erase(const size_t start, const size_t end)
Deletes all commands from index 'start' to index 'end'.
moveit_msgs::msg::MotionSequenceRequest toRequest() const
const moveit::core::RobotModelPtr & getModel() const
Get the constructed planning_models::RobotModel.
int main(int argc, char **argv)
TEST_F(IntegrationTestSequenceService, TestSendingOfEmptySequence)
Test behavior of service when empty sequence is sent.
const std::string TEST_DATA_FILE_NAME("testdata_file_name")
std::unique_ptr< TestdataLoader > TestdataLoaderUPtr