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
45namespace 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");
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");
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
#define ARMARXCOMPONENT_IMPORT_EXPORT
custom implementation of the StatechartContext for a statechart
RobotStateComponentInterfacePrx getRobotStateComponent()
const HandUnitInterfacePrx getHandUnit(const std::string &handName)
std::string getDefaultName() const override
Retrieve default name of component.
std::string prefix
Prefix of the properties such as namespace, domain, component name, etc.
PropertyDefinition< PropertyType > & defineOptionalProperty(const std::string &name, PropertyType defaultValue, const std::string &description="", PropertyDefinitionBase::PropertyConstness constness=PropertyDefinitionBase::eConstant)
PropertyDefinition< PropertyType > & defineRequiredProperty(const std::string &name, const std::string &description="", PropertyDefinitionBase::PropertyConstness constness=PropertyDefinitionBase::eConstant)
std::shared_ptr< class Robot > RobotPtr
Definition Bus.h:19
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.
::IceInternal::ProxyHandle<::IceProxy::armarx::RobotStateComponentInterface > RobotStateComponentInterfacePrx