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
26#include <mutex>
27
30
31#include <RobotAPI/interface/units/HeadIKUnit.h>
32#include <RobotAPI/interface/visualization/DebugDrawerInterface.h>
35
36namespace armarx
37{
38 /**
39 * \class HeadIKUnitPropertyDefinitions
40 * \brief
41 */
43 {
44 public:
46 {
47 defineRequiredProperty<std::string>("KinematicUnitName",
48 "Name of the KinematicUnit Proxy");
50 "HeadIKUnitTopicName", "HeadIKUnitTopic", "Name of the HeadIKUnit Topic");
52 "RobotStateComponentName",
53 "RobotStateComponent",
54 "Name of the RobotStateComponent that should be used");
55 defineOptionalProperty<bool>("VisualizeIKTarget",
56 true,
57 "Visualize the current IK target using the debug drawer");
58 defineOptionalProperty<int>("CycleTime", 30, "Cycle time of the tcp control in ms");
59 }
60 };
61
62 /**
63 * \defgroup Component-HeadIKUnit HeadIKUnit
64 * \ingroup RobotAPI-SensorActorUnits
65 * \brief Unit for controlling a robot head via IK targets.
66 */
67
68 /**
69 * @ingroup Component-HeadIKUnit
70 * @brief The HeadIKUnit class
71 */
72 class HeadIKUnit : virtual public Component, virtual public HeadIKUnitInterface
73 {
74 public:
75 HeadIKUnit();
76 void onInitComponent() override;
77 void onConnectComponent() override;
78 void onDisconnectComponent() override;
79 void onExitComponent() override;
80
81 std::string
82 getDefaultName() const override
83 {
84 return "HeadIKUnit";
85 }
86
87 // HeadIKUnitInterface interface
88 void setCycleTime(Ice::Int milliseconds,
89 const Ice::Current& c = Ice::emptyCurrent) override;
90 void setHeadTarget(const std::string& robotNodeSetName,
91 const FramedPositionBasePtr& targetPosition,
92 const Ice::Current& c = Ice::emptyCurrent) override;
93
94 // UnitExecutionManagementInterface interface
95 void init(const Ice::Current& c = Ice::emptyCurrent) override;
96 void start(const Ice::Current& c = Ice::emptyCurrent) override;
97 void stop(const Ice::Current& c = Ice::emptyCurrent) override;
98 UnitExecutionState getExecutionState(const Ice::Current& c = Ice::emptyCurrent) override;
99
100 // UnitResourceManagementInterface interface
101 void request(const Ice::Current& c = Ice::emptyCurrent) override;
102 void release(const Ice::Current& c = Ice::emptyCurrent) override;
103
104 // PropertyUser interface
106
107
108 private:
109 void periodicExec();
110
111 std::mutex accessMutex;
112 bool requested;
113 int cycleTime;
115
116 RobotStateComponentInterfacePrx robotStateComponentPrx;
117 KinematicUnitInterfacePrx kinematicUnitPrx;
118 //SharedRobotInterfacePrx remoteRobotPrx;
119 VirtualRobot::RobotPtr localRobot;
121
122 Ice::StringSeq robotNodeSetNames;
123 FramedPositionPtr targetPosition;
124 bool newTargetSet;
125
126 armarx::HeadIKUnitListenerPrx headIKUnitListener;
127 };
128
129} // namespace armarx
constexpr T c
ComponentPropertyDefinitions(std::string prefix, bool hasObjectNameParameter=true)
Definition Component.cpp:46
Component()
Protected default constructor. Used for virtual inheritance. Use createManagedIceObject() instead.
Definition Component.cpp:66
HeadIKUnitPropertyDefinitions(std::string prefix)
Definition HeadIKUnit.h:45
void onInitComponent() override
Pure virtual hook for the subclass.
void start(const Ice::Current &c=Ice::emptyCurrent) override
void release(const Ice::Current &c=Ice::emptyCurrent) override
UnitExecutionState getExecutionState(const Ice::Current &c=Ice::emptyCurrent) override
void onDisconnectComponent() override
Hook for subclass.
void init(const Ice::Current &c=Ice::emptyCurrent) override
void setCycleTime(Ice::Int milliseconds, const Ice::Current &c=Ice::emptyCurrent) override
void stop(const Ice::Current &c=Ice::emptyCurrent) override
void setHeadTarget(const std::string &robotNodeSetName, const FramedPositionBasePtr &targetPosition, const Ice::Current &c=Ice::emptyCurrent) override
void onConnectComponent() override
Pure virtual hook for the subclass.
void request(const Ice::Current &c=Ice::emptyCurrent) override
PropertyDefinitionsPtr createPropertyDefinitions() override
void onExitComponent() override
Hook for subclass.
std::string getDefaultName() const override
Retrieve default name of component.
Definition HeadIKUnit.h:82
IceUtil::Handle< PeriodicTask< T > > pointer_type
Shared pointer type for convenience.
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
This file offers overloads of toIce() and fromIce() functions for STL container types.
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.
IceInternal::Handle< FramedPosition > FramedPositionPtr
Definition FramedPose.h:149
::IceInternal::ProxyHandle<::IceProxy::armarx::RobotStateComponentInterface > RobotStateComponentInterfacePrx
::IceInternal::ProxyHandle<::IceProxy::armarx::DebugDrawerInterface > DebugDrawerInterfacePrx