WorldStateObserver.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::WorldStateObserver
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 
28 
29 #include <MemoryX/interface/observers/WorldStateObserver.h>
30 #include <MemoryX/interface/memorytypes/MemorySegments.h>
33 
34 #include <RobotAPI/interface/units/HandUnitInterface.h>
35 
36 #include <mutex>
37 
38 
39 namespace memoryx
40 {
41 
44  {
45  public:
48  {
49  }
50  };
51 
52 
53  /*!
54  * \brief The WorldStateObserver class
55  */
57  virtual public WorldStateObserverInterface,
58  virtual public armarx::Component
59  {
60  public:
61  // inherited from Component
62  std::string getDefaultName() const override
63  {
64  return "WorldStateObserver";
65  }
66  void onInitComponent() override;
67  void onConnectComponent() override;
68 
69  // virtual Ice::StringSeq getWorldState(const ::Ice::Current&);
70  memoryx::PredicateInstanceList getWorldState(const ::Ice::Current&) override;
71  bool isObservable(const ::std::string& predicateName, const ::Ice::Current&) override;
72  bool updatePredicateValue(const PredicateInstance& pi, bool removePredicate, const ::Ice::Current&) override;
73  void setPredicateArgumentWhitelist(const EntityBaseList& argumentWhitelist, const Ice::Current&) override;
74  void resetPredicateArgumentWhitelist(const ::Ice::Current&) override;
75 
76  private:
77  bool areAllowed(const std::vector<memoryx::EntityRefBasePtr>& entityRefs);
78  void addListToList(PredicateInstanceList& target, const PredicateInstanceList& source);
79  PredicateInstanceList getHandEmptyPredicates();
80 
81  PredicateInstanceList getNonobservableRelationsAndPredicates();
82 
83  std::mutex updaterMutex;
84  std::map<std::string, WorldStateUpdaterInterfacePrx> updaters;
85 
86  EntityBaseList argumentWhitelist;
87  WorkingMemoryInterfacePrx wm;
88  PriorKnowledgeInterfacePrx prior;
89 
90  ObjectInstanceMemorySegmentBasePrx objectInstances;
91  PersistentObjectClassSegmentBasePrx objectClasses;
92  RelationMemorySegmentBasePrx objectRelations;
93 
94  PredicateInstanceList observablePredicateInstances;
95 
96  // WorldStateObserverInterface interface
97  public:
98  void addObservablePredicateInstances(const PredicateInstanceList& predicates, const Ice::Current&) override;
99  void registerAsUpdater(const std::string& name, const WorldStateUpdaterInterfacePrx& updater, const Ice::Current&) override;
100  WorldStateUpdaterInterfaceList getRegisteredUpdaters(const Ice::Current&) override;
101  };
102 }
103 
boost::target
Vertex target(const detail::edge_base< Directed, Vertex > &e, const PCG &)
Definition: point_cloud_graph.h:688
armarx::PropertyDefinitionContainer::prefix
std::string prefix
Prefix of the properties such as namespace, domain, component name, etc.
Definition: PropertyDefinitionContainer.h:333
memoryx
VirtualRobot headers.
Definition: CommonPlacesTester.cpp:48
memoryx::WorldStateObserverPropertyDefinitions
Definition: WorldStateObserver.h:42
pi
#define pi
Definition: Transition.cpp:37
EntityRef.h
memoryx::WorldStateObserver
The WorldStateObserver class.
Definition: WorldStateObserver.h:56
ARMARXCOMPONENT_IMPORT_EXPORT
#define ARMARXCOMPONENT_IMPORT_EXPORT
Definition: ImportExportComponent.h:38
WorkingMemory.h
boost::source
Vertex source(const detail::edge_base< Directed, Vertex > &e, const PCG &)
Definition: point_cloud_graph.h:681
Component.h
armarx::Component
Baseclass for all ArmarX ManagedIceObjects requiring properties.
Definition: Component.h:95
memoryx::WorldStateObserver::getDefaultName
std::string getDefaultName() const override
Retrieve default name of component.
Definition: WorldStateObserver.h:62
armarx::ComponentPropertyDefinitions
Default component property definition container.
Definition: Component.h:70
armarx::ComponentPropertyDefinitions::ComponentPropertyDefinitions
ComponentPropertyDefinitions(std::string prefix, bool hasObjectNameParameter=true)
Definition: Component.cpp:37
memoryx::WorldStateObserverPropertyDefinitions::WorldStateObserverPropertyDefinitions
WorldStateObserverPropertyDefinitions(std::string prefix)
Definition: WorldStateObserver.h:46
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
ChannelRef.h
ImportExportComponent.h