CloseHandWithTorques.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::FindAndGraspObjectGroup
19  * @author Valerij Wittenbeck ( valerij dot wittenbeck at student dot kit dot edu )
20  * @date 2014
21  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
22  * GNU General Public License
23  */
24 
25 #include "CloseHandWithTorques.h"
26 
27 using namespace armarx;
28 using namespace FindAndGraspObjectGroup;
29 
30 // DO NOT EDIT NEXT LINE
31 CloseHandWithTorques::SubClassRegistry
34 
37 {
38 }
39 
40 void
42 {
43  ARMARX_VERBOSE << "Entering CloseHandWithTorques::onEnter()";
44 
45  RobotStatechartContext* rsContext = getContext<RobotStatechartContext>();
46  SingleTypeVariantListPtr jointNames = getInput<SingleTypeVariantList>("jointNames");
47  SingleTypeVariantListPtr jointTorquesGraspList =
48  getInput<SingleTypeVariantList>("jointTorquesGrasp");
49  NameValueMap jointNamesAndValues;
50 
51  if (jointNames->getSize() == jointTorquesGraspList->getSize())
52  {
53  for (int j = 0; j < jointNames->getSize(); j++)
54  {
55  jointNamesAndValues[jointNames->getVariant(j)->getString()] =
56  jointTorquesGraspList->getVariant(j)->getFloat();
57  }
58  }
59  else
60  {
61  throw LocalException("StateCloseHandWithTorques: List lengths do not match!");
62  }
63 
64  rsContext->kinematicUnitPrx->setJointTorques(jointNamesAndValues);
65 
66  ARMARX_DEBUG << "Installing timeoutMinExecutionTime condition";
67  float timeoutMinExecutionTime = getInput<float>("timeoutMinExecutionTime");
69  setTimeoutEvent(timeoutMinExecutionTime, createEvent<EvMinExecutionTimeout>());
70 
71  ARMARX_VERBOSE << "Done CloseHandWithTorques::onEnter()";
72 }
73 
74 void
76 {
78 }
79 
80 // DO NOT EDIT NEXT FUNCTION
81 std::string
83 {
84  return "CloseHandWithTorques";
85 }
86 
87 // DO NOT EDIT NEXT FUNCTION
90 {
91  return XMLStateFactoryBasePtr(new CloseHandWithTorques(stateData));
92 }
ARMARX_VERBOSE
#define ARMARX_VERBOSE
Definition: Logging.h:187
armarx::FindAndGraspObjectGroup::CloseHandWithTorques::CloseHandWithTorques
CloseHandWithTorques(XMLStateConstructorParams stateData)
Definition: CloseHandWithTorques.cpp:35
armarx::FindAndGraspObjectGroup::CloseHandWithTorques::Registry
static SubClassRegistry Registry
Definition: CloseHandWithTorques.h:50
armarx::XMLStateConstructorParams
Definition: XMLState.h:49
CloseHandWithTorques.h
armarx::XMLStateFactoryBasePtr
IceInternal::Handle< XMLStateFactoryBase > XMLStateFactoryBasePtr
Definition: XMLState.h:64
armarx::FindAndGraspObjectGroup::CloseHandWithTorques::CreateInstance
static XMLStateFactoryBasePtr CreateInstance(XMLStateConstructorParams stateData)
Definition: CloseHandWithTorques.cpp:89
IceInternal::Handle< SingleTypeVariantList >
armarx::RobotStatechartContext
Definition: RobotStatechartContext.h:79
armarx::StateUtility::setTimeoutEvent
ActionEventIdentifier setTimeoutEvent(int timeoutDurationMs, const EventPtr &evt)
Utility function to start a timer on the systemObserver and register an event on the conditionHandler...
Definition: StateUtil.cpp:162
armarx::XMLStateTemplate
Class for legacy to stay compatible with old statecharts.
Definition: XMLState.h:146
armarx::FindAndGraspObjectGroup::CloseHandWithTorques
Definition: CloseHandWithTorques.h:36
ARMARX_DEBUG
#define ARMARX_DEBUG
Definition: Logging.h:184
armarx::FindAndGraspObjectGroup::CloseHandWithTorques::GetName
static std::string GetName()
Definition: CloseHandWithTorques.cpp:82
armarx::FindAndGraspObjectGroup::CloseHandWithTorques::onEnter
void onEnter() override
Virtual function, in which the behaviour of state is defined, when it is entered. Can be overridden,...
Definition: CloseHandWithTorques.cpp:41
armarx::FindAndGraspObjectGroup::CloseHandWithTorques::condMinimumExecutionTimeout
ActionEventIdentifier condMinimumExecutionTimeout
Definition: CloseHandWithTorques.h:55
armarx::control::njoint_controller::platform::platform_follower_controller::NameValueMap
std::map< std::string, float > NameValueMap
Definition: PlatformFollowerController.h:88
armarx::FindAndGraspObjectGroup::CloseHandWithTorques::onExit
void onExit() override
Virtual function, in which the behaviour of state is defined, when it is exited. Can be overridden,...
Definition: CloseHandWithTorques.cpp:75
armarx::StateUtility::removeTimeoutEvent
void removeTimeoutEvent(const ActionEventIdentifier &id)
Definition: StateUtil.cpp:203
armarx::RobotStatechartContext::kinematicUnitPrx
KinematicUnitInterfacePrx kinematicUnitPrx
Definition: RobotStatechartContext.h:112
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:27