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 void onInitComponent() override;
66 void onConnectComponent() override;
67
68 // virtual Ice::StringSeq getWorldState(const ::Ice::Current&);
69 memoryx::PredicateInstanceList getWorldState(const ::Ice::Current&) override;
70 bool isObservable(const ::std::string& predicateName, const ::Ice::Current&) override;
71 bool updatePredicateValue(const PredicateInstance& pi,
72 bool removePredicate,
73 const ::Ice::Current&) override;
74 void setPredicateArgumentWhitelist(const EntityBaseList& argumentWhitelist,
75 const Ice::Current&) override;
76 void resetPredicateArgumentWhitelist(const ::Ice::Current&) override;
77
78 private:
79 bool areAllowed(const std::vector<memoryx::EntityRefBasePtr>& entityRefs);
80 void addListToList(PredicateInstanceList& target, const PredicateInstanceList& source);
81 PredicateInstanceList getHandEmptyPredicates();
82
83 PredicateInstanceList getNonobservableRelationsAndPredicates();
84
85 std::mutex updaterMutex;
86 std::map<std::string, WorldStateUpdaterInterfacePrx> updaters;
87
88 EntityBaseList argumentWhitelist;
89 WorkingMemoryInterfacePrx wm;
90 PriorKnowledgeInterfacePrx prior;
91
92 ObjectInstanceMemorySegmentBasePrx objectInstances;
93 PersistentObjectClassSegmentBasePrx objectClasses;
94 RelationMemorySegmentBasePrx objectRelations;
95
96 PredicateInstanceList observablePredicateInstances;
97
98 // WorldStateObserverInterface interface
99 public:
100 void addObservablePredicateInstances(const PredicateInstanceList& predicates,
101 const Ice::Current&) override;
102 void registerAsUpdater(const std::string& name,
103 const WorldStateUpdaterInterfacePrx& updater,
104 const Ice::Current&) override;
105 WorldStateUpdaterInterfaceList getRegisteredUpdaters(const Ice::Current&) override;
106 };
107} // 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.