SimpleEpisodicMemory.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 MemoryX::ArmarXObjects::SimpleEpisodicMemory
17  * @author fabian.peller-konrad@kit.edu ( fabian dot peller-konrad at kit dot edu )
18  * @date 2020
19  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20  * GNU General Public License
21  */
22 
23 #pragma once
24 
25 // STD/STL
26 #include <memory>
27 #include <mutex>
28 #include <string>
29 #include <vector>
30 
31 // Ice
32 #include <Ice/Current.h>
33 #include <IceUtil/Time.h>
34 
35 // ArmarX
37 #include <MemoryX/interface/components/SimpleEpisodicMemoryInterface.h>
38 
39 
40 namespace memoryx
41 {
42 
44  virtual public armarx::Component,
45  virtual public SimpleEpisodicMemoryInterface
46  {
47  public:
48  std::string getDefaultName() const override;
49 
50  static const std::map<EpisodeStatus, std::string> episode_status_descriptor;
51  static const std::map<ActionStatus, std::string> action_status_descriptor;
52  static const std::map<ObjectPoseEventType, std::string> object_type_descriptor;
53 
54 
55  protected:
56 
57  void onInitComponent() override;
58 
59  void onConnectComponent() override;
60 
61  void onDisconnectComponent() override;
62 
63  void onExitComponent() override;
64 
66 
67  void registerEpisodeEvent(const EpisodeEvent&, const Ice::Current& = Ice::emptyCurrent) override;
68  void registerImageEvent(const ImageEvent&, const Ice::Current& = Ice::emptyCurrent) override;
69  void registerObjectPoseEvent(const ObjectPoseEvent&, const Ice::Current& = Ice::emptyCurrent) override;
70  void registerActionEvent(const ActionEvent&, const Ice::Current& = Ice::emptyCurrent) override;
71  void registerHumanPoseEvent(const Body25HumanPoseEvent&, const Ice::Current& = Ice::emptyCurrent) override;
72  void registerSpeechEvent(const SpeechEvent&, const Ice::Current& = Ice::emptyCurrent) override;
73  void registerKinematicUnitEvent(const KinematicUnitEvent&, const Ice::Current& = Ice::emptyCurrent) override;
74  void registerPlatformUnitEvent(const PlatformUnitEvent&, const Ice::Current& = Ice::emptyCurrent) override;
75  void registerPlatformUnitTargetEvent(const PlatformUnitTargetEvent&, const Ice::Current& = Ice::emptyCurrent) override;
76  void notifyKeyframe(const Ice::Current& = Ice::emptyCurrent) override;
77 
78 
79  private:
80  void export_episode() const;
81  void clearAll();
82 
83  static const std::string NO_EPISODE;
84 
85  bool m_enable_export;
86  std::string m_export_folder;
87 
88  Episode m_current_episode;
89 
90  std::mutex episodeEventMutex;
91  std::mutex imageEventMutex;
92  std::mutex objectPoseEventMutex;
93  std::mutex actionEventMutex;
94  std::mutex humanPoseEventMutex;
95  std::mutex speechEventMutex;
96  std::mutex kinematicUnitEventMutex;
97  std::mutex platformUnitEventMutex;
98  std::mutex platformUnitTargetEventMutex;
99 
100  };
101 }
memoryx::SimpleEpisodicMemory::registerObjectPoseEvent
void registerObjectPoseEvent(const ObjectPoseEvent &, const Ice::Current &=Ice::emptyCurrent) override
Definition: SimpleEpisodicMemory.cpp:425
memoryx::SimpleEpisodicMemory::createPropertyDefinitions
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
Definition: SimpleEpisodicMemory.cpp:490
memoryx::SimpleEpisodicMemory::onDisconnectComponent
void onDisconnectComponent() override
Hook for subclass.
Definition: SimpleEpisodicMemory.cpp:76
memoryx::SimpleEpisodicMemory::object_type_descriptor
static const std::map< ObjectPoseEventType, std::string > object_type_descriptor
Definition: SimpleEpisodicMemory.h:52
memoryx::SimpleEpisodicMemory::registerSpeechEvent
void registerSpeechEvent(const SpeechEvent &, const Ice::Current &=Ice::emptyCurrent) override
Definition: SimpleEpisodicMemory.cpp:446
memoryx::SimpleEpisodicMemory::action_status_descriptor
static const std::map< ActionStatus, std::string > action_status_descriptor
Definition: SimpleEpisodicMemory.h:51
memoryx
VirtualRobot headers.
Definition: CommonPlacesTester.cpp:48
memoryx::SimpleEpisodicMemory::onExitComponent
void onExitComponent() override
Hook for subclass.
Definition: SimpleEpisodicMemory.cpp:80
memoryx::SimpleEpisodicMemory::registerImageEvent
void registerImageEvent(const ImageEvent &, const Ice::Current &=Ice::emptyCurrent) override
Definition: SimpleEpisodicMemory.cpp:418
memoryx::SimpleEpisodicMemory
Definition: SimpleEpisodicMemory.h:43
memoryx::SimpleEpisodicMemory::onInitComponent
void onInitComponent() override
Pure virtual hook for the subclass.
Definition: SimpleEpisodicMemory.cpp:65
memoryx::SimpleEpisodicMemory::registerHumanPoseEvent
void registerHumanPoseEvent(const Body25HumanPoseEvent &, const Ice::Current &=Ice::emptyCurrent) override
Definition: SimpleEpisodicMemory.cpp:439
memoryx::SimpleEpisodicMemory::registerActionEvent
void registerActionEvent(const ActionEvent &, const Ice::Current &=Ice::emptyCurrent) override
Definition: SimpleEpisodicMemory.cpp:432
memoryx::SimpleEpisodicMemory::onConnectComponent
void onConnectComponent() override
Pure virtual hook for the subclass.
Definition: SimpleEpisodicMemory.cpp:71
memoryx::SimpleEpisodicMemory::episode_status_descriptor
static const std::map< EpisodeStatus, std::string > episode_status_descriptor
Definition: SimpleEpisodicMemory.h:50
memoryx::SimpleEpisodicMemory::registerEpisodeEvent
void registerEpisodeEvent(const EpisodeEvent &, const Ice::Current &=Ice::emptyCurrent) override
Definition: SimpleEpisodicMemory.cpp:371
Component.h
armarx::Component
Baseclass for all ArmarX ManagedIceObjects requiring properties.
Definition: Component.h:95
IceUtil::Handle< class PropertyDefinitionContainer >
memoryx::SimpleEpisodicMemory::registerKinematicUnitEvent
void registerKinematicUnitEvent(const KinematicUnitEvent &, const Ice::Current &=Ice::emptyCurrent) override
Definition: SimpleEpisodicMemory.cpp:464
memoryx::SimpleEpisodicMemory::registerPlatformUnitEvent
void registerPlatformUnitEvent(const PlatformUnitEvent &, const Ice::Current &=Ice::emptyCurrent) override
Definition: SimpleEpisodicMemory.cpp:471
memoryx::SimpleEpisodicMemory::registerPlatformUnitTargetEvent
void registerPlatformUnitTargetEvent(const PlatformUnitTargetEvent &, const Ice::Current &=Ice::emptyCurrent) override
Definition: SimpleEpisodicMemory.cpp:478
memoryx::SimpleEpisodicMemory::notifyKeyframe
void notifyKeyframe(const Ice::Current &=Ice::emptyCurrent) override
Definition: SimpleEpisodicMemory.cpp:485
memoryx::SimpleEpisodicMemory::getDefaultName
std::string getDefaultName() const override
Retrieve default name of component.
Definition: SimpleEpisodicMemory.cpp:60