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