33 #include <Eigen/Eigen> 37 using shape_msgs::SolidPrimitive;
50 moveit_msgs::GripperTranslation translation;
51 translation.direction.vector.x = x_axis;
52 translation.direction.vector.y = y_axis;
53 translation.direction.vector.z = z_axis;
54 translation.direction.header.frame_id = frame;
55 translation.min_distance = min;
56 translation.desired_distance = desired;
62 float sy = sin(yaw*0.5);
63 float cy = cos(yaw*0.5);
64 float sp = sin(pitch*0.5);
65 float cp = cos(pitch*0.5);
66 float sr = sin(roll*0.5);
67 float cr = cos(roll*0.5);
68 float w = cr*cp*cy + sr*sp*sy;
69 float x = sr*cp*cy - cr*sp*sy;
70 float y = cr*sp*cy + sr*cp*sy;
71 float z = cr*cp*sy - sr*sp*cy;
72 return Eigen::Quaterniond(w,x,y,z);
82 nh.
param<std::string>(
"gripper/left_joint",
left_joint_,
"l_gripper_finger_joint");
83 nh.
param<std::string>(
"gripper/right_joint",
right_joint_,
"r_gripper_finger_joint");
109 double gripper_opening,
110 double gripper_pitch,
115 moveit_msgs::Grasp grasp;
116 grasp.grasp_pose =
pose;
130 Eigen::Affine3d p = Eigen::Translation3d(pose.pose.position.x,
131 pose.pose.position.y,
132 pose.pose.position.z) *
133 Eigen::Quaterniond(pose.pose.orientation.w,
134 pose.pose.orientation.x,
135 pose.pose.orientation.y,
136 pose.pose.orientation.z);
138 p = p * Eigen::Translation3d(x_offset, 0, z_offset);
144 grasp.grasp_pose.pose.position.x = p.translation().x();
145 grasp.grasp_pose.pose.position.y = p.translation().y();
146 grasp.grasp_pose.pose.position.z = p.translation().z();
147 Eigen::Quaterniond q = (Eigen::Quaterniond)p.linear();
148 grasp.grasp_pose.pose.orientation.x = q.x();
149 grasp.grasp_pose.pose.orientation.y = q.y();
150 grasp.grasp_pose.pose.orientation.z = q.z();
151 grasp.grasp_pose.pose.orientation.w = q.w();
153 grasp.grasp_quality = quality;
163 const geometry_msgs::PoseStamped&
pose,
164 double depth,
double width,
double height,
174 double x = depth/2.0;
175 double z = height/2.0;
210 count +=
createGrasp(pose, open, 1.57/2.0, x - 0.005, -z + 0.005, 0.25);
216 std::vector<moveit_msgs::Grasp>&
grasps)
218 ROS_INFO(
"shape grasp planning starting...");
221 if (
object.primitives.size() == 0)
228 if (
object.primitive_poses.size() !=
object.primitives.size())
238 geometry_msgs::PoseStamped grasp_pose;
239 grasp_pose.header =
object.header;
240 grasp_pose.pose =
object.primitive_poses[0];
243 Eigen::Quaterniond q(
object.primitive_poses[0].orientation.w,
244 object.primitive_poses[0].orientation.x,
245 object.primitive_poses[0].orientation.y,
246 object.primitive_poses[0].orientation.z);
250 if (
object.primitives[0].
type == SolidPrimitive::BOX)
252 x =
object.primitives[0].dimensions[SolidPrimitive::BOX_X];
253 y =
object.primitives[0].dimensions[SolidPrimitive::BOX_Y];
254 z =
object.primitives[0].dimensions[SolidPrimitive::BOX_Z];
256 else if (
object.primitives[0].
type == SolidPrimitive::CYLINDER)
258 x = y = 2.0 *
object.primitives[0].dimensions[SolidPrimitive::CYLINDER_RADIUS];
259 z =
object.primitives[0].dimensions[SolidPrimitive::CYLINDER_HEIGHT];
263 for (
int i = 0; i < 4; ++i)
265 grasp_pose.pose.orientation.x = q.x();
266 grasp_pose.pose.orientation.y = q.y();
267 grasp_pose.pose.orientation.z = q.z();
268 grasp_pose.pose.orientation.w = q.w();
285 ROS_INFO(
"shape grasp planning done.");
288 return grasps.size();
291 trajectory_msgs::JointTrajectory
294 trajectory_msgs::JointTrajectory trajectory;
297 trajectory_msgs::JointTrajectoryPoint point;
298 point.positions.push_back(pose/2.0);
299 point.positions.push_back(pose/2.0);
303 trajectory.points.push_back(point);
int createGraspSeries(const geometry_msgs::PoseStamped &pose, double depth, double width, double height, bool use_vertical=true)
Generate a series of grasps around the edge of a shape.
double approach_min_translation_
ShapeGraspPlanner(ros::NodeHandle &nh)
Constructor, loads grasp planner configuration from ROS params.
double retreat_desired_translation_
std::string retreat_frame_
Eigen::Quaterniond quaternionFromEuler(float yaw, float pitch, float roll)
double approach_desired_translation_
int createGrasp(const geometry_msgs::PoseStamped &pose, double gripper_opening, double gripper_pitch, double x_offset, double z_offset, double quality)
Generate a grasp, add it to internal grasps_.
double gripper_tolerance_
bool param(const std::string ¶m_name, T ¶m_val, const T &default_val) const
double retreat_min_translation_
TFSIMD_FORCE_INLINE const tfScalar & x() const
std::string approach_frame_
TFSIMD_FORCE_INLINE const tfScalar & z() const
TFSIMD_FORCE_INLINE const tfScalar & w() const
virtual int plan(const grasping_msgs::Object &object, std::vector< moveit_msgs::Grasp > &grasps)
std::vector< moveit_msgs::Grasp > grasps_
moveit_msgs::GripperTranslation makeGripperTranslation(std::string frame, double min, double desired, double x_axis=1.0, double y_axis=0.0, double z_axis=0.0)
trajectory_msgs::JointTrajectory makeGraspPosture(double pose)