ReleaseTable.cpp
Go to the documentation of this file.
1 /*
2  * This file is part of ArmarX.
3  *
4  * Copyright (C) 2014-2016, High Performance Humanoid Technologies (H2T), Karlsruhe Institute of Technology (KIT), all rights reserved.
5  *
6  * ArmarX is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation.
9  *
10  * ArmarX is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  *
18  * @package RobotSkillTemplates::ReleaseTableGroup
19  * @author [Author Name] ( [Author Email] )
20  * @date 2014
21  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
22  * GNU General Public License
23  */
24 
25 #include "ReleaseTable.h"
29 
30 using namespace armarx;
31 using namespace CoupledInteractionGroup;
32 
33 // DO NOT EDIT NEXT LINE
35 
36 
37 
39  XMLStateTemplate < ReleaseTable > (stateData), ReleaseTableGeneratedBase < ReleaseTable > (stateData)
40 {
41 }
42 
44 {
45  //CoupledInteractionGroupStatechartContext* context = getContext<CoupledInteractionGroupStatechartContext>();
46  float goBackDistance = in.getGoBackDistance();
47  Eigen::Vector3f targetPoseRelativeVec;
48  targetPoseRelativeVec(0) = 0.0;
49  targetPoseRelativeVec(1) = -goBackDistance;
50  targetPoseRelativeVec(2) = 0.0;
51  std::vector<std::string> jointNames;
52  jointNames.push_back("Shoulder 2 L"); // -> Pitch
53  jointNames.push_back("Shoulder 2 R"); // -> Pitch
54  jointNames.push_back("Upperarm L"); // -> Pitch
55  jointNames.push_back("Upperarm R"); // -> Pitch
56  jointNames.push_back("Elbow L"); // -> Pitch
57  jointNames.push_back("Elbow R"); // -> Pitch
58  local.setGoBackJointNames(jointNames);
59 
60 
61  std::vector<float> targetJointValues;
62  targetJointValues.push_back(0.5);
63  targetJointValues.push_back(0.5);
64  targetJointValues.push_back(0.0);
65  targetJointValues.push_back(0.0);
66  targetJointValues.push_back(-0.5);
67  targetJointValues.push_back(-0.5);
68  local.setGoBackTargetJointValues(targetJointValues);
69  local.setPlatformTargetPose(Vector3(targetPoseRelativeVec));
70 }
71 
72 
74 {
75  CoupledInteractionGroupStatechartContext* context = getContext<CoupledInteractionGroupStatechartContext>();
76 
77  // detach table from hand
78  // is always executed, even if release failed (but that should be ok)
79 
80  // todo: get object class name from input
81  std::string objClassName = "lighttable"; // in.getObjectClassName();
82  auto instances = context->getWorkingMemoryProxy()->getObjectInstancesSegment()->getObjectInstancesByClass(objClassName);
83 
84  if (instances.size() > 0)
85  {
86  memoryx::ObjectInstanceBasePtr obj = instances.front();
88  memoryx::ObjectInstancePtr obj2 = memoryx::ObjectInstancePtr::dynamicCast(obj);
89  FramedPosePtr pose = obj2->getPose();
90  ARMARX_VERBOSE << "Detaching " << objClassName << " from hand. Setting pose to:\n" << pose->output();
91 
93  context->getWorkingMemoryProxy()->getObjectInstancesSegment()->setObjectPose(obj->getId(),
94  new LinkedPose(*pose, context->getRobotStateComponent()->getRobotSnapshot(context->getRobot()->getName())));
95  context->getWorkingMemoryProxy()->getObjectInstancesSegment()->setNewMotionModel(obj->getId(), newMotionModel);
96  }
97  else
98  {
99  ARMARX_WARNING << "No object instance with name '" << objClassName << "' found! Could not change working memory position and motion model of object.";
100  }
101 
102 }
103 
104 // DO NOT EDIT NEXT FUNCTION
106 {
107  return "ReleaseTable";
108 }
109 
110 // DO NOT EDIT NEXT FUNCTION
112 {
113  return XMLStateFactoryBasePtr(new ReleaseTable(stateData));
114 }
115 
RemoteRobot.h
ARMARX_VERBOSE
#define ARMARX_VERBOSE
Definition: Logging.h:180
armarx::CoupledInteractionGroup::CoupledInteractionGroupStatechartContext::getRobotStateComponent
RobotStateComponentInterfacePrx getRobotStateComponent()
Definition: CoupledInteractionGroupStatechartContext.h:105
armarx::XMLStateConstructorParams
Definition: XMLState.h:50
armarx::CoupledInteractionGroup::ReleaseTable::Registry
static SubClassRegistry Registry
Definition: ReleaseTable.h:47
IceInternal::Handle< ObjectInstance >
armarx::CoupledInteractionGroup::CoupledInteractionGroupStatechartContext::getRobot
const VirtualRobot::RobotPtr getRobot()
Definition: CoupledInteractionGroupStatechartContext.h:101
armarx::XMLStateTemplate
Class for legacy to stay compatible with old statecharts.
Definition: XMLState.h:137
MotionModelStaticObject.h
ReleaseTable.h
armarx::CoupledInteractionGroup::ReleaseTable::GetName
static std::string GetName()
Definition: ReleaseTable.cpp:105
armarx::CoupledInteractionGroup::ReleaseTable::CreateInstance
static XMLStateFactoryBasePtr CreateInstance(XMLStateConstructorParams stateData)
Definition: ReleaseTable.cpp:111
memoryx::MotionModelStaticObject
Definition: MotionModelStaticObject.h:34
armarx::CoupledInteractionGroup::ReleaseTable::onEnter
void onEnter() override
Definition: ReleaseTable.cpp:43
armarx::XMLStateFactoryBasePtr
IceInternal::Handle< XMLStateFactoryBase > XMLStateFactoryBasePtr
Definition: XMLState.h:65
armarx::CoupledInteractionGroup::CoupledInteractionGroupStatechartContext::getWorkingMemoryProxy
memoryx::WorkingMemoryInterfacePrx getWorkingMemoryProxy()
Definition: CoupledInteractionGroupStatechartContext.h:125
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::CoupledInteractionGroup::ReleaseTable::ReleaseTable
ReleaseTable(XMLStateConstructorParams stateData)
Definition: ReleaseTable.cpp:38
memoryx::KBM::Vector3
Eigen::Vector3d Vector3
Definition: kbm.h:41
armarx::CoupledInteractionGroup::CoupledInteractionGroupStatechartContext
Definition: CoupledInteractionGroupStatechartContext.h:88
armarx::LinkedPose
The LinkedPose class.
Definition: LinkedPose.h:60
armarx::CoupledInteractionGroup::ReleaseTable
Definition: ReleaseTable.h:34
ARMARX_WARNING
#define ARMARX_WARNING
Definition: Logging.h:186
armarx::CoupledInteractionGroup::ReleaseTable::onExit
void onExit() override
Definition: ReleaseTable.cpp:73
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28