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"
26 
28 
31 
32 using namespace armarx;
33 using namespace CoupledInteractionGroup;
34 
35 // DO NOT EDIT NEXT LINE
36 ReleaseTable::SubClassRegistry ReleaseTable::Registry(ReleaseTable::GetName(),
38 
40  XMLStateTemplate<ReleaseTable>(stateData), ReleaseTableGeneratedBase<ReleaseTable>(stateData)
41 {
42 }
43 
44 void
46 {
47  //CoupledInteractionGroupStatechartContext* context = getContext<CoupledInteractionGroupStatechartContext>();
48  float goBackDistance = in.getGoBackDistance();
49  Eigen::Vector3f targetPoseRelativeVec;
50  targetPoseRelativeVec(0) = 0.0;
51  targetPoseRelativeVec(1) = -goBackDistance;
52  targetPoseRelativeVec(2) = 0.0;
53  std::vector<std::string> jointNames;
54  jointNames.push_back("Shoulder 2 L"); // -> Pitch
55  jointNames.push_back("Shoulder 2 R"); // -> Pitch
56  jointNames.push_back("Upperarm L"); // -> Pitch
57  jointNames.push_back("Upperarm R"); // -> Pitch
58  jointNames.push_back("Elbow L"); // -> Pitch
59  jointNames.push_back("Elbow R"); // -> Pitch
60  local.setGoBackJointNames(jointNames);
61 
62 
63  std::vector<float> targetJointValues;
64  targetJointValues.push_back(0.5);
65  targetJointValues.push_back(0.5);
66  targetJointValues.push_back(0.0);
67  targetJointValues.push_back(0.0);
68  targetJointValues.push_back(-0.5);
69  targetJointValues.push_back(-0.5);
70  local.setGoBackTargetJointValues(targetJointValues);
71  local.setPlatformTargetPose(Vector3(targetPoseRelativeVec));
72 }
73 
74 void
76 {
78  getContext<CoupledInteractionGroupStatechartContext>();
79 
80  // detach table from hand
81  // is always executed, even if release failed (but that should be ok)
82 
83  // todo: get object class name from input
84  std::string objClassName = "lighttable"; // in.getObjectClassName();
85  auto instances =
86  context->getWorkingMemoryProxy()->getObjectInstancesSegment()->getObjectInstancesByClass(
87  objClassName);
88 
89  if (instances.size() > 0)
90  {
91  memoryx::ObjectInstanceBasePtr obj = instances.front();
93  memoryx::ObjectInstancePtr obj2 = memoryx::ObjectInstancePtr::dynamicCast(obj);
94  FramedPosePtr pose = obj2->getPose();
95  ARMARX_VERBOSE << "Detaching " << objClassName << " from hand. Setting pose to:\n"
96  << pose->output();
97 
100  context->getWorkingMemoryProxy()->getObjectInstancesSegment()->setObjectPose(
101  obj->getId(),
102  new LinkedPose(*pose,
103  context->getRobotStateComponent()->getRobotSnapshot(
104  context->getRobot()->getName())));
105  context->getWorkingMemoryProxy()->getObjectInstancesSegment()->setNewMotionModel(
106  obj->getId(), newMotionModel);
107  }
108  else
109  {
111  << "No object instance with name '" << objClassName
112  << "' found! Could not change working memory position and motion model of object.";
113  }
114 }
115 
116 // DO NOT EDIT NEXT FUNCTION
117 std::string
119 {
120  return "ReleaseTable";
121 }
122 
123 // DO NOT EDIT NEXT FUNCTION
126 {
127  return XMLStateFactoryBasePtr(new ReleaseTable(stateData));
128 }
RemoteRobot.h
ARMARX_VERBOSE
#define ARMARX_VERBOSE
Definition: Logging.h:187
armarx::CoupledInteractionGroup::CoupledInteractionGroupStatechartContext::getRobotStateComponent
RobotStateComponentInterfacePrx getRobotStateComponent()
Definition: CoupledInteractionGroupStatechartContext.h:139
armarx::XMLStateConstructorParams
Definition: XMLState.h:49
armarx::XMLStateFactoryBasePtr
IceInternal::Handle< XMLStateFactoryBase > XMLStateFactoryBasePtr
Definition: XMLState.h:64
armarx::CoupledInteractionGroup::ReleaseTable::Registry
static SubClassRegistry Registry
Definition: ReleaseTable.h:49
IceInternal::Handle< ObjectInstance >
armarx::CoupledInteractionGroup::CoupledInteractionGroupStatechartContext::getRobot
const VirtualRobot::RobotPtr getRobot()
Definition: CoupledInteractionGroupStatechartContext.h:133
armarx::XMLStateTemplate
Class for legacy to stay compatible with old statecharts.
Definition: XMLState.h:146
MotionModelStaticObject.h
ReleaseTable.h
armarx::CoupledInteractionGroup::ReleaseTable::GetName
static std::string GetName()
Definition: ReleaseTable.cpp:118
armarx::CoupledInteractionGroup::ReleaseTable::CreateInstance
static XMLStateFactoryBasePtr CreateInstance(XMLStateConstructorParams stateData)
Definition: ReleaseTable.cpp:125
memoryx::MotionModelStaticObject
Definition: MotionModelStaticObject.h:32
armarx::CoupledInteractionGroup::ReleaseTable::onEnter
void onEnter() override
Definition: ReleaseTable.cpp:45
armarx::CoupledInteractionGroup::CoupledInteractionGroupStatechartContext::getWorkingMemoryProxy
memoryx::WorkingMemoryInterfacePrx getWorkingMemoryProxy()
Definition: CoupledInteractionGroupStatechartContext.h:169
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:39
memoryx::KBM::Vector3
Eigen::Vector3d Vector3
Definition: kbm.h:43
armarx::CoupledInteractionGroup::CoupledInteractionGroupStatechartContext
Definition: CoupledInteractionGroupStatechartContext.h:118
armarx::LinkedPose
The LinkedPose class.
Definition: LinkedPose.h:60
armarx::CoupledInteractionGroup::ReleaseTable
Definition: ReleaseTable.h:37
ARMARX_WARNING
#define ARMARX_WARNING
Definition: Logging.h:193
armarx::CoupledInteractionGroup::ReleaseTable::onExit
void onExit() override
Definition: ReleaseTable.cpp:75
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:27