LiftTable.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::LiftTableGroup
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 "LiftTable.h"
28 
30 
31 using namespace armarx;
32 using namespace CoupledInteractionGroup;
33 
34 // DO NOT EDIT NEXT LINE
36 
37 
38 
40  XMLStateTemplate < LiftTable > (stateData), LiftTableGeneratedBase < LiftTable > (stateData)
41 {
42 }
43 
45 {
46  CoupledInteractionGroupStatechartContext* context = getContext<CoupledInteractionGroupStatechartContext>();
47  context->getTCPControlUnit()->request();
48  Eigen::Matrix4f leftTcpPoseBase = context->getRobot()->getRobotNode(in.getLeftHandName())->getPoseInRootFrame();
49  Eigen::Matrix4f rightTcpPoseBase = context->getRobot()->getRobotNode(in.getRightHandName())->getPoseInRootFrame();
50  ARMARX_INFO << "LeftHandName in Liftable " << in.getLeftHandName();
51  ARMARX_INFO << "RightHandName in Liftable " << in.getRightHandName();
52  ARMARX_INFO << "Lift Offset " << in.getLiftOffset();
53  FramedPose leftTcpPose = FramedPose(leftTcpPoseBase, std::string("Armar3"), std::string("Armar3_Base"));
54  FramedPose rightTcpPose = FramedPose(rightTcpPoseBase, std::string("Armar3"), std::string("Armar3_Base"));
55  local.setInitialLeftTcpPose(leftTcpPose);
56  local.setInitialRightTcpPose(rightTcpPose);
57 }
58 
60 {
61  // put your user code for the execution-phase here
62  // runs in seperate thread, thus can do complex operations
63  // should check constantly whether isRunningTaskStopped() returns true
64 
65 
66 }
67 
69 {
70  // put your user code for the breaking point here
71  // execution time should be short (<100ms)
72 }
73 
75 {
76 
77  // put your user code for the exit point here
78  // execution time should be short (<100ms)
79  CoupledInteractionGroupStatechartContext* context = getContext<CoupledInteractionGroupStatechartContext>();
80  context->getTCPControlUnit()->release();
81 
82  // we attach table to left hand
83  // this code should go to a dedicated state, since it is also executed on falure!
84 
85  // set motion model AttachedToOtherObject
86  //if (in.isObjectInstanceChannelSet())
87  {
88  // todo: get objetc name
89  std::string objName = "lighttable";//in.getObjectInstanceChannel()->getDataField("className")->getString();
90  ARMARX_VERBOSE << "Attch to hand... Object Name:" << objName << ", hand name:" << in.getLeftHandMemoryChannel()->getDataField("className")->getString();
91  auto handInstances = context->getObjectMemoryObserverProxy()->getObjectInstancesByClass(in.getLeftHandMemoryChannel()->getDataField("className")->getString());
92 
93  ARMARX_CHECK_EXPRESSION(handInstances.size() != 0);
94  ChannelRefBasePtr handChannel = handInstances.front();
95 
96  memoryx::MotionModelAttachedToOtherObjectPtr newMotionModel = new memoryx::MotionModelAttachedToOtherObject(context->getRobotStateComponent(), ChannelRefPtr::dynamicCast(handChannel));
97  memoryx::ObjectInstancePtr object = memoryx::ObjectInstancePtr::dynamicCast(context->getWorkingMemoryProxy()->getObjectInstancesSegment()->getEntityByName(objName));
98 
99  context->getWorkingMemoryProxy()->getObjectInstancesSegment()->setNewMotionModel(object->getId(), newMotionModel);
100  ARMARX_IMPORTANT << "Attached " << objName << " to " << ChannelRefPtr::dynamicCast(handChannel)->getDataField("className")->getString();
101  }
102 
103 }
104 
105 // DO NOT EDIT NEXT FUNCTION
106 std::string LiftTable::GetName()
107 {
108  return "LiftTable";
109 }
110 
111 // DO NOT EDIT NEXT FUNCTION
113 {
114  return XMLStateFactoryBasePtr(new LiftTable(stateData));
115 }
116 
armarx::CoupledInteractionGroup::CoupledInteractionGroupStatechartContext::getObjectMemoryObserverProxy
memoryx::ObjectMemoryObserverInterfacePrx getObjectMemoryObserverProxy()
Definition: CoupledInteractionGroupStatechartContext.h:129
RemoteRobot.h
ARMARX_VERBOSE
#define ARMARX_VERBOSE
Definition: Logging.h:180
armarx::CoupledInteractionGroup::LiftTable::CreateInstance
static XMLStateFactoryBasePtr CreateInstance(XMLStateConstructorParams stateData)
Definition: LiftTable.cpp:112
armarx::CoupledInteractionGroup::LiftTable::onEnter
void onEnter() override
Definition: LiftTable.cpp:44
ARMARX_IMPORTANT
#define ARMARX_IMPORTANT
Definition: Logging.h:183
armarx::CoupledInteractionGroup::LiftTable::GetName
static std::string GetName()
Definition: LiftTable.cpp:106
armarx::CoupledInteractionGroup::LiftTable::LiftTable
LiftTable(XMLStateConstructorParams stateData)
Definition: LiftTable.cpp:39
armarx::FramedPose
The FramedPose class.
Definition: FramedPose.h:258
armarx::VariantType::FramedPose
const VariantTypeId FramedPose
Definition: FramedPose.h:37
armarx::CoupledInteractionGroup::CoupledInteractionGroupStatechartContext::getRobotStateComponent
RobotStateComponentInterfacePrx getRobotStateComponent()
Definition: CoupledInteractionGroupStatechartContext.h:105
armarx::XMLStateConstructorParams
Definition: XMLState.h:50
armarx::CoupledInteractionGroup::LiftTable::Registry
static SubClassRegistry Registry
Definition: LiftTable.h:48
IceInternal::Handle
Definition: forward_declarations.h:8
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
armarx::CoupledInteractionGroup::LiftTable::onBreak
void onBreak() override
Definition: LiftTable.cpp:68
armarx::CoupledInteractionGroup::LiftTable
Definition: LiftTable.h:33
armarx::CoupledInteractionGroup::LiftTable::run
void run() override
Definition: LiftTable.cpp:59
memoryx::MotionModelAttachedToOtherObject
Definition: MotionModelAttachedToOtherObject.h:34
MotionModelAttachedToOtherObject.h
armarx::XMLStateFactoryBasePtr
IceInternal::Handle< XMLStateFactoryBase > XMLStateFactoryBasePtr
Definition: XMLState.h:65
armarx::CoupledInteractionGroup::CoupledInteractionGroupStatechartContext::getWorkingMemoryProxy
memoryx::WorkingMemoryInterfacePrx getWorkingMemoryProxy()
Definition: CoupledInteractionGroupStatechartContext.h:125
GfxTL::Matrix4f
MatrixXX< 4, 4, float > Matrix4f
Definition: MatrixXX.h:601
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::CoupledInteractionGroupStatechartContext::getTCPControlUnit
TCPControlUnitInterfacePrx getTCPControlUnit()
Definition: CoupledInteractionGroupStatechartContext.h:117
ARMARX_INFO
#define ARMARX_INFO
Definition: Logging.h:174
armarx::CoupledInteractionGroup::CoupledInteractionGroupStatechartContext
Definition: CoupledInteractionGroupStatechartContext.h:88
LiftTable.h
armarx::CoupledInteractionGroup::LiftTable::onExit
void onExit() override
Definition: LiftTable.cpp:74
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28