50 getProxy(rsc,
"RobotStateComponent");
61 return "NaturalGraspFilter";
67 GeneratedGraspList result;
68 for (
const GeneratedGrasp& g : grasps)
71 FramedPosePtr::dynamicCast(g.framedPose)->toGlobalEigen(localRobot).block<3, 3>(0, 0);
72 Eigen::Vector3f rotatedYAxis = orientation * Eigen::Vector3f::UnitY();
73 rotatedYAxis.normalize();
74 if (rotatedYAxis(2) > 0.1)
77 <<
" seems to be an unnatural Grasp; it will not be used further!";
88 GraspingPlacementList result;
89 ARMARX_INFO <<
"Number of Placements: " << placements.size();
92 for (
const GraspingPlacement& placement : placements)
95 Eigen::Matrix3f robotOrientation = FramedPosePtr::dynamicCast(placement.robotPose)
96 ->toGlobalEigen(localRobot)
98 Eigen::Matrix3f graspOrientation = FramedPosePtr::dynamicCast(placement.grasp.framedPose)
99 ->toGlobalEigen(localRobot)
101 Eigen::Matrix3f graspToRobotTransform = robotOrientation.inverse() * graspOrientation;
102 Eigen::Vector3f graspXAxisInRobotCoordinates =
103 graspToRobotTransform * Eigen::Vector3f::UnitX();
104 graspXAxisInRobotCoordinates.normalize();
105 float x = graspXAxisInRobotCoordinates(0);
106 float y = graspXAxisInRobotCoordinates(1);
107 float z = graspXAxisInRobotCoordinates(2);
111 bool isInSegment =
false;
112 if (placement.grasp.eefName ==
"Hand_L_EEF")
115 isInSegment = (x > -0.1 && (y < 0 || x * x + z * z > 0.5 * 0.5));
120 isInSegment = (x > -0.1 && (y > 0 || x * x + z * z > 0.5 * 0.5));
124 result.push_back(placement);
138 NaturalGraspFilter::vectorIsWithinCircleSegment(
const Eigen::Vector2f vector,
143 <<
"Works only for circle segments smaller than Pi and is " <<
std::abs(angle2 - angle1);
144 Eigen::Rotation2Df rot1(angle1);
145 Eigen::Rotation2Df rot2(angle2);
146 Eigen::Vector2f boundary1 = rot1 * Eigen::Vector2f::UnitX();
147 Eigen::Vector2f boundary2 = rot2 * Eigen::Vector2f::UnitX();
148 bool vectorIsCounterClockwiseToBoundary1 =
149 boundary1(0) * vector(1) - boundary1(1) * vector(0) > 0;
150 bool vectorIsClockwiseToBoundary2 = -boundary2(0) * vector(1) + boundary2(1) * vector(0) > 0;
151 return vectorIsCounterClockwiseToBoundary1 && vectorIsClockwiseToBoundary2;