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/armem/server/MemoryInterface.h>
36 #include <RobotAPI/interface/objectpose/ObjectPoseProvider.h>
37 #include <RobotAPI/interface/objectpose/ObjectPoseStorageInterface.h>
38 
40 {
41  class Reader
42  {
43  public:
44  struct Properties
45  {
46  std::string memoryName = "Object";
47  };
48 
49  Reader() = default;
50  virtual ~Reader() = default;
51 
53  void connect(armem::client::MemoryNameSystem& memoryNameSystem);
54 
55  // localization stuff. Requires an instance index to be set.
56  std::map<std::string, bool> requestLocalization(const ObjectID& instanceId,
57  const armarx::core::time::Duration& until);
58  bool requestLocalization(const ObjectID& instanceId,
59  const std::string& provider,
60  const armarx::core::time::Duration& until);
61 
62  // query existing instance from the memory. Requires an instance index to be set.
63  std::optional<objpose::ObjectPose> queryLatestObjectInstance(const ObjectID& instanceId);
64 
65  // query the latest instances. Ignores the instance index.
66  std::map<std::string, objpose::ObjectPose>
67  queryLatestObjectInstances(const ObjectID& classId);
68 
69  // query all latest object instances.
70  std::map<std::string, objpose::ObjectPose> queryLatestObjectInstances();
71 
74  {
75  return this->properties;
76  }
77 
80  {
81  // TODO: see problem in source file. This performs a ice_isA every time this method is called
82  return objpose::ObjectPoseStorageInterfacePrx::checkedCast(this->readingPrx);
83  }
84 
85  private:
86  Properties properties;
87 
88  const std::string propertyPrefix = "mem.obj.instance.";
89 
90  armarx::armem::server::ReadingMemoryInterfacePrx readingPrx;
91  };
92 
93 
94 } // 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:65
armarx::ObjectPoseStorageInterfacePrx
::IceInternal::ProxyHandle<::IceProxy::armarx::objpose::ObjectPoseStorageInterface > ObjectPoseStorageInterfacePrx
Definition: ObjectPoseClientWidget.h:57
armarx::ObjectID
A known object ID of the form "Dataset/ClassName" or "Dataset/ClassName/InstanceName".
Definition: ObjectID.h:10
Reader.h
armarx::armem::obj::instance::Reader::Properties::memoryName
std::string memoryName
Definition: ObjectReader.h:46
armarx::armem::obj::instance::Reader::getObjectPoseStorage
objpose::ObjectPoseStorageInterfacePrx getObjectPoseStorage() const
Definition: ObjectReader.h:79
armarx::armem::obj::instance::Reader
Definition: ObjectReader.h:41
armarx::armem::obj::instance::Reader::queryLatestObjectInstance
std::optional< objpose::ObjectPose > queryLatestObjectInstance(const ObjectID &instanceId)
Definition: ObjectReader.cpp:102
armarx::armem::obj::instance::Reader::queryLatestObjectInstances
std::map< std::string, objpose::ObjectPose > queryLatestObjectInstances()
Definition: ObjectReader.cpp:122
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:44
PropertyDefinitionContainer.h
IceUtil::Handle< class PropertyDefinitionContainer >
armarx::core::time::Duration
Represents a duration.
Definition: Duration.h:16
armarx::armem::client::MemoryNameSystem
The memory name system (MNS) client.
Definition: MemoryNameSystem.h:68
armarx::armem::obj::instance::Reader::getProperties
Properties getProperties()
Definition: ObjectReader.h:73
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