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