ObjectReader.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  * @author Fabian Reister ( fabian dot reister at kit dot edu )
17  * @date 2021
18  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
19  * GNU General Public License
20  */
21 
22 #pragma once
23 
24 #include <mutex>
25 #include <optional>
26 
28 
31 #include <RobotAPI/libraries/armem_objects/aron/ObjectInstance.aron.generated.h>
33 
34 // The object pose provider. As long as the provider is not connected to armem we need the second proxy
35 #include <RobotAPI/interface/objectpose/ObjectPoseProvider.h>
36 #include <RobotAPI/interface/objectpose/ObjectPoseStorageInterface.h>
37 
39 {
40  class Reader
41  {
42  public:
43  struct Properties
44  {
45  std::string memoryName = "Object";
46  };
47 
48  Reader() = default;
49  virtual ~Reader() = default;
50 
52  void connect(armem::client::MemoryNameSystem& memoryNameSystem);
53 
54  // localization stuff. Requires an instance index to be set.
55  std::map<std::string, bool> requestLocalization(const ObjectID& instanceId,
56  const armarx::core::time::Duration& until);
57  bool requestLocalization(const ObjectID& instanceId,
58  const std::string& provider,
59  const armarx::core::time::Duration& until);
60 
61  // query existing instance from the memory. Requires an instance index to be set.
62  std::optional<objpose::ObjectPose> queryLatestObjectInstance(const ObjectID& instanceId);
63 
64  // query the latest instances. Ignores the instance index.
65  std::map<std::string, objpose::ObjectPose>
66  queryLatestObjectInstances(const ObjectID& classId);
67 
68  // query all latest object instances.
69  std::map<std::string, objpose::ObjectPose> queryLatestObjectInstances();
70 
73  {
74  return this->p;
75  }
76 
79  {
80  return objPoseStorage;
81  }
82 
83  private:
84  Properties p;
85 
86  const std::string propertyPrefix = "mem.obj.instance.";
87 
89  };
90 
91 
92 } // namespace armarx::armem::obj::instance
armarx::armem::obj::instance::Reader::requestLocalization
std::map< std::string, bool > requestLocalization(const ObjectID &instanceId, const armarx::core::time::Duration &until)
Definition: ObjectReader.cpp:57
armarx::ObjectPoseStorageInterfacePrx
::IceInternal::ProxyHandle<::IceProxy::armarx::objpose::ObjectPoseStorageInterface > ObjectPoseStorageInterfacePrx
Definition: ObjectPoseClientWidget.h:51
armarx::ObjectID
A known object ID of the form "Dataset/ClassName" or "Dataset/ClassName/InstanceName".
Definition: ObjectID.h:11
Reader.h
armarx::armem::obj::instance::Reader::Properties::memoryName
std::string memoryName
Definition: ObjectReader.h:45
armarx::armem::obj::instance::Reader::getObjectPoseStorage
objpose::ObjectPoseStorageInterfacePrx getObjectPoseStorage() const
Definition: ObjectReader.h:78
armarx::armem::obj::instance::Reader
Definition: ObjectReader.h:40
armarx::armem::obj::instance::Reader::queryLatestObjectInstance
std::optional< objpose::ObjectPose > queryLatestObjectInstance(const ObjectID &instanceId)
Definition: ObjectReader.cpp:94
armarx::armem::obj::instance::Reader::queryLatestObjectInstances
std::map< std::string, objpose::ObjectPose > queryLatestObjectInstances()
Definition: ObjectReader.cpp:114
types.h
armarx::armem::obj::instance::Reader::connect
void connect(armem::client::MemoryNameSystem &memoryNameSystem)
Definition: ObjectReader.cpp:33
armarx::armem::obj::instance::Reader::Reader
Reader()=default
armarx::armem::obj::instance::Reader::~Reader
virtual ~Reader()=default
armarx::armem::obj::instance::Reader::Properties
Definition: ObjectReader.h:43
PropertyDefinitionContainer.h
IceUtil::Handle< class PropertyDefinitionContainer >
armarx::core::time::Duration
Represents a duration.
Definition: Duration.h:17
armarx::armem::client::MemoryNameSystem
The memory name system (MNS) client.
Definition: MemoryNameSystem.h:69
armarx::armem::obj::instance::Reader::getProperties
Properties getProperties()
Definition: ObjectReader.h:72
MemoryNameSystem.h
armarx::armem::obj::instance
Definition: ObjectReader.cpp:22
armarx::armem::obj::instance::Reader::registerPropertyDefinitions
void registerPropertyDefinitions(armarx::PropertyDefinitionsPtr &def)
Definition: ObjectReader.cpp:25