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 
30 using namespace armarx;
31 using namespace GraspObjectGroup;
32 
33 // DO NOT EDIT NEXT LINE
34 CalculateGraspConfiguration::SubClassRegistry
35  CalculateGraspConfiguration::Registry(CalculateGraspConfiguration::GetName(),
37 
38 void
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()));
56  ARMARX_CHECK_EXPRESSION(objclass);
57  memoryx::GridFileManagerPtr fileManager(
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 
99 void
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
109 {
111 }
armarx::RemoteRobot::synchronizeLocalClone
static bool synchronizeLocalClone(VirtualRobot::RobotPtr robot, RobotStateComponentInterfacePrx robotStatePrx)
Definition: RemoteRobot.cpp:522
armarx::RemoteRobot::createLocalCloneFromFile
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...
Definition: RemoteRobot.cpp:512
armarx::XMLStateConstructorParams
Definition: XMLState.h:49
GridFileManager.h
ObjectClass.h
armarx::XMLStateFactoryBasePtr
IceInternal::Handle< XMLStateFactoryBase > XMLStateFactoryBasePtr
Definition: XMLState.h:64
IceInternal::Handle< ObjectInstance >
armarx::GraspObjectGroup::CalculateGraspConfiguration::onEnter
void onEnter() override
Definition: CalculateGraspConfiguration.cpp:39
memoryx::EntityWrappers::SimoxObjectWrapper
SimoxObjectWrapper offers a simplified access to the Simox ManipulationObject (i.e visualization,...
Definition: SimoxObjectWrapper.h:46
CalculateGraspConfiguration.h
armarx::GraspObjectGroup::CalculateGraspConfiguration::CalculateGraspConfiguration
CalculateGraspConfiguration(const XMLStateConstructorParams &stateData)
Definition: CalculateGraspConfiguration.h:33
SimoxObjectWrapper.h
ObjectInstance.h
ARMARX_CHECK_EXPRESSION
#define ARMARX_CHECK_EXPRESSION(expression)
This macro evaluates the expression and if it turns out to be false it will throw an ExpressionExcept...
Definition: ExpressionException.h:73
ARMARX_INFO
#define ARMARX_INFO
Definition: Logging.h:181
memoryx::GridFileManagerPtr
std::shared_ptr< GridFileManager > GridFileManagerPtr
Definition: AbstractEntityWrapper.h:33
armarx::GraspObjectGroup::CalculateGraspConfiguration::Registry
static SubClassRegistry Registry
Definition: CalculateGraspConfiguration.h:47
memoryx::GridFileManager
GridFileManager provides utility functions for working with files in Mongo GridFS and links to them s...
Definition: GridFileManager.h:41
MemoryXTypesObjectFactories.h
armarx::GraspObjectGroup::CalculateGraspConfiguration::CreateInstance
static XMLStateFactoryBasePtr CreateInstance(XMLStateConstructorParams stateData)
Definition: CalculateGraspConfiguration.cpp:108
armarx::GraspObjectGroup::CalculateGraspConfiguration::onExit
void onExit() override
Definition: CalculateGraspConfiguration.cpp:100
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:27