CalculateGraspConfiguration.cpp
Go to the documentation of this file.
1/*
2 * This file is part of ArmarX.
3 *
4 * ArmarX is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
8 * ArmarX is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * @package RobotSkillTemplates::GraspObjectGroup
17 * @author Mirko Waechter ( mirko dot waechter at kit dot edu )
18 * @date 2017
19 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20 * GNU General Public License
21 */
22
24
30using namespace armarx;
31using namespace GraspObjectGroup;
32
33// DO NOT EDIT NEXT LINE
34CalculateGraspConfiguration::SubClassRegistry
35 CalculateGraspConfiguration::Registry(CalculateGraspConfiguration::GetName(),
37
38void
40{
41 // put your user code for the enter-point here
42 // execution time should be short (<100ms)
43 ARMARX_INFO << "Instance content: "
44 << getWorkingMemory()->getObjectInstancesSegment()->getJSONEntityById(
45 in.getObjectInstanceChannel()->getDataField("id")->getString());
46 memoryx::ObjectInstancePtr objInstance = memoryx::ObjectInstancePtr::dynamicCast(
47 getWorkingMemory()->getObjectInstancesSegment()->getObjectInstanceById(
48 in.getObjectInstanceChannel()->getDataField("id")->getString()));
49 ARMARX_INFO << "instance content local: " << *objInstance;
50 auto robot = RemoteRobot::createLocalCloneFromFile(getRobotStateComponent(),
51 VirtualRobot::RobotIO::eCollisionModel);
52 RemoteRobot::synchronizeLocalClone(robot, getRobotStateComponent());
53 memoryx::ObjectClassPtr objclass = memoryx::ObjectClassPtr::dynamicCast(
54 getWorkingMemory()->getObjectClassesSegment()->getEntityByName(
55 in.getObjectInstanceChannel()->getDataField("className")->getString()));
58 new memoryx::GridFileManager(getWorkingMemory()->getCommonStorage()));
60 objclass->addWrapper(new memoryx::EntityWrappers::SimoxObjectWrapper(fileManager));
61 simoxObject->getManipulationObject();
62 objInstance->setPose(objInstance->getPose()->toGlobal(robot));
63 auto endeffector = robot->getEndEffector(in.getHandName());
64 simoxObject->updateFromEntity(objInstance);
65 ARMARX_INFO << "GCP Pose: " << endeffector->getGCP()->getGlobalPose();
66 ARMARX_INFO << "ObjectPose: " << simoxObject->getManipulationObject()->getGlobalPose();
67 ARMARX_INFO << "JointConfig before: "
68 << endeffector->getConfiguration()->getRobotNodeJointValueMap();
69 endeffector->closeActors(simoxObject->getManipulationObject());
70 // getEntityDrawerTopic()->setObjectVisu("Grasping", "TargetObjectVisu", objclass, new Pose(simoxObject->getManipulationObject()->getGlobalPose()));
71
72 // memoryx::ObjectClassPtr handobjclass = memoryx::ObjectClassPtr::dynamicCast(getWorkingMemory()->getObjectClassesSegment()->getEntityByName(in.getHandInstanceChannel()->getDataField("className")->getString()));
73
74 // getEntityDrawerTopic()->setObjectVisu("Grasping", "HandVisu", handobjclass, new Pose(robot->getRobotNode(in.getHandName())->getGlobalPose()));
75 // getEntityDrawerTopic()->updateObjectColor("Grasping", "HandVisu", DrawColor {1, 0, 0, 0.5});
76 out.setJointValueMap(endeffector->getConfiguration()->getRobotNodeJointValueMap());
77 emitSuccess();
78}
79
80//void CalculateGraspConfiguration::run()
81//{
82// // put your user code for the execution-phase here
83// // runs in seperate thread, thus can do complex operations
84// // should check constantly whether isRunningTaskStopped() returns true
85//
86//// uncomment this if you need a continous run function. Make sure to use sleep or use blocking wait to reduce cpu load.
87// while (!isRunningTaskStopped()) // stop run function if returning true
88// {
89// // do your calculations
90// }
91//}
92
93//void CalculateGraspConfiguration::onBreak()
94//{
95// // put your user code for the breaking point here
96// // execution time should be short (<100ms)
97//}
98
99void
101{
102 // put your user code for the exit point here
103 // execution time should be short (<100ms)
104}
105
106// DO NOT EDIT NEXT FUNCTION
CalculateGraspConfiguration(const XMLStateConstructorParams &stateData)
static XMLStateFactoryBasePtr CreateInstance(XMLStateConstructorParams stateData)
static VirtualRobot::RobotPtr createLocalCloneFromFile(RobotStateComponentInterfacePrx robotStatePrx, VirtualRobot::RobotIO::RobotDescription loadMode=VirtualRobot::RobotIO::eFull)
This is a convenience function for createLocalClone, which automatically gets the filename from the R...
static bool synchronizeLocalClone(VirtualRobot::RobotPtr robot, RobotStateComponentInterfacePrx robotStatePrx)
SimoxObjectWrapper offers a simplified access to the Simox ManipulationObject (i.e visualization,...
GridFileManager provides utility functions for working with files in Mongo GridFS and links to them s...
#define ARMARX_CHECK_EXPRESSION(expression)
This macro evaluates the expression and if it turns out to be false it will throw an ExpressionExcept...
#define ARMARX_INFO
The normal logging level.
Definition Logging.h:181
This file offers overloads of toIce() and fromIce() functions for STL container types.
IceInternal::Handle< XMLStateFactoryBase > XMLStateFactoryBasePtr
Definition XMLState.h:64
IceInternal::Handle< SimoxObjectWrapper > SimoxObjectWrapperPtr
IceInternal::Handle< ObjectInstance > ObjectInstancePtr
IceInternal::Handle< ObjectClass > ObjectClassPtr
Definition ObjectClass.h:35
std::shared_ptr< GridFileManager > GridFileManagerPtr