HeadIKUnit.h
Go to the documentation of this file.
1 /*
2 * This file is part of ArmarX.
3 *
4 * ArmarX is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
8 * ArmarX is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * @package ArmarX::
17 * @author David Schiebener ( schiebener at kit dot edu)
18 * @date 2014
19 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20 * GNU General Public License
21 */
22 
23 #pragma once
24 
25 
28 #include <RobotAPI/interface/visualization/DebugDrawerInterface.h>
31 
32 #include <RobotAPI/interface/units/HeadIKUnit.h>
33 
34 #include <mutex>
35 
36 
37 namespace armarx
38 {
39  /**
40  * \class HeadIKUnitPropertyDefinitions
41  * \brief
42  */
45  {
46  public:
49  {
50  defineRequiredProperty<std::string>("KinematicUnitName", "Name of the KinematicUnit Proxy");
51  defineOptionalProperty<std::string>("HeadIKUnitTopicName", "HeadIKUnitTopic", "Name of the HeadIKUnit Topic");
52  defineOptionalProperty<std::string>("RobotStateComponentName", "RobotStateComponent", "Name of the RobotStateComponent that should be used");
53  defineOptionalProperty<bool>("VisualizeIKTarget", true, "Visualize the current IK target using the debug drawer");
54  defineOptionalProperty<int>("CycleTime", 30, "Cycle time of the tcp control in ms");
55  }
56  };
57 
58  /**
59  * \defgroup Component-HeadIKUnit HeadIKUnit
60  * \ingroup RobotAPI-SensorActorUnits
61  * \brief Unit for controlling a robot head via IK targets.
62  */
63 
64  /**
65  * @ingroup Component-HeadIKUnit
66  * @brief The HeadIKUnit class
67  */
68  class HeadIKUnit : virtual public Component, virtual public HeadIKUnitInterface
69  {
70  public:
71  HeadIKUnit();
72  void onInitComponent() override;
73  void onConnectComponent() override;
74  void onDisconnectComponent() override;
75  void onExitComponent() override;
76  std::string getDefaultName() const override
77  {
78  return "HeadIKUnit";
79  }
80 
81  // HeadIKUnitInterface interface
82  void setCycleTime(Ice::Int milliseconds, const Ice::Current& c = Ice::emptyCurrent) override;
83  void setHeadTarget(const std::string& robotNodeSetName, const FramedPositionBasePtr& targetPosition, const Ice::Current& c = Ice::emptyCurrent) override;
84 
85  // UnitExecutionManagementInterface interface
86  void init(const Ice::Current& c = Ice::emptyCurrent) override;
87  void start(const Ice::Current& c = Ice::emptyCurrent) override;
88  void stop(const Ice::Current& c = Ice::emptyCurrent) override;
89  UnitExecutionState getExecutionState(const Ice::Current& c = Ice::emptyCurrent) override;
90 
91  // UnitResourceManagementInterface interface
92  void request(const Ice::Current& c = Ice::emptyCurrent) override;
93  void release(const Ice::Current& c = Ice::emptyCurrent) override;
94 
95  // PropertyUser interface
97 
98 
99  private:
100  void periodicExec();
101 
102  std::mutex accessMutex;
103  bool requested;
104  int cycleTime;
106 
107  RobotStateComponentInterfacePrx robotStateComponentPrx;
108  KinematicUnitInterfacePrx kinematicUnitPrx;
109  //SharedRobotInterfacePrx remoteRobotPrx;
110  VirtualRobot::RobotPtr localRobot;
112 
113  Ice::StringSeq robotNodeSetNames;
114  FramedPositionPtr targetPosition;
115  bool newTargetSet;
116 
117  armarx::HeadIKUnitListenerPrx headIKUnitListener;
118  };
119 
120 }
121 
122 
RemoteRobot.h
armarx::HeadIKUnit::onDisconnectComponent
void onDisconnectComponent() override
Hook for subclass.
Definition: HeadIKUnit.cpp:101
armarx::HeadIKUnit::request
void request(const Ice::Current &c=Ice::emptyCurrent) override
Definition: HeadIKUnit.cpp:208
armarx::HeadIKUnit::release
void release(const Ice::Current &c=Ice::emptyCurrent) override
Definition: HeadIKUnit.cpp:228
armarx::PropertyDefinitionContainer::prefix
std::string prefix
Prefix of the properties such as namespace, domain, component name, etc.
Definition: PropertyDefinitionContainer.h:333
armarx::HeadIKUnit::HeadIKUnit
HeadIKUnit()
Definition: HeadIKUnit.cpp:41
PeriodicTask.h
c
constexpr T c
Definition: UnscentedKalmanFilterTest.cpp:43
armarx::HeadIKUnit::onExitComponent
void onExitComponent() override
Hook for subclass.
Definition: HeadIKUnit.cpp:120
armarx::HeadIKUnitPropertyDefinitions::HeadIKUnitPropertyDefinitions
HeadIKUnitPropertyDefinitions(std::string prefix)
Definition: HeadIKUnit.h:47
armarx::HeadIKUnit::setHeadTarget
void setHeadTarget(const std::string &robotNodeSetName, const FramedPositionBasePtr &targetPosition, const Ice::Current &c=Ice::emptyCurrent) override
Definition: HeadIKUnit.cpp:139
armarx::HeadIKUnit::onConnectComponent
void onConnectComponent() override
Pure virtual hook for the subclass.
Definition: HeadIKUnit.cpp:65
armarx::HeadIKUnit::stop
void stop(const Ice::Current &c=Ice::emptyCurrent) override
Definition: HeadIKUnit.cpp:181
IceInternal::Handle< FramedPosition >
armarx::HeadIKUnit::getDefaultName
std::string getDefaultName() const override
Retrieve default name of component.
Definition: HeadIKUnit.h:76
FramedPose.h
armarx::HeadIKUnitPropertyDefinitions
Definition: HeadIKUnit.h:43
armarx::HeadIKUnit::init
void init(const Ice::Current &c=Ice::emptyCurrent) override
Definition: HeadIKUnit.cpp:173
armarx::HeadIKUnit::setCycleTime
void setCycleTime(Ice::Int milliseconds, const Ice::Current &c=Ice::emptyCurrent) override
Definition: HeadIKUnit.cpp:126
Component.h
armarx::Component
Baseclass for all ArmarX ManagedIceObjects requiring properties.
Definition: Component.h:95
armarx::HeadIKUnit::getExecutionState
UnitExecutionState getExecutionState(const Ice::Current &c=Ice::emptyCurrent) override
Definition: HeadIKUnit.cpp:185
armarx::HeadIKUnit
The HeadIKUnit class.
Definition: HeadIKUnit.h:68
armarx::ComponentPropertyDefinitions
Default component property definition container.
Definition: Component.h:70
IceUtil::Handle
Definition: forward_declarations.h:29
IceInternal::ProxyHandle<::IceProxy::armarx::RobotStateComponentInterface >
armarx::VariantType::Int
const VariantTypeId Int
Definition: Variant.h:916
armarx::HeadIKUnit::start
void start(const Ice::Current &c=Ice::emptyCurrent) override
Definition: HeadIKUnit.cpp:177
armarx::HeadIKUnit::createPropertyDefinitions
PropertyDefinitionsPtr createPropertyDefinitions() override
Definition: HeadIKUnit.cpp:415
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
VirtualRobot::RobotPtr
std::shared_ptr< class Robot > RobotPtr
Definition: Bus.h:18
armarx::HeadIKUnit::onInitComponent
void onInitComponent() override
Pure virtual hook for the subclass.
Definition: HeadIKUnit.cpp:50