Preshape.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 "Preshape.h"
26
27using namespace armarx;
28using namespace FindAndGraspObjectGroup;
29
30// DO NOT EDIT NEXT LINE
32
36
37void
39{
40 ARMARX_VERBOSE << "Entering Preshape::onEnter()";
41
44 SingleTypeVariantListPtr jointAnglesPreshapeList =
45 getInput<SingleTypeVariantList>("jointAnglesPreshape");
46 NameValueMap jointNamesAndValues;
47
48 if (jointNames->getSize() == jointAnglesPreshapeList->getSize())
49 {
50 for (int j = 0; j < jointNames->getSize(); j++)
51 {
52 jointNamesAndValues[jointNames->getVariant(j)->getString()] =
53 jointAnglesPreshapeList->getVariant(j)->getFloat();
54 }
55 }
56 else
57 {
58 throw LocalException("Preshape: List lengths do not match!");
59 }
60
61 rsContext->kinematicUnitPrx->setJointAngles(jointNamesAndValues);
62
63 ARMARX_DEBUG << "Installing preshape timeout condition";
64 float timeoutPreshape = getInput<float>("timeoutPreshape");
65
66 bool useTorquesForGrasping = getInput<bool>("useTorquesForGrasping");
67
68 if (useTorquesForGrasping)
69 {
72 }
73 else
74 {
77 }
78
79 ARMARX_VERBOSE << "Done Preshape::onEnter()";
80}
81
82void
84{
86 ARMARX_VERBOSE << "Done Preshape::onExit()";
87}
88
89// DO NOT EDIT NEXT FUNCTION
90std::string
92{
93 return "Preshape";
94}
95
96// DO NOT EDIT NEXT FUNCTION
ActionEventIdentifier condPreshapeTimeout
Definition Preshape.h:54
Preshape(XMLStateConstructorParams stateData)
Definition Preshape.cpp:33
void onEnter() override
Virtual function, in which the behaviour of state is defined, when it is entered. Can be overridden,...
Definition Preshape.cpp:38
void onExit() override
Virtual function, in which the behaviour of state is defined, when it is exited. Can be overridden,...
Definition Preshape.cpp:83
static SubClassRegistry Registry
Definition Preshape.h:49
static XMLStateFactoryBasePtr CreateInstance(XMLStateConstructorParams stateData)
Definition Preshape.cpp:98
KinematicUnitInterfacePrx kinematicUnitPrx
ContextType * getContext() const
Definition StateBase.h:71
void removeTimeoutEvent(const ActionEventIdentifier &id)
ActionEventIdentifier setTimeoutEvent(int timeoutDurationMs, const EventPtr &evt)
Utility function to start a timer on the systemObserver and register an event on the conditionHandler...
EventPtr createEvent()
Utility function to create a new Event.
Definition StateUtil.h:63
std::enable_if_t< std::is_base_of_v< VariantDataClass, T >, IceInternal::Handle< T > > getInput(const std::string &key) const
getInput can be used to access a specific input parameter.
Definition State.h:620
XMLStateTemplate(const XMLStateConstructorParams &params)
Definition XMLState.h:149
#define ARMARX_DEBUG
The logging level for output that is only interesting while debugging.
Definition Logging.h:184
#define ARMARX_VERBOSE
The logging level for verbose information.
Definition Logging.h:187
This file offers overloads of toIce() and fromIce() functions for STL container types.
IceInternal::Handle< SingleTypeVariantList > SingleTypeVariantListPtr
IceInternal::Handle< XMLStateFactoryBase > XMLStateFactoryBasePtr
Definition XMLState.h:64