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