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:
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>
68
69 // query all latest object instances.
70 std::map<std::string, objpose::ObjectPose> queryLatestObjectInstances();
71
74 {
75 return this->properties;
76 }
77
78 objpose::ObjectPoseStorageInterfacePrx
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 // key: provider name
86 std::map<std::string, std::vector<objpose::ObjectPose>> queryAttachedObjectInstancesForProviders();
87
88 private:
89 Properties properties;
90
91 const std::string propertyPrefix = "mem.obj.instance.";
92
93 armarx::armem::server::ReadingMemoryInterfacePrx readingPrx;
94 };
95
96
97} // namespace armarx::armem::obj::instance
A known object ID of the form "Dataset/ClassName" or "Dataset/ClassName/InstanceName".
Definition ObjectID.h:11
The memory name system (MNS) client.
std::optional< objpose::ObjectPose > queryLatestObjectInstance(const ObjectID &instanceId)
std::map< std::string, objpose::ObjectPose > queryLatestObjectInstances()
void connect(armem::client::MemoryNameSystem &memoryNameSystem)
objpose::ObjectPoseStorageInterfacePrx getObjectPoseStorage() const
std::map< std::string, std::vector< objpose::ObjectPose > > queryAttachedObjectInstancesForProviders()
std::map< std::string, bool > requestLocalization(const ObjectID &instanceId, const armarx::core::time::Duration &until)
void registerPropertyDefinitions(armarx::PropertyDefinitionsPtr &def)
Represents a duration.
Definition Duration.h:17
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.