MoveToPregraspArmConfig.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::GraspObjectGroup
19  * @author David ( david dot schiebener at kit dot edu )
20  * @date 2015
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 GraspObjectGroup;
29 
30 // DO NOT EDIT NEXT LINE
31 MoveToPregraspArmConfig::SubClassRegistry
32  MoveToPregraspArmConfig::Registry(MoveToPregraspArmConfig::GetName(),
34 
37  MoveToPregraspArmConfigGeneratedBase<MoveToPregraspArmConfig>(stateData)
38 {
39 }
40 
41 void
43 {
44  std::string handName = in.getHandNameInMemory();
45  std::string locationName = in.getLocationName();
46 
47  // decide for left or right hand
48  bool useRightHand;
49  if (handName.find("left") != std::string::npos || handName.find("Left") != std::string::npos)
50  {
51  useRightHand = false;
52  }
53  else if (handName.find("right") != std::string::npos ||
54  handName.find("Right") != std::string::npos)
55  {
56  useRightHand = true;
57  }
58  else if (handName.find("l") != std::string::npos || handName.find("L") != std::string::npos)
59  {
60  useRightHand = false;
61  }
62  else
63  {
64  useRightHand = true;
65  }
66 
67  // check if it is a special location
68  if (locationName.find("fridge") != std::string::npos ||
69  locationName.find("Fridge") != std::string::npos)
70  {
71  if (useRightHand)
72  {
73  local.setPregraspConfig(in.getPregraspConfigFridgeRight());
74  }
75  else
76  {
77  ARMARX_ERROR << "cannot grasp from fridge with left hand";
78  }
79  }
80  else
81  {
82  if (useRightHand)
83  {
84  local.setPregraspConfig(in.getPregraspConfigDefaultRight());
85  }
86  else
87  {
88  local.setPregraspConfig(in.getPregraspConfigDefaultLeft());
89  }
90  }
91 }
92 
93 void
95 {
96  // put your user code for the execution-phase here
97  // runs in seperate thread, thus can do complex operations
98  // should check constantly whether isRunningTaskStopped() returns true
99 
100  // uncomment this if you need a continous run function. Make sure to use sleep or use blocking wait to reduce cpu load.
101  // while (!isRunningTaskStopped()) // stop run function if returning true
102  // {
103  // // do your calculations
104  // }
105 }
106 
107 void
109 {
110  // put your user code for the breaking point here
111  // execution time should be short (<100ms)
112 }
113 
114 void
116 {
117  // put your user code for the exit point here
118  // execution time should be short (<100ms)
119 }
120 
121 // DO NOT EDIT NEXT FUNCTION
124 {
125  return XMLStateFactoryBasePtr(new MoveToPregraspArmConfig(stateData));
126 }
armarx::XMLStateConstructorParams
Definition: XMLState.h:49
armarx::GraspObjectGroup::MoveToPregraspArmConfig::CreateInstance
static XMLStateFactoryBasePtr CreateInstance(XMLStateConstructorParams stateData)
Definition: MoveToPregraspArmConfig.cpp:123
armarx::GraspObjectGroup::MoveToPregraspArmConfig::run
void run() override
Definition: MoveToPregraspArmConfig.cpp:94
armarx::GraspObjectGroup::MoveToPregraspArmConfig::onBreak
void onBreak() override
Definition: MoveToPregraspArmConfig.cpp:108
armarx::GraspObjectGroup::MoveToPregraspArmConfig::MoveToPregraspArmConfig
MoveToPregraspArmConfig(const XMLStateConstructorParams &stateData)
Definition: MoveToPregraspArmConfig.cpp:35
armarx::XMLStateFactoryBasePtr
IceInternal::Handle< XMLStateFactoryBase > XMLStateFactoryBasePtr
Definition: XMLState.h:64
IceInternal::Handle
Definition: forward_declarations.h:8
armarx::XMLStateTemplate
Class for legacy to stay compatible with old statecharts.
Definition: XMLState.h:146
MoveToPregraspArmConfig.h
armarx::GraspObjectGroup::MoveToPregraspArmConfig::onExit
void onExit() override
Definition: MoveToPregraspArmConfig.cpp:115
armarx::GraspObjectGroup::MoveToPregraspArmConfig::onEnter
void onEnter() override
Definition: MoveToPregraspArmConfig.cpp:42
ARMARX_ERROR
#define ARMARX_ERROR
Definition: Logging.h:196
armarx::GraspObjectGroup::MoveToPregraspArmConfig::Registry
static SubClassRegistry Registry
Definition: MoveToPregraspArmConfig.h:45
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:27
armarx::GraspObjectGroup::MoveToPregraspArmConfig
Definition: MoveToPregraspArmConfig.h:31