33 #include <VirtualRobot/Grasping/Grasp.h>
34 #include <VirtualRobot/Grasping/GraspSet.h>
38 using namespace PlaceObjectGroup;
52 const float ZoffsetForPreAndPostPlacePoses = 120;
53 const float xRetreatOffset = in.getXRetreatOffset();
54 const float offsetForRetreatPoseY = 20;
56 PlaceObjectGroupStatechartContextBase* context = getContext<PlaceObjectGroupStatechartContextBase>();
58 std::string handName = in.getHandChannelRef()->getDataField(
"className")->getString();
60 local.setHandName(handName);
63 std::string objectName = in.getObjectClassName();
64 memoryx::ObjectClassBasePtr objectClassBase = context->getPriorKnowledge()->getObjectClassesSegment()->getObjectClassByName(objectName);
66 if (in.isPlaceOrientationSet())
69 orientation = ori->toRootEigen(getRobotStateComponent()->getSynchronizedRobot()).block<3, 3>(0, 0);
79 Eigen::Vector3f placeOrientationAngles = simoxWrapper->getPutdownOrientationRPY();
86 if (!in.isPlaceOrientationSet())
88 ARMARX_INFO <<
"Using placing orientation of the object (RPY): " << placeOrientationAngles;
89 orientation = Eigen::AngleAxisf(placeOrientationAngles(0), Eigen::Vector3f::UnitX())
90 * Eigen::AngleAxisf(placeOrientationAngles(1), Eigen::Vector3f::UnitY())
91 * Eigen::AngleAxisf(placeOrientationAngles(2), Eigen::Vector3f::UnitZ());
95 ARMARX_INFO <<
"Using placing orientation from input: " << orientation;
98 VirtualRobot::GraspSetPtr graspSet = simoxWrapper->getManipulationObject()->getGraspSet(in.getGraspSetName());
102 VirtualRobot::GraspPtr grasp = graspSet->getGrasp(in.getGraspName());
106 transformationFromTCPToObject = grasp->getTransformation();
107 ARMARX_VERBOSE <<
"Found grasp " << in.getGraspName() <<
", trafo:\n" <<
VAROUT(transformationFromTCPToObject);
111 ARMARX_WARNING <<
"Grasp " << in.getGraspName() <<
" not found in grasp set";
116 ARMARX_WARNING <<
"Grasp set " << in.getGraspSetName() <<
" not found";
121 ARMARX_WARNING <<
"Object class with name " << objectName <<
" not found in the classes segment of PriorKnowledge";
125 placePoseObjectLocal.block<3, 3>(0, 0) = orientation;
127 placePoseTemp->changeFrame(context->getRobot(), context->getRobot()->getRootNode()->getName());
128 placePoseObjectLocal.block<3, 1>(0, 3) = placePoseTemp->toEigen();
129 armarx::FramedPosePtr placeObjectPoseGobal(
new FramedPose(placePoseObjectLocal, context->getRobot()->getRootNode()->getName(), context->getRobotStateComponent()->getSynchronizedRobot()->getName()));
130 ARMARX_IMPORTANT <<
"Placing pose of the object: " << *placeObjectPoseGobal;
131 placeObjectPoseGobal->changeToGlobal(context->getRobotStateComponent()->getSynchronizedRobot());
133 getEntityDrawerTopic()->setObjectVisu(
"PlaceObject", objectName, objectClassBase, placeObjectPoseGobal);
134 getEntityDrawerTopic()->updateObjectColor(
"PlaceObject", objectName, DrawColor {0, 0, 0, 0.3});
161 Eigen::Matrix4f placePoseTcpLocal = placePoseObjectLocal * transformationFromTCPToObject.inverse();
163 local.setObjectFinalPose(placeObjectPoseGobal);
164 armarx::FramedPose placePoseTcpFramed(placePoseTcpLocal, context->getRobot()->getRootNode()->getName(), context->getRobotStateComponent()->getSynchronizedRobot()->getName());
165 local.setPlacePose(placePoseTcpFramed);
167 placePoseGobal->changeToGlobal(context->getRobotStateComponent()->getSynchronizedRobot());
168 context->getDebugDrawerTopic()->setPoseVisu(
"PlacingPoses",
"PlaceTargetHand", placePoseGobal);
171 placePoseTcpLocal(2, 3) += ZoffsetForPreAndPostPlacePoses;
172 armarx::FramedPose prePlacePose(placePoseTcpLocal, context->getRobot()->getRootNode()->getName(), context->getRobotStateComponent()->getSynchronizedRobot()->getName());
173 local.setPrePlacePose(prePlacePose);
175 prePlacePoseGobal->changeToGlobal(context->getRobotStateComponent()->getSynchronizedRobot());
176 context->getDebugDrawerTopic()->setPoseVisu(
"PlacingPoses",
"PrePlaceTarget", prePlacePoseGobal);
178 bool useLeftHand =
false;
180 if (handName.find(
"left") != std::string::npos || handName.find(
"Left") != std::string::npos)
193 placePoseTcpLocal(0, 3) -= xRetreatOffset;
197 placePoseTcpLocal(0, 3) += xRetreatOffset;
201 placePoseTcpLocal(1, 3) -= offsetForRetreatPoseY;
203 armarx::FramedPose retreatPose(placePoseTcpLocal, context->getRobot()->getRootNode()->getName(), context->getRobotStateComponent()->getSynchronizedRobot()->getName());
204 local.setRetreatPose(retreatPose);
206 retreatPoseGobal->changeToGlobal(context->getRobotStateComponent()->getSynchronizedRobot());
214 Eigen::Vector3f placeOrientationRPY = ori.eulerAngles(0, 1, 2);
215 ARMARX_VERBOSE <<
"Place orientation angles: " << placeOrientationRPY;
216 ori.transposeInPlace();
217 placeOrientationRPY = ori.eulerAngles(0, 1, 2);
218 ARMARX_VERBOSE <<
"Place orientation inverse angles: " << placeOrientationRPY;
225 std::string speechOutput =
"I will now put down the " + objectName;
226 ARMARX_INFO <<
"Speech output: '" << speechOutput <<
"'";
227 context->getTextToSpeech()->reportText(speechOutput);
229 local.setDecelerationTimeForStopping(1000);
234 std::string objectName = in.getObjectClassName();
235 getEntityDrawerTopic()->removeObjectVisu(
"PlaceObject", objectName);
236 getDebugDrawerTopic()->removeLayer(
"PlacingPoses");