CarryTable.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::CarryTableGroup
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 "CarryTable.h"
26 
27 #include <RobotAPI/interface/components/ViewSelectionInterface.h>
29 
30 using namespace armarx;
31 using namespace CoupledInteractionGroup;
32 
33 // DO NOT EDIT NEXT LINE
34 CarryTable::SubClassRegistry CarryTable::Registry(CarryTable::GetName(),
36 
38  XMLStateTemplate<CarryTable>(stateData), CarryTableGeneratedBase<CarryTable>(stateData)
39 {
40 }
41 
43 CarryTable::getChannelRef(std::string objectName)
44 {
45 
47  getContext<CoupledInteractionGroupStatechartContext>();
48  ChannelRefBasePtr memoryChannel =
49  context->getObjectMemoryObserverProxy()->requestObjectClassRepeated(
50  objectName, 250, armarx::DEFAULT_VIEWTARGET_PRIORITY);
51 
52 
53  if (memoryChannel)
54  {
55  memoryChannel->validate();
56  return ChannelRefPtr::dynamicCast(memoryChannel);
57  }
58  else
59  {
60  return nullptr;
61  }
62 }
63 
64 void
66 {
67  std::string leftHandNameInMemory = in.getLeftHandNameInMemory();
68  local.setLeftHandMemoryChannelRef(getChannelRef(leftHandNameInMemory));
69  ARMARX_CHECK_EXPRESSION(local.getLeftHandMemoryChannelRef());
70 
71  std::string rightHandNameInMemory = in.getRightHandNameInMemory();
72  local.setRightHandMemoryChannelRef(getChannelRef(rightHandNameInMemory));
73  ARMARX_CHECK_EXPRESSION(local.getRightHandMemoryChannelRef());
75  getContext<CoupledInteractionGroupStatechartContext>();
76  armarx::ChannelRefPtr poseRef =
77  context->getChannelRef(context->getPlatformUnitObserverName(), "platformPose");
78  Eigen::Vector3f tableStartPose;
79  tableStartPose(0) = poseRef->getDataField("positionX")->getFloat();
80  tableStartPose(1) = poseRef->getDataField("positionY")->getFloat();
81  tableStartPose(2) = poseRef->getDataField("rotation")->getFloat();
82 
83  Eigen::Vector3f tableTargetPose = in.getTableTargetPose_2()->toEigen();
84  local.setTablePose(FramedDirection(tableStartPose, "Global", "Armar3"));
85  local.setTableTargetPose(FramedDirection(tableTargetPose, "Global", "Armar3"));
86 }
87 
88 void
90 {
91 
92  // put your user code for the exit point here
93  // execution time should be short (<100ms)
94 }
95 
96 // DO NOT EDIT NEXT FUNCTION
97 std::string
99 {
100  return "CarryTable";
101 }
102 
103 // DO NOT EDIT NEXT FUNCTION
106 {
107  return XMLStateFactoryBasePtr(new CarryTable(stateData));
108 }
armarx::CoupledInteractionGroup::CoupledInteractionGroupStatechartContext::getObjectMemoryObserverProxy
memoryx::ObjectMemoryObserverInterfacePrx getObjectMemoryObserverProxy()
Definition: CoupledInteractionGroupStatechartContext.h:175
RemoteRobot.h
armarx::CoupledInteractionGroup::CarryTable::CreateInstance
static XMLStateFactoryBasePtr CreateInstance(XMLStateConstructorParams stateData)
Definition: CarryTable.cpp:105
armarx::CoupledInteractionGroup::CarryTable
Definition: CarryTable.h:37
armarx::XMLStateConstructorParams
Definition: XMLState.h:49
armarx::CoupledInteractionGroup::CarryTable::getChannelRef
ChannelRefPtr getChannelRef(std::string objectName)
Definition: CarryTable.cpp:43
armarx::CoupledInteractionGroup::CarryTable::CarryTable
CarryTable(XMLStateConstructorParams stateData)
Definition: CarryTable.cpp:37
armarx::StatechartContext::getChannelRef
ChannelRefPtr getChannelRef(const std::string &observerName, const std::string &channelName) override
Definition: StatechartContext.cpp:152
armarx::CoupledInteractionGroup::CarryTable::Registry
static SubClassRegistry Registry
Definition: CarryTable.h:51
armarx::XMLStateFactoryBasePtr
IceInternal::Handle< XMLStateFactoryBase > XMLStateFactoryBasePtr
Definition: XMLState.h:64
IceInternal::Handle< ChannelRef >
armarx::CoupledInteractionGroup::CarryTable::onExit
void onExit() override
Definition: CarryTable.cpp:89
armarx::CoupledInteractionGroup::CoupledInteractionGroupStatechartContext::getPlatformUnitObserverName
std::string getPlatformUnitObserverName()
Definition: CoupledInteractionGroupStatechartContext.h:207
armarx::XMLStateTemplate
Class for legacy to stay compatible with old statecharts.
Definition: XMLState.h:146
armarx::CoupledInteractionGroup::CarryTable::GetName
static std::string GetName()
Definition: CarryTable.cpp:98
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::VariantType::FramedDirection
const VariantTypeId FramedDirection
Definition: FramedPose.h:37
armarx::CoupledInteractionGroup::CoupledInteractionGroupStatechartContext
Definition: CoupledInteractionGroupStatechartContext.h:118
CarryTable.h
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:27
armarx::CoupledInteractionGroup::CarryTable::onEnter
void onEnter() override
Definition: CarryTable.cpp:65