49 #include <gtest/gtest.h>
56 #include <tf2_geometry_msgs/tf2_geometry_msgs.hpp>
58 static const std::string PLANNING_GROUP =
"panda_arm";
68 nh_ = ros::NodeHandle(
"/move_group_pick_place_test");
69 move_group_ = std::make_shared<moveit::planning_interface::MoveGroupInterface>(PLANNING_GROUP);
81 moveit::planning_interface::MoveGroupInterfacePtr
move_group_;
88 std::vector<moveit_msgs::CollisionObject> collision_objects;
89 collision_objects.resize(3);
92 collision_objects[0].id =
"table1";
93 collision_objects[0].header.frame_id =
"panda_link0";
96 tf2::Quaternion zero_orientation;
97 zero_orientation.setRPY(0, 0, 0);
98 geometry_msgs::Quaternion zero_orientation_msg = tf2::toMsg(zero_orientation);
101 collision_objects[0].primitives.resize(1);
102 collision_objects[0].primitives[0].type = collision_objects[0].primitives[0].BOX;
103 collision_objects[0].primitives[0].dimensions.resize(3);
104 collision_objects[0].primitives[0].dimensions[0] = 0.2;
105 collision_objects[0].primitives[0].dimensions[1] = 0.4;
106 collision_objects[0].primitives[0].dimensions[2] = 0.4;
109 collision_objects[0].primitive_poses.resize(1);
110 collision_objects[0].primitive_poses[0].position.x = 0.5;
111 collision_objects[0].primitive_poses[0].position.y = 0;
112 collision_objects[0].primitive_poses[0].position.z = 0.2;
113 collision_objects[0].primitive_poses[0].orientation = zero_orientation_msg;
115 collision_objects[0].operation = collision_objects[0].ADD;
118 collision_objects[1].id =
"table2";
119 collision_objects[1].header.frame_id =
"panda_link0";
122 collision_objects[1].primitives.resize(1);
123 collision_objects[1].primitives[0].type = collision_objects[1].primitives[0].BOX;
124 collision_objects[1].primitives[0].dimensions.resize(3);
125 collision_objects[1].primitives[0].dimensions[0] = 0.4;
126 collision_objects[1].primitives[0].dimensions[1] = 0.2;
127 collision_objects[1].primitives[0].dimensions[2] = 0.4;
130 collision_objects[1].primitive_poses.resize(1);
131 collision_objects[1].primitive_poses[0].position.x = 0;
132 collision_objects[1].primitive_poses[0].position.y = 0.5;
133 collision_objects[1].primitive_poses[0].position.z = 0.2;
134 collision_objects[1].primitive_poses[0].orientation = zero_orientation_msg;
136 collision_objects[1].operation = collision_objects[1].ADD;
139 collision_objects[2].header.frame_id =
"panda_link0";
140 collision_objects[2].id =
"object";
143 collision_objects[2].primitives.resize(1);
144 collision_objects[2].primitives[0].type = collision_objects[1].primitives[0].BOX;
145 collision_objects[2].primitives[0].dimensions.resize(3);
146 collision_objects[2].primitives[0].dimensions[0] = 0.02;
147 collision_objects[2].primitives[0].dimensions[1] = 0.02;
148 collision_objects[2].primitives[0].dimensions[2] = 0.2;
151 collision_objects[2].primitive_poses.resize(1);
152 collision_objects[2].primitive_poses[0].position.x = 0.5;
153 collision_objects[2].primitive_poses[0].position.y = 0;
154 collision_objects[2].primitive_poses[0].position.z = 0.5;
155 collision_objects[2].primitive_poses[0].orientation = zero_orientation_msg;
157 collision_objects[2].operation = collision_objects[2].ADD;
159 planning_scene_interface_.applyCollisionObjects(collision_objects);
163 std::vector<moveit_msgs::Grasp> grasps;
172 grasps[0].grasp_pose.header.frame_id =
"panda_link0";
173 tf2::Quaternion grasp_orientation;
174 grasp_orientation.setRPY(-M_PI / 2, -M_PI / 4, -M_PI / 2);
175 grasps[0].grasp_pose.pose.orientation = tf2::toMsg(grasp_orientation);
176 grasps[0].grasp_pose.pose.position.x = 0.415;
177 grasps[0].grasp_pose.pose.position.y = 0;
178 grasps[0].grasp_pose.pose.position.z = 0.5;
183 grasps[0].pre_grasp_approach.direction.header.frame_id =
"panda_link0";
185 grasps[0].pre_grasp_approach.direction.vector.x = 1.0;
186 grasps[0].pre_grasp_approach.min_distance = 0.095;
187 grasps[0].pre_grasp_approach.desired_distance = 0.115;
192 grasps[0].post_grasp_retreat.direction.header.frame_id =
"panda_link0";
194 grasps[0].post_grasp_retreat.direction.vector.z = 1.0;
195 grasps[0].post_grasp_retreat.min_distance = 0.1;
196 grasps[0].post_grasp_retreat.desired_distance = 0.25;
201 grasps[0].pre_grasp_posture.joint_names.resize(2);
202 grasps[0].pre_grasp_posture.joint_names[0] =
"panda_finger_joint1";
203 grasps[0].pre_grasp_posture.joint_names[1] =
"panda_finger_joint2";
206 grasps[0].pre_grasp_posture.points.resize(1);
207 grasps[0].pre_grasp_posture.points[0].positions.resize(2);
208 grasps[0].pre_grasp_posture.points[0].positions[0] = 0.04;
209 grasps[0].pre_grasp_posture.points[0].positions[1] = 0.04;
210 grasps[0].pre_grasp_posture.points[0].time_from_start = ros::Duration(0.5);
215 grasps[0].grasp_posture = grasps[0].pre_grasp_posture;
216 grasps[0].grasp_posture.points[0].positions[0] = 0.00;
217 grasps[0].grasp_posture.points[0].positions[1] = 0.00;
220 move_group_->setSupportSurfaceName(
"table1");
222 ASSERT_EQ(move_group_->pick(
"object", grasps), moveit::core::MoveItErrorCode::SUCCESS);
226 std::vector<moveit_msgs::PlaceLocation> place_location;
227 place_location.resize(1);
231 place_location[0].place_pose.header.frame_id =
"panda_link0";
232 tf2::Quaternion place_orientation;
233 place_orientation.setRPY(0, 0, M_PI / 2);
234 place_location[0].place_pose.pose.orientation = tf2::toMsg(place_orientation);
237 place_location[0].place_pose.pose.position.x = 0;
238 place_location[0].place_pose.pose.position.y = 0.5;
239 place_location[0].place_pose.pose.position.z = 0.5;
244 place_location[0].pre_place_approach.direction.header.frame_id =
"panda_link0";
246 place_location[0].pre_place_approach.direction.vector.z = -1.0;
247 place_location[0].pre_place_approach.min_distance = 0.095;
248 place_location[0].pre_place_approach.desired_distance = 0.115;
253 place_location[0].post_place_retreat.direction.header.frame_id =
"panda_link0";
255 place_location[0].post_place_retreat.direction.vector.y = -1.0;
256 place_location[0].post_place_retreat.min_distance = 0.1;
257 place_location[0].post_place_retreat.desired_distance = 0.25;
263 place_location[0].post_place_posture.joint_names.resize(2);
264 place_location[0].post_place_posture.joint_names[0] =
"panda_finger_joint1";
265 place_location[0].post_place_posture.joint_names[1] =
"panda_finger_joint2";
268 place_location[0].post_place_posture.points.resize(1);
269 place_location[0].post_place_posture.points[0].positions.resize(2);
270 place_location[0].post_place_posture.points[0].positions[0] = 0.04;
271 place_location[0].post_place_posture.points[0].positions[1] = 0.04;
272 place_location[0].post_place_posture.points[0].time_from_start = ros::Duration(0.5);
275 move_group_->setSupportSurfaceName(
"table2");
277 ASSERT_EQ(move_group_->place(
"object", place_location), moveit::core::MoveItErrorCode::SUCCESS);
280 int main(
int argc,
char** argv)
282 ros::init(argc, argv,
"move_group_pick_place_test");
283 testing::InitGoogleTest(&argc, argv);
285 ros::AsyncSpinner spinner(1);
288 int result = RUN_ALL_TESTS();
moveit::planning_interface::PlanningSceneInterface planning_scene_interface_
moveit::planning_interface::MoveGroupInterfacePtr move_group_
constexpr double PLANNING_TIME_S
constexpr double MAX_ACCELERATION_SCALE
int main(int argc, char **argv)
TEST_F(PickPlaceTestFixture, PickPlaceTest)
constexpr double MAX_VELOCITY_SCALE