KinematicSelfLocalization.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 ArmarXSimulation::ArmarXObjects::KinematicSelfLocalization
17  * @author Mirko Waechter ( mirko dot waechter at kit dot edu )
18  * @date 2016
19  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20  * GNU General Public License
21  */
22 
23 #pragma once
24 
27 #include <RobotAPI/interface/core/RobotLocalization.h>
28 #include <RobotAPI/interface/core/RobotState.h>
29 
30 // MemoryX
33 #include <MemoryX/interface/components/WorkingMemoryInterface.h>
34 
35 // Simulator
36 #include <ArmarXSimulation/interface/simulator/SimulatorInterface.h>
37 
38 #include <VirtualRobot/VirtualRobot.h>
39 
40 #include <mutex>
41 
42 namespace armarx
43 {
44  /**
45  * @class KinematicSelfLocalizationPropertyDefinitions
46  * @brief
47  */
50  {
51  public:
54  {
55  defineOptionalProperty<std::string>("PlatformTopicName", "PlatformState", "Name of the platform report topic");
56  defineRequiredProperty<std::string>("RobotName", "Name of the robot in the simulator (as specified in the robot's xml file)");
57  defineOptionalProperty<std::string>("AgentName", "Name of the agent instance. If empty, RobotName property is used");
58  defineOptionalProperty<std::string>("RobotStateComponentName", "RobotStateComponent", "Name of the RobotStateComponent that should be used");
59  defineOptionalProperty<std::string>("WorkingMemoryName", "WorkingMemory", "Name of the WorkingMemory that should be used");
60  defineOptionalProperty<float>("RobotPoseZ", 0, "Set the z component of the robot pose to a fixed value");
61  defineOptionalProperty<float>("InitialPlatformPoseX", 0, "Set the x component of the initial platform pose");
62  defineOptionalProperty<float>("InitialPlatformPoseY", 0, "Set the y component of the initial platform pose");
63  defineOptionalProperty<float>("InitialPlatformPoseAngle", 0, "Set the angle component of the initial platform pose");
64  }
65  };
66 
67  /**
68  * @defgroup Component-KinematicSelfLocalization KinematicSelfLocalization
69  * @ingroup ArmarXSimulation-Components
70  * A description of the component KinematicSelfLocalization.
71  *
72  * @class KinematicSelfLocalization
73  * @ingroup Component-KinematicSelfLocalization
74  * @brief Brief description of class KinematicSelfLocalization.
75  *
76  * Detailed description of class KinematicSelfLocalization.
77  */
79  virtual public armarx::Component,
80  public GlobalRobotPoseLocalizationListener
81  {
82  public:
83  /**
84  * @see armarx::ManagedIceObject::getDefaultName()
85  */
86  std::string getDefaultName() const override
87  {
88  return "KinematicSelfLocalization";
89  }
90 
91  protected:
92  /**
93  * @see armarx::ManagedIceObject::onInitComponent()
94  */
95  void onInitComponent() override;
96 
97  /**
98  * @see armarx::ManagedIceObject::onConnectComponent()
99  */
100  void onConnectComponent() override;
101 
102  /**
103  * @see armarx::ManagedIceObject::onDisconnectComponent()
104  */
105  void onDisconnectComponent() override;
106 
107  /**
108  * @see armarx::ManagedIceObject::onExitComponent()
109  */
110  void onExitComponent() override;
111 
112  /**
113  * @see PropertyUser::createPropertyDefinitions()
114  */
116  protected:
117  void periodicExec();
118 
119  void reportRobotPose();
121 
125 
126  memoryx::WorkingMemoryInterfacePrx memoryPrx;
127  memoryx::AgentInstancesSegmentBasePrx agentsMemoryPrx;
129 
130  std::string robotAgentId;
131  std::string robotName;
132 
133  std::mutex dataMutex;
134 
135  float robotPoseZ;
136 
137  public:
138  void reportGlobalRobotPose(const ::armarx::TransformStamped&, const ::Ice::Current& = ::Ice::emptyCurrent) override;
139  };
140 }
armarx::KinematicSelfLocalization::dataMutex
std::mutex dataMutex
Definition: KinematicSelfLocalization.h:133
armarx::KinematicSelfLocalizationPropertyDefinitions
Definition: KinematicSelfLocalization.h:48
armarx::KinematicSelfLocalization
Brief description of class KinematicSelfLocalization.
Definition: KinematicSelfLocalization.h:78
armarx::KinematicSelfLocalization::reportGlobalRobotPose
void reportGlobalRobotPose(const ::armarx::TransformStamped &, const ::Ice::Current &=::Ice::emptyCurrent) override
Definition: KinematicSelfLocalization.cpp:142
armarx::PropertyDefinitionContainer::prefix
std::string prefix
Prefix of the properties such as namespace, domain, component name, etc.
Definition: PropertyDefinitionContainer.h:333
PeriodicTask.h
armarx::KinematicSelfLocalization::onInitComponent
void onInitComponent() override
Definition: KinematicSelfLocalization.cpp:34
armarx::KinematicSelfLocalization::robotName
std::string robotName
Definition: KinematicSelfLocalization.h:131
armarx::KinematicSelfLocalization::robotStateComponentPrx
RobotStateComponentInterfacePrx robotStateComponentPrx
Definition: KinematicSelfLocalization.h:124
armarx::KinematicSelfLocalization::robotAgentId
std::string robotAgentId
Definition: KinematicSelfLocalization.h:130
armarx::KinematicSelfLocalization::onDisconnectComponent
void onDisconnectComponent() override
Definition: KinematicSelfLocalization.cpp:100
IceInternal::Handle< FramedPose >
armarx::KinematicSelfLocalization::robotAgent
memoryx::AgentInstancePtr robotAgent
Definition: KinematicSelfLocalization.h:128
armarx::KinematicSelfLocalization::periodicExec
void periodicExec()
armarx::KinematicSelfLocalization::getDefaultName
std::string getDefaultName() const override
Definition: KinematicSelfLocalization.h:86
armarx::KinematicSelfLocalization::cycleTime
int cycleTime
Definition: KinematicSelfLocalization.h:122
armarx::KinematicSelfLocalization::onConnectComponent
void onConnectComponent() override
Definition: KinematicSelfLocalization.cpp:42
armarx::KinematicSelfLocalization::onExitComponent
void onExitComponent() override
Definition: KinematicSelfLocalization.cpp:105
armarx::KinematicSelfLocalization::execTask
PeriodicTask< KinematicSelfLocalization >::pointer_type execTask
Definition: KinematicSelfLocalization.h:120
armarx::KinematicSelfLocalization::agentsMemoryPrx
memoryx::AgentInstancesSegmentBasePrx agentsMemoryPrx
Definition: KinematicSelfLocalization.h:127
Component.h
armarx::Component
Baseclass for all ArmarX ManagedIceObjects requiring properties.
Definition: Component.h:95
armarx::ComponentPropertyDefinitions
Default component property definition container.
Definition: Component.h:70
Entity.h
IceUtil::Handle< class PropertyDefinitionContainer >
IceInternal::ProxyHandle<::IceProxy::armarx::RobotStateComponentInterface >
armarx::KinematicSelfLocalization::robotPoseZ
float robotPoseZ
Definition: KinematicSelfLocalization.h:135
armarx::KinematicSelfLocalization::reportRobotPose
void reportRobotPose()
Definition: KinematicSelfLocalization.cpp:116
AgentInstance.h
armarx::KinematicSelfLocalization::memoryPrx
memoryx::WorkingMemoryInterfacePrx memoryPrx
Definition: KinematicSelfLocalization.h:126
armarx::KinematicSelfLocalization::currentRobotPose
FramedPosePtr currentRobotPose
Definition: KinematicSelfLocalization.h:123
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
armarx::KinematicSelfLocalizationPropertyDefinitions::KinematicSelfLocalizationPropertyDefinitions
KinematicSelfLocalizationPropertyDefinitions(std::string prefix)
Definition: KinematicSelfLocalization.h:52
armarx::KinematicSelfLocalization::createPropertyDefinitions
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
Definition: KinematicSelfLocalization.cpp:110