27 #include <VirtualRobot/Grasping/Grasp.h>
28 #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 =
57 getContext<PlaceObjectGroupStatechartContextBase>();
59 std::string handName = in.getHandChannelRef()->getDataField(
"className")->getString();
61 local.setHandName(handName);
64 std::string objectName =
65 in.getObjectClassName();
66 memoryx::ObjectClassBasePtr objectClassBase =
67 context->getPriorKnowledge()->getObjectClassesSegment()->getObjectClassByName(objectName);
69 if (in.isPlaceOrientationSet())
73 ori->toRootEigen(getRobotStateComponent()->getSynchronizedRobot()).block<3, 3>(0, 0);
85 Eigen::Vector3f placeOrientationAngles = simoxWrapper->getPutdownOrientationRPY();
92 if (!in.isPlaceOrientationSet())
94 ARMARX_INFO <<
"Using placing orientation of the object (RPY): "
95 << placeOrientationAngles;
96 orientation = Eigen::AngleAxisf(placeOrientationAngles(0), Eigen::Vector3f::UnitX()) *
97 Eigen::AngleAxisf(placeOrientationAngles(1), Eigen::Vector3f::UnitY()) *
98 Eigen::AngleAxisf(placeOrientationAngles(2), Eigen::Vector3f::UnitZ());
102 ARMARX_INFO <<
"Using placing orientation from input: " << orientation;
105 VirtualRobot::GraspSetPtr graspSet =
106 simoxWrapper->getManipulationObject()->getGraspSet(in.getGraspSetName());
110 VirtualRobot::GraspPtr grasp = graspSet->getGrasp(in.getGraspName());
114 transformationFromTCPToObject = grasp->getTransformation();
115 ARMARX_VERBOSE <<
"Found grasp " << in.getGraspName() <<
", trafo:\n"
116 <<
VAROUT(transformationFromTCPToObject);
120 ARMARX_WARNING <<
"Grasp " << in.getGraspName() <<
" not found in grasp set";
125 ARMARX_WARNING <<
"Grasp set " << in.getGraspSetName() <<
" not found";
131 <<
" not found in the classes segment of PriorKnowledge";
135 placePoseObjectLocal.block<3, 3>(0, 0) = orientation;
137 placePoseTemp->changeFrame(context->getRobot(), context->getRobot()->getRootNode()->getName());
138 placePoseObjectLocal.block<3, 1>(0, 3) = placePoseTemp->toEigen();
141 context->getRobot()->getRootNode()->getName(),
142 context->getRobotStateComponent()->getSynchronizedRobot()->getName()));
143 ARMARX_IMPORTANT <<
"Placing pose of the object: " << *placeObjectPoseGobal;
144 placeObjectPoseGobal->changeToGlobal(context->getRobotStateComponent()->getSynchronizedRobot());
146 getEntityDrawerTopic()->setObjectVisu(
147 "PlaceObject", objectName, objectClassBase, placeObjectPoseGobal);
148 getEntityDrawerTopic()->updateObjectColor(
"PlaceObject", objectName, DrawColor{0, 0, 0, 0.3});
176 placePoseObjectLocal * transformationFromTCPToObject.inverse();
178 local.setObjectFinalPose(placeObjectPoseGobal);
181 context->getRobot()->getRootNode()->getName(),
182 context->getRobotStateComponent()->getSynchronizedRobot()->getName());
183 local.setPlacePose(placePoseTcpFramed);
185 placePoseGobal->changeToGlobal(context->getRobotStateComponent()->getSynchronizedRobot());
186 context->getDebugDrawerTopic()->setPoseVisu(
"PlacingPoses",
"PlaceTargetHand", placePoseGobal);
189 placePoseTcpLocal(2, 3) += ZoffsetForPreAndPostPlacePoses;
192 context->getRobot()->getRootNode()->getName(),
193 context->getRobotStateComponent()->getSynchronizedRobot()->getName());
194 local.setPrePlacePose(prePlacePose);
196 prePlacePoseGobal->changeToGlobal(context->getRobotStateComponent()->getSynchronizedRobot());
197 context->getDebugDrawerTopic()->setPoseVisu(
198 "PlacingPoses",
"PrePlaceTarget", prePlacePoseGobal);
200 bool useLeftHand =
false;
202 if (handName.find(
"left") != std::string::npos || handName.find(
"Left") != std::string::npos)
215 placePoseTcpLocal(0, 3) -= xRetreatOffset;
219 placePoseTcpLocal(0, 3) += xRetreatOffset;
223 placePoseTcpLocal(1, 3) -= offsetForRetreatPoseY;
227 context->getRobot()->getRootNode()->getName(),
228 context->getRobotStateComponent()->getSynchronizedRobot()->getName());
229 local.setRetreatPose(retreatPose);
231 retreatPoseGobal->changeToGlobal(context->getRobotStateComponent()->getSynchronizedRobot());
239 Eigen::Vector3f placeOrientationRPY = ori.eulerAngles(0, 1, 2);
240 ARMARX_VERBOSE <<
"Place orientation angles: " << placeOrientationRPY;
241 ori.transposeInPlace();
242 placeOrientationRPY = ori.eulerAngles(0, 1, 2);
243 ARMARX_VERBOSE <<
"Place orientation inverse angles: " << placeOrientationRPY;
250 std::string speechOutput =
"I will now put down the " + objectName;
251 ARMARX_INFO <<
"Speech output: '" << speechOutput <<
"'";
252 context->getTextToSpeech()->reportText(speechOutput);
254 local.setDecelerationTimeForStopping(1000);
260 std::string objectName = in.getObjectClassName();
261 getEntityDrawerTopic()->removeObjectVisu(
"PlaceObject", objectName);
262 getDebugDrawerTopic()->removeLayer(
"PlacingPoses");