47 getProxy(rsc,
"RobotStateComponent");
56 return "NaturalGraspFilter";
61 GeneratedGraspList result;
62 for (
const GeneratedGrasp& g : grasps)
64 Eigen::Matrix3f orientation = FramedPosePtr::dynamicCast(g.framedPose)->toGlobalEigen(localRobot).block<3, 3>(0, 0);
65 Eigen::Vector3f rotatedYAxis = orientation * Eigen::Vector3f::UnitY();
66 rotatedYAxis.normalize();
67 if (rotatedYAxis(2) > 0.1)
69 ARMARX_WARNING << g.graspName <<
" seems to be an unnatural Grasp; it will not be used further!";
80 GraspingPlacementList result;
81 ARMARX_INFO <<
"Number of Placements: " << placements.size();
84 for (
const GraspingPlacement& placement : placements)
87 Eigen::Matrix3f robotOrientation = FramedPosePtr::dynamicCast(placement.robotPose)->toGlobalEigen(localRobot).block<3, 3>(
89 Eigen::Matrix3f graspOrientation = FramedPosePtr::dynamicCast(placement.grasp.framedPose)->toGlobalEigen(
90 localRobot).block<3, 3>(0, 0);
91 Eigen::Matrix3f graspToRobotTransform = robotOrientation.inverse() * graspOrientation;
92 Eigen::Vector3f graspXAxisInRobotCoordinates = graspToRobotTransform * Eigen::Vector3f::UnitX();
93 graspXAxisInRobotCoordinates.normalize();
94 float x = graspXAxisInRobotCoordinates(0);
95 float y = graspXAxisInRobotCoordinates(1);
96 float z = graspXAxisInRobotCoordinates(2);
100 bool isInSegment =
false;
101 if (placement.grasp.eefName ==
"Hand_L_EEF")
104 isInSegment = (x > -0.1 && (y < 0 || x * x + z * z > 0.5 * 0.5));
109 isInSegment = (x > -0.1 && (y > 0 || x * x + z * z > 0.5 * 0.5));
113 result.push_back(placement);
124 bool NaturalGraspFilter::vectorIsWithinCircleSegment(
const Eigen::Vector2f vector,
double angle1,
double angle2)
127 "Works only for circle segments smaller than Pi and is " <<
std::abs(angle2 - angle1);
128 Eigen::Rotation2Df rot1(angle1);
129 Eigen::Rotation2Df rot2(angle2);
130 Eigen::Vector2f boundary1 = rot1 * Eigen::Vector2f::UnitX();
131 Eigen::Vector2f boundary2 = rot2 * Eigen::Vector2f::UnitX();
132 bool vectorIsCounterClockwiseToBoundary1 = boundary1(0) * vector(1) - boundary1(1) * vector(0) > 0;
133 bool vectorIsClockwiseToBoundary2 = - boundary2(0) * vector(1) + boundary2(1) * vector(0) > 0;
134 return vectorIsCounterClockwiseToBoundary1 && vectorIsClockwiseToBoundary2;