CloseHandWithJointAngles.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 
26 
27 using namespace armarx;
28 using namespace FindAndGraspObjectGroup;
29 
30 // DO NOT EDIT NEXT LINE
32 
33 
34 
37 {
38 }
39 
41 {
42  ARMARX_VERBOSE << "Entering CloseHandWithJointAngles::onEnter()";
43 
44  RobotStatechartContext* rsContext = getContext<RobotStatechartContext>();
45  SingleTypeVariantListPtr jointNames = getInput<SingleTypeVariantList>("jointNames");
46  SingleTypeVariantListPtr jointAnglesGraspList = getInput<SingleTypeVariantList>("jointAnglesGrasp");
47  NameValueMap jointNamesAndValues;
48  NameControlModeMap controlModes;
49 
50  if (jointNames->getSize() == jointAnglesGraspList->getSize())
51  {
52  for (int j = 0; j < jointNames->getSize(); j++)
53  {
54  jointNamesAndValues[jointNames->getVariant(j)->getString()] = jointAnglesGraspList->getVariant(j)->getFloat();
55  controlModes[jointNames->getVariant(j)->getString()] = ePositionControl;
56  }
57  }
58  else
59  {
60  throw LocalException("stateCloseHandWithJointAngles: List lengths do not match!");
61  }
62 
63  rsContext->kinematicUnitPrx->switchControlMode(controlModes);
64  rsContext->kinematicUnitPrx->setJointAngles(jointNamesAndValues);
65 
66  ARMARX_LOG << eINFO << "Installing timeoutGrasp condition";
67  float timeoutGrasp = getInput<float>("timeoutGrasp");
68  condGraspWithJointAnglesTimeout = setTimeoutEvent(timeoutGrasp, createEvent<EvGraspWithJointAnglesTimeout>());
69 
70  ARMARX_VERBOSE << "Done CloseHandWithJointAngles::onEnter()";
71 }
72 
74 {
76 }
77 
78 // DO NOT EDIT NEXT FUNCTION
80 {
81  return "CloseHandWithJointAngles";
82 }
83 
84 // DO NOT EDIT NEXT FUNCTION
86 {
87  return XMLStateFactoryBasePtr(new CloseHandWithJointAngles(stateData));
88 }
89 
ARMARX_VERBOSE
#define ARMARX_VERBOSE
Definition: Logging.h:180
armarx::FindAndGraspObjectGroup::CloseHandWithJointAngles::CreateInstance
static XMLStateFactoryBasePtr CreateInstance(XMLStateConstructorParams stateData)
Definition: CloseHandWithJointAngles.cpp:85
armarx::XMLStateConstructorParams
Definition: XMLState.h:50
armarx::FindAndGraspObjectGroup::CloseHandWithJointAngles::onExit
void onExit() override
Virtual function, in which the behaviour of state is defined, when it is exited. Can be overridden,...
Definition: CloseHandWithJointAngles.cpp:73
CloseHandWithJointAngles.h
IceInternal::Handle< SingleTypeVariantList >
armarx::RobotStatechartContext
Definition: RobotStatechartContext.h:66
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:144
armarx::XMLStateTemplate
Class for legacy to stay compatible with old statecharts.
Definition: XMLState.h:137
ARMARX_LOG
#define ARMARX_LOG
Definition: Logging.h:163
armarx::FindAndGraspObjectGroup::CloseHandWithJointAngles::CloseHandWithJointAngles
CloseHandWithJointAngles(XMLStateConstructorParams stateData)
Definition: CloseHandWithJointAngles.cpp:35
armarx::XMLStateFactoryBasePtr
IceInternal::Handle< XMLStateFactoryBase > XMLStateFactoryBasePtr
Definition: XMLState.h:65
armarx::control::njoint_controller::platform::platform_follower_controller::NameValueMap
std::map< std::string, float > NameValueMap
Definition: PlatformFollowerController.h:91
armarx::FindAndGraspObjectGroup::CloseHandWithJointAngles::condGraspWithJointAnglesTimeout
ActionEventIdentifier condGraspWithJointAnglesTimeout
Definition: CloseHandWithJointAngles.h:53
armarx::FindAndGraspObjectGroup::CloseHandWithJointAngles
Definition: CloseHandWithJointAngles.h:34
armarx::FindAndGraspObjectGroup::CloseHandWithJointAngles::onEnter
void onEnter() override
Virtual function, in which the behaviour of state is defined, when it is entered. Can be overridden,...
Definition: CloseHandWithJointAngles.cpp:40
armarx::FindAndGraspObjectGroup::CloseHandWithJointAngles::GetName
static std::string GetName()
Definition: CloseHandWithJointAngles.cpp:79
armarx::FindAndGraspObjectGroup::CloseHandWithJointAngles::Registry
static SubClassRegistry Registry
Definition: CloseHandWithJointAngles.h:48
armarx::StateUtility::removeTimeoutEvent
void removeTimeoutEvent(const ActionEventIdentifier &id)
Definition: StateUtil.cpp:178
armarx::RobotStatechartContext::kinematicUnitPrx
KinematicUnitInterfacePrx kinematicUnitPrx
Definition: RobotStatechartContext.h:97
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28