HandGroupStatechartContext.h
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::HandGroup
19  * @author Simon Ottenhaus ( simon dot ottenhaus at 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 
26 #pragma once
27 
31 
34 
36 
37 // Custom Includes
38 //#include <RobotAPI/interface/units/KinematicUnitInterface.h>
39 //#include <RobotAPI/interface/units/TCPControlUnit.h>
40 //#include <RobotAPI/interface/observers/KinematicUnitObserverInterface.h>
41 #include <VirtualRobot/VirtualRobot.h>
42 
43 #include <RobotAPI/interface/core/RobotState.h>
44 
45 namespace armarx::HandGroup
46 {
47 
49  {
52  {
53  // defineRequiredProperty<std::string>("KinematicUnitName", "Name of the kinematic unit that should be used");
54  // defineRequiredProperty<std::string>("KinematicUnitObserverName", "Name of the kinematic unit observer that should be used");
55  defineOptionalProperty<std::string>(
56  "RobotStateComponentName",
57  "RobotStateComponent",
58  "Name of the robot state component that should be used");
59  // defineOptionalProperty<std::string>("TCPControlUnitName", "TCPControlUnit", "Name of the tcp control unit component that should be used");
60  defineRequiredProperty<std::string>("HandUnitNames",
61  "Comma separated list of hand unit to use");
62  }
63  };
64 
65  /**
66  * @class HandGroupStatechartContext is a custom implementation of the StatechartContext
67  * for a statechart
68  */
70  virtual public XMLStatechartContext
71  {
72  public:
73  // inherited from Component
74  std::string
75  getDefaultName() const override
76  {
77  return "HandGroupStatechartContext";
78  }
79 
80  void onInitStatechartContext() override;
81  void onConnectStatechartContext() override;
82 
85  {
86  return remoteRobot;
87  }
88 
91  {
92  return robotStateComponent;
93  }
94 
95  // KinematicUnitInterfacePrx getKinematicUnit() { return kinematicUnitPrx; }
96  // std::string getKinematicUnitObserverName() { return getProperty<std::string>("KinematicUnitObserverName").getValue(); }
97  // TCPControlUnitInterfacePrx getTCPControlUnit() { return tcpControlPrx;}
98 
99  const HandUnitInterfacePrx
100  getHandUnit(const std::string& handName)
101  {
102  std::stringstream handUnitNamesSS;
103 
104  for (std::pair<std::string, HandUnitInterfacePrx> pair : handUnits)
105  {
106  if (pair.first == handName)
107  {
108  return pair.second;
109  }
110 
111  handUnitNamesSS << pair.first << "; ";
112  }
113 
114  throw LocalException("Could not find HandUnit Proxy for hand name '" + handName +
115  "'. Available Hand Units: " + handUnitNamesSS.str());
116  }
117 
118  private:
119  /**
120  * @see PropertyUser::createPropertyDefinitions()
121  */
122  PropertyDefinitionsPtr createPropertyDefinitions() override;
123 
124 
125  RobotStateComponentInterfacePrx robotStateComponent;
126  // KinematicUnitInterfacePrx kinematicUnitPrx;
127  // KinematicUnitObserverInterfacePrx kinematicUnitObserverPrx;
128  // TCPControlUnitInterfacePrx tcpControlPrx;
129  VirtualRobot::RobotPtr remoteRobot;
130  std::map<std::string, HandUnitInterfacePrx> handUnits;
131  std::vector<std::string> handUnitNames;
132  };
133 
134 } // namespace armarx::HandGroup
armarx::XMLStatechartContext
Definition: StatechartContext.h:208
armarx::HandGroup::HandGroupStatechartContext
Definition: HandGroupStatechartContext.h:69
armarx::PropertyDefinitionContainer::prefix
std::string prefix
Prefix of the properties such as namespace, domain, component name, etc.
Definition: PropertyDefinitionContainer.h:345
armarx::HandGroup::HandGroupStatechartContext::getRobot
const VirtualRobot::RobotPtr getRobot()
Definition: HandGroupStatechartContext.h:84
RobotAPIObjectFactories.h
StatechartContext.h
armarx::HandGroup::HandGroupStatechartContext::getRobotStateComponent
RobotStateComponentInterfacePrx getRobotStateComponent()
Definition: HandGroupStatechartContext.h:90
armarx::HandGroup::HandGroupStatechartContextProperties::HandGroupStatechartContextProperties
HandGroupStatechartContextProperties(std::string prefix)
Definition: HandGroupStatechartContext.h:50
ARMARXCOMPONENT_IMPORT_EXPORT
#define ARMARXCOMPONENT_IMPORT_EXPORT
Definition: ImportExportComponent.h:38
HandUnit.h
armarx::HandGroup::HandGroupStatechartContext::getDefaultName
std::string getDefaultName() const override
Retrieve default name of component.
Definition: HandGroupStatechartContext.h:75
MemoryXCoreObjectFactories.h
Component.h
IceUtil::Handle< class PropertyDefinitionContainer >
armarx::HandGroup::HandGroupStatechartContextProperties
Definition: HandGroupStatechartContext.h:48
IceInternal::ProxyHandle<::IceProxy::armarx::RobotStateComponentInterface >
armarx::StatechartContextPropertyDefinitions
The StatechartContextPropertyDefinitions class contains properties associated with all statecharts.
Definition: StatechartContext.h:56
armarx::HandGroup::HandGroupStatechartContext::getHandUnit
const HandUnitInterfacePrx getHandUnit(const std::string &handName)
Definition: HandGroupStatechartContext.h:100
VirtualRobot::RobotPtr
std::shared_ptr< class Robot > RobotPtr
Definition: Bus.h:19
armarx::HandGroup
Definition: CloseHand.h:29
ImportExportComponent.h