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